Skip to content

Commit 0d09983

Browse files
authored
feat(tracing): Revert browser tracing integration changes (#10328)
Due to #10327, this reverts changes to the browser tracing integration as we're actually going to replace this differently.
1 parent f613940 commit 0d09983

File tree

32 files changed

+241
-488
lines changed

32 files changed

+241
-488
lines changed

MIGRATION.md

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ npx @sentry/migr8@latest
1010
This will let you select which updates to run, and automatically update your code. Make sure to still review all code
1111
changes!
1212

13-
## Deprecate transaction-related options to `BrowserTracing`
14-
15-
When configuring the `BrowserTracing` integration, some options have been renamed:
16-
17-
- `startTransactionOnPageLoad` --> `spanOnPageLoad`
18-
- `startTransactionOnLocationChange` --> `spanOnLocationChange`
19-
- `markBackgroundTransactions` --> `markBackgroundSpan`
20-
21-
Also, `beforeNavigate` is replaced with a `beforeStartSpan` callback, which receives `StartSpanOptions`.
22-
2313
## Deprecate using `getClient()` to check if the SDK was initialized
2414

2515
In v8, `getClient()` will stop returning `undefined` if `Sentry.init()` was not called. For cases where this may be used
@@ -46,7 +36,6 @@ The following list shows how integrations should be migrated:
4636

4737
| Old | New | Packages |
4838
| ------------------------- | -------------------------------- | ------------------------------------------------------------------------------------------------------- |
49-
| `new BrowserTracing()` | `browserTracingIntegration()` | `@sentry/browser` |
5039
| `new InboundFilters()` | `inboundFiltersIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
5140
| `new FunctionToString()` | `functionToStringIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |
5241
| `new LinkedErrors()` | `linkedErrorsIntegration()` | `@sentry/core`, `@sentry/browser`, `@sentry/node`, `@sentry/deno`, `@sentry/bun`, `@sentry/vercel-edge` |

packages/astro/src/client/sdk.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { BrowserOptions } from '@sentry/browser';
22
import {
3-
browserTracingIntegration,
3+
BrowserTracing,
44
getDefaultIntegrations as getBrowserDefaultIntegrations,
55
init as initBrowserSdk,
66
setTag,
@@ -34,7 +34,7 @@ function getDefaultIntegrations(options: BrowserOptions): Integration[] | undefi
3434
// in which case everything inside will get treeshaken away
3535
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
3636
if (hasTracingEnabled(options)) {
37-
return [...getBrowserDefaultIntegrations(options), browserTracingIntegration()];
37+
return [...getBrowserDefaultIntegrations(options), new BrowserTracing()];
3838
}
3939
}
4040

packages/astro/test/client/sdk.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { BrowserClient, BrowserTracing } from '@sentry/browser';
1+
import type { BrowserClient } from '@sentry/browser';
22
import { getCurrentScope } from '@sentry/browser';
33
import * as SentryBrowser from '@sentry/browser';
4-
import { SDK_VERSION, WINDOW, browserTracingIntegration, getClient } from '@sentry/browser';
4+
import { BrowserTracing, SDK_VERSION, WINDOW, getClient } from '@sentry/browser';
55
import { vi } from 'vitest';
66

77
import { init } from '../../../astro/src/client/sdk';
@@ -103,13 +103,12 @@ describe('Sentry client SDK', () => {
103103
it('Overrides the automatically default BrowserTracing instance with a a user-provided instance', () => {
104104
init({
105105
dsn: 'https://[email protected]/1337',
106-
integrations: [browserTracingIntegration({ finalTimeout: 10, startTransactionOnLocationChange: false })],
106+
integrations: [new BrowserTracing({ finalTimeout: 10, startTransactionOnLocationChange: false })],
107107
enableTracing: true,
108108
});
109109

110110
const integrationsToInit = browserInit.mock.calls[0][0]?.defaultIntegrations;
111111

112-
// eslint-disable-next-line deprecation/deprecation
113112
const browserTracing = getClient<BrowserClient>()?.getIntegrationByName('BrowserTracing') as BrowserTracing;
114113
const options = browserTracing.options;
115114

packages/browser/src/index.bundle.feedback.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,18 @@
11
// This is exported so the loader does not fail when switching off Replay/Tracing
22
import { Feedback, feedbackIntegration } from '@sentry-internal/feedback';
3-
import {
4-
BrowserTracing,
5-
Replay,
6-
addTracingExtensions,
7-
browserTracingIntegration,
8-
replayIntegration,
9-
} from '@sentry-internal/integration-shims';
3+
import { BrowserTracing, Replay, addTracingExtensions, replayIntegration } from '@sentry-internal/integration-shims';
104

115
import * as Sentry from './index.bundle.base';
126

137
// TODO (v8): Remove this as it was only needed for backwards compatibility
148
// eslint-disable-next-line deprecation/deprecation
159
Sentry.Integrations.Replay = Replay;
1610

17-
// eslint-disable-next-line deprecation/deprecation
1811
Sentry.Integrations.BrowserTracing = BrowserTracing;
1912

2013
export * from './index.bundle.base';
2114
export {
22-
// eslint-disable-next-line deprecation/deprecation
2315
BrowserTracing,
24-
browserTracingIntegration,
2516
addTracingExtensions,
2617
// eslint-disable-next-line deprecation/deprecation
2718
Replay,

packages/browser/src/index.bundle.replay.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
BrowserTracing,
44
Feedback,
55
addTracingExtensions,
6-
browserTracingIntegration,
76
feedbackIntegration,
87
} from '@sentry-internal/integration-shims';
98
import { Replay, replayIntegration } from '@sentry/replay';
@@ -14,14 +13,11 @@ import * as Sentry from './index.bundle.base';
1413
// eslint-disable-next-line deprecation/deprecation
1514
Sentry.Integrations.Replay = Replay;
1615

17-
// eslint-disable-next-line deprecation/deprecation
1816
Sentry.Integrations.BrowserTracing = BrowserTracing;
1917

2018
export * from './index.bundle.base';
2119
export {
22-
// eslint-disable-next-line deprecation/deprecation
2320
BrowserTracing,
24-
browserTracingIntegration,
2521
addTracingExtensions,
2622
// eslint-disable-next-line deprecation/deprecation
2723
Replay,

packages/browser/src/index.bundle.tracing.replay.feedback.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Feedback, feedbackIntegration } from '@sentry-internal/feedback';
2-
import { BrowserTracing, Span, addExtensionMethods, browserTracingIntegration } from '@sentry-internal/tracing';
2+
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
33
import { Replay, replayIntegration } from '@sentry/replay';
44

55
import * as Sentry from './index.bundle.base';
@@ -10,7 +10,6 @@ import * as Sentry from './index.bundle.base';
1010
// eslint-disable-next-line deprecation/deprecation
1111
Sentry.Integrations.Replay = Replay;
1212

13-
// eslint-disable-next-line deprecation/deprecation
1413
Sentry.Integrations.BrowserTracing = BrowserTracing;
1514

1615
// We are patching the global object with our hub extension methods
@@ -23,9 +22,7 @@ export {
2322
Replay,
2423
feedbackIntegration,
2524
replayIntegration,
26-
// eslint-disable-next-line deprecation/deprecation
2725
BrowserTracing,
28-
browserTracingIntegration,
2926
Span,
3027
addExtensionMethods,
3128
};

packages/browser/src/index.bundle.tracing.replay.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Feedback, feedbackIntegration } from '@sentry-internal/integration-shims';
2-
import { BrowserTracing, Span, addExtensionMethods, browserTracingIntegration } from '@sentry-internal/tracing';
2+
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
33
import { Replay, replayIntegration } from '@sentry/replay';
44

55
import * as Sentry from './index.bundle.base';
@@ -10,7 +10,6 @@ import * as Sentry from './index.bundle.base';
1010
// eslint-disable-next-line deprecation/deprecation
1111
Sentry.Integrations.Replay = Replay;
1212

13-
// eslint-disable-next-line deprecation/deprecation
1413
Sentry.Integrations.BrowserTracing = BrowserTracing;
1514

1615
// We are patching the global object with our hub extension methods
@@ -23,9 +22,7 @@ export {
2322
Replay,
2423
replayIntegration,
2524
feedbackIntegration,
26-
// eslint-disable-next-line deprecation/deprecation
2725
BrowserTracing,
28-
browserTracingIntegration,
2926
Span,
3027
addExtensionMethods,
3128
};

packages/browser/src/index.bundle.tracing.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is exported so the loader does not fail when switching off Replay
22
import { Feedback, Replay, feedbackIntegration, replayIntegration } from '@sentry-internal/integration-shims';
3-
import { BrowserTracing, Span, addExtensionMethods, browserTracingIntegration } from '@sentry-internal/tracing';
3+
import { BrowserTracing, Span, addExtensionMethods } from '@sentry-internal/tracing';
44

55
import * as Sentry from './index.bundle.base';
66

@@ -10,7 +10,6 @@ import * as Sentry from './index.bundle.base';
1010
// eslint-disable-next-line deprecation/deprecation
1111
Sentry.Integrations.Replay = Replay;
1212

13-
// eslint-disable-next-line deprecation/deprecation
1413
Sentry.Integrations.BrowserTracing = BrowserTracing;
1514

1615
// We are patching the global object with our hub extension methods
@@ -23,9 +22,7 @@ export {
2322
Replay,
2423
feedbackIntegration,
2524
replayIntegration,
26-
// eslint-disable-next-line deprecation/deprecation
2725
BrowserTracing,
28-
browserTracingIntegration,
2926
Span,
3027
addExtensionMethods,
3128
};

packages/browser/src/index.bundle.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
Feedback,
55
Replay,
66
addTracingExtensions,
7-
browserTracingIntegration,
87
feedbackIntegration,
98
replayIntegration,
109
} from '@sentry-internal/integration-shims';
@@ -15,19 +14,16 @@ import * as Sentry from './index.bundle.base';
1514
// eslint-disable-next-line deprecation/deprecation
1615
Sentry.Integrations.Replay = Replay;
1716

18-
// eslint-disable-next-line deprecation/deprecation
1917
Sentry.Integrations.BrowserTracing = BrowserTracing;
2018

2119
export * from './index.bundle.base';
2220
export {
23-
// eslint-disable-next-line deprecation/deprecation
2421
BrowserTracing,
2522
addTracingExtensions,
2623
// eslint-disable-next-line deprecation/deprecation
2724
Replay,
2825
// eslint-disable-next-line deprecation/deprecation
2926
Feedback,
30-
browserTracingIntegration,
3127
feedbackIntegration,
3228
replayIntegration,
3329
};

packages/browser/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ export {
5454
} from '@sentry-internal/feedback';
5555

5656
export {
57-
// eslint-disable-next-line deprecation/deprecation
5857
BrowserTracing,
59-
browserTracingIntegration,
6058
defaultRequestInstrumentationOptions,
6159
instrumentOutgoingRequests,
6260
} from '@sentry-internal/tracing';

packages/browser/test/unit/profiling/integration.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('BrowserProfilingIntegration', () => {
4444
send,
4545
};
4646
},
47-
integrations: [Sentry.browserTracingIntegration(), new BrowserProfilingIntegration()],
47+
integrations: [new Sentry.BrowserTracing(), new BrowserProfilingIntegration()],
4848
});
4949

5050
const client = Sentry.getClient<BrowserClient>();

packages/core/src/tracing/trace.ts

Lines changed: 111 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
import type { Span, SpanTimeInput, StartSpanOptions, TransactionContext } from '@sentry/types';
2-
1+
import type {
2+
Instrumenter,
3+
Primitive,
4+
Scope,
5+
Span,
6+
SpanTimeInput,
7+
TransactionContext,
8+
TransactionMetadata,
9+
} from '@sentry/types';
10+
import type { SpanAttributes } from '@sentry/types';
11+
import type { SpanOrigin } from '@sentry/types';
12+
import type { TransactionSource } from '@sentry/types';
313
import { dropUndefinedKeys, logger, tracingContextFromHeaders } from '@sentry/utils';
414

515
import { DEBUG_BUILD } from '../debug-build';
@@ -10,6 +20,105 @@ import { handleCallbackErrors } from '../utils/handleCallbackErrors';
1020
import { hasTracingEnabled } from '../utils/hasTracingEnabled';
1121
import { spanTimeInputToSeconds, spanToJSON } from '../utils/spanUtils';
1222

23+
interface StartSpanOptions extends TransactionContext {
24+
/** A manually specified start time for the created `Span` object. */
25+
startTime?: SpanTimeInput;
26+
27+
/** If defined, start this span off this scope instead off the current scope. */
28+
scope?: Scope;
29+
30+
/** The name of the span. */
31+
name: string;
32+
33+
/** An op for the span. This is a categorization for spans. */
34+
op?: string;
35+
36+
/** The origin of the span - if it comes from auto instrumenation or manual instrumentation. */
37+
origin?: SpanOrigin;
38+
39+
/** Attributes for the span. */
40+
attributes?: SpanAttributes;
41+
42+
// All remaining fields are deprecated
43+
44+
/**
45+
* @deprecated Manually set the end timestamp instead.
46+
*/
47+
trimEnd?: boolean;
48+
49+
/**
50+
* @deprecated This cannot be set manually anymore.
51+
*/
52+
parentSampled?: boolean;
53+
54+
/**
55+
* @deprecated Use attributes or set data on scopes instead.
56+
*/
57+
metadata?: Partial<TransactionMetadata>;
58+
59+
/**
60+
* The name thingy.
61+
* @deprecated Use `name` instead.
62+
*/
63+
description?: string;
64+
65+
/**
66+
* @deprecated Use `span.setStatus()` instead.
67+
*/
68+
status?: string;
69+
70+
/**
71+
* @deprecated Use `scope` instead.
72+
*/
73+
parentSpanId?: string;
74+
75+
/**
76+
* @deprecated You cannot manually set the span to sampled anymore.
77+
*/
78+
sampled?: boolean;
79+
80+
/**
81+
* @deprecated You cannot manually set the spanId anymore.
82+
*/
83+
spanId?: string;
84+
85+
/**
86+
* @deprecated You cannot manually set the traceId anymore.
87+
*/
88+
traceId?: string;
89+
90+
/**
91+
* @deprecated Use an attribute instead.
92+
*/
93+
source?: TransactionSource;
94+
95+
/**
96+
* @deprecated Use attributes or set tags on the scope instead.
97+
*/
98+
tags?: { [key: string]: Primitive };
99+
100+
/**
101+
* @deprecated Use attributes instead.
102+
*/
103+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
104+
data?: { [key: string]: any };
105+
106+
/**
107+
* @deprecated Use `startTime` instead.
108+
*/
109+
startTimestamp?: number;
110+
111+
/**
112+
* @deprecated Use `span.end()` instead.
113+
*/
114+
endTimestamp?: number;
115+
116+
/**
117+
* @deprecated You cannot set the instrumenter manually anymore.
118+
*/
119+
instrumenter?: Instrumenter;
120+
}
121+
13122
/**
14123
* Wraps a function with a transaction/span and finishes the span after the function is done.
15124
*

packages/ember/addon/instance-initializers/sentry-performance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,11 +404,11 @@ export async function instrumentForPerformance(appInstance: ApplicationInstance)
404404
// Maintaining backwards compatibility with config.browserTracingOptions, but passing it with Sentry options is preferred.
405405
const browserTracingOptions = config.browserTracingOptions || config.sentry.browserTracingOptions || {};
406406

407-
const { browserTracingIntegration } = await import('@sentry/browser');
407+
const { BrowserTracing } = await import('@sentry/browser');
408408

409409
const idleTimeout = config.transitionTimeout || 5000;
410410

411-
const browserTracing = browserTracingIntegration({
411+
const browserTracing = new BrowserTracing({
412412
routingInstrumentation: (customStartTransaction, startTransactionOnPageLoad) => {
413413
// eslint-disable-next-line ember/no-private-routing-service
414414
const routerMain = appInstance.lookup('router:main') as EmberRouterMain;

packages/ember/addon/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import type { BrowserOptions, browserTracingIntegration } from '@sentry/browser';
1+
import type { BrowserOptions, BrowserTracing } from '@sentry/browser';
22
import type { Transaction, TransactionContext } from '@sentry/types';
33

4-
type BrowserTracingOptions = Parameters<typeof browserTracingIntegration>[0];
4+
type BrowserTracingOptions = ConstructorParameters<typeof BrowserTracing>[0];
55

66
export type EmberSentryConfig = {
77
sentry: BrowserOptions & { browserTracingOptions?: BrowserTracingOptions };

0 commit comments

Comments
 (0)