1
1
import type { BrowserOptions } from '@sentry/browser' ;
2
- import { BrowserTracing , init as initBrowserSdk } from '@sentry/browser' ;
3
- import { getCurrentScope , hasTracingEnabled } from '@sentry/core' ;
4
- import { addOrUpdateIntegration } from '@sentry/utils' ;
2
+ import {
3
+ BrowserTracing ,
4
+ getDefaultIntegrations as getBrowserDefaultIntegrations ,
5
+ init as initBrowserSdk ,
6
+ setTag ,
7
+ } from '@sentry/browser' ;
8
+ import { hasTracingEnabled } from '@sentry/core' ;
9
+ import type { Integration } from '@sentry/types' ;
5
10
6
11
import { applySdkMetadata } from '../common/metadata' ;
7
12
@@ -14,27 +19,26 @@ declare const __SENTRY_TRACING__: boolean;
14
19
* @param options Configuration options for the SDK.
15
20
*/
16
21
export function init ( options : BrowserOptions ) : void {
17
- applySdkMetadata ( options , [ 'astro' , 'browser' ] ) ;
22
+ const opts = {
23
+ defaultIntegrations : getDefaultIntegrations ( options ) ,
24
+ ...options ,
25
+ } ;
18
26
19
- addClientIntegrations ( options ) ;
27
+ applySdkMetadata ( opts , [ 'astro' , 'browser' ] ) ;
20
28
21
- initBrowserSdk ( options ) ;
29
+ initBrowserSdk ( opts ) ;
22
30
23
- getCurrentScope ( ) . setTag ( 'runtime' , 'browser' ) ;
31
+ setTag ( 'runtime' , 'browser' ) ;
24
32
}
25
33
26
- function addClientIntegrations ( options : BrowserOptions ) : void {
27
- let integrations = options . integrations || [ ] ;
28
-
34
+ function getDefaultIntegrations ( options : BrowserOptions ) : Integration [ ] | undefined {
29
35
// This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false",
30
36
// in which case everything inside will get treeshaken away
31
37
if ( typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__ ) {
32
38
if ( hasTracingEnabled ( options ) ) {
33
- const defaultBrowserTracingIntegration = new BrowserTracing ( { } ) ;
34
-
35
- integrations = addOrUpdateIntegration ( defaultBrowserTracingIntegration , integrations ) ;
39
+ return [ ...getBrowserDefaultIntegrations ( options ) , new BrowserTracing ( ) ] ;
36
40
}
37
41
}
38
42
39
- options . integrations = integrations ;
43
+ return undefined ;
40
44
}
0 commit comments