From eab9fd99d954791c8c3c6973b6c4dcf18c8c1a8d Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Fri, 27 Oct 2023 17:11:53 -0400 Subject: [PATCH 1/4] feat: Move LinkedErrors integration to @sentry/core - Remove LinkedErrors from Node SDK and use Core SDK LinkedErrors instead - Use LinkedErrors integration in Vercel Edge SDK - Update Deno SDK to use LinkedErrors integration from Core instead of Browser --- packages/bun/src/sdk.ts | 3 +-- packages/core/src/index.ts | 2 +- packages/core/src/integrations/index.ts | 1 + packages/{node => core}/src/integrations/linkederrors.ts | 3 ++- packages/deno/src/sdk.ts | 4 ++-- packages/node-experimental/src/integrations/index.ts | 2 -- packages/node/src/integrations/index.ts | 1 - packages/node/src/sdk.ts | 4 +--- packages/node/test/index.test.ts | 4 ++-- packages/vercel-edge/src/sdk.ts | 6 +++++- 10 files changed, 15 insertions(+), 15 deletions(-) rename packages/{node => core}/src/integrations/linkederrors.ts (94%) diff --git a/packages/bun/src/sdk.ts b/packages/bun/src/sdk.ts index d512e7208bf5..ea4702b6b19b 100644 --- a/packages/bun/src/sdk.ts +++ b/packages/bun/src/sdk.ts @@ -11,6 +11,7 @@ export const defaultIntegrations = [ // Common new CoreIntegrations.InboundFilters(), new CoreIntegrations.FunctionToString(), + new CoreIntegrations.LinkedErrors(), // Native Wrappers new NodeIntegrations.Console(), new NodeIntegrations.Http(), @@ -24,8 +25,6 @@ export const defaultIntegrations = [ new NodeIntegrations.Context(), new NodeIntegrations.Modules(), new NodeIntegrations.RequestData(), - // Misc - new NodeIntegrations.LinkedErrors(), // Bun Specific new BunServer(), ]; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index b80c83cdfdfa..a912475e6c41 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -48,7 +48,7 @@ export { makeOfflineTransport } from './transports/offline'; export { makeMultiplexedTransport } from './transports/multiplexed'; export { SDK_VERSION } from './version'; export { getIntegrationsToSetup, addIntegration } from './integration'; -export { FunctionToString, InboundFilters } from './integrations'; +export { FunctionToString, InboundFilters, LinkedErrors } from './integrations'; export { prepareEvent } from './utils/prepareEvent'; export { createCheckInEnvelope } from './checkin'; export { hasTracingEnabled } from './utils/hasTracingEnabled'; diff --git a/packages/core/src/integrations/index.ts b/packages/core/src/integrations/index.ts index ddb199ef4e5f..5e81ff7a7754 100644 --- a/packages/core/src/integrations/index.ts +++ b/packages/core/src/integrations/index.ts @@ -1,2 +1,3 @@ export { FunctionToString } from './functiontostring'; export { InboundFilters } from './inboundfilters'; +export { LinkedErrors } from './linkederrors'; diff --git a/packages/node/src/integrations/linkederrors.ts b/packages/core/src/integrations/linkederrors.ts similarity index 94% rename from packages/node/src/integrations/linkederrors.ts rename to packages/core/src/integrations/linkederrors.ts index de2a6e0cc1e8..1b3ef1c39a19 100644 --- a/packages/node/src/integrations/linkederrors.ts +++ b/packages/core/src/integrations/linkederrors.ts @@ -14,7 +14,7 @@ export class LinkedErrors implements Integration { /** * @inheritDoc */ - public readonly name: string = LinkedErrors.id; + public readonly name: string; /** * @inheritDoc @@ -32,6 +32,7 @@ export class LinkedErrors implements Integration { public constructor(options: { key?: string; limit?: number } = {}) { this._key = options.key || DEFAULT_KEY; this._limit = options.limit || DEFAULT_LIMIT; + this.name = LinkedErrors.id; } /** @inheritdoc */ diff --git a/packages/deno/src/sdk.ts b/packages/deno/src/sdk.ts index cff16148453e..52de20ffd6fd 100644 --- a/packages/deno/src/sdk.ts +++ b/packages/deno/src/sdk.ts @@ -1,4 +1,4 @@ -import { Breadcrumbs, Dedupe, LinkedErrors } from '@sentry/browser'; +import { Breadcrumbs, Dedupe } from '@sentry/browser'; import type { ServerRuntimeClientOptions } from '@sentry/core'; import { getIntegrationsToSetup, initAndBind, Integrations as CoreIntegrations } from '@sentry/core'; import type { StackParser } from '@sentry/types'; @@ -13,9 +13,9 @@ export const defaultIntegrations = [ // Common new CoreIntegrations.InboundFilters(), new CoreIntegrations.FunctionToString(), + new CoreIntegrations.LinkedErrors(), // From Browser new Dedupe(), - new LinkedErrors(), new Breadcrumbs({ dom: false, history: false, diff --git a/packages/node-experimental/src/integrations/index.ts b/packages/node-experimental/src/integrations/index.ts index 35858c52c7a1..b625872d2fb7 100644 --- a/packages/node-experimental/src/integrations/index.ts +++ b/packages/node-experimental/src/integrations/index.ts @@ -4,7 +4,6 @@ const { Console, OnUncaughtException, OnUnhandledRejection, - LinkedErrors, Modules, ContextLines, Context, @@ -16,7 +15,6 @@ export { Console, OnUncaughtException, OnUnhandledRejection, - LinkedErrors, Modules, ContextLines, Context, diff --git a/packages/node/src/integrations/index.ts b/packages/node/src/integrations/index.ts index 79fd4f93541a..62e7b58e85b2 100644 --- a/packages/node/src/integrations/index.ts +++ b/packages/node/src/integrations/index.ts @@ -2,7 +2,6 @@ export { Console } from './console'; export { Http } from './http'; export { OnUncaughtException } from './onuncaughtexception'; export { OnUnhandledRejection } from './onunhandledrejection'; -export { LinkedErrors } from './linkederrors'; export { Modules } from './modules'; export { ContextLines } from './contextlines'; export { Context } from './context'; diff --git a/packages/node/src/sdk.ts b/packages/node/src/sdk.ts index 7bb0257fc463..a01cdfbcae23 100644 --- a/packages/node/src/sdk.ts +++ b/packages/node/src/sdk.ts @@ -23,7 +23,6 @@ import { Context, ContextLines, Http, - LinkedErrors, LocalVariables, Modules, OnUncaughtException, @@ -39,6 +38,7 @@ export const defaultIntegrations = [ // Common new CoreIntegrations.InboundFilters(), new CoreIntegrations.FunctionToString(), + new CoreIntegrations.LinkedErrors(), // Native Wrappers new Console(), new Http(), @@ -52,8 +52,6 @@ export const defaultIntegrations = [ new Context(), new Modules(), new RequestData(), - // Misc - new LinkedErrors(), ]; /** diff --git a/packages/node/test/index.test.ts b/packages/node/test/index.test.ts index 6ee7b526ca86..24f2b95e398b 100644 --- a/packages/node/test/index.test.ts +++ b/packages/node/test/index.test.ts @@ -1,4 +1,4 @@ -import { getMainCarrier, initAndBind, runWithAsyncContext, SDK_VERSION } from '@sentry/core'; +import { getMainCarrier, initAndBind, LinkedErrors, runWithAsyncContext, SDK_VERSION } from '@sentry/core'; import type { EventHint, Integration } from '@sentry/types'; import type { Event, Scope } from '../src'; @@ -13,7 +13,7 @@ import { NodeClient, } from '../src'; import { setNodeAsyncContextStrategy } from '../src/async'; -import { ContextLines, LinkedErrors } from '../src/integrations'; +import { ContextLines } from '../src/integrations'; import { defaultStackParser } from '../src/sdk'; import type { NodeClientOptions } from '../src/types'; import { getDefaultNodeClientOptions } from './helper/node-client-options'; diff --git a/packages/vercel-edge/src/sdk.ts b/packages/vercel-edge/src/sdk.ts index f2c57c7f9546..417c55bf809e 100644 --- a/packages/vercel-edge/src/sdk.ts +++ b/packages/vercel-edge/src/sdk.ts @@ -13,7 +13,11 @@ declare const process: { const nodeStackParser = createStackParser(nodeStackLineParser()); -export const defaultIntegrations = [new CoreIntegrations.InboundFilters(), new CoreIntegrations.FunctionToString()]; +export const defaultIntegrations = [ + new CoreIntegrations.InboundFilters(), + new CoreIntegrations.FunctionToString(), + new CoreIntegrations.LinkedErrors(), +]; /** Inits the Sentry NextJS SDK on the Edge Runtime. */ export function init(options: VercelEdgeOptions = {}): void { From 3769510b97d51a6ab0a8b235ddb52171fb23b3a6 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Mon, 30 Oct 2023 09:04:33 -0400 Subject: [PATCH 2/4] update snapshot for deno --- .../deno/test/__snapshots__/mod.test.ts.snap | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/deno/test/__snapshots__/mod.test.ts.snap b/packages/deno/test/__snapshots__/mod.test.ts.snap index 501508e1a268..070b6081cd25 100644 --- a/packages/deno/test/__snapshots__/mod.test.ts.snap +++ b/packages/deno/test/__snapshots__/mod.test.ts.snap @@ -42,39 +42,46 @@ snapshot[`captureException 1`] = ` stacktrace: { frames: [ { - colno: 20, + colno: 26, filename: "ext:cli/40_testing.js", - function: "outerWrapped", + function: "runTests", in_app: false, - lineno: 488, + lineno: 1026, + }, + { + colno: 26, + filename: "ext:cli/40_testing.js", + function: "runTest", + in_app: false, + lineno: 782, }, { colno: 33, filename: "ext:cli/40_testing.js", function: "exitSanitizer", in_app: false, - lineno: 474, + lineno: 410, }, { colno: 31, filename: "ext:cli/40_testing.js", function: "resourceSanitizer", in_app: false, - lineno: 425, + lineno: 361, }, { colno: 33, filename: "ext:cli/40_testing.js", function: "asyncOpSanitizer", in_app: false, - lineno: 192, + lineno: 145, }, { colno: 11, filename: "ext:cli/40_testing.js", - function: "innerWrapped", + function: "testStepSanitizer", in_app: false, - lineno: 543, + lineno: 460, }, { colno: 24, From a03806ff694d7a09a053dff60d68265fa9aad21a Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Mon, 30 Oct 2023 10:18:00 -0400 Subject: [PATCH 3/4] update snapshots --- packages/deno/test/__snapshots__/mod.test.ts.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/deno/test/__snapshots__/mod.test.ts.snap b/packages/deno/test/__snapshots__/mod.test.ts.snap index 070b6081cd25..c4fa814eb7f5 100644 --- a/packages/deno/test/__snapshots__/mod.test.ts.snap +++ b/packages/deno/test/__snapshots__/mod.test.ts.snap @@ -147,8 +147,8 @@ snapshot[`captureException 1`] = ` integrations: [ "InboundFilters", "FunctionToString", - "Dedupe", "LinkedErrors", + "Dedupe", "Breadcrumbs", "DenoContext", "ContextLines", @@ -207,8 +207,8 @@ snapshot[`captureMessage 1`] = ` integrations: [ "InboundFilters", "FunctionToString", - "Dedupe", "LinkedErrors", + "Dedupe", "Breadcrumbs", "DenoContext", "ContextLines", From c74864bc09e14a51e36fec9361e15f8ff3b2a491 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Mon, 30 Oct 2023 11:36:52 -0400 Subject: [PATCH 4/4] Revert "update snapshot for deno" This reverts commit 3769510b97d51a6ab0a8b235ddb52171fb23b3a6. --- .../deno/test/__snapshots__/mod.test.ts.snap | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/packages/deno/test/__snapshots__/mod.test.ts.snap b/packages/deno/test/__snapshots__/mod.test.ts.snap index c4fa814eb7f5..67823708e07e 100644 --- a/packages/deno/test/__snapshots__/mod.test.ts.snap +++ b/packages/deno/test/__snapshots__/mod.test.ts.snap @@ -42,46 +42,39 @@ snapshot[`captureException 1`] = ` stacktrace: { frames: [ { - colno: 26, + colno: 20, filename: "ext:cli/40_testing.js", - function: "runTests", + function: "outerWrapped", in_app: false, - lineno: 1026, - }, - { - colno: 26, - filename: "ext:cli/40_testing.js", - function: "runTest", - in_app: false, - lineno: 782, + lineno: 488, }, { colno: 33, filename: "ext:cli/40_testing.js", function: "exitSanitizer", in_app: false, - lineno: 410, + lineno: 474, }, { colno: 31, filename: "ext:cli/40_testing.js", function: "resourceSanitizer", in_app: false, - lineno: 361, + lineno: 425, }, { colno: 33, filename: "ext:cli/40_testing.js", function: "asyncOpSanitizer", in_app: false, - lineno: 145, + lineno: 192, }, { colno: 11, filename: "ext:cli/40_testing.js", - function: "testStepSanitizer", + function: "innerWrapped", in_app: false, - lineno: 460, + lineno: 543, }, { colno: 24,