@@ -83,7 +83,7 @@ interface StartTrackingWebVitalsOptions {
83
83
*/
84
84
export function startTrackingWebVitals ( { recordClsStandaloneSpans } : StartTrackingWebVitalsOptions ) : ( ) => void {
85
85
const performance = getBrowserPerformanceAPI ( ) ;
86
- if ( performance && browserPerformanceTimeOrigin ) {
86
+ if ( performance && browserPerformanceTimeOrigin ( ) ) {
87
87
// @ts -expect-error we want to make sure all of these are available, even if TS is sure they are
88
88
if ( performance . mark ) {
89
89
WINDOW . performance . mark ( 'sentry-tracing-init' ) ;
@@ -117,7 +117,7 @@ export function startTrackingLongTasks(): void {
117
117
const { op : parentOp , start_timestamp : parentStartTimestamp } = spanToJSON ( parent ) ;
118
118
119
119
for ( const entry of entries ) {
120
- const startTime = msToSec ( ( browserPerformanceTimeOrigin as number ) + entry . startTime ) ;
120
+ const startTime = msToSec ( ( browserPerformanceTimeOrigin ( ) as number ) + entry . startTime ) ;
121
121
const duration = msToSec ( entry . duration ) ;
122
122
123
123
if ( parentOp === 'navigation' && parentStartTimestamp && startTime < parentStartTimestamp ) {
@@ -156,7 +156,7 @@ export function startTrackingLongAnimationFrames(): void {
156
156
continue ;
157
157
}
158
158
159
- const startTime = msToSec ( ( browserPerformanceTimeOrigin as number ) + entry . startTime ) ;
159
+ const startTime = msToSec ( ( browserPerformanceTimeOrigin ( ) as number ) + entry . startTime ) ;
160
160
161
161
const { start_timestamp : parentStartTimestamp , op : parentOp } = spanToJSON ( parent ) ;
162
162
@@ -167,7 +167,6 @@ export function startTrackingLongAnimationFrames(): void {
167
167
// routing instrumentations
168
168
continue ;
169
169
}
170
-
171
170
const duration = msToSec ( entry . duration ) ;
172
171
173
172
const attributes : SpanAttributes = {
@@ -210,7 +209,7 @@ export function startTrackingInteractions(): void {
210
209
}
211
210
for ( const entry of entries ) {
212
211
if ( entry . name === 'click' ) {
213
- const startTime = msToSec ( ( browserPerformanceTimeOrigin as number ) + entry . startTime ) ;
212
+ const startTime = msToSec ( ( browserPerformanceTimeOrigin ( ) as number ) + entry . startTime ) ;
214
213
const duration = msToSec ( entry . duration ) ;
215
214
216
215
const spanOptions : StartSpanOptions & Required < Pick < StartSpanOptions , 'attributes' > > = {
@@ -271,7 +270,7 @@ function _trackFID(): () => void {
271
270
return ;
272
271
}
273
272
274
- const timeOrigin = msToSec ( browserPerformanceTimeOrigin as number ) ;
273
+ const timeOrigin = msToSec ( browserPerformanceTimeOrigin ( ) as number ) ;
275
274
const startTime = msToSec ( entry . startTime ) ;
276
275
_measurements [ 'fid' ] = { value : metric . value , unit : 'millisecond' } ;
277
276
_measurements [ 'mark.fid' ] = { value : timeOrigin + startTime , unit : 'second' } ;
@@ -300,12 +299,13 @@ interface AddPerformanceEntriesOptions {
300
299
/** Add performance related spans to a transaction */
301
300
export function addPerformanceEntries ( span : Span , options : AddPerformanceEntriesOptions ) : void {
302
301
const performance = getBrowserPerformanceAPI ( ) ;
303
- if ( ! performance ?. getEntries || ! browserPerformanceTimeOrigin ) {
302
+ const origin = browserPerformanceTimeOrigin ( ) ;
303
+ if ( ! performance ?. getEntries || ! origin ) {
304
304
// Gatekeeper if performance API not available
305
305
return ;
306
306
}
307
307
308
- const timeOrigin = msToSec ( browserPerformanceTimeOrigin ) ;
308
+ const timeOrigin = msToSec ( origin ) ;
309
309
310
310
const performanceEntries = performance . getEntries ( ) ;
311
311
0 commit comments