diff --git a/packages/mobile/package.json b/packages/mobile/package.json index cedc71ee925..5c8bfe53492 100644 --- a/packages/mobile/package.json +++ b/packages/mobile/package.json @@ -77,6 +77,7 @@ "@react-navigation/stack": "^7.4.2", "@redux-devtools/remote": "0.8.0", "@reduxjs/toolkit": "1.6.1", + "@sentry/react-native": "^6.20.0", "@shopify/flash-list": "^1.8.3", "@snapchat/snap-kit-react-native": "0.4.0", "@solana-mobile/mobile-wallet-adapter-protocol": "2.2.5", diff --git a/packages/mobile/src/app/sentry.ts b/packages/mobile/src/app/sentry.ts index c9665de5cf0..455bda7f153 100644 --- a/packages/mobile/src/app/sentry.ts +++ b/packages/mobile/src/app/sentry.ts @@ -1,8 +1,44 @@ -// Sentry removed from mobile - using only console logging and other error tracking +import * as Sentry from '@sentry/react-native' -export const navigationIntegration = null +import { env } from 'app/services/env' + +import packageJson from '../../package.json' + +const { version: appVersion } = packageJson + +export const navigationIntegration = Sentry.reactNavigationIntegration({ + enableTimeToInitialDisplay: true +}) export const initSentry = () => { - // No-op: Sentry disabled for mobile - // console.log('Sentry disabled for mobile app') + if (!env.SENTRY_DSN) return + + Sentry.init({ + dsn: env.SENTRY_DSN, + release: appVersion, + integrations: [ + navigationIntegration, + Sentry.reactNativeTracingIntegration() + ], + enableUserInteractionTracing: true, + tracesSampleRate: 0.1, + ignoreErrors: [ + 'Network request failed', + 'Network Error', + 'NetworkError', + 'The Internet connection appears to be offline', + 'No internet connection', + 'Connection lost', + /timeout.*exceeded/i, + 'AbortError', + 'User cancelled', + 'Login cancelled', + 'cancelled by user', + 'Non-Error promise rejection captured' + ] + }) + Sentry.setTag('platform', 'mobile') + if (process.env.VITE_CURRENT_GIT_SHA) { + Sentry.setTag('commit_sha', process.env.VITE_CURRENT_GIT_SHA) + } }