my fork of the bluesky client

Use Sentry only for errors (#1776)

* Use Sentry only for errors

* Fix merge

authored by danabra.mov and committed by GitHub fa821943 7ffbee18

Changed files
+3 -62
__mocks__
src
-7
__mocks__/sentry-expo.js
··· 1 1 jest.mock('sentry-expo', () => ({ 2 2 init: () => jest.fn(), 3 - Native: { 4 - ReactNativeTracing: jest.fn().mockImplementation(() => ({ 5 - start: jest.fn(), 6 - stop: jest.fn(), 7 - })), 8 - ReactNavigationInstrumentation: jest.fn(), 9 - }, 10 3 }))
+1 -2
src/App.native.tsx
··· 10 10 11 11 import 'view/icons' 12 12 13 - import {withSentry} from 'lib/sentry' 14 13 import {ThemeProvider} from 'lib/ThemeContext' 15 14 import {s} from 'lib/styles' 16 15 import {RootStoreModel, setupState, RootStoreProvider} from './state' ··· 62 61 ) 63 62 }) 64 63 65 - export default withSentry(App) 64 + export default App
-7
src/Navigation.tsx
··· 34 34 import {router} from './routes' 35 35 import {usePalette} from 'lib/hooks/usePalette' 36 36 import {useStores} from './state' 37 - import {getRoutingInstrumentation} from 'lib/sentry' 38 37 import {bskyTitle} from 'lib/strings/headings' 39 38 import {JSX} from 'react/jsx-runtime' 40 39 import {timeout} from 'lib/async/timeout' ··· 478 477 ) 479 478 console.log(`Time to first paint: ${initMs} ms`) 480 479 logModuleInitTrace() 481 - 482 - // Register the navigation container with the Sentry instrumentation (only works on native) 483 - if (isNative) { 484 - const routingInstrumentation = getRoutingInstrumentation() 485 - routingInstrumentation.registerNavigationContainer(navigationRef) 486 - } 487 480 }}> 488 481 {children} 489 482 </NavigationContainer>
+2 -46
src/lib/sentry.ts
··· 1 - import {isNative, isWeb} from 'platform/detection' 2 - import {FC} from 'react' 3 - import * as Sentry from 'sentry-expo' 4 - 5 - // Sentry Initialization 6 - 7 - export const getRoutingInstrumentation = () => { 8 - return new Sentry.Native.ReactNavigationInstrumentation() // initialize this in `onReady` prop of NavigationContainer 9 - } 1 + import {init} from 'sentry-expo' 10 2 11 - Sentry.init({ 3 + init({ 12 4 dsn: 'https://05bc3789bf994b81bd7ce20c86ccd3ae@o4505071687041024.ingest.sentry.io/4505071690514432', 13 5 enableInExpoDevelopment: false, // if true, Sentry will try to send events/errors in development mode. 14 6 debug: false, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production 15 7 environment: __DEV__ ? 'development' : 'production', // Set the environment 16 - // @ts-ignore exists but not in types, see https://docs.sentry.io/platforms/react-native/configuration/options/#enableAutoPerformanceTracking 17 - enableAutoPerformanceTracking: true, // Enable auto performance tracking 18 - tracesSampleRate: 0.5, // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // TODO: this might be too much in production 19 - _experiments: { 20 - // The sampling rate for profiling is relative to TracesSampleRate. 21 - // In this case, we'll capture profiles for 50% of transactions. 22 - profilesSampleRate: 0.5, 23 - }, 24 - integrations: isNative 25 - ? [ 26 - new Sentry.Native.ReactNativeTracing({ 27 - shouldCreateSpanForRequest: url => { 28 - // Do not create spans for outgoing requests to a `/logs` endpoint as it is too noisy due to expo 29 - return !url.match(/\/logs$/) 30 - }, 31 - routingInstrumentation: getRoutingInstrumentation(), 32 - }), 33 - ] 34 - : [], // no integrations for web, yet 35 8 }) 36 - 37 - // if web, use Browser client, otherwise use Native client 38 - export function getSentryClient() { 39 - if (isWeb) { 40 - return Sentry.Browser 41 - } 42 - return Sentry.Native 43 - } 44 - 45 - // wrap root App component with Sentry for automatic touch event tracking and performance monitoring 46 - export function withSentry(Component: FC) { 47 - if (isWeb) { 48 - return Component // .wrap is not required or available for web 49 - } 50 - const sentryClient = getSentryClient() 51 - return sentryClient.wrap(Component) 52 - }