Skip to content

Commit

Permalink
fix(docs): fix sentry setup
Browse files Browse the repository at this point in the history
  • Loading branch information
yjose committed Dec 20, 2024
1 parent 15fb6ee commit bf82c29
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
29 changes: 13 additions & 16 deletions docs/src/content/docs/recipes/sentry-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -135,33 +135,30 @@ The starter kit did not come with Sentry pre-configured, but it's very easy to s
Create a new file `src/lib/sentry.ts` and add the following code:

```tsx title='src/lib/sentry.ts'
import { Env } from '@env';
import * as Sentry from '@sentry/react-native';
import { useNavigationContainerRef } from 'expo-router';
import { useEffect } from 'react';
import * as Sentry from '@sentry/react-native';
import { Env } from '@env';

const routingInstrumentation = new Sentry.ReactNavigationInstrumentation();
const navigationIntegration = Sentry.reactNavigationIntegration({
enableTimeToInitialDisplay: true,
});

export const initSentry = () => {
Sentry.init({
dsn: Env.SENTRY_DSN,
// debug: Env.APP_ENV === 'development',
integrations: [
new Sentry.ReactNativeTracing({
routingInstrumentation,
enableNativeFramesTracking: true,
// ...
}),
],
});
if (!__DEV__) {
Sentry.init({
dsn: Env.SENTRY_DSN,
integrations: [navigationIntegration],
});
}
};

export const useSentryNavigationConfig = () => {
const navigationRef = useNavigationContainerRef();

useEffect(() => {
if (navigationRef) {
routingInstrumentation.registerNavigationContainer(navigationRef);
if (navigationRef && !__DEV__) {
navigationIntegration.registerNavigationContainer(navigationRef);
}
}, [navigationRef]);
};
Expand Down
6 changes: 2 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module.exports = {
preset: 'jest-expo',
setupFilesAfterEnv: [
'<rootDir>/jest-setup.ts',
],
setupFilesAfterEnv: ['<rootDir>/jest-setup.ts'],
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
collectCoverageFrom: [
'src/**/*.{ts,tsx}',
Expand All @@ -15,7 +13,7 @@ module.exports = {
],
moduleFileExtensions: ['js', 'ts', 'tsx'],
transformIgnorePatterns: [
`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))`,
`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))`,
],
coverageReporters: ['json-summary', ['text', { file: 'coverage.txt' }]],
reporters: [
Expand Down

0 comments on commit bf82c29

Please sign in to comment.