-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathsdk.ts
More file actions
34 lines (29 loc) · 1.25 KB
/
sdk.ts
File metadata and controls
34 lines (29 loc) · 1.25 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
29
30
31
32
33
34
import type { BrowserOptions } from '@sentry/browser';
import { getDefaultIntegrations as getBrowserDefaultIntegrations, init as initBrowserSdk } from '@sentry/browser';
import type { Client, Integration } from '@sentry/core';
import { applySdkMetadata } from '@sentry/core';
import { browserTracingIntegration } from './browserTracingIntegration';
// Tree-shakable guard to remove all code related to tracing
declare const __SENTRY_TRACING__: boolean;
/**
* Initialize the client side of the Sentry Astro SDK.
*
* @param options Configuration options for the SDK.
*/
export function init(options: BrowserOptions): Client | undefined {
const opts = {
defaultIntegrations: getDefaultIntegrations(options),
...options,
};
applySdkMetadata(opts, 'astro', ['astro', 'browser']);
return initBrowserSdk(opts);
}
function getDefaultIntegrations(options: BrowserOptions): Integration[] {
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false",
// in which case everything inside will get tree-shaken away
if (typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__) {
return [...getBrowserDefaultIntegrations(options), browserTracingIntegration()];
} else {
return getBrowserDefaultIntegrations(options);
}
}