Skip to content

Commit

Permalink
feat: enable Sentry tracing and profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
Harjot1Singh committed Apr 3, 2022
1 parent bc86943 commit af55258
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions src/services/telemetry/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ReactNativeTracing,
ReactNavigationInstrumentation,
setContext,
startTransaction as startSentryTransaction,
startTransaction,
wrap,
} from '@sentry/react-native'

Expand All @@ -17,6 +17,8 @@ const sentryAdapterFactory = () => {
dsn: configuration.sentry.dsn,
release: configuration.sentry.releaseName,
environment: configuration.environment.name,
enableAutoSessionTracking: true,
tracesSampleRate: 1,
integrations: [
new ReactNativeTracing( {
tracingOrigins: [ 'api.gurbaninow.com' ],
Expand All @@ -25,26 +27,11 @@ const sentryAdapterFactory = () => {
],
} )

const registerNavigation = ( navigationRef: any ) => (
const registerNavigation = ( navigationRef: any ) => {
routingInstrumentation.registerNavigationContainer( navigationRef )
)

const transactions = new Map<string, ReturnType<typeof startSentryTransaction>>()
const startTransaction = ( name: string ) => {
const transaction = startSentryTransaction( { name } )

transactions.set( name, transaction )

return transaction
}

const endTransaction = ( name: string ) => {
if ( !transactions.has( name ) ) return

transactions.get( name )?.finish()
}

return { initialize, wrap, registerNavigation, startTransaction, endTransaction, setContext }
return { initialize, wrap, registerNavigation, startTransaction, setContext }
}

export default sentryAdapterFactory()

0 comments on commit af55258

Please sign in to comment.