Skip to content

Commit 2780c3c

Browse files
authored
ref: Use applySdkMetadata everywhere (#15305)
This was still set differently in a few places. This PR unifies this so we do this consistently. For aws-serverless, we also still hard-coded the `AWSLambda` integration name, but this is already reflected via the `Aws` and `AwsLambda` integrations anyhow.
1 parent 0a74795 commit 2780c3c

File tree

4 files changed

+21
-48
lines changed

4 files changed

+21
-48
lines changed

packages/aws-serverless/src/sdk.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import { existsSync } from 'fs';
22
import { hostname } from 'os';
33
import { basename, resolve } from 'path';
44
import { types } from 'util';
5-
import type { Integration, Options, Scope, SdkMetadata, Span } from '@sentry/core';
6-
import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, logger } from '@sentry/core';
5+
import type { Integration, Options, Scope, Span } from '@sentry/core';
6+
import {
7+
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
8+
SEMANTIC_ATTRIBUTE_SENTRY_SOURCE,
9+
applySdkMetadata,
10+
logger,
11+
} from '@sentry/core';
712
import type { NodeClient, NodeOptions } from '@sentry/node';
813
import {
9-
SDK_VERSION,
1014
captureException,
1115
captureMessage,
1216
continueTrace,
@@ -73,22 +77,11 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
7377
*/
7478
export function init(options: NodeOptions = {}): NodeClient | undefined {
7579
const opts = {
76-
_metadata: {} as SdkMetadata,
7780
defaultIntegrations: getDefaultIntegrations(options),
7881
...options,
7982
};
8083

81-
opts._metadata.sdk = opts._metadata.sdk || {
82-
name: 'sentry.javascript.aws-serverless',
83-
integrations: ['AWSLambda'],
84-
packages: [
85-
{
86-
name: 'npm:@sentry/aws-serverless',
87-
version: SDK_VERSION,
88-
},
89-
],
90-
version: SDK_VERSION,
91-
};
84+
applySdkMetadata(opts, 'aws-serverless');
9285

9386
return initWithoutDefaultIntegrations(opts);
9487
}

packages/aws-serverless/test/sdk.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,6 @@ describe('AWSLambda', () => {
515515
_metadata: {
516516
sdk: {
517517
name: 'sentry.javascript.aws-serverless',
518-
integrations: ['AWSLambda'],
519518
packages: [
520519
{
521520
name: 'npm:@sentry/aws-serverless',

packages/google-cloud-serverless/src/sdk.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import type { Integration, Options, SdkMetadata } from '@sentry/core';
1+
import type { Integration, Options } from '@sentry/core';
2+
import { applySdkMetadata } from '@sentry/core';
23
import type { NodeClient, NodeOptions } from '@sentry/node';
3-
import { SDK_VERSION, getDefaultIntegrationsWithoutPerformance, init as initNode } from '@sentry/node';
4+
import { getDefaultIntegrationsWithoutPerformance, init as initNode } from '@sentry/node';
45

56
import { googleCloudGrpcIntegration } from './integrations/google-cloud-grpc';
67
import { googleCloudHttpIntegration } from './integrations/google-cloud-http';
@@ -28,21 +29,11 @@ export function getDefaultIntegrations(_options: Options): Integration[] {
2829
*/
2930
export function init(options: NodeOptions = {}): NodeClient | undefined {
3031
const opts = {
31-
_metadata: {} as SdkMetadata,
3232
defaultIntegrations: getDefaultIntegrations(options),
3333
...options,
3434
};
3535

36-
opts._metadata.sdk = opts._metadata.sdk || {
37-
name: 'sentry.javascript.google-cloud-serverless',
38-
packages: [
39-
{
40-
name: 'npm:@sentry/google-cloud-serverless',
41-
version: SDK_VERSION,
42-
},
43-
],
44-
version: SDK_VERSION,
45-
};
36+
applySdkMetadata(opts, 'google-cloud-serverless');
4637

4738
return initNode(opts);
4839
}

packages/vue/src/sdk.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
import { SDK_VERSION, getDefaultIntegrations, init as browserInit } from '@sentry/browser';
2-
1+
import { getDefaultIntegrations, init as browserInit } from '@sentry/browser';
32
import type { Client } from '@sentry/core';
3+
import { applySdkMetadata } from '@sentry/core';
44
import { vueIntegration } from './integration';
55
import type { Options } from './types';
66

77
/**
88
* Inits the Vue SDK
99
*/
10-
export function init(config: Partial<Omit<Options, 'tracingOptions'>> = {}): Client | undefined {
11-
const options = {
12-
_metadata: {
13-
sdk: {
14-
name: 'sentry.javascript.vue',
15-
packages: [
16-
{
17-
name: 'npm:@sentry/vue',
18-
version: SDK_VERSION,
19-
},
20-
],
21-
version: SDK_VERSION,
22-
},
23-
},
24-
defaultIntegrations: [...getDefaultIntegrations(config), vueIntegration()],
25-
...config,
10+
export function init(options: Partial<Omit<Options, 'tracingOptions'>> = {}): Client | undefined {
11+
const opts = {
12+
defaultIntegrations: [...getDefaultIntegrations(options), vueIntegration()],
13+
...options,
2614
};
2715

28-
return browserInit(options);
16+
applySdkMetadata(opts, 'vue');
17+
18+
return browserInit(opts);
2919
}

0 commit comments

Comments
 (0)