File tree Expand file tree Collapse file tree 5 files changed +36
-3
lines changed Expand file tree Collapse file tree 5 files changed +36
-3
lines changed Original file line number Diff line number Diff line change 2525
2626- Fix ` WITH_ENVIRONMENT ` overwrite in ` sentry-xcode-debug-files.sh ` ([ #3525 ] ( https://github.com/getsentry/sentry-react-native/pull/3525 ) )
2727- Sentry CLI 2.25.1 fixes background debug files uploads during Xcode builds ([ #3486 ] ( https://github.com/getsentry/sentry-react-native/pull/3486 ) )
28+ - Performance Tracing should be disabled by default ([ #3533 ] ( https://github.com/getsentry/sentry-react-native/pull/3533 ) )
2829
2930### Dependencies
3031
Original file line number Diff line number Diff line change 1- import { hasTracingEnabled } from '@sentry/core' ;
21import { HttpClient } from '@sentry/integrations' ;
32import { Integrations as BrowserReactIntegrations } from '@sentry/react' ;
43import type { Integration } from '@sentry/types' ;
@@ -77,7 +76,14 @@ export function getDefaultIntegrations(options: ReactNativeClientOptions): Integ
7776 }
7877 }
7978
80- if ( hasTracingEnabled ( options ) && options . enableAutoPerformanceTracing ) {
79+ // hasTracingEnabled from `@sentry/core` only check if tracesSampler or tracesSampleRate keys are present
80+ // that's different from prev imp here and might lead misconfiguration
81+ // `tracesSampleRate: undefined` should not enable tracing
82+ const hasTracingEnabled =
83+ options . enableTracing ||
84+ typeof options . tracesSampleRate === 'number' ||
85+ typeof options . tracesSampler === 'function' ;
86+ if ( hasTracingEnabled && options . enableAutoPerformanceTracing ) {
8187 integrations . push ( new ReactNativeTracing ( ) ) ;
8288 }
8389 if ( options . enableCaptureFailedRequests ) {
Original file line number Diff line number Diff line change @@ -76,8 +76,11 @@ export function init(passedOptions: ReactNativeOptions): void {
7676 stackParser : stackParserFromStackParserOptions ( passedOptions . stackParser || defaultStackParser ) ,
7777 beforeBreadcrumb : safeFactory ( passedOptions . beforeBreadcrumb , { loggerMessage : 'The beforeBreadcrumb threw an error' } ) ,
7878 initialScope : safeFactory ( passedOptions . initialScope , { loggerMessage : 'The initialScope threw an error' } ) ,
79- tracesSampler : safeTracesSampler ( passedOptions . tracesSampler ) ,
8079 } ;
80+ if ( 'tracesSampler' in options ) {
81+ options . tracesSampler = safeTracesSampler ( options . tracesSampler ) ;
82+ }
83+
8184 if ( ! ( 'environment' in options ) ) {
8285 options . environment = getDefaultEnvironment ( ) ;
8386 }
Original file line number Diff line number Diff line change @@ -334,6 +334,7 @@ function initTestClient(
334334 const transportSendMock = jest . fn < ReturnType < Transport [ 'send' ] > , Parameters < Transport [ 'send' ] > > ( ) ;
335335 const options : Sentry . ReactNativeOptions = {
336336 dsn : MOCK_DSN ,
337+ enableTracing : true ,
337338 _experiments : {
338339 profilesSampleRate : 1 ,
339340 } ,
Original file line number Diff line number Diff line change @@ -115,6 +115,28 @@ describe('Tests the SDK functionality', () => {
115115 return new ReactNativeTracing ( { routingInstrumentation : nav } ) ;
116116 } ;
117117
118+ it ( 'Auto Performance is disabled by default' , ( ) => {
119+ init ( { } ) ;
120+
121+ expect ( autoPerformanceIsEnabled ( ) ) . toBe ( false ) ;
122+ } ) ;
123+
124+ it ( 'Auto Performance is disabled when tracesSampleRate is set to undefined' , ( ) => {
125+ init ( {
126+ tracesSampleRate : undefined ,
127+ } ) ;
128+
129+ expect ( autoPerformanceIsEnabled ( ) ) . toBe ( false ) ;
130+ } ) ;
131+
132+ it ( 'Auto Performance is disabled when tracesSampler is set to undefined' , ( ) => {
133+ init ( {
134+ tracesSampler : undefined ,
135+ } ) ;
136+
137+ expect ( autoPerformanceIsEnabled ( ) ) . toBe ( false ) ;
138+ } ) ;
139+
118140 it ( 'Auto Performance is enabled when tracing is enabled (tracesSampler)' , ( ) => {
119141 init ( {
120142 tracesSampler : ( ) => true ,
You can’t perform that action at this time.
0 commit comments