From 97e6ff36523934b6631965f9a22a4b5403068be8 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:11:49 -0400 Subject: [PATCH 01/17] [v7] feat: Remove references to @sentry/apm (#4845) Removes all references to `@sentry/apm`, a deprecated package we do not use anymore. --- packages/integrations/src/vue.ts | 58 ++++---------------- packages/react/src/profiler.tsx | 90 +++----------------------------- 2 files changed, 16 insertions(+), 132 deletions(-) diff --git a/packages/integrations/src/vue.ts b/packages/integrations/src/vue.ts index 1b1cf3caa63a..12c55f53df32 100644 --- a/packages/integrations/src/vue.ts +++ b/packages/integrations/src/vue.ts @@ -5,15 +5,6 @@ import { basename, getGlobalObject, logger, timestampWithMs } from '@sentry/util import { IS_DEBUG_BUILD } from './flags'; -/** - * Used to extract Tracing integration from the current client, - * without the need to import `Tracing` itself from the @sentry/apm package. - * @deprecated as @sentry/tracing should be used over @sentry/apm. - */ -const TRACING_GETTER = { - id: 'Tracing', -} as any as IntegrationClass; - /** * Used to extract BrowserTracing integration from @sentry/tracing */ @@ -150,7 +141,6 @@ export class Vue implements Integration { private readonly _componentsCache: { [key: string]: string } = {}; private _rootSpan?: Span; private _rootSpanTimer?: ReturnType; - private _tracingActivity?: number; /** * @inheritDoc @@ -260,30 +250,12 @@ export class Vue implements Integration { vm.$once(`hook:${hook}`, () => { // Create an activity on the first event call. There'll be no second call, as rootSpan will be in place, // thus new event handler won't be attached. - - // We do this whole dance with `TRACING_GETTER` to prevent `@sentry/apm` from becoming a peerDependency. - // We also need to ask for the `.constructor`, as `pushActivity` and `popActivity` are static, not instance methods. - /* eslint-disable @typescript-eslint/no-unsafe-member-access */ - // eslint-disable-next-line deprecation/deprecation - const tracingIntegration = getCurrentHub().getIntegration(TRACING_GETTER); - if (tracingIntegration) { - this._tracingActivity = (tracingIntegration as any).constructor.pushActivity('Vue Application Render'); - const transaction = (tracingIntegration as any).constructor.getTransaction(); - if (transaction) { - this._rootSpan = transaction.startChild({ - description: 'Application Render', - op: VUE_OP, - }); - } - // Use functionality from @sentry/tracing - } else { - const activeTransaction = getActiveTransaction(getCurrentHub()); - if (activeTransaction) { - this._rootSpan = activeTransaction.startChild({ - description: 'Application Render', - op: VUE_OP, - }); - } + const activeTransaction = getActiveTransaction(getCurrentHub()); + if (activeTransaction) { + this._rootSpan = activeTransaction.startChild({ + description: 'Application Render', + op: VUE_OP, + }); } /* eslint-enable @typescript-eslint/no-unsafe-member-access */ }); @@ -349,24 +321,13 @@ export class Vue implements Integration { }; /** Finish top-level span and activity with a debounce configured using `timeout` option */ - private _finishRootSpan(timestamp: number, getCurrentHub: () => Hub): void { + private _finishRootSpan(timestamp: number, _getCurrentHub: () => Hub): void { if (this._rootSpanTimer) { clearTimeout(this._rootSpanTimer); } this._rootSpanTimer = setTimeout(() => { - if (this._tracingActivity) { - // We do this whole dance with `TRACING_GETTER` to prevent `@sentry/apm` from becoming a peerDependency. - // We also need to ask for the `.constructor`, as `pushActivity` and `popActivity` are static, not instance methods. - // eslint-disable-next-line deprecation/deprecation - const tracingIntegration = getCurrentHub().getIntegration(TRACING_GETTER); - if (tracingIntegration) { - // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access - (tracingIntegration as any).constructor.popActivity(this._tracingActivity); - } - } - - // We should always finish the span, only should pop activity if using @sentry/apm + // We should always finish the span if (this._rootSpan) { this._rootSpan.finish(timestamp); } @@ -379,8 +340,7 @@ export class Vue implements Integration { this._options.Vue.mixin({ beforeCreate(this: ViewModel): void { - // eslint-disable-next-line deprecation/deprecation - if (getCurrentHub().getIntegration(TRACING_GETTER) || getCurrentHub().getIntegration(BROWSER_TRACING_GETTER)) { + if (getCurrentHub().getIntegration(BROWSER_TRACING_GETTER)) { // `this` points to currently rendered component applyTracingHooks(this, getCurrentHub); } else { diff --git a/packages/react/src/profiler.tsx b/packages/react/src/profiler.tsx index acf764347c69..c52d503eb92b 100644 --- a/packages/react/src/profiler.tsx +++ b/packages/react/src/profiler.tsx @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { getCurrentHub, Hub } from '@sentry/browser'; -import { Integration, IntegrationClass, Span, Transaction } from '@sentry/types'; +import { Span, Transaction } from '@sentry/types'; import { timestampWithMs } from '@sentry/utils'; import hoistNonReactStatics from 'hoist-non-react-statics'; import * as React from 'react'; @@ -10,66 +10,6 @@ import { REACT_MOUNT_OP, REACT_RENDER_OP, REACT_UPDATE_OP } from './constants'; export const UNKNOWN_COMPONENT = 'unknown'; -const TRACING_GETTER = ({ - id: 'Tracing', -} as any) as IntegrationClass; - -let globalTracingIntegration: Integration | null = null; -/** @deprecated remove when @sentry/apm no longer used */ -const getTracingIntegration = (): Integration | null => { - if (globalTracingIntegration) { - return globalTracingIntegration; - } - - globalTracingIntegration = getCurrentHub().getIntegration(TRACING_GETTER); - return globalTracingIntegration; -}; - -/** - * pushActivity creates an new react activity. - * Is a no-op if Tracing integration is not valid - * @param name displayName of component that started activity - * @deprecated remove when @sentry/apm no longer used - */ -function pushActivity(name: string, op: string): number | null { - if (globalTracingIntegration === null) { - return null; - } - - return (globalTracingIntegration as any).constructor.pushActivity(name, { - description: `<${name}>`, - op, - }); -} - -/** - * popActivity removes a React activity. - * Is a no-op if Tracing integration is not valid. - * @param activity id of activity that is being popped - * @deprecated remove when @sentry/apm no longer used - */ -function popActivity(activity: number | null): void { - if (activity === null || globalTracingIntegration === null) { - return; - } - - (globalTracingIntegration as any).constructor.popActivity(activity); -} - -/** - * Obtain a span given an activity id. - * Is a no-op if Tracing integration is not valid. - * @param activity activity id associated with obtained span - * @deprecated remove when @sentry/apm no longer used - */ -function getActivitySpan(activity: number | null): Span | undefined { - if (activity === null || globalTracingIntegration === null) { - return undefined; - } - - return (globalTracingIntegration as any).constructor.getActivitySpan(activity) as Span | undefined; -} - export type ProfilerProps = { // The name of the component being profiled. name: string; @@ -95,9 +35,6 @@ class Profiler extends React.Component { */ protected _mountSpan: Span | undefined = undefined; - // The activity representing how long it takes to mount a component. - private _mountActivity: number | null = null; - // eslint-disable-next-line @typescript-eslint/member-ordering public static defaultProps: Partial = { disabled: false, @@ -113,19 +50,12 @@ class Profiler extends React.Component { return; } - // If they are using @sentry/apm, we need to push/pop activities - // eslint-disable-next-line deprecation/deprecation - if (getTracingIntegration()) { - // eslint-disable-next-line deprecation/deprecation - this._mountActivity = pushActivity(name, REACT_MOUNT_OP); - } else { - const activeTransaction = getActiveTransaction(); - if (activeTransaction) { - this._mountSpan = activeTransaction.startChild({ - description: `<${name}>`, - op: REACT_MOUNT_OP, - }); - } + const activeTransaction = getActiveTransaction(); + if (activeTransaction) { + this._mountSpan = activeTransaction.startChild({ + description: `<${name}>`, + op: REACT_MOUNT_OP, + }); } } @@ -133,12 +63,6 @@ class Profiler extends React.Component { public componentDidMount(): void { if (this._mountSpan) { this._mountSpan.finish(); - } else { - // eslint-disable-next-line deprecation/deprecation - this._mountSpan = getActivitySpan(this._mountActivity); - // eslint-disable-next-line deprecation/deprecation - popActivity(this._mountActivity); - this._mountActivity = null; } } From 57d37c29249d5c71eac486c86e5bb91a4c3c4159 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:12:47 -0400 Subject: [PATCH 02/17] [v7] feat(core): Delete API class (#4848) Removes the deprecated `API` class. --- packages/core/src/api.ts | 69 +----------------------------- packages/core/src/index.ts | 2 - packages/core/test/lib/api.test.ts | 39 +++++++++++------ 3 files changed, 26 insertions(+), 84 deletions(-) diff --git a/packages/core/src/api.ts b/packages/core/src/api.ts index bace0ad07591..8d76cb135400 100644 --- a/packages/core/src/api.ts +++ b/packages/core/src/api.ts @@ -17,73 +17,6 @@ export interface APIDetails { readonly tunnel?: string; } -/** - * Helper class to provide urls, headers and metadata that can be used to form - * different types of requests to Sentry endpoints. - * Supports both envelopes and regular event requests. - * - * @deprecated Please use APIDetails - **/ -export class API { - /** The DSN as passed to Sentry.init() */ - public dsn: DsnLike; - - /** Metadata about the SDK (name, version, etc) for inclusion in envelope headers */ - public metadata: SdkMetadata; - - /** The internally used Dsn object. */ - private readonly _dsnObject: DsnComponents; - - /** The envelope tunnel to use. */ - private readonly _tunnel?: string; - - /** Create a new instance of API */ - public constructor(dsn: DsnLike, metadata: SdkMetadata = {}, tunnel?: string) { - this.dsn = dsn; - this._dsnObject = makeDsn(dsn); - this.metadata = metadata; - this._tunnel = tunnel; - } - - /** Returns the Dsn object. */ - public getDsn(): DsnComponents { - return this._dsnObject; - } - - /** Does this transport force envelopes? */ - public forceEnvelope(): boolean { - return !!this._tunnel; - } - - /** Returns the prefix to construct Sentry ingestion API endpoints. */ - public getBaseApiEndpoint(): string { - return getBaseApiEndpoint(this._dsnObject); - } - - /** Returns the store endpoint URL. */ - public getStoreEndpoint(): string { - return getStoreEndpoint(this._dsnObject); - } - - /** - * Returns the store endpoint URL with auth in the query string. - * - * Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests. - */ - public getStoreEndpointWithUrlEncodedAuth(): string { - return getStoreEndpointWithUrlEncodedAuth(this._dsnObject); - } - - /** - * Returns the envelope endpoint URL with auth in the query string. - * - * Sending auth as part of the query string and not as custom HTTP headers avoids CORS preflight requests. - */ - public getEnvelopeEndpointWithUrlEncodedAuth(): string { - return getEnvelopeEndpointWithUrlEncodedAuth(this._dsnObject, this._tunnel); - } -} - /** Initializes API Details */ export function initAPIDetails(dsn: DsnLike, metadata?: SdkMetadata, tunnel?: string): APIDetails { return { @@ -117,7 +50,7 @@ function _encodedAuth(dsn: DsnComponents): string { } /** Returns the store endpoint URL. */ -function getStoreEndpoint(dsn: DsnComponents): string { +export function getStoreEndpoint(dsn: DsnComponents): string { return _getIngestEndpoint(dsn, 'store'); } diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index f09d804d3bed..b066724ce099 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -15,8 +15,6 @@ export { } from '@sentry/minimal'; export { addGlobalEventProcessor, getCurrentHub, getHubFromCarrier, Hub, makeMain, Scope, Session } from '@sentry/hub'; export { - // eslint-disable-next-line deprecation/deprecation - API, APIDetails, getEnvelopeEndpointWithUrlEncodedAuth, getStoreEndpointWithUrlEncodedAuth, diff --git a/packages/core/test/lib/api.test.ts b/packages/core/test/lib/api.test.ts index 14b44aed9602..af3a7bfb8ca3 100644 --- a/packages/core/test/lib/api.test.ts +++ b/packages/core/test/lib/api.test.ts @@ -1,27 +1,38 @@ /* eslint-disable deprecation/deprecation */ import { makeDsn } from '@sentry/utils'; -import { API, getReportDialogEndpoint, getRequestHeaders } from '../../src/api'; +import { + getEnvelopeEndpointWithUrlEncodedAuth, + getReportDialogEndpoint, + getRequestHeaders, + getStoreEndpoint, + getStoreEndpointWithUrlEncodedAuth, + initAPIDetails, +} from '../../src/api'; const ingestDsn = 'https://abc@xxxx.ingest.sentry.io:1234/subpath/123'; const dsnPublic = 'https://abc@sentry.io:1234/subpath/123'; const legacyDsn = 'https://abc:123@sentry.io:1234/subpath/123'; const tunnel = 'https://hello.com/world'; +const ingestDsnAPI = initAPIDetails(ingestDsn); +const dsnPublicAPI = initAPIDetails(dsnPublic); + describe('API', () => { test('getStoreEndpoint', () => { - expect(new API(dsnPublic).getStoreEndpointWithUrlEncodedAuth()).toEqual( + expect(getStoreEndpointWithUrlEncodedAuth(dsnPublicAPI.dsn)).toEqual( 'https://sentry.io:1234/subpath/api/123/store/?sentry_key=abc&sentry_version=7', ); - expect(new API(dsnPublic).getStoreEndpoint()).toEqual('https://sentry.io:1234/subpath/api/123/store/'); - expect(new API(ingestDsn).getStoreEndpoint()).toEqual('https://xxxx.ingest.sentry.io:1234/subpath/api/123/store/'); + expect(getStoreEndpoint(dsnPublicAPI.dsn)).toEqual('https://sentry.io:1234/subpath/api/123/store/'); + expect(getStoreEndpoint(ingestDsnAPI.dsn)).toEqual('https://xxxx.ingest.sentry.io:1234/subpath/api/123/store/'); }); test('getEnvelopeEndpoint', () => { - expect(new API(dsnPublic).getEnvelopeEndpointWithUrlEncodedAuth()).toEqual( + expect(getEnvelopeEndpointWithUrlEncodedAuth(dsnPublicAPI.dsn)).toEqual( 'https://sentry.io:1234/subpath/api/123/envelope/?sentry_key=abc&sentry_version=7', ); - expect(new API(dsnPublic, {}, tunnel).getEnvelopeEndpointWithUrlEncodedAuth()).toEqual(tunnel); + const dsnPublicAPIWithTunnel = initAPIDetails(dsnPublic, {}, tunnel); + expect(getEnvelopeEndpointWithUrlEncodedAuth(dsnPublicAPIWithTunnel.dsn, tunnel)).toEqual(tunnel); }); test('getRequestHeaders', () => { @@ -118,13 +129,13 @@ describe('API', () => { ); }); - test('getDsn', () => { - expect(new API(dsnPublic).getDsn().host).toEqual(makeDsn(dsnPublic).host); - expect(new API(dsnPublic).getDsn().path).toEqual(makeDsn(dsnPublic).path); - expect(new API(dsnPublic).getDsn().pass).toEqual(makeDsn(dsnPublic).pass); - expect(new API(dsnPublic).getDsn().port).toEqual(makeDsn(dsnPublic).port); - expect(new API(dsnPublic).getDsn().protocol).toEqual(makeDsn(dsnPublic).protocol); - expect(new API(dsnPublic).getDsn().projectId).toEqual(makeDsn(dsnPublic).projectId); - expect(new API(dsnPublic).getDsn().publicKey).toEqual(makeDsn(dsnPublic).publicKey); + test('initAPIDetails dsn', () => { + expect(dsnPublicAPI.dsn.host).toEqual(makeDsn(dsnPublic).host); + expect(dsnPublicAPI.dsn.path).toEqual(makeDsn(dsnPublic).path); + expect(dsnPublicAPI.dsn.pass).toEqual(makeDsn(dsnPublic).pass); + expect(dsnPublicAPI.dsn.port).toEqual(makeDsn(dsnPublic).port); + expect(dsnPublicAPI.dsn.protocol).toEqual(makeDsn(dsnPublic).protocol); + expect(dsnPublicAPI.dsn.projectId).toEqual(makeDsn(dsnPublic).projectId); + expect(dsnPublicAPI.dsn.publicKey).toEqual(makeDsn(dsnPublic).publicKey); }); }); From 424df271f1b58de8b67d50cff2129de87aa861c1 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:13:38 -0400 Subject: [PATCH 03/17] [v7] feat: Delete deprecated `startSpan` and `child` methods (#4849) Remove deprecated methods `startSpan` and `child`. These deprecated methods were removed in favour of `span.startChild`. --- packages/hub/src/hub.ts | 9 --------- packages/tracing/src/span.ts | 10 ---------- packages/types/src/hub.ts | 6 ------ packages/types/src/span.ts | 8 -------- 4 files changed, 33 deletions(-) diff --git a/packages/hub/src/hub.ts b/packages/hub/src/hub.ts index 67761953abfa..b6ebffc74866 100644 --- a/packages/hub/src/hub.ts +++ b/packages/hub/src/hub.ts @@ -14,8 +14,6 @@ import { Primitive, SessionContext, Severity, - Span, - SpanContext, Transaction, TransactionContext, User, @@ -385,13 +383,6 @@ export class Hub implements HubInterface { } } - /** - * @inheritDoc - */ - public startSpan(context: SpanContext): Span { - return this._callExtensionMethod('startSpan', context); - } - /** * @inheritDoc */ diff --git a/packages/tracing/src/span.ts b/packages/tracing/src/span.ts index 990f56ce981c..baece680f52c 100644 --- a/packages/tracing/src/span.ts +++ b/packages/tracing/src/span.ts @@ -149,16 +149,6 @@ export class Span implements SpanInterface { } } - /** - * @inheritDoc - * @deprecated - */ - public child( - spanContext?: Pick>, - ): Span { - return this.startChild(spanContext); - } - /** * @inheritDoc */ diff --git a/packages/types/src/hub.ts b/packages/types/src/hub.ts index c80ea1b51686..49452266fe9f 100644 --- a/packages/types/src/hub.ts +++ b/packages/types/src/hub.ts @@ -7,7 +7,6 @@ import { Primitive } from './misc'; import { Scope } from './scope'; import { Session, SessionContext } from './session'; import { Severity } from './severity'; -import { Span, SpanContext } from './span'; import { CustomSamplingContext, Transaction, TransactionContext } from './transaction'; import { User } from './user'; @@ -180,11 +179,6 @@ export interface Hub { /** Returns all trace headers that are currently on the top scope. */ traceHeaders(): { [key: string]: string }; - /** - * @deprecated No longer does anything. Use use {@link Transaction.startChild} instead. - */ - startSpan(context: SpanContext): Span; - /** * Starts a new `Transaction` and returns it. This is the entry point to manual tracing instrumentation. * diff --git a/packages/types/src/span.ts b/packages/types/src/span.ts index 09b69454835e..d26887a93f2a 100644 --- a/packages/types/src/span.ts +++ b/packages/types/src/span.ts @@ -128,14 +128,6 @@ export interface Span extends SpanContext { */ setHttpStatus(httpStatus: number): this; - /** - * Use {@link startChild} - * @deprecated - */ - child( - spanContext?: Pick>, - ): Span; - /** * Creates a new `Span` while setting the current `Span.id` as `parentSpanId`. * Also the `sampled` decision will be inherited. From 5a7f1450a38f045b974233e514fd6d26da2a5c64 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:14:07 -0400 Subject: [PATCH 04/17] feat(core): Remove whitelistUrls/blacklistUrls (#4850) --- packages/browser/src/backend.ts | 6 ----- .../core/src/integrations/inboundfilters.ts | 23 ++----------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/packages/browser/src/backend.ts b/packages/browser/src/backend.ts index 4cdef3d11047..89cf843d48ae 100644 --- a/packages/browser/src/backend.ts +++ b/packages/browser/src/backend.ts @@ -23,12 +23,6 @@ export interface BrowserOptions extends Options { * By default, all errors will be sent. */ denyUrls?: Array; - - /** @deprecated use {@link Options.allowUrls} instead. */ - whitelistUrls?: Array; - - /** @deprecated use {@link Options.denyUrls} instead. */ - blacklistUrls?: Array; } /** diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index ff6c616c442d..83d635ff3256 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -13,11 +13,6 @@ export interface InboundFiltersOptions { denyUrls: Array; ignoreErrors: Array; ignoreInternal: boolean; - - /** @deprecated use {@link InboundFiltersOptions.allowUrls} instead. */ - whitelistUrls: Array; - /** @deprecated use {@link InboundFiltersOptions.denyUrls} instead. */ - blacklistUrls: Array; } /** Inbound filters configurable by the user */ @@ -60,22 +55,8 @@ export function _mergeOptions( clientOptions: Partial = {}, ): Partial { return { - allowUrls: [ - // eslint-disable-next-line deprecation/deprecation - ...(internalOptions.whitelistUrls || []), - ...(internalOptions.allowUrls || []), - // eslint-disable-next-line deprecation/deprecation - ...(clientOptions.whitelistUrls || []), - ...(clientOptions.allowUrls || []), - ], - denyUrls: [ - // eslint-disable-next-line deprecation/deprecation - ...(internalOptions.blacklistUrls || []), - ...(internalOptions.denyUrls || []), - // eslint-disable-next-line deprecation/deprecation - ...(clientOptions.blacklistUrls || []), - ...(clientOptions.denyUrls || []), - ], + allowUrls: [...(internalOptions.allowUrls || []), ...(clientOptions.allowUrls || [])], + denyUrls: [...(internalOptions.denyUrls || []), ...(clientOptions.denyUrls || [])], ignoreErrors: [ ...(internalOptions.ignoreErrors || []), ...(clientOptions.ignoreErrors || []), From f855260c904f939b712b9fb7044a3528a51d73b4 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:14:50 -0400 Subject: [PATCH 05/17] feat(gatsby): Remove Sentry from window (#4857) --- packages/gatsby/gatsby-browser.js | 8 +++----- packages/gatsby/test/gatsby-browser.test.ts | 10 ---------- packages/gatsby/test/integration.test.tsx | 3 ++- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/packages/gatsby/gatsby-browser.js b/packages/gatsby/gatsby-browser.js index 5cf1e3d26f80..598ce44ade08 100644 --- a/packages/gatsby/gatsby-browser.js +++ b/packages/gatsby/gatsby-browser.js @@ -6,12 +6,11 @@ exports.onClientEntry = function (_, pluginParams) { const areOptionsDefined = areSentryOptionsDefined(pluginParams); if (isIntialized) { - window.Sentry = Sentry; // For backwards compatibility if (areOptionsDefined) { console.warn( 'Sentry Logger [Warn]: The SDK was initialized in the Sentry config file, but options were found in the Gatsby config. ' + - 'These have been ignored, merge them to the Sentry config if you want to use them.\n' + - 'Learn more about the Gatsby SDK on https://docs.sentry.io/platforms/javascript/guides/gatsby/', + 'These have been ignored, merge them to the Sentry config if you want to use them.\n' + + 'Learn more about the Gatsby SDK on https://docs.sentry.io/platforms/javascript/guides/gatsby/', ); } return; @@ -20,7 +19,7 @@ exports.onClientEntry = function (_, pluginParams) { if (!areOptionsDefined) { console.error( 'Sentry Logger [Error]: No config for the Gatsby SDK was found.\n' + - 'Learn how to configure it on https://docs.sentry.io/platforms/javascript/guides/gatsby/', + 'Learn how to configure it on https://docs.sentry.io/platforms/javascript/guides/gatsby/', ); return; } @@ -32,7 +31,6 @@ exports.onClientEntry = function (_, pluginParams) { dsn: __SENTRY_DSN__, ...pluginParams, }); - window.Sentry = Sentry; // For backwards compatibility }; function isSentryInitialized() { diff --git a/packages/gatsby/test/gatsby-browser.test.ts b/packages/gatsby/test/gatsby-browser.test.ts index a3c98524a2fd..a2044dd2c8a9 100644 --- a/packages/gatsby/test/gatsby-browser.test.ts +++ b/packages/gatsby/test/gatsby-browser.test.ts @@ -36,10 +36,6 @@ describe('onClientEntry', () => { tracingAddExtensionMethods = jest.fn(); }); - afterEach(() => { - (window as any).Sentry = undefined; - }); - it.each([ [{}, ['dsn', 'release']], [{ key: 'value' }, ['dsn', 'release', 'key']], @@ -54,7 +50,6 @@ describe('onClientEntry', () => { describe('inits Sentry once', () => { afterEach(() => { - delete (window as any).Sentry; delete (window as any).__SENTRY__; (global.console.warn as jest.Mock).mockClear(); (global.console.error as jest.Mock).mockClear(); @@ -78,7 +73,6 @@ describe('onClientEntry', () => { // eslint-disable-next-line no-console expect(console.error).not.toHaveBeenCalled(); expect(sentryInit).not.toHaveBeenCalled(); - expect((window as any).Sentry).toBeDefined(); }); it('initialized in injected config, with pluginParams', () => { @@ -94,7 +88,6 @@ describe('onClientEntry', () => { // eslint-disable-next-line no-console expect(console.error).not.toHaveBeenCalled(); expect(sentryInit).not.toHaveBeenCalled(); - expect((window as any).Sentry).toBeDefined(); }); it('not initialized in injected config, without pluginParams', () => { @@ -108,7 +101,6 @@ describe('onClientEntry', () => { Learn how to configure it on https://docs.sentry.io/platforms/javascript/guides/gatsby/", ] `); - expect((window as any).Sentry).not.toBeDefined(); }); it('not initialized in injected config, with pluginParams', () => { @@ -125,7 +117,6 @@ describe('onClientEntry', () => { "release": "release", } `); - expect((window as any).Sentry).toBeDefined(); }); }); @@ -164,7 +155,6 @@ describe('onClientEntry', () => { it('does not run if plugin params are undefined', () => { onClientEntry(); expect(sentryInit).toHaveBeenCalledTimes(0); - expect((window as any).Sentry).toBeUndefined(); expect(tracingAddExtensionMethods).toHaveBeenCalledTimes(0); }); }); diff --git a/packages/gatsby/test/integration.test.tsx b/packages/gatsby/test/integration.test.tsx index e758aa90a79d..18c738ba2ac2 100644 --- a/packages/gatsby/test/integration.test.tsx +++ b/packages/gatsby/test/integration.test.tsx @@ -5,6 +5,7 @@ import { useEffect } from 'react'; import * as React from 'react'; import { onClientEntry } from '../gatsby-browser'; +import * as Sentry from '../src'; beforeAll(() => { (global as any).__SENTRY_RELEASE__ = '683f3a6ab819d47d23abfca9a914c81f0524d35b'; @@ -28,7 +29,7 @@ describe('useEffect', () => { function TestComponent() { useEffect(() => { const error = new Error('testing 123'); - (window as any).Sentry.captureException(error); + Sentry.captureException(error); }); return
Hello
; From f1e9da28e9c8dbd9e6ecf1bd446437f8cd04700e Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:15:35 -0400 Subject: [PATCH 06/17] feat(hub): Remove getActiveDomain (#4858) Removes `getActiveDomain` function and corresponding type. --- packages/hub/src/hub.ts | 23 ----------------------- packages/hub/src/index.ts | 4 ---- 2 files changed, 27 deletions(-) diff --git a/packages/hub/src/hub.ts b/packages/hub/src/hub.ts index b6ebffc74866..94c8e3ea91fe 100644 --- a/packages/hub/src/hub.ts +++ b/packages/hub/src/hub.ts @@ -80,15 +80,6 @@ export interface Carrier { }; } -/** - * @hidden - * @deprecated Can be removed once `Hub.getActiveDomain` is removed. - */ -export interface DomainAsCarrier extends Carrier { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - members: { [key: string]: any }[]; -} - /** * @inheritDoc */ @@ -559,20 +550,6 @@ export function getCurrentHub(): Hub { return getHubFromCarrier(registry); } -/** - * Returns the active domain, if one exists - * @deprecated No longer used; remove in v7 - * @returns The domain, or undefined if there is no active domain - */ -// eslint-disable-next-line deprecation/deprecation -export function getActiveDomain(): DomainAsCarrier | undefined { - IS_DEBUG_BUILD && logger.warn('Function `getActiveDomain` is deprecated and will be removed in a future version.'); - - const sentry = getMainCarrier().__SENTRY__; - - return sentry && sentry.extensions && sentry.extensions.domain && sentry.extensions.domain.active; -} - /** * Try to read the hub from an active domain, and fallback to the registry if one doesn't exist * @returns discovered hub diff --git a/packages/hub/src/index.ts b/packages/hub/src/index.ts index 9c0a77625dc2..3d3b97fa239b 100644 --- a/packages/hub/src/index.ts +++ b/packages/hub/src/index.ts @@ -2,8 +2,6 @@ export { addGlobalEventProcessor, Scope } from './scope'; export { Session } from './session'; export { SessionFlusher } from './sessionflusher'; export { - // eslint-disable-next-line deprecation/deprecation - getActiveDomain, getCurrentHub, getHubFromCarrier, getMainCarrier, @@ -11,7 +9,5 @@ export { makeMain, setHubOnCarrier, Carrier, - // eslint-disable-next-line deprecation/deprecation - DomainAsCarrier, Layer, } from './hub'; From 55b057049fc7f02876e724c3f5d6b68949357b03 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:17:36 -0400 Subject: [PATCH 07/17] feat(types): Remove deprecated user dsn field (#4864) The `user` dsn component was renamed to `publicKey`. This PR removes that from the dsn field. --- packages/types/src/dsn.ts | 2 -- packages/utils/src/dsn.ts | 6 ------ 2 files changed, 8 deletions(-) diff --git a/packages/types/src/dsn.ts b/packages/types/src/dsn.ts index b21130802903..761c52889caf 100644 --- a/packages/types/src/dsn.ts +++ b/packages/types/src/dsn.ts @@ -5,8 +5,6 @@ export type DsnProtocol = 'http' | 'https'; export interface DsnComponents { /** Protocol used to connect to Sentry. */ protocol: DsnProtocol; - /** Public authorization key (deprecated, renamed to publicKey). */ - user?: string; /** Public authorization key. */ publicKey?: string; /** Private authorization key (deprecated, optional). */ diff --git a/packages/utils/src/dsn.ts b/packages/utils/src/dsn.ts index 0b58a7974821..5c500c5ec654 100644 --- a/packages/utils/src/dsn.ts +++ b/packages/utils/src/dsn.ts @@ -55,13 +55,7 @@ function dsnFromString(str: string): DsnComponents { } function dsnFromComponents(components: DsnComponents): DsnComponents { - // TODO this is for backwards compatibility, and can be removed in a future version - if ('user' in components && !('publicKey' in components)) { - components.publicKey = components.user; - } - return { - user: components.publicKey || '', protocol: components.protocol, publicKey: components.publicKey || '', pass: components.pass || '', From 2fc13c6398e540a41ff929595f94572b516e7489 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:18:08 -0400 Subject: [PATCH 08/17] feat(hub): Remove setTransaction scope method (#4865) --- packages/hub/src/scope.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/packages/hub/src/scope.ts b/packages/hub/src/scope.ts index 9243cd409b66..09dd244734ee 100644 --- a/packages/hub/src/scope.ts +++ b/packages/hub/src/scope.ts @@ -223,14 +223,6 @@ export class Scope implements ScopeInterface { return this; } - /** - * Can be removed in major version. - * @deprecated in favor of {@link this.setTransactionName} - */ - public setTransaction(name?: string): this { - return this.setTransactionName(name); - } - /** * @inheritDoc */ From 20c777399ee5afc58c148919274192ff9cef1869 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:19:14 -0400 Subject: [PATCH 09/17] [v7] feat: Drop support for Node 6 (#4851) --- .github/workflows/build.yml | 2 +- packages/angular/package.json | 2 +- packages/browser/package.json | 2 +- packages/core/package.json | 2 +- packages/eslint-config-sdk/package.json | 2 +- packages/eslint-plugin-sdk/package.json | 2 +- packages/gatsby/package.json | 2 +- packages/hub/package.json | 2 +- packages/integrations/package.json | 2 +- packages/minimal/package.json | 2 +- packages/nextjs/package.json | 2 +- packages/node/package.json | 2 +- packages/node/test/integrations/http.test.ts | 4 +--- packages/react/package.json | 2 +- packages/tracing/package.json | 2 +- packages/types/package.json | 2 +- packages/utils/package.json | 2 +- packages/vue/package.json | 2 +- packages/wasm/package.json | 2 +- scripts/test.ts | 16 +--------------- 20 files changed, 20 insertions(+), 36 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a8f026b2729f..368412a4515c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -217,7 +217,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [6, 8, 10, 12, 14, 16] + node: [8, 10, 12, 14, 16] steps: - name: Check out current commit (${{ env.HEAD_COMMIT }}) uses: actions/checkout@v2 diff --git a/packages/angular/package.json b/packages/angular/package.json index e8745aa6621e..319a3942e10b 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "MIT", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "dist/index.js", "module": "esm/index.js", diff --git a/packages/browser/package.json b/packages/browser/package.json index ca4a18f2bbc4..7161a66e6197 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/npm/dist/index.js", "module": "build/npm/esm/index.js", diff --git a/packages/core/package.json b/packages/core/package.json index 2dd008baa23e..71b42e232391 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/eslint-config-sdk/package.json b/packages/eslint-config-sdk/package.json index babde25d977f..d2ec6952d893 100644 --- a/packages/eslint-config-sdk/package.json +++ b/packages/eslint-config-sdk/package.json @@ -12,7 +12,7 @@ "sentry" ], "engines": { - "node": ">=6" + "node": ">=8" }, "main": "src/index.js", "publishConfig": { diff --git a/packages/eslint-plugin-sdk/package.json b/packages/eslint-plugin-sdk/package.json index ba6d9e327475..dfcbd8a7d0cb 100644 --- a/packages/eslint-plugin-sdk/package.json +++ b/packages/eslint-plugin-sdk/package.json @@ -12,7 +12,7 @@ "sentry" ], "engines": { - "node": ">=6" + "node": ">=8" }, "main": "src/index.js", "publishConfig": { diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index d72cad81bd39..381e8c774136 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -11,7 +11,7 @@ "gatsby-plugin" ], "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/hub/package.json b/packages/hub/package.json index 140b0eab4041..ad5be53d5b5b 100644 --- a/packages/hub/package.json +++ b/packages/hub/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/integrations/package.json b/packages/integrations/package.json index 65e951c262cb..26537b9e586d 100644 --- a/packages/integrations/package.json +++ b/packages/integrations/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "publishConfig": { "access": "public" diff --git a/packages/minimal/package.json b/packages/minimal/package.json index 94f621ee8d77..1906267520fe 100644 --- a/packages/minimal/package.json +++ b/packages/minimal/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 099b2e539b38..0469ec7704ce 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "MIT", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.server.js", "module": "build/esm/index.server.js", diff --git a/packages/node/package.json b/packages/node/package.json index 94b658305fea..b6d1b47f4997 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/node/test/integrations/http.test.ts b/packages/node/test/integrations/http.test.ts index c7a9c3e0a621..bc71b994c7a5 100644 --- a/packages/node/test/integrations/http.test.ts +++ b/packages/node/test/integrations/http.test.ts @@ -44,9 +44,7 @@ describe('tracing', () => { http.get('http://dogs.are.great/'); - // TODO: For some reason in node 6 two request spans are appearing. Once we stop testing against it, this can go - // back to being `toEqual()`. - expect(spans.length).toBeGreaterThanOrEqual(2); + expect(spans.length).toEqual(2); // our span is at index 1 because the transaction itself is at index 0 expect(spans[1].description).toEqual('GET http://dogs.are.great/'); diff --git a/packages/react/package.json b/packages/react/package.json index e95c942d65d7..2051ed2f6154 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/tracing/package.json b/packages/tracing/package.json index fcf443c1a579..ec117ee72942 100644 --- a/packages/tracing/package.json +++ b/packages/tracing/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "MIT", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/npm/dist/index.js", "module": "build/npm/esm/index.js", diff --git a/packages/types/package.json b/packages/types/package.json index f776f8ae2484..5d43a4c33237 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/utils/package.json b/packages/utils/package.json index 590a3c0626be..1a5cab8cc85b 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "BSD-3-Clause", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/vue/package.json b/packages/vue/package.json index dda682c3d545..6ce89beb7eff 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "MIT", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/dist/index.js", "module": "build/esm/index.js", diff --git a/packages/wasm/package.json b/packages/wasm/package.json index 3602b4dc87f5..8ae7c44a8b93 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -7,7 +7,7 @@ "author": "Sentry", "license": "MIT", "engines": { - "node": ">=6" + "node": ">=8" }, "main": "build/npm/dist/index.js", "module": "build/npm/esm/index.js", diff --git a/scripts/test.ts b/scripts/test.ts index 6c2efd8a1b68..51a1dc06245e 100644 --- a/scripts/test.ts +++ b/scripts/test.ts @@ -11,21 +11,7 @@ function run(cmd: string, cwd: string = '') { const nodeMajorVersion = parseInt(process.version.split('.')[0].replace('v', ''), 10); -// control which packages we test on each version of node -if (nodeMajorVersion <= 6) { - // install legacy versions of packages whose current versions don't support node 6 - // ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing - run('yarn add --dev --ignore-engines --ignore-scripts nock@10.x', 'packages/node'); - run('yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x', 'packages/tracing'); - run('yarn add --dev --ignore-engines --ignore-scripts jsdom@11.x', 'packages/utils'); - - // only test against @sentry/node and its dependencies - node 6 is too old for anything else to work - const scope = ['@sentry/core', '@sentry/hub', '@sentry/minimal', '@sentry/node', '@sentry/utils', '@sentry/tracing'] - .map(dep => `--scope="${dep}"`) - .join(' '); - - run(`yarn test ${scope}`); -} else if (nodeMajorVersion <= 8) { +if (nodeMajorVersion <= 8) { // install legacy versions of packages whose current versions don't support node 8 // ignoring engines and scripts lets us get away with having incompatible things installed for packages we're not testing run('yarn add --dev --ignore-engines --ignore-scripts jsdom@15.x', 'packages/tracing'); From 244eb0e217998f3f4fce3ab8d778be4c80ea9eed Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Wed, 6 Apr 2022 21:16:08 -0400 Subject: [PATCH 10/17] [v7] feat(tracing): Rename registerRequestInstrumentation -> instrumentOutgoingRequests (#4859) --- packages/tracing/src/index.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/tracing/src/index.ts b/packages/tracing/src/index.ts index 89e3b3ba92d5..dcfea00f422a 100644 --- a/packages/tracing/src/index.ts +++ b/packages/tracing/src/index.ts @@ -26,8 +26,7 @@ export { Span, SpanStatusType, spanStatusfromHttpCode } from './span'; export { SpanStatus } from './spanstatus'; export { Transaction } from './transaction'; export { - // TODO deprecate old name in v7 - instrumentOutgoingRequests as registerRequestInstrumentation, + instrumentOutgoingRequests, RequestInstrumentationOptions, defaultRequestInstrumentationOptions, } from './browser'; From 285ca26a45894f90c51f5a5ec8c50666a089d8a7 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 7 Apr 2022 14:26:42 +0200 Subject: [PATCH 11/17] fix(test): Increase MongoMemoryServer creation timeout (#4881) Increases the creation timeout of `MongoMemoryServer` to temporarily fix Node integration test flakiness --- .../suites/tracing/auto-instrument/mongodb/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/node-integration-tests/suites/tracing/auto-instrument/mongodb/test.ts b/packages/node-integration-tests/suites/tracing/auto-instrument/mongodb/test.ts index d118a03261a5..dd5f88f860ca 100644 --- a/packages/node-integration-tests/suites/tracing/auto-instrument/mongodb/test.ts +++ b/packages/node-integration-tests/suites/tracing/auto-instrument/mongodb/test.ts @@ -8,7 +8,7 @@ conditionalTest({ min: 12 })('MongoDB Test', () => { beforeAll(async () => { mongoServer = await MongoMemoryServer.create(); process.env.MONGO_URL = mongoServer.getUri(); - }, 30000); + }, 40000); afterAll(async () => { await mongoServer.stop(); From 8afb70c4d9c7074c2f3f567eae8b0d5b13ab7f1f Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 7 Apr 2022 16:04:34 +0100 Subject: [PATCH 12/17] Removes usage of deprecated `event.stacktrace` --- packages/browser/src/eventbuilder.ts | 8 +++--- packages/browser/src/integrations/dedupe.ts | 2 -- .../core/src/integrations/inboundfilters.ts | 3 --- packages/integrations/src/dedupe.ts | 2 -- packages/integrations/src/rewriteframes.ts | 16 ------------ .../integrations/test/rewriteframes.test.ts | 26 ------------------- packages/node/src/eventbuilder.ts | 9 ++++++- packages/types/src/event.ts | 2 -- packages/wasm/src/index.ts | 3 --- 9 files changed, 13 insertions(+), 58 deletions(-) diff --git a/packages/browser/src/eventbuilder.ts b/packages/browser/src/eventbuilder.ts index f999eb2854ca..88047061e71f 100644 --- a/packages/browser/src/eventbuilder.ts +++ b/packages/browser/src/eventbuilder.ts @@ -71,10 +71,10 @@ export function eventFromPlainObject( }, }; - if (syntheticException) { + if (syntheticException && event.exception?.values?.[0]) { const frames = parseStackFrames(syntheticException); if (frames.length) { - event.stacktrace = { frames }; + event.exception.values[0].stacktrace = { frames }; } } @@ -273,7 +273,9 @@ export function eventFromString(input: string, syntheticException?: Error, attac if (attachStacktrace && syntheticException) { const frames = parseStackFrames(syntheticException); if (frames.length) { - event.stacktrace = { frames }; + event.exception = { + values: [{ stacktrace: { frames } }], + }; } } diff --git a/packages/browser/src/integrations/dedupe.ts b/packages/browser/src/integrations/dedupe.ts index 24e01d2f1226..c486c84c815e 100644 --- a/packages/browser/src/integrations/dedupe.ts +++ b/packages/browser/src/integrations/dedupe.ts @@ -198,8 +198,6 @@ function _getFramesFromEvent(event: Event): StackFrame[] | undefined { } catch (_oO) { return undefined; } - } else if (event.stacktrace) { - return event.stacktrace.frames; } return undefined; } diff --git a/packages/core/src/integrations/inboundfilters.ts b/packages/core/src/integrations/inboundfilters.ts index 83d635ff3256..6151e32e5bbd 100644 --- a/packages/core/src/integrations/inboundfilters.ts +++ b/packages/core/src/integrations/inboundfilters.ts @@ -170,9 +170,6 @@ function _getLastValidUrl(frames: StackFrame[] = []): string | null { function _getEventFilterUrl(event: Event): string | null { try { - if (event.stacktrace) { - return _getLastValidUrl(event.stacktrace.frames); - } let frames; try { // @ts-ignore we only care about frames if the whole thing here is defined diff --git a/packages/integrations/src/dedupe.ts b/packages/integrations/src/dedupe.ts index 2ce72a6b636c..644f3d41cd62 100644 --- a/packages/integrations/src/dedupe.ts +++ b/packages/integrations/src/dedupe.ts @@ -198,8 +198,6 @@ function _getFramesFromEvent(event: Event): StackFrame[] | undefined { } catch (_oO) { return undefined; } - } else if (event.stacktrace) { - return event.stacktrace.frames; } return undefined; } diff --git a/packages/integrations/src/rewriteframes.ts b/packages/integrations/src/rewriteframes.ts index 9eb95e54f6d3..7b1129e45032 100644 --- a/packages/integrations/src/rewriteframes.ts +++ b/packages/integrations/src/rewriteframes.ts @@ -61,10 +61,6 @@ export class RewriteFrames implements Integration { processedEvent = this._processExceptionsEvent(processedEvent); } - if (originalEvent.stacktrace) { - processedEvent = this._processStacktraceEvent(processedEvent); - } - return processedEvent; } @@ -110,18 +106,6 @@ export class RewriteFrames implements Integration { } } - /** JSDoc */ - private _processStacktraceEvent(event: Event): Event { - try { - return { - ...event, - stacktrace: this._processStacktrace(event.stacktrace), - }; - } catch (_oO) { - return event; - } - } - /** JSDoc */ private _processStacktrace(stacktrace?: Stacktrace): Stacktrace { return { diff --git a/packages/integrations/test/rewriteframes.test.ts b/packages/integrations/test/rewriteframes.test.ts index 92346d99ebcb..ff18e16f753d 100644 --- a/packages/integrations/test/rewriteframes.test.ts +++ b/packages/integrations/test/rewriteframes.test.ts @@ -65,12 +65,6 @@ describe('RewriteFrames', () => { rewriteFrames = new RewriteFrames(); }); - it('transforms messageEvent frames', () => { - const event = rewriteFrames.process(messageEvent); - expect(event.stacktrace!.frames![0].filename).toEqual('app:///file1.js'); - expect(event.stacktrace!.frames![1].filename).toEqual('app:///file2.js'); - }); - it('transforms exceptionEvent frames', () => { const event = rewriteFrames.process(exceptionEvent); expect(event.exception!.values![0].stacktrace!.frames![0].filename).toEqual('app:///file1.js'); @@ -85,12 +79,6 @@ describe('RewriteFrames', () => { }); }); - it('transforms messageEvent frames', () => { - const event = rewriteFrames.process(messageEvent); - expect(event.stacktrace!.frames![0].filename).toEqual('foobar/file1.js'); - expect(event.stacktrace!.frames![1].filename).toEqual('foobar/file2.js'); - }); - it('transforms exceptionEvent frames', () => { const event = rewriteFrames.process(exceptionEvent); expect(event.exception!.values![0].stacktrace!.frames![0].filename).toEqual('foobar/file1.js'); @@ -117,12 +105,6 @@ describe('RewriteFrames', () => { }); }); - it('transforms messageEvent frames', () => { - const event = rewriteFrames.process(messageEvent); - expect(event.stacktrace!.frames![0].filename).toEqual('app:///src/app/file1.js'); - expect(event.stacktrace!.frames![1].filename).toEqual('app:///src/app/mo\\dule/file2.js'); - }); - it('transforms exceptionEvent frames', () => { const event = rewriteFrames.process(exceptionEvent); expect(event.exception!.values![0].stacktrace!.frames![0].filename).toEqual('app:///src/app/file1.js'); @@ -146,14 +128,6 @@ describe('RewriteFrames', () => { }); }); - it('transforms messageEvent frames', () => { - const event = rewriteFrames.process(messageEvent); - expect(event.stacktrace!.frames![0].filename).toEqual('/www/src/app/file1.js'); - expect(event.stacktrace!.frames![0].function).toEqual('whoops'); - expect(event.stacktrace!.frames![1].filename).toEqual('/www/src/app/mo\\dule/file2.js'); - expect(event.stacktrace!.frames![1].function).toEqual('whoops'); - }); - it('transforms exceptionEvent frames', () => { const event = rewriteFrames.process(exceptionEvent); expect(event.exception!.values![0].stacktrace!.frames![0].filename).toEqual('/www/src/app/file1.js'); diff --git a/packages/node/src/eventbuilder.ts b/packages/node/src/eventbuilder.ts index 0376f21a59c8..1287f2a47f48 100644 --- a/packages/node/src/eventbuilder.ts +++ b/packages/node/src/eventbuilder.ts @@ -105,7 +105,14 @@ export function eventFromMessage( if (attachStacktrace && hint && hint.syntheticException) { const frames = parseStackFrames(hint.syntheticException); if (frames.length) { - event.stacktrace = { frames }; + event.exception = { + values: [ + { + value: message, + stacktrace: { frames }, + }, + ], + }; } } diff --git a/packages/types/src/event.ts b/packages/types/src/event.ts index 0aa146f43848..6711322baab4 100644 --- a/packages/types/src/event.ts +++ b/packages/types/src/event.ts @@ -9,7 +9,6 @@ import { CaptureContext } from './scope'; import { SdkInfo } from './sdkinfo'; import { Severity } from './severity'; import { Span } from './span'; -import { Stacktrace } from './stacktrace'; import { Measurements } from './transaction'; import { User } from './user'; @@ -34,7 +33,6 @@ export interface Event { exception?: { values?: Exception[]; }; - stacktrace?: Stacktrace; breadcrumbs?: Breadcrumb[]; contexts?: Contexts; tags?: { [key: string]: Primitive }; diff --git a/packages/wasm/src/index.ts b/packages/wasm/src/index.ts index 14252305fa76..cc5e678ee123 100644 --- a/packages/wasm/src/index.ts +++ b/packages/wasm/src/index.ts @@ -58,9 +58,6 @@ export class Wasm implements Integration { } }); } - if (event.stacktrace?.frames) { - haveWasm = haveWasm || patchFrames(event.stacktrace.frames); - } if (haveWasm) { event.debug_meta = event.debug_meta || {}; From 1bfb3aa4a5016971fa0e006c1c1764e2790226a3 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 7 Apr 2022 16:10:17 +0100 Subject: [PATCH 13/17] add exception value --- packages/browser/src/eventbuilder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/browser/src/eventbuilder.ts b/packages/browser/src/eventbuilder.ts index 88047061e71f..9ff94ca5775e 100644 --- a/packages/browser/src/eventbuilder.ts +++ b/packages/browser/src/eventbuilder.ts @@ -274,7 +274,7 @@ export function eventFromString(input: string, syntheticException?: Error, attac const frames = parseStackFrames(syntheticException); if (frames.length) { event.exception = { - values: [{ stacktrace: { frames } }], + values: [{ value: input, stacktrace: { frames } }], }; } } From 4c74bfa37eb3cf80df62b6dd56aef3935d043d84 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 7 Apr 2022 16:30:51 +0100 Subject: [PATCH 14/17] Remove redundent check --- packages/browser/src/eventbuilder.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/browser/src/eventbuilder.ts b/packages/browser/src/eventbuilder.ts index 9ff94ca5775e..d8acd41c12c0 100644 --- a/packages/browser/src/eventbuilder.ts +++ b/packages/browser/src/eventbuilder.ts @@ -71,10 +71,11 @@ export function eventFromPlainObject( }, }; - if (syntheticException && event.exception?.values?.[0]) { + if (syntheticException) { const frames = parseStackFrames(syntheticException); if (frames.length) { - event.exception.values[0].stacktrace = { frames }; + // event.exception.values[0] has been set above + (event.exception as { values: Exception[] }).values[0].stacktrace = { frames }; } } From 270ce531592505ef848f748a70c76815eb9b7836 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 7 Apr 2022 16:49:36 +0100 Subject: [PATCH 15/17] Fix tests --- .../lib/integrations/inboundfilters.test.ts | 84 ++++++++++++------- 1 file changed, 54 insertions(+), 30 deletions(-) diff --git a/packages/core/test/lib/integrations/inboundfilters.test.ts b/packages/core/test/lib/integrations/inboundfilters.test.ts index fd6530cd75e3..ea2790f08921 100644 --- a/packages/core/test/lib/integrations/inboundfilters.test.ts +++ b/packages/core/test/lib/integrations/inboundfilters.test.ts @@ -1,4 +1,4 @@ -import { EventProcessor } from '@sentry/types'; +import { EventProcessor, Event } from '@sentry/types'; import { InboundFilters, InboundFiltersOptions } from '../../../src/integrations/inboundfilters'; @@ -52,50 +52,68 @@ function createInboundFiltersEventProcessor( // Fixtures -const MESSAGE_EVENT = { +const MESSAGE_EVENT: Event = { message: 'captureMessage', }; -const MESSAGE_EVENT_2 = { +const MESSAGE_EVENT_2: Event = { message: 'captureMessageSomething', }; -const MESSAGE_EVENT_WITH_STACKTRACE = { +const MESSAGE_EVENT_WITH_STACKTRACE: Event = { message: 'wat', - stacktrace: { - // Frames are always in the reverse order, as this is how Sentry expect them to come. - // Frame that crashed is the last one, the one from awesome-analytics - frames: [ - { filename: 'https://our-side.com/js/bundle.js' }, - { filename: 'https://our-side.com/js/bundle.js' }, - { filename: 'https://awesome-analytics.io/some/file.js' }, + exception: { + values: [ + { + stacktrace: { + // Frames are always in the reverse order, as this is how Sentry expect them to come. + // Frame that crashed is the last one, the one from awesome-analytics + frames: [ + { filename: 'https://our-side.com/js/bundle.js' }, + { filename: 'https://our-side.com/js/bundle.js' }, + { filename: 'https://awesome-analytics.io/some/file.js' }, + ], + }, + }, ], }, }; -const MESSAGE_EVENT_WITH_ANON_LAST_FRAME = { +const MESSAGE_EVENT_WITH_ANON_LAST_FRAME: Event = { message: 'any', - stacktrace: { - frames: [ - { filename: 'https://our-side.com/js/bundle.js' }, - { filename: 'https://awesome-analytics.io/some/file.js' }, - { filename: '' }, + exception: { + values: [ + { + stacktrace: { + frames: [ + { filename: 'https://our-side.com/js/bundle.js' }, + { filename: 'https://awesome-analytics.io/some/file.js' }, + { filename: '' }, + ], + }, + }, ], }, }; -const MESSAGE_EVENT_WITH_NATIVE_LAST_FRAME = { +const MESSAGE_EVENT_WITH_NATIVE_LAST_FRAME: Event = { message: 'any', - stacktrace: { - frames: [ - { filename: 'https://our-side.com/js/bundle.js' }, - { filename: 'https://awesome-analytics.io/some/file.js' }, - { filename: '[native code]' }, + exception: { + values: [ + { + stacktrace: { + frames: [ + { filename: 'https://our-side.com/js/bundle.js' }, + { filename: 'https://awesome-analytics.io/some/file.js' }, + { filename: '[native code]' }, + ], + }, + }, ], }, }; -const EXCEPTION_EVENT = { +const EXCEPTION_EVENT: Event = { exception: { values: [ { @@ -106,7 +124,7 @@ const EXCEPTION_EVENT = { }, }; -const EXCEPTION_EVENT_WITH_FRAMES = { +const EXCEPTION_EVENT_WITH_FRAMES: Event = { exception: { values: [ { @@ -124,7 +142,7 @@ const EXCEPTION_EVENT_WITH_FRAMES = { }, }; -const SENTRY_EVENT = { +const SENTRY_EVENT: Event = { exception: { values: [ { @@ -135,7 +153,7 @@ const SENTRY_EVENT = { }, }; -const SCRIPT_ERROR_EVENT = { +const SCRIPT_ERROR_EVENT: Event = { exception: { values: [ { @@ -146,9 +164,15 @@ const SCRIPT_ERROR_EVENT = { }, }; -const MALFORMED_EVENT = { - stacktrace: { - frames: undefined, +const MALFORMED_EVENT: Event = { + exception: { + values: [ + { + stacktrace: { + frames: undefined, + }, + }, + ], }, }; From 6865b6e53824a6277f62a1050697d2a18af98a07 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 7 Apr 2022 17:23:52 +0100 Subject: [PATCH 16/17] Fix dedup test and lint --- .../lib/integrations/inboundfilters.test.ts | 2 +- packages/integrations/test/dedupe.test.ts | 40 ++++++++++++------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/packages/core/test/lib/integrations/inboundfilters.test.ts b/packages/core/test/lib/integrations/inboundfilters.test.ts index ea2790f08921..74672a3f56e5 100644 --- a/packages/core/test/lib/integrations/inboundfilters.test.ts +++ b/packages/core/test/lib/integrations/inboundfilters.test.ts @@ -1,4 +1,4 @@ -import { EventProcessor, Event } from '@sentry/types'; +import { Event, EventProcessor } from '@sentry/types'; import { InboundFilters, InboundFiltersOptions } from '../../../src/integrations/inboundfilters'; diff --git a/packages/integrations/test/dedupe.test.ts b/packages/integrations/test/dedupe.test.ts index 46cac4d06320..c56ab59d5b82 100644 --- a/packages/integrations/test/dedupe.test.ts +++ b/packages/integrations/test/dedupe.test.ts @@ -1,3 +1,5 @@ +import { Event } from '@sentry/types'; + import { _shouldDropEvent } from '../src/dedupe'; /** JSDoc */ @@ -5,27 +7,34 @@ function clone(data: T): T { return JSON.parse(JSON.stringify(data)); } -const messageEvent = { +const messageEvent: Event = { fingerprint: ['MrSnuffles'], message: 'PickleRick', - stacktrace: { - frames: [ - { - colno: 1, - filename: 'filename.js', - function: 'function', - lineno: 1, - }, + exception: { + values: [ { - colno: 2, - filename: 'filename.js', - function: 'function', - lineno: 2, + value: 'PickleRick', + stacktrace: { + frames: [ + { + colno: 1, + filename: 'filename.js', + function: 'function', + lineno: 1, + }, + { + colno: 2, + filename: 'filename.js', + function: 'function', + lineno: 2, + }, + ], + }, }, ], }, }; -const exceptionEvent = { +const exceptionEvent: Event = { exception: { values: [ { @@ -64,13 +73,14 @@ describe('Dedupe', () => { const eventA = clone(messageEvent); const eventB = clone(messageEvent); eventB.message = 'EvilMorty'; + eventB.exception.values[0].value = 'EvilMorty'; expect(_shouldDropEvent(eventA, eventB)).toBe(false); }); it('should not drop if events have same messages, but different stacktraces', () => { const eventA = clone(messageEvent); const eventB = clone(messageEvent); - eventB.stacktrace.frames[0].colno = 1337; + eventB.exception.values[0].stacktrace.frames[0].colno = 1337; expect(_shouldDropEvent(eventA, eventB)).toBe(false); }); From 5600f872b83b0f98f1e01f2f2502e7af82b27c98 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Thu, 7 Apr 2022 18:08:33 +0100 Subject: [PATCH 17/17] Fix integration tests --- packages/browser/test/integration/suites/api.js | 4 ++-- .../browser/test/integration/suites/breadcrumbs.js | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/packages/browser/test/integration/suites/api.js b/packages/browser/test/integration/suites/api.js index f51928c5bed5..be5de29abd0e 100644 --- a/packages/browser/test/integration/suites/api.js +++ b/packages/browser/test/integration/suites/api.js @@ -65,8 +65,8 @@ describe('API', function () { return runInSandbox(sandbox, function () { throwNonError(); }).then(function (summary) { - assert.isAtLeast(summary.events[0].stacktrace.frames.length, 1); - assert.isAtMost(summary.events[0].stacktrace.frames.length, 3); + assert.isAtLeast(summary.events[0].exception.values[0].stacktrace.frames.length, 1); + assert.isAtMost(summary.events[0].exception.values[0].stacktrace.frames.length, 3); }); }); diff --git a/packages/browser/test/integration/suites/breadcrumbs.js b/packages/browser/test/integration/suites/breadcrumbs.js index 434bcacc8b4a..5e5c2973efc7 100644 --- a/packages/browser/test/integration/suites/breadcrumbs.js +++ b/packages/browser/test/integration/suites/breadcrumbs.js @@ -234,8 +234,6 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbHints.length, 1); assert.equal(summary.breadcrumbHints[0].name, 'click'); assert.equal(summary.breadcrumbHints[0].event.target.tagName, 'INPUT'); - // There should be no expection, if there is one it means we threw it - assert.isUndefined(summary.events[0].exception); } }); }); @@ -265,9 +263,6 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[1].category, 'ui.input'); assert.equal(summary.breadcrumbs[1].message, 'body > form#foo-form > input[name="foo"]'); - - // There should be no expection, if there is one it means we threw it - assert.isUndefined(summary.events[0].exception); } }); }); @@ -288,8 +283,6 @@ describe('breadcrumbs', function () { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); } else { - // There should be no expection, if there is one it means we threw it - assert.isUndefined(summary.events[0].exception); assert.equal(summary.breadcrumbs.length, 0); } }); @@ -309,8 +302,6 @@ describe('breadcrumbs', function () { // The async loader doesn't wrap event listeners, but we should receive the event without breadcrumbs assert.lengthOf(summary.events, 1); } else { - // There should be no expection, if there is one it means we threw it - assert.isUndefined(summary.events[0].exception); assert.equal(summary.breadcrumbs.length, 0); } }); @@ -472,7 +463,6 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]'); assert.equal(summary.breadcrumbHints[0].global, false); assert.equal(summary.breadcrumbHints[1].global, false); - assert.isUndefined(summary.events[0].exception); } }); }); @@ -507,7 +497,6 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[0].message, 'body > form#foo-form > input[name="foo"]'); assert.equal(summary.breadcrumbHints[0].global, false); assert.equal(summary.breadcrumbHints[1].global, false); - assert.isUndefined(summary.events[0].exception); } }); }); @@ -538,7 +527,6 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs[1].message, 'body > form#foo-form > div.contenteditable'); assert.equal(summary.breadcrumbHints[0].global, false); assert.equal(summary.breadcrumbHints[1].global, false); - assert.isUndefined(summary.events[0].exception); } }); }); @@ -706,7 +694,6 @@ describe('breadcrumbs', function () { assert.equal(summary.breadcrumbs.length, 2); assert.equal(summary.breadcrumbHints[0].global, true); assert.equal(summary.breadcrumbHints[1].global, true); - assert.isUndefined(summary.events[0].exception); } }); });