Skip to content

Commit dc696c0

Browse files
authored
ref(tracing): Re-organize exports for node/browser (#7345)
1 parent 04d551e commit dc696c0

25 files changed

+123
-48
lines changed

packages/tracing/.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
extends: ['../../.eslintrc.js'],
33
overrides: [
44
{
5-
files: ['src/integrations/node/**'],
5+
files: ['src/node/**'],
66
rules: {
77
'@sentry-internal/sdk/no-optional-chaining': 'off',
88
},

packages/tracing/package.json

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@sentry/tracing",
33
"version": "7.41.0",
4-
"description": "Extensions for Sentry AM",
4+
"description": "Sentry Performance Monitoring Package",
55
"repository": "git://github.com/getsentry/sentry-javascript.git",
66
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/tracing",
77
"author": "Sentry",
@@ -12,6 +12,36 @@
1212
"main": "build/npm/cjs/index.js",
1313
"module": "build/npm/esm/index.js",
1414
"types": "build/npm/types/index.d.ts",
15+
"exports": {
16+
".": {
17+
"import": "./build/npm/esm/index.js",
18+
"require": "./build/npm/cjs/index.js",
19+
"types": "./build/npm/types/index.d.ts"
20+
},
21+
"./node": {
22+
"import": "./build/npm/esm/node/index.js",
23+
"require": "./build/npm/cjs/node/index.js",
24+
"types": "./build/npm/types/node/index.d.ts"
25+
},
26+
"./browser": {
27+
"import": "./build/npm/esm/browser/index.js",
28+
"require": "./build/npm/cjs/browser/index.js",
29+
"types": "./build/npm/types/browser/index.d.ts"
30+
}
31+
},
32+
"typesVersions": {
33+
"*": {
34+
"*": [
35+
"./build/npm/types/index.d.ts"
36+
],
37+
"node": [
38+
"./build/npm/types/node/index.d.ts"
39+
],
40+
"browser": [
41+
"./build/npm/types/browser/index.d.ts"
42+
]
43+
}
44+
},
1545
"publishConfig": {
1646
"access": "public"
1747
},

packages/tracing/rollup.npm.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { makeBaseNPMConfig, makeNPMConfigVariants } from '../../rollup/index.js'
22

33
export default makeNPMConfigVariants(
44
makeBaseNPMConfig({
5+
entrypoints: ['src/browser/index.ts', 'src/node/index.ts', 'src/index.ts'],
56
// packages with bundles have a different build directory structure
67
hasBundles: true,
78
}),

packages/tracing/src/browser/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export * from '../exports';
2+
13
export type { RequestInstrumentationOptions } from './request';
24

35
export { BrowserTracing, BROWSER_TRACING_INTEGRATION_ID } from './browsertracing';

packages/tracing/src/exports/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export {
2+
extractTraceparentData,
3+
getActiveTransaction,
4+
hasTracingEnabled,
5+
IdleTransaction,
6+
Span,
7+
// eslint-disable-next-line deprecation/deprecation
8+
SpanStatus,
9+
spanStatusfromHttpCode,
10+
startIdleTransaction,
11+
stripUrlQueryAndFragment,
12+
TRACEPARENT_REGEXP,
13+
Transaction,
14+
} from '@sentry/core';
15+
export type { SpanStatusType } from '@sentry/core';

packages/tracing/src/extensions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@ function _autoloadDatabaseIntegrations(): void {
1515

1616
const packageToIntegrationMapping: Record<string, () => Integration> = {
1717
mongodb() {
18-
const integration = dynamicRequire(module, './integrations/node/mongo') as {
18+
const integration = dynamicRequire(module, './node/integrations/mongo') as {
1919
Mongo: IntegrationClass<Integration>;
2020
};
2121
return new integration.Mongo();
2222
},
2323
mongoose() {
24-
const integration = dynamicRequire(module, './integrations/node/mongo') as {
24+
const integration = dynamicRequire(module, './node/integrations/mongo') as {
2525
Mongo: IntegrationClass<Integration>;
2626
};
2727
return new integration.Mongo({ mongoose: true });
2828
},
2929
mysql() {
30-
const integration = dynamicRequire(module, './integrations/node/mysql') as {
30+
const integration = dynamicRequire(module, './node/integrations/mysql') as {
3131
Mysql: IntegrationClass<Integration>;
3232
};
3333
return new integration.Mysql();
3434
},
3535
pg() {
36-
const integration = dynamicRequire(module, './integrations/node/postgres') as {
36+
const integration = dynamicRequire(module, './node/integrations/postgres') as {
3737
Postgres: IntegrationClass<Integration>;
3838
};
3939
return new integration.Postgres();

packages/tracing/src/index.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,7 @@
1-
export {
2-
extractTraceparentData,
3-
getActiveTransaction,
4-
hasTracingEnabled,
5-
IdleTransaction,
6-
Span,
7-
// eslint-disable-next-line deprecation/deprecation
8-
SpanStatus,
9-
spanStatusfromHttpCode,
10-
startIdleTransaction,
11-
stripUrlQueryAndFragment,
12-
TRACEPARENT_REGEXP,
13-
Transaction,
14-
} from '@sentry/core';
15-
export type { SpanStatusType } from '@sentry/core';
1+
export * from './exports';
162

173
import { addExtensionMethods } from './extensions';
18-
import * as Integrations from './integrations';
19-
20-
export type { RequestInstrumentationOptions } from './browser';
4+
import * as Integrations from './node/integrations';
215

226
export { Integrations };
237

@@ -37,9 +21,14 @@ export { Integrations };
3721
// const instance = new BrowserTracing();
3822
//
3923
// For an example of of the new usage of BrowserTracing, see @sentry/nextjs index.client.ts
40-
export { BrowserTracing, BROWSER_TRACING_INTEGRATION_ID } from './browser';
24+
export {
25+
BrowserTracing,
26+
BROWSER_TRACING_INTEGRATION_ID,
27+
instrumentOutgoingRequests,
28+
defaultRequestInstrumentationOptions,
29+
} from './browser';
4130

42-
export { instrumentOutgoingRequests, defaultRequestInstrumentationOptions } from './browser';
31+
export type { RequestInstrumentationOptions } from './browser';
4332

4433
// Treeshakable guard to remove all code related to tracing
4534
declare const __SENTRY_TRACING__: boolean;

packages/tracing/src/integrations/index.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

packages/tracing/src/node/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from '../exports';
2+
3+
export * from './integrations';

0 commit comments

Comments
 (0)