Skip to content

Commit

Permalink
ref(tracing-internal): Deprecate tracePropagationTargets in `Browse…
Browse files Browse the repository at this point in the history
…rTracing` (#8874)

This PR deprecates `BrowserTracing`'s `tracePropagationTargets` option
in favour of the top-level Sentry.init option.

When introducing Tracing without Performance, we opted to [promote
`tracePropagationTargets` to a top-level
option](#8395). We
deprecated the integration-level option in Node's `Http` integration but
not in `BrowserTracing`. This patch fixes that.
  • Loading branch information
Lms24 authored Aug 28, 2023
1 parent 5afb861 commit 341bc4c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions packages/node/src/integrations/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ interface TracingOptions {
* array, and only attach tracing headers if a match was found.
*
* @deprecated Use top level `tracePropagationTargets` option instead.
* This option will be removed in v8.
*
* ```
* Sentry.init({
* tracePropagationTargets: ['api.site.com'],
Expand Down
7 changes: 2 additions & 5 deletions packages/sveltekit/test/client/sdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ describe('Sentry client SDK', () => {
it('Merges a user-provided BrowserTracing integration with the automatically added one', () => {
init({
dsn: 'https://public@dsn.ingest.sentry.io/1337',
integrations: [
new BrowserTracing({ tracePropagationTargets: ['myDomain.com'], startTransactionOnLocationChange: false }),
],
integrations: [new BrowserTracing({ finalTimeout: 10, startTransactionOnLocationChange: false })],
enableTracing: true,
});

Expand All @@ -126,8 +124,7 @@ describe('Sentry client SDK', () => {
expect(browserTracing).toBeDefined();

// This shows that the user-configured options are still here
expect(options.tracePropagationTargets).toEqual(['myDomain.com']);
expect(options.startTransactionOnLocationChange).toBe(false);
expect(options.finalTimeout).toEqual(10);

// But we force the routing instrumentation to be ours
expect(options.routingInstrumentation).toEqual(svelteKitRoutingInstrumentation);
Expand Down
1 change: 1 addition & 0 deletions packages/tracing-internal/src/browser/browsertracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export class BrowserTracing implements Integration {
// This is done as it minimizes bundle size (we don't have to have undefined checks).
//
// If both 1 and either one of 2 or 3 are set (from above), we log out a warning.
// eslint-disable-next-line deprecation/deprecation
const tracePropagationTargets = clientOptionsTracePropagationTargets || this.options.tracePropagationTargets;
if (__DEBUG_BUILD__ && this._hasSetTracePropagationTargets && clientOptionsTracePropagationTargets) {
logger.warn(
Expand Down
6 changes: 5 additions & 1 deletion packages/tracing-internal/src/browser/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export interface RequestInstrumentationOptions {
* List of strings and/or regexes used to determine which outgoing requests will have `sentry-trace` and `baggage`
* headers attached.
*
* Default: ['localhost', /^\//] {@see DEFAULT_TRACE_PROPAGATION_TARGETS}
* @deprecated Use the top-level `tracePropagationTargets` option in `Sentry.init` instead.
* This option will be removed in v8.
*
* Default: ['localhost', /^\//] @see {DEFAULT_TRACE_PROPAGATION_TARGETS}
*/
tracePropagationTargets: Array<string | RegExp>;

Expand Down Expand Up @@ -125,6 +128,7 @@ export function instrumentOutgoingRequests(_options?: Partial<RequestInstrumenta
const {
traceFetch,
traceXHR,
// eslint-disable-next-line deprecation/deprecation
tracePropagationTargets,
// eslint-disable-next-line deprecation/deprecation
tracingOrigins,
Expand Down

0 comments on commit 341bc4c

Please sign in to comment.