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