File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ import {
4343 TRACE_FLAG_NONE ,
4444 TRACE_FLAG_SAMPLED ,
4545} from '../utils/spanUtils' ;
46- import { performanceNowInMs , timestampInSeconds } from '../utils/time' ;
46+ import { safePerformanceNow , timestampInSeconds } from '../utils/time' ;
4747import { getDynamicSamplingContextFromSpan } from './dynamicSamplingContext' ;
4848import { logSpanEnd } from './logSpans' ;
4949import { timedEventsToMeasurements } from './measurement' ;
@@ -105,7 +105,7 @@ export class SentrySpan implements Span {
105105 this . _startTime = spanContext . startTimestamp ;
106106 } else {
107107 this . _startTime = timestampInSeconds ( ) ;
108- this . _startPerformanceNow = performanceNowInMs ( ) ;
108+ this . _startPerformanceNow = safePerformanceNow ( ) ;
109109 }
110110 this . _links = spanContext . links ;
111111
@@ -367,7 +367,7 @@ export class SentrySpan implements Span {
367367 * device slept), and it can never be negative.
368368 */
369369 private _getEndTimeFromDuration ( ) : number {
370- const performanceNow = this . _startPerformanceNow === undefined ? undefined : performanceNowInMs ( ) ;
370+ const performanceNow = this . _startPerformanceNow === undefined ? undefined : safePerformanceNow ( ) ;
371371 if ( performanceNow === undefined || this . _startPerformanceNow === undefined ) {
372372 return timestampInSeconds ( ) ;
373373 }
Original file line number Diff line number Diff line change @@ -119,7 +119,7 @@ function createUnixTimestampInSecondsFunc(): () => number {
119119/**
120120 * Returns `performance.now()` in milliseconds, or `undefined` if the Performance API is unavailable.
121121 */
122- export function performanceNowInMs ( ) : number | undefined {
122+ export function safePerformanceNow ( ) : number | undefined {
123123 const { performance } = GLOBAL_OBJ as typeof GLOBAL_OBJ & { performance ?: Performance } ;
124124 return performance ?. now ? withRandomSafeContext ( ( ) => performance . now ( ) ) : undefined ;
125125}
You can’t perform that action at this time.
0 commit comments