Skip to content

Commit

Permalink
feat: Move LinkedErrors integration to @sentry/core (#9404)
Browse files Browse the repository at this point in the history
- 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

In a future PR I'm going to remove browser specific `LinkedErrors`
integration and make everything rely on implementation in Core SDK.

This refactor came from two places

1. We noticed the Deno SDK relies on the browser SDK. This is not ideal,
so this helps with that
2. We got feedback via customer that `LinkedErrors` was not available in
`@sentry/vercel-edge`
  • Loading branch information
AbhiPrasad committed Oct 30, 2023
1 parent 4fc18b9 commit 89a4d42
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 17 deletions.
3 changes: 1 addition & 2 deletions packages/bun/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -24,8 +25,6 @@ export const defaultIntegrations = [
new NodeIntegrations.Context(),
new NodeIntegrations.Modules(),
new NodeIntegrations.RequestData(),
// Misc
new NodeIntegrations.LinkedErrors(),
// Bun Specific
new BunServer(),
];
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/integrations/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { FunctionToString } from './functiontostring';
export { InboundFilters } from './inboundfilters';
export { LinkedErrors } from './linkederrors';
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class LinkedErrors implements Integration {
/**
* @inheritDoc
*/
public readonly name: string = LinkedErrors.id;
public readonly name: string;

/**
* @inheritDoc
Expand All @@ -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 */
Expand Down
4 changes: 2 additions & 2 deletions packages/deno/src/sdk.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/deno/test/__snapshots__/mod.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ snapshot[`captureException 1`] = `
integrations: [
"InboundFilters",
"FunctionToString",
"Dedupe",
"LinkedErrors",
"Dedupe",
"Breadcrumbs",
"DenoContext",
"ContextLines",
Expand Down Expand Up @@ -200,8 +200,8 @@ snapshot[`captureMessage 1`] = `
integrations: [
"InboundFilters",
"FunctionToString",
"Dedupe",
"LinkedErrors",
"Dedupe",
"Breadcrumbs",
"DenoContext",
"ContextLines",
Expand Down
2 changes: 0 additions & 2 deletions packages/node-experimental/src/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const {
Console,
OnUncaughtException,
OnUnhandledRejection,
LinkedErrors,
Modules,
ContextLines,
Context,
Expand All @@ -16,7 +15,6 @@ export {
Console,
OnUncaughtException,
OnUnhandledRejection,
LinkedErrors,
Modules,
ContextLines,
Context,
Expand Down
1 change: 0 additions & 1 deletion packages/node/src/integrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions packages/node/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
Context,
ContextLines,
Http,
LinkedErrors,
LocalVariables,
Modules,
OnUncaughtException,
Expand All @@ -39,6 +38,7 @@ export const defaultIntegrations = [
// Common
new CoreIntegrations.InboundFilters(),
new CoreIntegrations.FunctionToString(),
new CoreIntegrations.LinkedErrors(),
// Native Wrappers
new Console(),
new Http(),
Expand All @@ -52,8 +52,6 @@ export const defaultIntegrations = [
new Context(),
new Modules(),
new RequestData(),
// Misc
new LinkedErrors(),
];

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/node/test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down
6 changes: 5 additions & 1 deletion packages/vercel-edge/src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 89a4d42

Please sign in to comment.