From 4a4c27d29b7e05e756b2762270fc7acb9a1825c7 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 19 Mar 2024 14:17:23 +0100 Subject: [PATCH 1/3] misc(sample): Disable Expo Web static routes, export command hangs --- samples/expo/app.json | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/expo/app.json b/samples/expo/app.json index d49b9c9dd..01ce7fc5d 100644 --- a/samples/expo/app.json +++ b/samples/expo/app.json @@ -29,7 +29,6 @@ }, "web": { "bundler": "metro", - "output": "static", "favicon": "./assets/favicon.png" }, "experiments": { From c947f1d6745efcdca1df76e4b19b4b93456e4c48 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 19 Mar 2024 14:45:55 +0100 Subject: [PATCH 2/3] misc(sample): Enable expo-router auto instrumentation --- samples/expo/app/_layout.tsx | 23 +++++++++++++++++++++-- samples/expo/utils/isExpoGo.ts | 5 +++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 samples/expo/utils/isExpoGo.ts diff --git a/samples/expo/app/_layout.tsx b/samples/expo/app/_layout.tsx index 620217cb0..e0cbc9c7d 100644 --- a/samples/expo/app/_layout.tsx +++ b/samples/expo/app/_layout.tsx @@ -1,13 +1,14 @@ import FontAwesome from '@expo/vector-icons/FontAwesome'; import { DarkTheme, DefaultTheme, ThemeProvider } from '@react-navigation/native'; import { useFonts } from 'expo-font'; -import { SplashScreen, Stack } from 'expo-router'; +import { SplashScreen, Stack, useNavigationContainerRef } from 'expo-router'; import { useEffect } from 'react'; import { useColorScheme } from '@/components/useColorScheme'; import { HttpClient } from '@sentry/integrations'; import { SENTRY_INTERNAL_DSN } from '../utils/dsn'; import * as Sentry from '@sentry/react-native'; +import { isExpoGo } from '../utils/isExpoGo'; export { // Catch any errors thrown by the Layout component. @@ -17,6 +18,10 @@ export { // Prevent the splash screen from auto-hiding before asset loading is complete. SplashScreen.preventAutoHideAsync(); +const routingInstrumentation = new Sentry.ReactNavigationInstrumentation({ + enableTimeToInitialDisplay: !isExpoGo(), // This is not supported in Expo Go. +}); + process.env.EXPO_SKIP_DURING_EXPORT !== 'true' && Sentry.init({ // Replace the example DSN below with your own DSN: dsn: SENTRY_INTERNAL_DSN, @@ -47,6 +52,10 @@ process.env.EXPO_SKIP_DURING_EXPORT !== 'true' && Sentry.init({ failedRequestTargets: [/.*/], }), Sentry.metrics.metricsAggregatorIntegration(), + new Sentry.ReactNativeTracing({ + routingInstrumentation, + enableNativeFramesTracking: !isExpoGo(), // Only in native builds, not in Expo Go. + }), ); return integrations.filter(i => i.name !== 'Dedupe'); }, @@ -74,7 +83,15 @@ process.env.EXPO_SKIP_DURING_EXPORT !== 'true' && Sentry.init({ enableSpotlight: true, }); -export default function RootLayout() { +function RootLayout() { + const ref = useNavigationContainerRef(); + + useEffect(() => { + if (ref) { + routingInstrumentation.registerNavigationContainer(ref); + } + }, [ref]); + const [loaded, error] = useFonts({ SpaceMono: require('../assets/fonts/SpaceMono-Regular.ttf'), ...FontAwesome.font, @@ -110,3 +127,5 @@ function RootLayoutNav() { ); } + +export default Sentry.wrap(RootLayout); diff --git a/samples/expo/utils/isExpoGo.ts b/samples/expo/utils/isExpoGo.ts new file mode 100644 index 000000000..b534c8c13 --- /dev/null +++ b/samples/expo/utils/isExpoGo.ts @@ -0,0 +1,5 @@ +import Constants, { AppOwnership } from 'expo-constants'; + +export function isExpoGo(): boolean { + return Constants.appOwnership === AppOwnership.Expo; +} From f94970594392ce9ac4464d4f3230314b95acf93a Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Tue, 19 Mar 2024 18:46:34 +0100 Subject: [PATCH 3/3] Revert "misc(sample): Disable Expo Web static routes, export command hangs" This reverts commit 4a4c27d29b7e05e756b2762270fc7acb9a1825c7. --- samples/expo/app.json | 1 + 1 file changed, 1 insertion(+) diff --git a/samples/expo/app.json b/samples/expo/app.json index 01ce7fc5d..d49b9c9dd 100644 --- a/samples/expo/app.json +++ b/samples/expo/app.json @@ -29,6 +29,7 @@ }, "web": { "bundler": "metro", + "output": "static", "favicon": "./assets/favicon.png" }, "experiments": {