Skip to content

Commit c2f2e58

Browse files
committed
Move files from @sentry/tracing to @sentry-internal/tracing
1 parent 67486a8 commit c2f2e58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+71
-80
lines changed
Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
export {};
1+
export * from './exports';
2+
3+
import { addExtensionMethods } from './extensions';
4+
import * as Integrations from './node/integrations';
5+
6+
export { Integrations };
7+
8+
// BrowserTracing is already exported as part of `Integrations` above (and for the moment will remain so for
9+
// backwards compatibility), but that interferes with treeshaking, so we also export it separately
10+
// here.
11+
//
12+
// Previously we expected users to import tracing integrations like
13+
//
14+
// import { Integrations } from '@sentry/tracing';
15+
// const instance = new Integrations.BrowserTracing();
16+
//
17+
// This makes the integrations unable to be treeshaken though. To address this, we now have
18+
// this individual export. We now expect users to consume BrowserTracing like so:
19+
//
20+
// import { BrowserTracing } from '@sentry/tracing';
21+
// const instance = new BrowserTracing();
22+
//
23+
// For an example of of the new usage of BrowserTracing, see @sentry/nextjs index.client.ts
24+
export const BrowserTracing = Integrations.BrowserTracing;
25+
26+
export {
27+
BROWSER_TRACING_INTEGRATION_ID,
28+
instrumentOutgoingRequests,
29+
defaultRequestInstrumentationOptions,
30+
} from './browser';
31+
32+
export type { RequestInstrumentationOptions } from './browser';
33+
34+
export { addExtensionMethods };

packages/tracing/test/browser/backgroundtab.test.ts renamed to packages/tracing-internal/test/browser/backgroundtab.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { BrowserClient } from '@sentry/browser';
22
import { Hub, makeMain } from '@sentry/core';
33
import { JSDOM } from 'jsdom';
44

5-
import { addExtensionMethods } from '../../src';
5+
import { addExtensionMethods } from '../../../tracing/src';
6+
import { getDefaultBrowserClientOptions } from '../../../tracing/test/testutils';
67
import { registerBackgroundTabDetection } from '../../src/browser/backgroundtab';
7-
import { getDefaultBrowserClientOptions } from '../testutils';
88

99
describe('registerBackgroundTabDetection', () => {
1010
let events: Record<string, any> = {};

packages/tracing/test/browser/browsertracing.test.ts renamed to packages/tracing-internal/test/browser/browsertracing.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import type { BaseTransportOptions, ClientOptions, DsnComponents } from '@sentry
55
import type { InstrumentHandlerCallback, InstrumentHandlerType } from '@sentry/utils';
66
import { JSDOM } from 'jsdom';
77

8-
import type { IdleTransaction } from '../../src';
9-
import { getActiveTransaction } from '../../src';
8+
import type { IdleTransaction } from '../../../tracing/src';
9+
import { getActiveTransaction } from '../../../tracing/src';
10+
import { getDefaultBrowserClientOptions } from '../../../tracing/test/testutils';
1011
import type { BrowserTracingOptions } from '../../src/browser/browsertracing';
1112
import { BrowserTracing, getMetaContent } from '../../src/browser/browsertracing';
1213
import { defaultRequestInstrumentationOptions } from '../../src/browser/request';
1314
import { instrumentRoutingWithDefaults } from '../../src/browser/router';
14-
import { getDefaultBrowserClientOptions } from '../testutils';
1515

1616
let mockChangeHistory: ({ to, from }: { to: string; from?: string }) => void = () => undefined;
1717

packages/tracing/test/browser/request.test.ts renamed to packages/tracing-internal/test/browser/request.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { BrowserClient } from '@sentry/browser';
22
import * as sentryCore from '@sentry/core';
33
import * as utils from '@sentry/utils';
44

5-
import type { Transaction } from '../../src';
6-
import { addExtensionMethods, Span, spanStatusfromHttpCode } from '../../src';
5+
import type { Transaction } from '../../../tracing/src';
6+
import { addExtensionMethods, Span, spanStatusfromHttpCode } from '../../../tracing/src';
7+
import { getDefaultBrowserClientOptions } from '../../../tracing/test/testutils';
78
import type { FetchData, XHRData } from '../../src/browser/request';
89
import { fetchCallback, instrumentOutgoingRequests, shouldAttachHeaders, xhrCallback } from '../../src/browser/request';
9-
import { getDefaultBrowserClientOptions } from '../testutils';
1010

1111
beforeAll(() => {
1212
addExtensionMethods();

packages/tracing/test/errors.test.ts renamed to packages/tracing-internal/test/errors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { BrowserClient } from '@sentry/browser';
22
import { addTracingExtensions, Hub, makeMain } from '@sentry/core';
33
import type { InstrumentHandlerCallback, InstrumentHandlerType } from '@sentry/utils';
44

5+
import { getDefaultBrowserClientOptions } from '../../tracing/test/testutils';
56
import { registerErrorInstrumentation } from '../src/errors';
6-
import { getDefaultBrowserClientOptions } from './testutils';
77

88
const mockAddInstrumentationHandler = jest.fn();
99
let mockErrorCallback: InstrumentHandlerCallback = () => undefined;

packages/tracing/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
"access": "public"
1717
},
1818
"dependencies": {
19-
"@sentry/core": "7.43.0",
20-
"@sentry/types": "7.43.0",
21-
"@sentry/utils": "7.43.0",
22-
"tslib": "^1.9.3"
19+
"@sentry-internal/tracing": "7.43.0"
2320
},
2421
"devDependencies": {
2522
"@sentry/browser": "7.43.0",
26-
"@types/express": "^4.17.14"
23+
"@types/express": "^4.17.14",
24+
"@sentry/core": "7.43.0",
25+
"@sentry/types": "7.43.0",
26+
"@sentry/utils": "7.43.0"
2727
},
2828
"scripts": {
2929
"build": "run-p build:transpile build:types build:bundle",

packages/tracing/src/index.bundle.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ export {
5353
} from '@sentry/browser';
5454
export { SDK_VERSION } from '@sentry/browser';
5555

56+
import { addExtensionMethods, BrowserTracing } from '@sentry-internal/tracing';
5657
import { Integrations as BrowserIntegrations } from '@sentry/browser';
5758
import type { Integration } from '@sentry/types';
5859
import { GLOBAL_OBJ } from '@sentry/utils';
5960

60-
import { BrowserTracing } from './browser';
61-
import { addExtensionMethods } from './extensions';
62-
6361
export { Span } from '@sentry/core';
6462

6563
let windowIntegrations = {};
@@ -79,12 +77,7 @@ const INTEGRATIONS: Record<
7977
BrowserTracing,
8078
};
8179

82-
export { INTEGRATIONS as Integrations };
83-
// Though in this case exporting `BrowserTracing` separately (in addition to exporting it as part of
84-
// `Sentry.Integrations`) doesn't gain us any bundle size advantage (we're making the bundle here, not the user, and we
85-
// can't leave anything out of ours), it does bring the API for using the integration in line with that recommended for
86-
// users bundling Sentry themselves.
87-
export { BrowserTracing };
80+
export { INTEGRATIONS as Integrations, BrowserTracing };
8881

8982
// We are patching the global object with our hub extension methods
9083
addExtensionMethods();

packages/tracing/src/index.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,6 @@
1-
export * from './exports';
1+
export * from '@sentry-internal/tracing';
22

3-
import { addExtensionMethods } from './extensions';
4-
import * as Integrations from './node/integrations';
5-
6-
export { Integrations };
7-
8-
// This is already exported as part of `Integrations` above (and for the moment will remain so for
9-
// backwards compatibility), but that interferes with treeshaking, so we also export it separately
10-
// here.
11-
//
12-
// Previously we expected users to import tracing integrations like
13-
//
14-
// import { Integrations } from '@sentry/tracing';
15-
// const instance = new Integrations.BrowserTracing();
16-
//
17-
// This makes the integrations unable to be treeshaken though. To address this, we now have
18-
// this individual export. We now expect users to consume BrowserTracing like so:
19-
//
20-
// import { BrowserTracing } from '@sentry/tracing';
21-
// const instance = new BrowserTracing();
22-
//
23-
// For an example of of the new usage of BrowserTracing, see @sentry/nextjs index.client.ts
24-
export {
25-
BrowserTracing,
26-
BROWSER_TRACING_INTEGRATION_ID,
27-
instrumentOutgoingRequests,
28-
defaultRequestInstrumentationOptions,
29-
} from './browser';
30-
31-
export type { RequestInstrumentationOptions } from './browser';
3+
import { addExtensionMethods } from '@sentry-internal/tracing';
324

335
// Treeshakable guard to remove all code related to tracing
346
declare const __SENTRY_TRACING__: boolean;

packages/tracing/test/hub.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { Hub, makeMain } from '@sentry/core';
44
import * as utilsModule from '@sentry/utils'; // for mocking
55
import { logger } from '@sentry/utils';
66

7-
import { addExtensionMethods, extractTraceparentData, TRACEPARENT_REGEXP, Transaction } from '../src';
8-
import { BrowserTracing } from '../src/browser/browsertracing';
7+
import { addExtensionMethods, BrowserTracing, extractTraceparentData, TRACEPARENT_REGEXP, Transaction } from '../src';
98
import {
109
addDOMPropertiesToGlobal,
1110
getDefaultBrowserClientOptions,

packages/tracing/test/integrations/apollo-nestjs.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import { Hub, Scope } from '@sentry/core';
33
import { logger } from '@sentry/utils';
44

5-
import { Span } from '../../src';
6-
import { Apollo } from '../../src/node/integrations/apollo';
5+
import { Integrations, Span } from '../../src';
76
import { getTestClient } from '../testutils';
87

98
type ApolloResolverGroup = {
@@ -67,7 +66,7 @@ describe('setupOnce', () => {
6766
let GraphQLFactoryInstance: GraphQLFactory;
6867

6968
beforeAll(() => {
70-
new Apollo({
69+
new Integrations.Apollo({
7170
useNestjs: true,
7271
}).setupOnce(
7372
() => undefined,
@@ -113,7 +112,7 @@ describe('setupOnce', () => {
113112
const client = getTestClient({ instrumenter: 'otel' });
114113
const hub = new Hub(client);
115114

116-
const integration = new Apollo({ useNestjs: true });
115+
const integration = new Integrations.Apollo({ useNestjs: true });
117116
integration.setupOnce(
118117
() => {},
119118
() => hub,

packages/tracing/test/integrations/apollo.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import { Hub, Scope } from '@sentry/core';
33
import { logger } from '@sentry/utils';
44

5-
import { Span } from '../../src';
6-
import { Apollo } from '../../src/node/integrations/apollo';
5+
import { Integrations, Span } from '../../src';
76
import { getTestClient } from '../testutils';
87

98
type ApolloResolverGroup = {
@@ -69,7 +68,7 @@ describe('setupOnce', () => {
6968
let ApolloServer: ApolloServerBase;
7069

7170
beforeAll(() => {
72-
new Apollo().setupOnce(
71+
new Integrations.Apollo().setupOnce(
7372
() => undefined,
7473
() => new Hub(undefined, scope),
7574
);
@@ -113,7 +112,7 @@ describe('setupOnce', () => {
113112
const client = getTestClient({ instrumenter: 'otel' });
114113
const hub = new Hub(client);
115114

116-
const integration = new Apollo();
115+
const integration = new Integrations.Apollo();
117116
integration.setupOnce(
118117
() => {},
119118
() => hub,

packages/tracing/test/integrations/graphql.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import { Hub, Scope } from '@sentry/core';
33
import { logger } from '@sentry/utils';
44

5-
import { Span } from '../../src';
6-
import { GraphQL } from '../../src/node/integrations/graphql';
5+
import { Integrations, Span } from '../../src';
76
import { getTestClient } from '../testutils';
87

98
const GQLExecute = {
@@ -33,7 +32,7 @@ describe('setupOnce', () => {
3332
let childSpan: Span;
3433

3534
beforeAll(() => {
36-
new GraphQL().setupOnce(
35+
new Integrations.GraphQL().setupOnce(
3736
() => undefined,
3837
() => new Hub(undefined, scope),
3938
);
@@ -66,7 +65,7 @@ describe('setupOnce', () => {
6665
const client = getTestClient({ instrumenter: 'otel' });
6766
const hub = new Hub(client);
6867

69-
const integration = new GraphQL();
68+
const integration = new Integrations.GraphQL();
7069
integration.setupOnce(
7170
() => {},
7271
() => hub,

packages/tracing/test/integrations/node/mongo.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import { Hub, Scope } from '@sentry/core';
33
import { logger } from '@sentry/utils';
44

5-
import { Span } from '../../../src';
6-
import { Mongo } from '../../../src/node/integrations/mongo';
5+
import { Integrations, Span } from '../../../src';
76
import { getTestClient } from '../../testutils';
87

98
class Collection {
@@ -52,7 +51,7 @@ describe('patchOperation()', () => {
5251
let childSpan: Span;
5352

5453
beforeAll(() => {
55-
new Mongo({
54+
new Integrations.Mongo({
5655
operations: ['insertOne', 'initializeOrderedBulkOp'],
5756
}).setupOnce(
5857
() => undefined,
@@ -124,7 +123,7 @@ describe('patchOperation()', () => {
124123
const client = getTestClient({ instrumenter: 'otel' });
125124
const hub = new Hub(client);
126125

127-
const integration = new Mongo();
126+
const integration = new Integrations.Mongo();
128127
integration.setupOnce(
129128
() => {},
130129
() => hub,

packages/tracing/test/integrations/node/postgres.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import { Hub, Scope } from '@sentry/core';
33
import { logger } from '@sentry/utils';
44

5-
import { Span } from '../../../src';
6-
import { Postgres } from '../../../src/node/integrations/postgres';
5+
import { Integrations, Span } from '../../../src';
76
import { getTestClient } from '../../testutils';
87

98
class PgClient {
@@ -51,7 +50,7 @@ describe('setupOnce', () => {
5150
let childSpan: Span;
5251

5352
beforeAll(() => {
54-
(pgApi === 'pg' ? new Postgres() : new Postgres({ usePgNative: true })).setupOnce(
53+
(pgApi === 'pg' ? new Integrations.Postgres() : new Integrations.Postgres({ usePgNative: true })).setupOnce(
5554
() => undefined,
5655
() => new Hub(undefined, scope),
5756
);
@@ -107,7 +106,7 @@ describe('setupOnce', () => {
107106
const client = getTestClient({ instrumenter: 'otel' });
108107
const hub = new Hub(client);
109108

110-
const integration = new Postgres();
109+
const integration = new Integrations.Postgres();
111110
integration.setupOnce(
112111
() => {},
113112
() => hub,

packages/tracing/test/integrations/node/prisma.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
import { Hub, Scope } from '@sentry/core';
33
import { logger } from '@sentry/utils';
44

5-
import { Span } from '../../../src';
6-
import { Prisma } from '../../../src/node/integrations/prisma';
5+
import { Integrations, Span } from '../../../src';
76
import { getTestClient } from '../../testutils';
87

98
type PrismaMiddleware = (params: unknown, next: (params?: unknown) => Promise<unknown>) => Promise<unknown>;
@@ -32,7 +31,7 @@ describe('setupOnce', function () {
3231
let childSpan: Span;
3332

3433
beforeAll(() => {
35-
new Prisma({ client: Client }).setupOnce(
34+
new Integrations.Prisma({ client: Client }).setupOnce(
3635
() => undefined,
3736
() => new Hub(undefined, scope),
3837
);
@@ -66,7 +65,7 @@ describe('setupOnce', function () {
6665
const client = getTestClient({ instrumenter: 'otel' });
6766
const hub = new Hub(client);
6867

69-
const integration = new Prisma({ client: Client });
68+
const integration = new Integrations.Prisma({ client: Client });
7069
integration.setupOnce(
7170
() => {},
7271
() => hub,

0 commit comments

Comments
 (0)