From bf82c29877bda0fc44459778e57eefd9920d46cd Mon Sep 17 00:00:00 2001 From: Youssouf EL Azizi Date: Fri, 20 Dec 2024 12:12:20 +0100 Subject: [PATCH] fix(docs): fix sentry setup --- .../src/content/docs/recipes/sentry-setup.mdx | 29 +++++++++---------- jest.config.js | 6 ++-- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/docs/src/content/docs/recipes/sentry-setup.mdx b/docs/src/content/docs/recipes/sentry-setup.mdx index 7665d709..884b2f21 100644 --- a/docs/src/content/docs/recipes/sentry-setup.mdx +++ b/docs/src/content/docs/recipes/sentry-setup.mdx @@ -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]); }; diff --git a/jest.config.js b/jest.config.js index d727db17..2b0241b5 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,8 +1,6 @@ module.exports = { preset: 'jest-expo', - setupFilesAfterEnv: [ - '/jest-setup.ts', - ], + setupFilesAfterEnv: ['/jest-setup.ts'], testMatch: ['**/?(*.)+(spec|test).ts?(x)'], collectCoverageFrom: [ 'src/**/*.{ts,tsx}', @@ -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: [