feat(onboarding): Add logs onboarding for React Native#107666
feat(onboarding): Add logs onboarding for React Native#107666
Conversation
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
There was a problem hiding this comment.
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/
|
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
| it('has logs onboarding configuration', () => { | ||
| expect(docs.logsOnboarding).toBeDefined(); | ||
| expect(docs.logsOnboarding?.install).toBeDefined(); | ||
| expect(docs.logsOnboarding?.configure).toBeDefined(); | ||
| expect(docs.logsOnboarding?.verify).toBeDefined(); | ||
| }); |
There was a problem hiding this comment.
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 🙏)
There was a problem hiding this comment.
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
…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>
<!-- 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>
…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>
<!-- 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>
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: