-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsdk.ts
More file actions
23 lines (20 loc) · 948 Bytes
/
sdk.ts
File metadata and controls
23 lines (20 loc) · 948 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { getDefaultIntegrations as getBrowserDefaultIntegrations, init as initBrowser } from '@sentry/browser';
import type { Client } from '@sentry/core';
import { applySdkMetadata, DEFAULT_ENVIRONMENT, DEV_ENVIRONMENT } from '@sentry/core';
import type { SentryNuxtClientOptions } from '../common/types';
/**
* Initializes the client-side of the Nuxt SDK
*
* @param options Configuration options for the SDK.
*/
export function init(options: SentryNuxtClientOptions): Client | undefined {
const envFallback = import.meta.dev ? DEV_ENVIRONMENT : DEFAULT_ENVIRONMENT;
const sentryOptions = {
/* BrowserTracing is added later with the Nuxt client plugin */
defaultIntegrations: [...getBrowserDefaultIntegrations(options)],
environment: options.environment ?? process.env.SENTRY_ENVIRONMENT ?? envFallback,
...options,
};
applySdkMetadata(sentryOptions, 'nuxt', ['nuxt', 'vue']);
return initBrowser(sentryOptions);
}