11import 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' ;
510
611import { applySdkMetadata } from '../common/metadata' ;
712
@@ -14,27 +19,26 @@ declare const __SENTRY_TRACING__: boolean;
1419 * @param options Configuration options for the SDK.
1520 */
1621export function init ( options : BrowserOptions ) : void {
17- applySdkMetadata ( options , [ 'astro' , 'browser' ] ) ;
22+ const opts = {
23+ defaultIntegrations : getDefaultIntegrations ( options ) ,
24+ ...options ,
25+ } ;
1826
19- addClientIntegrations ( options ) ;
27+ applySdkMetadata ( opts , [ 'astro' , 'browser' ] ) ;
2028
21- initBrowserSdk ( options ) ;
29+ initBrowserSdk ( opts ) ;
2230
23- getCurrentScope ( ) . setTag ( 'runtime' , 'browser' ) ;
31+ setTag ( 'runtime' , 'browser' ) ;
2432}
2533
26- function addClientIntegrations ( options : BrowserOptions ) : void {
27- let integrations = options . integrations || [ ] ;
28-
34+ function getDefaultIntegrations ( options : BrowserOptions ) : Integration [ ] | undefined {
2935 // This evaluates to true unless __SENTRY_TRACING__ is text-replaced with "false",
3036 // in which case everything inside will get treeshaken away
3137 if ( typeof __SENTRY_TRACING__ === 'undefined' || __SENTRY_TRACING__ ) {
3238 if ( hasTracingEnabled ( options ) ) {
33- const defaultBrowserTracingIntegration = new BrowserTracing ( { } ) ;
34-
35- integrations = addOrUpdateIntegration ( defaultBrowserTracingIntegration , integrations ) ;
39+ return [ ...getBrowserDefaultIntegrations ( options ) , new BrowserTracing ( ) ] ;
3640 }
3741 }
3842
39- options . integrations = integrations ;
43+ return undefined ;
4044}
0 commit comments