1
1
import type { BrowserClient } from '@sentry/browser' ;
2
2
import * as SentryBrowser from '@sentry/browser' ;
3
- import { BrowserTracing , getCurrentHub , SDK_VERSION , WINDOW } from '@sentry/browser' ;
3
+ import { BrowserTracing , getClient , getCurrentHub , SDK_VERSION , WINDOW } from '@sentry/browser' ;
4
4
import { vi } from 'vitest' ;
5
5
6
6
import { init } from '../../../astro/src/client/sdk' ;
@@ -60,7 +60,7 @@ describe('Sentry client SDK', () => {
60
60
} ) ;
61
61
62
62
const integrationsToInit = browserInit . mock . calls [ 0 ] [ 0 ] ?. integrations ;
63
- const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
63
+ const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationById ( 'BrowserTracing' ) ;
64
64
65
65
expect ( integrationsToInit ) . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
66
66
expect ( browserTracing ) . toBeDefined ( ) ;
@@ -76,7 +76,7 @@ describe('Sentry client SDK', () => {
76
76
} ) ;
77
77
78
78
const integrationsToInit = browserInit . mock . calls [ 0 ] [ 0 ] ?. integrations ;
79
- const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
79
+ const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationById ( 'BrowserTracing' ) ;
80
80
81
81
expect ( integrationsToInit ) . not . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
82
82
expect ( browserTracing ) . toBeUndefined ( ) ;
@@ -91,7 +91,7 @@ describe('Sentry client SDK', () => {
91
91
} ) ;
92
92
93
93
const integrationsToInit = browserInit . mock . calls [ 0 ] [ 0 ] ?. integrations ;
94
- const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById ( 'BrowserTracing' ) ;
94
+ const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationById ( 'BrowserTracing' ) ;
95
95
96
96
expect ( integrationsToInit ) . not . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
97
97
expect ( browserTracing ) . toBeUndefined ( ) ;
@@ -108,9 +108,7 @@ describe('Sentry client SDK', () => {
108
108
109
109
const integrationsToInit = browserInit . mock . calls [ 0 ] [ 0 ] ?. integrations ;
110
110
111
- const browserTracing = ( getCurrentHub ( ) . getClient ( ) as BrowserClient ) ?. getIntegrationById (
112
- 'BrowserTracing' ,
113
- ) as BrowserTracing ;
111
+ const browserTracing = getClient < BrowserClient > ( ) ?. getIntegrationById ( 'BrowserTracing' ) as BrowserTracing ;
114
112
const options = browserTracing . options ;
115
113
116
114
expect ( integrationsToInit ) . toContainEqual ( expect . objectContaining ( { name : 'BrowserTracing' } ) ) ;
0 commit comments