From 72e7085710a1d72b40001aada290551fc188f5a3 Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Thu, 23 Jan 2025 12:53:27 +0100 Subject: [PATCH] fix(samples): Only load browser replay when Expo sample is running on web --- samples/expo/app/_layout.tsx | 5 ++++- samples/expo/utils/isWeb.ts | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 samples/expo/utils/isWeb.ts diff --git a/samples/expo/app/_layout.tsx b/samples/expo/app/_layout.tsx index e950ff4a66..0791ec47d0 100644 --- a/samples/expo/app/_layout.tsx +++ b/samples/expo/app/_layout.tsx @@ -10,6 +10,7 @@ import * as Sentry from '@sentry/react-native'; import { ErrorEvent } from '@sentry/core'; import { isExpoGo } from '../utils/isExpoGo'; import { LogBox } from 'react-native'; +import { isWeb } from '../utils/isWeb'; export { // Catch any errors thrown by the Layout component. @@ -56,8 +57,10 @@ Sentry.init({ }), navigationIntegration, Sentry.reactNativeTracingIntegration(), - Sentry.browserReplayIntegration(), ); + if (isWeb()) { + integrations.push(Sentry.browserReplayIntegration()); + } return integrations.filter(i => i.name !== 'Dedupe'); }, enableAutoSessionTracking: true, diff --git a/samples/expo/utils/isWeb.ts b/samples/expo/utils/isWeb.ts new file mode 100644 index 0000000000..a6327791f6 --- /dev/null +++ b/samples/expo/utils/isWeb.ts @@ -0,0 +1,5 @@ +import { Platform } from 'react-native'; + +export function isWeb(): boolean { + return Platform.OS === 'web'; +}