Skip to content

Commit 8e11393

Browse files
committed
ref: Move SDKInformation integration into core prepareEvent method
1 parent dd45d3b commit 8e11393

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- [browser] fix: Array.from is not available in old mobile browsers
1010
- [browser] fix: Check for anonymous function before getting its name for mechanism
1111
- [browser] test: Add loader + integration tests
12+
- [core] ref: Move SDKInformation integration into core prepareEvent method
13+
- [core] ref: Move debug initialization as the first step
1214

1315
## 4.0.4
1416

packages/browser/src/client.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { API, BaseClient, Scope, SentryError } from '@sentry/core';
22
import { DsnLike, SentryEvent, SentryEventHint } from '@sentry/types';
33
import { getGlobalObject } from '@sentry/utils/misc';
44
import { BrowserBackend, BrowserOptions } from './backend';
5+
import { SDK_NAME, SDK_VERSION } from './version';
56

67
/**
78
* All properties the report dialog supports
@@ -49,6 +50,19 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
4950
*/
5051
protected async prepareEvent(event: SentryEvent, scope?: Scope, hint?: SentryEventHint): Promise<SentryEvent | null> {
5152
event.platform = event.platform || 'javascript';
53+
event.sdk = {
54+
...event.sdk,
55+
name: SDK_NAME,
56+
packages: [
57+
...((event.sdk && event.sdk.packages) || []),
58+
{
59+
name: 'npm:@sentry/browser',
60+
version: SDK_VERSION,
61+
},
62+
],
63+
version: SDK_VERSION,
64+
};
65+
5266
return super.prepareEvent(event, scope, hint);
5367
}
5468

packages/browser/src/sdk.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@ import { DsnLike } from '@sentry/types';
33
import { BrowserOptions } from './backend';
44
import { BrowserClient } from './client';
55
import { Breadcrumbs, GlobalHandlers, LinkedErrors, ReportingObserver, TryCatch, UserAgent } from './integrations';
6-
import { SDK_NAME, SDK_VERSION } from './version';
76

87
export const defaultIntegrations = [
98
// Common
109
new CoreIntegrations.Dedupe(),
1110
new CoreIntegrations.InboundFilters(),
1211
new CoreIntegrations.FunctionToString(),
13-
new CoreIntegrations.SDKInformation({
14-
name: 'npm:@sentry/browser',
15-
sdkName: SDK_NAME,
16-
sdkVersion: SDK_VERSION,
17-
}),
1812
// Native Wrappers
1913
new TryCatch(),
2014
new Breadcrumbs(),
Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { configureScope } from '@sentry/minimal';
2-
import { Integration, SentryEvent } from '@sentry/types';
1+
import { Integration } from '@sentry/types';
2+
import { logger } from '../logger';
3+
4+
/**
5+
* @deprecated
6+
* This file can be safely removed in the next major bump
7+
*/
38

49
/** Adds SDK info to an event. */
510
export class SDKInformation implements Integration {
@@ -8,36 +13,12 @@ export class SDKInformation implements Integration {
813
*/
914
public name: string = 'SDKInformation';
1015

11-
/**
12-
* @inheritDoc
13-
*/
14-
public constructor(
15-
private readonly config: {
16-
name: string;
17-
sdkName: string;
18-
sdkVersion: string;
19-
},
20-
) {}
21-
2216
/**
2317
* @inheritDoc
2418
*/
2519
public install(): void {
26-
configureScope(scope => {
27-
scope.addEventProcessor(async (event: SentryEvent) => ({
28-
...event,
29-
sdk: {
30-
name: this.config.sdkName,
31-
packages: [
32-
...((event.sdk && event.sdk.packages) || []),
33-
{
34-
name: this.config.name,
35-
version: this.config.sdkVersion,
36-
},
37-
],
38-
version: this.config.sdkVersion,
39-
},
40-
}));
41-
});
20+
logger.warn(
21+
"SDKInformation Integration is deprecated and can be safely removed. It's functionality has been merged into the SDK's core.",
22+
);
4223
}
4324
}

packages/node/src/client.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BaseClient, Scope } from '@sentry/core';
22
import { SentryEvent, SentryEventHint } from '@sentry/types';
33
import { NodeBackend, NodeOptions } from './backend';
4+
import { SDK_NAME, SDK_VERSION } from './version';
45

56
/**
67
* The Sentry Node SDK Client.
@@ -22,9 +23,23 @@ export class NodeClient extends BaseClient<NodeBackend, NodeOptions> {
2223
*/
2324
protected async prepareEvent(event: SentryEvent, scope?: Scope, hint?: SentryEventHint): Promise<SentryEvent | null> {
2425
event.platform = event.platform || 'node';
26+
event.sdk = {
27+
...event.sdk,
28+
name: SDK_NAME,
29+
packages: [
30+
...((event.sdk && event.sdk.packages) || []),
31+
{
32+
name: 'npm:@sentry/node',
33+
version: SDK_VERSION,
34+
},
35+
],
36+
version: SDK_VERSION,
37+
};
38+
2539
if (this.getOptions().serverName) {
2640
event.server_name = this.getOptions().serverName;
2741
}
42+
2843
return super.prepareEvent(event, scope, hint);
2944
}
3045
}

packages/node/src/sdk.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@ import { initAndBind, Integrations as CoreIntegrations } from '@sentry/core';
22
import { NodeOptions } from './backend';
33
import { NodeClient } from './client';
44
import { Console, Http, LinkedErrors, OnUncaughtException, OnUnhandledRejection } from './integrations';
5-
import { SDK_NAME, SDK_VERSION } from './version';
65

76
export const defaultIntegrations = [
87
// Common
98
new CoreIntegrations.Dedupe(),
109
new CoreIntegrations.InboundFilters(),
1110
new CoreIntegrations.FunctionToString(),
12-
new CoreIntegrations.SDKInformation({
13-
name: 'npm:@sentry/node',
14-
sdkName: SDK_NAME,
15-
sdkVersion: SDK_VERSION,
16-
}),
1711
// Native Wrappers
1812
new Console(),
1913
new Http(),

0 commit comments

Comments
 (0)