Skip to content

Commit bf82c29

Browse files
committed
fix(docs): fix sentry setup
1 parent 15fb6ee commit bf82c29

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

docs/src/content/docs/recipes/sentry-setup.mdx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -135,33 +135,30 @@ The starter kit did not come with Sentry pre-configured, but it's very easy to s
135135
Create a new file `src/lib/sentry.ts` and add the following code:
136136

137137
```tsx title='src/lib/sentry.ts'
138+
import { Env } from '@env';
139+
import * as Sentry from '@sentry/react-native';
138140
import { useNavigationContainerRef } from 'expo-router';
139141
import { useEffect } from 'react';
140-
import * as Sentry from '@sentry/react-native';
141-
import { Env } from '@env';
142142

143-
const routingInstrumentation = new Sentry.ReactNavigationInstrumentation();
143+
const navigationIntegration = Sentry.reactNavigationIntegration({
144+
enableTimeToInitialDisplay: true,
145+
});
144146

145147
export const initSentry = () => {
146-
Sentry.init({
147-
dsn: Env.SENTRY_DSN,
148-
// debug: Env.APP_ENV === 'development',
149-
integrations: [
150-
new Sentry.ReactNativeTracing({
151-
routingInstrumentation,
152-
enableNativeFramesTracking: true,
153-
// ...
154-
}),
155-
],
156-
});
148+
if (!__DEV__) {
149+
Sentry.init({
150+
dsn: Env.SENTRY_DSN,
151+
integrations: [navigationIntegration],
152+
});
153+
}
157154
};
158155

159156
export const useSentryNavigationConfig = () => {
160157
const navigationRef = useNavigationContainerRef();
161158

162159
useEffect(() => {
163-
if (navigationRef) {
164-
routingInstrumentation.registerNavigationContainer(navigationRef);
160+
if (navigationRef && !__DEV__) {
161+
navigationIntegration.registerNavigationContainer(navigationRef);
165162
}
166163
}, [navigationRef]);
167164
};

jest.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module.exports = {
22
preset: 'jest-expo',
3-
setupFilesAfterEnv: [
4-
'<rootDir>/jest-setup.ts',
5-
],
3+
setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
64
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
75
collectCoverageFrom: [
86
'src/**/*.{ts,tsx}',
@@ -15,7 +13,7 @@ module.exports = {
1513
],
1614
moduleFileExtensions: ['js', 'ts', 'tsx'],
1715
transformIgnorePatterns: [
18-
`node_modules/(?!(?:.pnpm/)?((jest-)?react-native|@react-native(-community)?|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|sentry-expo|native-base|react-native-svg))`,
16+
`node_modules/(?!(?:.pnpm/)?((jest-)?react-native|@react-native(-community)?|expo(nent)?|@expo(nent)?/.*|@expo-google-fonts/.*|react-navigation|@react-navigation/.*|@unimodules/.*|unimodules|@sentry/.*|native-base|react-native-svg))`,
1917
],
2018
coverageReporters: ['json-summary', ['text', { file: 'coverage.txt' }]],
2119
reporters: [

0 commit comments

Comments
 (0)