-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsdkMetadata.ts
More file actions
28 lines (26 loc) · 1.04 KB
/
sdkMetadata.ts
File metadata and controls
28 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import type { CoreOptions } from '../types-hoist/options';
import { SDK_VERSION } from '../utils/version';
/**
* A builder for the SDK metadata in the options for the SDK initialization.
*
* Note: This function is identical to `buildMetadata` in Remix and NextJS and SvelteKit.
* We don't extract it for bundle size reasons.
* @see https://github.com/getsentry/sentry-javascript/pull/7404
* @see https://github.com/getsentry/sentry-javascript/pull/4196
*
* If you make changes to this function consider updating the others as well.
*
* @param options SDK options object that gets mutated
* @param names list of package names
*/
export function applySdkMetadata(options: CoreOptions, name: string, names = [name], source = 'npm'): void {
const sdk = ((options._metadata = options._metadata || {}).sdk = options._metadata.sdk || {});
if (!sdk.name) {
sdk.name = `sentry.javascript.${name}`;
sdk.packages = names.map(name => ({
name: `${source}:@sentry/${name}`,
version: SDK_VERSION,
}));
sdk.version = SDK_VERSION;
}
}