Skip to content

ref(tracing): Re-organize exports for node/browser #7345

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 13 commits into from
Mar 7, 2023
Merged
2 changes: 1 addition & 1 deletion packages/tracing/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sentry/tracing",
"version": "7.41.0",
"description": "Extensions for Sentry AM",
"description": "Sentry Performance Monitoring Package",
"repository": "git://github.com/getsentry/sentry-javascript.git",
"homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/tracing",
"author": "Sentry",
Expand Down
2 changes: 2 additions & 0 deletions packages/tracing/src/browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export * from '../exports';

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

export { BrowserTracing, BROWSER_TRACING_INTEGRATION_ID } from './browsertracing';
Expand Down
15 changes: 15 additions & 0 deletions packages/tracing/src/exports/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export {
extractTraceparentData,
getActiveTransaction,
hasTracingEnabled,
IdleTransaction,
Span,
// eslint-disable-next-line deprecation/deprecation
SpanStatus,
spanStatusfromHttpCode,
startIdleTransaction,
stripUrlQueryAndFragment,
TRACEPARENT_REGEXP,
Transaction,
} from '@sentry/core';
export type { SpanStatusType } from '@sentry/core';
8 changes: 4 additions & 4 deletions packages/tracing/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ function _autoloadDatabaseIntegrations(): void {

const packageToIntegrationMapping: Record<string, () => Integration> = {
mongodb() {
const integration = dynamicRequire(module, './integrations/node/mongo') as {
const integration = dynamicRequire(module, './node/integrations/mongo') as {
Mongo: IntegrationClass<Integration>;
};
return new integration.Mongo();
},
mongoose() {
const integration = dynamicRequire(module, './integrations/node/mongo') as {
const integration = dynamicRequire(module, './node/integrations/mongo') as {
Mongo: IntegrationClass<Integration>;
};
return new integration.Mongo({ mongoose: true });
},
mysql() {
const integration = dynamicRequire(module, './integrations/node/mysql') as {
const integration = dynamicRequire(module, './node/integrations/mysql') as {
Mysql: IntegrationClass<Integration>;
};
return new integration.Mysql();
},
pg() {
const integration = dynamicRequire(module, './integrations/node/postgres') as {
const integration = dynamicRequire(module, './node/integrations/postgres') as {
Postgres: IntegrationClass<Integration>;
};
return new integration.Postgres();
Expand Down
29 changes: 9 additions & 20 deletions packages/tracing/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
export {
extractTraceparentData,
getActiveTransaction,
hasTracingEnabled,
IdleTransaction,
Span,
// eslint-disable-next-line deprecation/deprecation
SpanStatus,
spanStatusfromHttpCode,
startIdleTransaction,
stripUrlQueryAndFragment,
TRACEPARENT_REGEXP,
Transaction,
} from '@sentry/core';
export type { SpanStatusType } from '@sentry/core';
export * from './exports';

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

export type { RequestInstrumentationOptions } from './browser';
import * as Integrations from './node';

export { Integrations };

Expand All @@ -37,9 +21,14 @@ export { Integrations };
// const instance = new BrowserTracing();
//
// For an example of of the new usage of BrowserTracing, see @sentry/nextjs index.client.ts
export { BrowserTracing, BROWSER_TRACING_INTEGRATION_ID } from './browser';
export {
BrowserTracing,
BROWSER_TRACING_INTEGRATION_ID,
instrumentOutgoingRequests,
defaultRequestInstrumentationOptions,
} from './browser';

export { instrumentOutgoingRequests, defaultRequestInstrumentationOptions } from './browser';
export type { RequestInstrumentationOptions } from './browser';

// Treeshakable guard to remove all code related to tracing
declare const __SENTRY_TRACING__: boolean;
Expand Down
11 changes: 0 additions & 11 deletions packages/tracing/src/integrations/index.ts

This file was deleted.

13 changes: 13 additions & 0 deletions packages/tracing/src/node/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export * from '../exports';

export { Express } from './integrations/express';
export { Postgres } from './integrations/postgres';
export { Mysql } from './integrations/mysql';
export { Mongo } from './integrations/mongo';
export { Prisma } from './integrations/prisma';
export { GraphQL } from './integrations/graphql';
export { Apollo } from './integrations/apollo';

// TODO(v7): Remove this export
// Please see `src/index.ts` for more details.
export { BrowserTracing } from '../browser';
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @sentry-internal/sdk/no-optional-chaining */

import type { Hub } from '@sentry/core';
import type { EventProcessor, Integration } from '@sentry/types';
import { arrayify, fill, isThenable, loadModule, logger } from '@sentry/utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @sentry-internal/sdk/no-optional-chaining */
import type { Hub } from '@sentry/types';

/**
Expand Down