Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/node-core/src/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Integration, Options } from '@sentry/core';
import {
applySdkMetadata,
consoleIntegration,
consoleSandbox,
functionToStringIntegration,
Expand Down Expand Up @@ -120,6 +121,8 @@ function _init(
);
}

applySdkMetadata(options, 'node-core');

const client = new NodeClient(options);
// The client is on the current scope, from where it generally is inherited
getCurrentScope().setClient(client);
Expand Down
20 changes: 19 additions & 1 deletion packages/node-core/test/sdk/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Integration } from '@sentry/core';
import { logger } from '@sentry/core';
import { logger, SDK_VERSION } from '@sentry/core';
import * as SentryOpentelemetry from '@sentry/opentelemetry';
import { type Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { getClient } from '../../src/';
Expand Down Expand Up @@ -31,6 +31,24 @@ describe('init()', () => {
vi.clearAllMocks();
});

describe('metadata', () => {
it('has the correct metadata', () => {
init({ dsn: PUBLIC_DSN });

const client = getClient<NodeClient>();

expect(client?.getSdkMetadata()).toEqual(
expect.objectContaining({
sdk: {
name: 'sentry.javascript.node-core',
version: SDK_VERSION,
packages: [{ name: 'npm:@sentry/node-core', version: SDK_VERSION }],
},
}),
);
});
});

describe('integrations', () => {
it("doesn't install default integrations if told not to", () => {
init({ dsn: PUBLIC_DSN, defaultIntegrations: false });
Expand Down
4 changes: 3 additions & 1 deletion packages/node/src/sdk/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Integration, Options } from '@sentry/core';
import { hasSpansEnabled } from '@sentry/core';
import { applySdkMetadata, hasSpansEnabled } from '@sentry/core';
import type { NodeClient } from '@sentry/node-core';
import {
getDefaultIntegrations as getNodeCoreDefaultIntegrations,
Expand Down Expand Up @@ -50,6 +50,8 @@ function _init(
options: NodeOptions | undefined = {},
getDefaultIntegrationsImpl: (options: Options) => Integration[],
): NodeClient | undefined {
applySdkMetadata(options, 'node');

const client = initNodeCore({
...options,
// Only use Node SDK defaults if none provided
Expand Down
20 changes: 19 additions & 1 deletion packages/node/test/sdk/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Integration } from '@sentry/core';
import { logger } from '@sentry/core';
import { logger, SDK_VERSION } from '@sentry/core';
import * as SentryOpentelemetry from '@sentry/opentelemetry';
import { type Mock, type MockInstance, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { getClient, NodeClient, validateOpenTelemetrySetup } from '../../src/';
Expand Down Expand Up @@ -38,6 +38,24 @@ describe('init()', () => {
vi.clearAllMocks();
});

describe('metadata', () => {
it('has the correct metadata', () => {
init({ dsn: PUBLIC_DSN });

const client = getClient<NodeClient>();

expect(client?.getSdkMetadata()).toEqual(
expect.objectContaining({
sdk: {
name: 'sentry.javascript.node',
version: SDK_VERSION,
packages: [{ name: 'npm:@sentry/node', version: SDK_VERSION }],
},
}),
);
});
});

describe('integrations', () => {
it("doesn't install default integrations if told not to", () => {
init({ dsn: PUBLIC_DSN, defaultIntegrations: false });
Expand Down
Loading