Skip to content

feat(onboarding): Add logs onboarding for React Native#107666

Merged
antonis merged 14 commits intomasterfrom
antonis/logs-onboarding
Feb 6, 2026
Merged

feat(onboarding): Add logs onboarding for React Native#107666
antonis merged 14 commits intomasterfrom
antonis/logs-onboarding

Conversation

@antonis
Copy link
Contributor

@antonis antonis commented Feb 5, 2026

Adds logs onboarding documentation for React Native SDK, similar to
the implementation for Apple platforms.

- Requires SDK version 7.0.0 and above
- Includes install, configure, and verify steps
- Requires enableLogs: true in SDK initialization
- Provides examples for different log levels and formatted messages
- Links to official React Native logs documentation

Refs getsentry/sentry-react-native#5610
Adds logs onboarding documentation for React Native SDK following
the same patterns as metrics implementation.

- Use installCodeBlock from utils for consistency
- Add logs test to onboarding.spec.tsx (no separate logs.spec.tsx)
- Add tabs with 'JavaScript' label for code blocks
- Use double quotes for imports to match React Native conventions
- Add react-native to withLoggingOnboarding in platformCategories
- Requires SDK version 7.0.0 with enableLogs: true

Refs getsentry/sentry-react-native#5610
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 5, 2026
@antonis antonis marked this pull request as ready for review February 5, 2026 13:10
@antonis antonis requested a review from a team as a code owner February 5, 2026 13:10
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Fixes npm install command to properly update the SDK when already installed.

Before: `npm install @sentry/react-native --save` would NOT update if already installed
After: `npm install @sentry/react-native@latest` forces update to latest version

This ensures the documentation text "you can update it to the latest version"
is accurate and users actually get the latest SDK when following instructions.

Affected files:
- utils.tsx (installCodeBlock) - fixes logs.tsx, profiling.tsx
- sessionReplay.tsx - had inline code block

Note: yarn and pnpm commands were already correct as `add` updates by default.
…gOnboarding

Moves react-native from between flutter and go to its correct alphabetical
position after python-wsgi and before ruby.
…sion replay

Replace inline install code block with shared installCodeBlock utility
to eliminate duplication and ensure consistency with other React Native
onboarding docs (metrics, logs, profiling).
Fix the Sentry.logger.warn() example to pass attributes as a plain
object in the second parameter, not nested under an "attributes" key.

Before: Sentry.logger.warn('...', { attributes: { log_type: 'test' } })
After: Sentry.logger.warn('...', { log_type: 'test' })

This matches the official Sentry React Native SDK documentation at
https://docs.sentry.io/platforms/react-native/logs/
@antonis antonis marked this pull request as ready for review February 5, 2026 14:57
@lucas-zimerman
Copy link
Contributor

Looking good! I don't have power to approve here but have a 👍 :D

# Conflicts:
#	static/app/gettingStartedDocs/react-native/index.tsx
#	static/app/gettingStartedDocs/react-native/onboarding.spec.tsx
Comment on lines 35 to 40
it('has logs onboarding configuration', () => {
expect(docs.logsOnboarding).toBeDefined();
expect(docs.logsOnboarding?.install).toBeDefined();
expect(docs.logsOnboarding?.configure).toBeDefined();
expect(docs.logsOnboarding?.verify).toBeDefined();
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d suggest moving this test into its own file (logs.spec.tsx) and focusing on testing what the user sees in the UI rather than implementation details. That’s one of the core ideas behind React Testing Library 🙂

This approach would also make the test more resilient - for example, if we rename a property like verify, the test wouldn’t need to be updated.

I just noticed that we do not have a test utility for the stepper onboarding like we have for the main onboarding renderWithOnboardingLayout, so you would need to do something like:

import {OrganizationFixture} from 'sentry-fixture/organization';
import {ProjectFixture} from 'sentry-fixture/project';
import {ProjectKeysFixture} from 'sentry-fixture/projectKeys';

import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';

import type {Organization} from 'sentry/types/organization';
import type {Project} from 'sentry/types/project';
import {LogsTabOnboarding} from 'sentry/views/explore/logs/logsOnboarding';

function renderMockRequests({
  organization,
  project,
}: {
  organization: Organization;
  project: Project;
}) {
  MockApiClient.addMockResponse({
    url: `/projects/${organization.slug}/${project.slug}/keys/`,
    method: 'GET',
    body: [ProjectKeysFixture()[0]],
  });
  MockApiClient.addMockResponse({
    url: `/subscriptions/${organization.slug}/`,
    method: 'GET',
    body: {},
  });
  MockApiClient.addMockResponse({
    url: `/organizations/${organization.slug}/sdks/`,
    method: 'GET',
    body: [],
  });
  MockApiClient.addMockResponse({
    url: `/organizations/${organization.slug}/stats_v2/`,
    method: 'GET',
    body: {},
  });
}

describe('getting started with react-native', () => {
  it('shows React Native logs onboarding content', async () => {
    const organization = OrganizationFixture();
    const project = ProjectFixture({platform: 'react-native'});
    renderMockRequests({organization, project});

    render(
      <LogsTabOnboarding
        datePageFilterProps={{}}
        organization={organization}
        project={project}
      />
    );

    expect(await screen.findByRole('heading', {name: /install/i})).toBeInTheDocument();
    expect(screen.getByRole('heading', {name: /configure/i})).toBeInTheDocument();
    expect(screen.getByRole('heading', {name: /verify/i})).toBeInTheDocument();

    // Goes to the configure step
    await userEvent.click(screen.getByRole('button', {name: 'Next'}));
    expect(await screen.findByText(/enableLogs: true/)).toBeInTheDocument();

    // Goes to the verify step
    await userEvent.click(screen.getByRole('button', {name: 'Next'}));
    expect(await screen.findByText(/Send a test log/)).toBeInTheDocument();
  });
});

It would be great if we could apply a similar approach to the metrics test in the same file as well (in a separate PR 🙏)

Copy link
Contributor Author

@antonis antonis Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback @priscilawebdev! I really appreciate this 🙇
Updated with 3bb9829

It would be great if we could apply a similar approach to the metrics test in the same file as well (in a separate PR 🙏)

Opened a separate PR #107764

Copy link
Member

@philipphofmann philipphofmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@priscilawebdev priscilawebdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@antonis antonis merged commit 633990e into master Feb 6, 2026
59 checks passed
@antonis antonis deleted the antonis/logs-onboarding branch February 6, 2026 09:58
antonis added a commit that referenced this pull request Feb 9, 2026
…ed test (#107764)

<!-- Describe your PR here. -->

Replaces metrics implementation test with UI-focused test

This is a follow up to #107665
based on the feedback in
#107666 (comment)

**Based on: #107666 to avoid
conflicts

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Co-authored-by: Priscila Oliveira <priscila.oliveira@sentry.io>
jaydgoss pushed a commit that referenced this pull request Feb 12, 2026
<!-- Describe your PR here. -->

Adds logs onboarding documentation for React Native SDK.

See https://docs.sentry.io/platforms/react-native/logs/

Part of getsentry/sentry-react-native#5610

To test:
- [Get Cookie sync and sync
cookies](https://develop.sentry.dev/development-infrastructure/frontend-development-server/)
- Visit Vercel Preview at
https://sentry-j5iz9nq62.sentry.dev/explore/logs/?guidedStep=1

<img width="1539" height="1255" alt="Screenshot 2026-02-05 at 15 54 56"
src="https://github.com/user-attachments/assets/0fdf2276-3f32-40f8-b61b-be50980d31e5"
/>
<img width="1539" height="1255" alt="Screenshot 2026-02-05 at 15 55 11"
src="https://github.com/user-attachments/assets/3a417bad-07a5-4b47-b7e6-e15f34380ee7"
/>
<img width="1539" height="1255" alt="Screenshot 2026-02-05 at 15 55 24"
src="https://github.com/user-attachments/assets/d7dcc115-cfa7-4ffc-b6a3-92307bba8ccc"
/>

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
jaydgoss pushed a commit that referenced this pull request Feb 12, 2026
…ed test (#107764)

<!-- Describe your PR here. -->

Replaces metrics implementation test with UI-focused test

This is a follow up to #107665
based on the feedback in
#107666 (comment)

**Based on: #107666 to avoid
conflicts

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Co-authored-by: Priscila Oliveira <priscila.oliveira@sentry.io>
dcramer pushed a commit that referenced this pull request Feb 17, 2026
<!-- Describe your PR here. -->

Adds logs onboarding documentation for React Native SDK.

See https://docs.sentry.io/platforms/react-native/logs/

Part of getsentry/sentry-react-native#5610

To test:
- [Get Cookie sync and sync
cookies](https://develop.sentry.dev/development-infrastructure/frontend-development-server/)
- Visit Vercel Preview at
https://sentry-j5iz9nq62.sentry.dev/explore/logs/?guidedStep=1

<img width="1539" height="1255" alt="Screenshot 2026-02-05 at 15 54 56"
src="https://github.com/user-attachments/assets/0fdf2276-3f32-40f8-b61b-be50980d31e5"
/>
<img width="1539" height="1255" alt="Screenshot 2026-02-05 at 15 55 11"
src="https://github.com/user-attachments/assets/3a417bad-07a5-4b47-b7e6-e15f34380ee7"
/>
<img width="1539" height="1255" alt="Screenshot 2026-02-05 at 15 55 24"
src="https://github.com/user-attachments/assets/d7dcc115-cfa7-4ffc-b6a3-92307bba8ccc"
/>

---------

Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants