Skip to content

Commit 6c3b183

Browse files
committed
feat: Provide correct platform and make a place to override event internals
1 parent 543f11c commit 6c3b183

File tree

5 files changed

+24
-38
lines changed

5 files changed

+24
-38
lines changed

packages/browser/src/client.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { API, BaseClient, SentryError } from '@sentry/core';
2-
import { DsnLike } from '@sentry/types';
1+
import { API, BaseClient, Scope, SentryError } from '@sentry/core';
2+
import { DsnLike, SentryEvent, SentryEventHint } from '@sentry/types';
33
import { getGlobalObject } from '@sentry/utils/misc';
44
import { BrowserBackend, BrowserOptions } from './backend';
55

@@ -19,6 +19,14 @@ export class BrowserClient extends BaseClient<BrowserBackend, BrowserOptions> {
1919
super(BrowserBackend, options);
2020
}
2121

22+
/**
23+
* @inheritDoc
24+
*/
25+
protected async prepareEvent(event: SentryEvent, scope?: Scope, hint?: SentryEventHint): Promise<SentryEvent | null> {
26+
event.platform = event.platform || 'javascript';
27+
return super.prepareEvent(event, scope, hint);
28+
}
29+
2230
/** JSDoc */
2331
public showReportDialog(options: {
2432
[key: string]: any;

packages/node/src/client.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { BaseClient } from '@sentry/core';
1+
import { BaseClient, Scope } from '@sentry/core';
2+
import { SentryEvent, SentryEventHint } from '@sentry/types';
23
import { NodeBackend, NodeOptions } from './backend';
34

45
/**
@@ -15,4 +16,15 @@ export class NodeClient extends BaseClient<NodeBackend, NodeOptions> {
1516
public constructor(options: NodeOptions) {
1617
super(NodeBackend, options);
1718
}
19+
20+
/**
21+
* @inheritDoc
22+
*/
23+
protected async prepareEvent(event: SentryEvent, scope?: Scope, hint?: SentryEventHint): Promise<SentryEvent | null> {
24+
event.platform = event.platform || 'node';
25+
if (this.getOptions().serverName) {
26+
event.server_name = this.getOptions().serverName;
27+
}
28+
return super.prepareEvent(event, scope, hint);
29+
}
1830
}

packages/node/src/integrations/clientoptions.ts

Lines changed: 0 additions & 32 deletions
This file was deleted.

packages/node/src/integrations/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ export { Console } from './console';
22
export { Http } from './http';
33
export { OnUncaughtException } from './onuncaughtexception';
44
export { OnUnhandledRejection } from './onunhandledrejection';
5-
export { ClientOptions } from './clientoptions';
65
export { LinkedErrors } from './linkederrors';
76

87
export { Modules } from './pluggable/modules';

packages/node/src/sdk.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { initAndBind, Integrations as CoreIntegrations } from '@sentry/core';
22
import { NodeOptions } from './backend';
33
import { NodeClient } from './client';
4-
import { ClientOptions, Console, Http, LinkedErrors, OnUncaughtException, OnUnhandledRejection } from './integrations';
4+
import { Console, Http, LinkedErrors, OnUncaughtException, OnUnhandledRejection } from './integrations';
55
import { SDK_NAME, SDK_VERSION } from './version';
66

77
export const defaultIntegrations = [
@@ -21,7 +21,6 @@ export const defaultIntegrations = [
2121
new OnUncaughtException(),
2222
new OnUnhandledRejection(),
2323
// Misc
24-
new ClientOptions(),
2524
new LinkedErrors(),
2625
];
2726

0 commit comments

Comments
 (0)