Skip to content

feat(tracing): Move Integrations from tracing-internal to @sentry/tracing #7471

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 2 commits into from
Mar 15, 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
26 changes: 3 additions & 23 deletions packages/tracing-internal/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
export * from './exports';

import { addExtensionMethods } from './extensions';
import * as Integrations from './node/integrations';

export { Integrations };

// BrowserTracing is already exported as part of `Integrations` above (and for the moment will remain so for
// backwards compatibility), but that interferes with treeshaking, so we also export it separately
// here.
//
// Previously we expected users to import tracing integrations like
//
// import { Integrations } from '@sentry/tracing';
// const instance = new Integrations.BrowserTracing();
//
// This makes the integrations unable to be treeshaken though. To address this, we now have
// this individual export. We now expect users to consume BrowserTracing like so:
//
// import { BrowserTracing } from '@sentry/tracing';
// const instance = new BrowserTracing();
//
// For an example of of the new usage of BrowserTracing, see @sentry/nextjs index.client.ts
export { BrowserTracing } from './browser';
export { Apollo, Express, GraphQL, Mongo, Mysql, Postgres, Prisma } from './node/integrations';

export {
BrowserTracing,
BROWSER_TRACING_INTEGRATION_ID,
instrumentOutgoingRequests,
defaultRequestInstrumentationOptions,
} from './browser';

export type { RequestInstrumentationOptions } from './browser';

export { addExtensionMethods };
export { addExtensionMethods } from './extensions';
4 changes: 0 additions & 4 deletions packages/tracing-internal/src/node/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,3 @@ export { Mongo } from './mongo';
export { Prisma } from './prisma';
export { GraphQL } from './graphql';
export { Apollo } from './apollo';

// TODO(v8): Remove this export
// Please see `src/index.ts` for more details.
export { BrowserTracing } from '../../browser';
49 changes: 45 additions & 4 deletions packages/tracing/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,49 @@
export * from '@sentry-internal/tracing';
export {
// BrowserTracing is already exported as part of `Integrations` below (and for the moment will remain so for
// backwards compatibility), but that interferes with treeshaking, so we also export it separately
// here.
BrowserTracing,
BROWSER_TRACING_INTEGRATION_ID,
IdleTransaction,
Span,
// eslint-disable-next-line deprecation/deprecation
SpanStatus,
TRACEPARENT_REGEXP,
Transaction,
addExtensionMethods,
defaultRequestInstrumentationOptions,
extractTraceparentData,
instrumentOutgoingRequests,
getActiveTransaction,
hasTracingEnabled,
spanStatusfromHttpCode,
startIdleTransaction,
stripUrlQueryAndFragment,
} from '@sentry-internal/tracing';
export type { RequestInstrumentationOptions, SpanStatusType } from '@sentry-internal/tracing';

import { addExtensionMethods } from '@sentry-internal/tracing';
import {
addExtensionMethods,
Apollo,
BrowserTracing,
Express,
GraphQL,
Mongo,
Mysql,
Postgres,
Prisma,
} from '@sentry-internal/tracing';

export const Integrations = {
BrowserTracing: BrowserTracing,
Apollo: Apollo,
Express: Express,
GraphQL: GraphQL,
Mongo: Mongo,
Mysql: Mysql,
Postgres: Postgres,
Prisma: Prisma,
};

// Treeshakable guard to remove all code related to tracing
declare const __SENTRY_TRACING__: boolean;
Expand All @@ -10,5 +53,3 @@ if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
// We are patching the global object with our hub extension methods
addExtensionMethods();
}

export { addExtensionMethods };