From d599fd116bba804d616aaff13e79a6f625601b5f Mon Sep 17 00:00:00 2001 From: Krystof Woldrich Date: Fri, 6 Oct 2023 16:58:49 +0200 Subject: [PATCH] fix(tracing): Ignore defaults when warning about duplicate definition of trace propagation targets --- CHANGELOG.md | 1 + src/js/tracing/reactnativetracing.ts | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbe9d81770..9c10a3c57c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ ### Fixes - Change log output to show what paths are considered when collecting modules ([#3316](https://github.com/getsentry/sentry-react-native/pull/3316)) +- Ignore defaults when warning about duplicate definition of trace propagation targets ([#3327](https://github.com/getsentry/sentry-react-native/pull/3327)) ### Dependencies diff --git a/src/js/tracing/reactnativetracing.ts b/src/js/tracing/reactnativetracing.ts index e05efe5dbe..b69763a7f7 100644 --- a/src/js/tracing/reactnativetracing.ts +++ b/src/js/tracing/reactnativetracing.ts @@ -136,8 +136,19 @@ export class ReactNativeTracing implements Integration { private _awaitingAppStartData?: NativeAppStartResponse; private _appStartFinishTimestamp?: number; private _currentRoute?: string; + private _hasSetTracePropagationTargets: boolean; public constructor(options: Partial = {}) { + this._hasSetTracePropagationTargets = false; + + if (__DEV__) { + this._hasSetTracePropagationTargets = !!( + options && + // eslint-disable-next-line deprecation/deprecation + (options.tracePropagationTargets || options.tracingOrigins) + ); + } + this.options = { ...defaultReactNativeTracingOptions, ...options, @@ -193,7 +204,7 @@ export class ReactNativeTracing implements Integration { // // If both 1 and either one of 2 or 3 are set (from above), we log out a warning. const tracePropagationTargets = clientOptionsTracePropagationTargets || thisOptionsTracePropagationTargets; - if (__DEV__ && (thisOptionsTracePropagationTargets || tracingOrigins) && clientOptionsTracePropagationTargets) { + if (__DEV__ && this._hasSetTracePropagationTargets && clientOptionsTracePropagationTargets) { logger.warn( '[ReactNativeTracing] The `tracePropagationTargets` option was set in the ReactNativeTracing integration and top level `Sentry.init`. The top level `Sentry.init` value is being used.', );