Skip to content

Commit baff7dd

Browse files
authored
feat(nextjs): Remove @sentry/tracing dependency from nextjs SDK (#7561)
1 parent 86b89b9 commit baff7dd

File tree

9 files changed

+24
-10
lines changed

9 files changed

+24
-10
lines changed

packages/browser/src/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const INTEGRATIONS = {
2121
export { INTEGRATIONS as Integrations };
2222

2323
export { Replay } from '@sentry/replay';
24-
export { BrowserTracing } from '@sentry-internal/tracing';
25-
export { addTracingExtensions } from '@sentry/core';
24+
export { BrowserTracing, defaultRequestInstrumentationOptions } from '@sentry-internal/tracing';
25+
export { addTracingExtensions, getActiveTransaction } from '@sentry/core';
2626
export { makeBrowserOfflineTransport } from './transports/offline';
2727
export { onProfilingStartRouteTransaction } from './profiling/hubextensions';
2828
export { BrowserProfilingIntegration } from './profiling/integration';

packages/nextjs/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"@sentry/integrations": "7.44.2",
2323
"@sentry/node": "7.44.2",
2424
"@sentry/react": "7.44.2",
25-
"@sentry/tracing": "7.44.2",
2625
"@sentry/types": "7.44.2",
2726
"@sentry/utils": "7.44.2",
2827
"@sentry/webpack-plugin": "1.20.0",

packages/nextjs/src/client/index.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { hasTracingEnabled } from '@sentry/core';
22
import { RewriteFrames } from '@sentry/integrations';
33
import type { BrowserOptions } from '@sentry/react';
4-
import { configureScope, init as reactInit, Integrations } from '@sentry/react';
5-
import { BrowserTracing, defaultRequestInstrumentationOptions } from '@sentry/tracing';
4+
import {
5+
BrowserTracing,
6+
configureScope,
7+
defaultRequestInstrumentationOptions,
8+
init as reactInit,
9+
Integrations,
10+
} from '@sentry/react';
611
import type { EventProcessor } from '@sentry/types';
712
import { addOrUpdateIntegration } from '@sentry/utils';
813

packages/nextjs/src/edge/edgeclient.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Scope } from '@sentry/core';
2-
import { BaseClient, SDK_VERSION } from '@sentry/core';
2+
import { addTracingExtensions, BaseClient, SDK_VERSION } from '@sentry/core';
33
import type { ClientOptions, Event, EventHint, Severity, SeverityLevel } from '@sentry/types';
44

55
import { eventFromMessage, eventFromUnknownInput } from './eventbuilder';
@@ -28,6 +28,9 @@ export class EdgeClient extends BaseClient<EdgeClientOptions> {
2828
version: SDK_VERSION,
2929
};
3030

31+
// The Edge client always supports tracing
32+
addTracingExtensions();
33+
3134
super(options);
3235
}
3336

packages/nextjs/src/edge/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import '@sentry/tracing'; // Allow people to call tracing API methods without explicitly importing the tracing package.
2-
31
import { getCurrentHub, getIntegrationsToSetup, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';
42
import type { Options } from '@sentry/types';
53
import {

packages/nextjs/src/server/utils/wrapperUtils.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { captureException, getCurrentHub, startTransaction } from '@sentry/core';
2-
import { getActiveTransaction } from '@sentry/tracing';
1+
import { captureException, getActiveTransaction, getCurrentHub, startTransaction } from '@sentry/core';
32
import type { Transaction } from '@sentry/types';
43
import { baggageHeaderToDynamicSamplingContext, extractTraceparentData } from '@sentry/utils';
54
import * as domain from 'domain';

packages/nextjs/test/config/wrappers.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import * as SentryCore from '@sentry/core';
2+
import { addTracingExtensions } from '@sentry/core';
23
import * as SentryNode from '@sentry/node';
34
import type { IncomingMessage, ServerResponse } from 'http';
45

56
import { wrapGetInitialPropsWithSentry, wrapGetServerSidePropsWithSentry } from '../../src/server';
67

78
const startTransactionSpy = jest.spyOn(SentryCore, 'startTransaction');
89

10+
// The wrap* functions require the hub to have tracing extensions. This is normally called by the NodeClient
11+
// constructor but the client isn't used in these tests.
12+
addTracingExtensions();
13+
914
describe('data-fetching function wrappers', () => {
1015
const route = '/tricks/[trickName]';
1116
let req: IncomingMessage;

packages/nextjs/test/edge/withSentryAPI.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import * as coreSdk from '@sentry/core';
22

33
import { wrapApiHandlerWithSentry } from '../../src/edge';
44

5+
// The wrap* functions require the hub to have tracing extensions. This is normally called by the EdgeClient
6+
// constructor but the client isn't used in these tests.
7+
coreSdk.addTracingExtensions();
8+
59
// @ts-ignore Request does not exist on type Global
610
const origRequest = global.Request;
711
// @ts-ignore Response does not exist on type Global

packages/node/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export {
3030
captureMessage,
3131
configureScope,
3232
createTransport,
33+
getActiveTransaction,
3334
getHubFromCarrier,
3435
getCurrentHub,
3536
Hub,

0 commit comments

Comments
 (0)