Skip to content

feat(nextjs): Remove @sentry/tracing dependency from nextjs SDK #7561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const INTEGRATIONS = {
export { INTEGRATIONS as Integrations };

export { Replay } from '@sentry/replay';
export { BrowserTracing } from '@sentry-internal/tracing';
export { addTracingExtensions } from '@sentry/core';
export { BrowserTracing, defaultRequestInstrumentationOptions } from '@sentry-internal/tracing';
export { addTracingExtensions, getActiveTransaction } from '@sentry/core';
export { makeBrowserOfflineTransport } from './transports/offline';
export { onProfilingStartRouteTransaction } from './profiling/hubextensions';
export { BrowserProfilingIntegration } from './profiling/integration';
1 change: 0 additions & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"@sentry/integrations": "7.44.2",
"@sentry/node": "7.44.2",
"@sentry/react": "7.44.2",
"@sentry/tracing": "7.44.2",
"@sentry/types": "7.44.2",
"@sentry/utils": "7.44.2",
"@sentry/webpack-plugin": "1.20.0",
Expand Down
9 changes: 7 additions & 2 deletions packages/nextjs/src/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { hasTracingEnabled } from '@sentry/core';
import { RewriteFrames } from '@sentry/integrations';
import type { BrowserOptions } from '@sentry/react';
import { configureScope, init as reactInit, Integrations } from '@sentry/react';
import { BrowserTracing, defaultRequestInstrumentationOptions } from '@sentry/tracing';
import {
BrowserTracing,
configureScope,
defaultRequestInstrumentationOptions,
init as reactInit,
Integrations,
} from '@sentry/react';
import type { EventProcessor } from '@sentry/types';
import { addOrUpdateIntegration } from '@sentry/utils';

Expand Down
5 changes: 4 additions & 1 deletion packages/nextjs/src/edge/edgeclient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Scope } from '@sentry/core';
import { BaseClient, SDK_VERSION } from '@sentry/core';
import { addTracingExtensions, BaseClient, SDK_VERSION } from '@sentry/core';
import type { ClientOptions, Event, EventHint, Severity, SeverityLevel } from '@sentry/types';

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

// The Edge client always supports tracing
addTracingExtensions();

super(options);
}

Expand Down
2 changes: 0 additions & 2 deletions packages/nextjs/src/edge/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import '@sentry/tracing'; // Allow people to call tracing API methods without explicitly importing the tracing package.

import { getCurrentHub, getIntegrationsToSetup, initAndBind, Integrations as CoreIntegrations } from '@sentry/core';
import type { Options } from '@sentry/types';
import {
Expand Down
3 changes: 1 addition & 2 deletions packages/nextjs/src/server/utils/wrapperUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { captureException, getCurrentHub, startTransaction } from '@sentry/core';
import { getActiveTransaction } from '@sentry/tracing';
import { captureException, getActiveTransaction, getCurrentHub, startTransaction } from '@sentry/core';
import type { Transaction } from '@sentry/types';
import { baggageHeaderToDynamicSamplingContext, extractTraceparentData } from '@sentry/utils';
import * as domain from 'domain';
Expand Down
5 changes: 5 additions & 0 deletions packages/nextjs/test/config/wrappers.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import * as SentryCore from '@sentry/core';
import { addTracingExtensions } from '@sentry/core';
import * as SentryNode from '@sentry/node';
import type { IncomingMessage, ServerResponse } from 'http';

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

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

// The wrap* functions require the hub to have tracing extensions. This is normally called by the NodeClient
// constructor but the client isn't used in these tests.
addTracingExtensions();

describe('data-fetching function wrappers', () => {
const route = '/tricks/[trickName]';
let req: IncomingMessage;
Expand Down
4 changes: 4 additions & 0 deletions packages/nextjs/test/edge/withSentryAPI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import * as coreSdk from '@sentry/core';

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

// The wrap* functions require the hub to have tracing extensions. This is normally called by the EdgeClient
// constructor but the client isn't used in these tests.
coreSdk.addTracingExtensions();

// @ts-ignore Request does not exist on type Global
const origRequest = global.Request;
// @ts-ignore Response does not exist on type Global
Expand Down
1 change: 1 addition & 0 deletions packages/node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export {
captureMessage,
configureScope,
createTransport,
getActiveTransaction,
getHubFromCarrier,
getCurrentHub,
Hub,
Expand Down