Skip to content

Commit 2f19b32

Browse files
committed
set node SDK data globally
1 parent 7059b84 commit 2f19b32

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/node/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ export { NodeClient } from './client';
4242
export { defaultIntegrations, init, lastEventId, flush, close } from './sdk';
4343
export { SDK_NAME, SDK_VERSION } from './version';
4444

45+
import { setSDKInfo } from '@sentry/utils';
46+
47+
import { SDK_VERSION } from './version';
48+
49+
setSDKInfo('sentry.javascript.node', 'npm:@sentry/node', SDK_VERSION, false);
50+
4551
import { Integrations as CoreIntegrations } from '@sentry/core';
4652
import { getMainCarrier } from '@sentry/hub';
4753
import * as domain from 'domain';

packages/node/test/index.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
init,
1212
NodeClient,
1313
Scope,
14+
SDK_VERSION,
1415
} from '../src';
1516
import { NodeBackend } from '../src/backend';
1617

@@ -270,6 +271,16 @@ describe('SentryNode', () => {
270271
});
271272

272273
describe('SentryNode initialization', () => {
274+
test('sets SDK info globally', () => {
275+
// the SDK data is set when we import from (and therefore run) `../src/index.ts`, so no action is necessary here
276+
// before we run the `expect`s
277+
278+
expect(global.__SENTRY__.sdkInfo).toBeDefined();
279+
expect(global.__SENTRY__.sdkInfo.name).toEqual('sentry.javascript.node');
280+
expect(global.__SENTRY__.sdkInfo.version).toEqual(SDK_VERSION);
281+
expect(global.__SENTRY__.sdkInfo.packages).toEqual([{ name: 'npm:@sentry/node', version: SDK_VERSION }]);
282+
});
283+
273284
test('global.SENTRY_RELEASE is used to set release on initialization if available', () => {
274285
global.SENTRY_RELEASE = { id: 'foobar' };
275286
init({ dsn });

0 commit comments

Comments
 (0)