Skip to content

Commit 886628a

Browse files
committed
use getGlobalObject
1 parent 726b175 commit 886628a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/tracing/src/browser/web-vitals/getTTFB.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { getGlobalObject } from '@sentry/utils';
18+
1719
import { initMetric } from './lib/initMetric';
1820
import { ReportHandler } from './types';
1921

22+
const global = getGlobalObject<Window>();
23+
2024
interface NavigationEntryShim {
2125
// From `PerformanceNavigationTimingEntry`.
2226
entryType: string;
@@ -80,7 +84,7 @@ const getNavigationEntryFromPerformanceTiming = (): PerformanceNavigationTiming
8084
// Note: browsers that do not support navigation entries will fall back to using performance.timing
8185
// (with the timestamps converted from epoch time to DOMHighResTimeStamp).
8286
// eslint-disable-next-line deprecation/deprecation
83-
const timing = performance.timing;
87+
const timing = global.performance.timing;
8488

8589
const navigationEntry: NavigationEntryShim = {
8690
entryType: 'navigation',
@@ -105,7 +109,7 @@ export const getTTFB = (onReport: ReportHandler): void => {
105109
try {
106110
// Use the NavigationTiming L2 entry if available.
107111
const navigationEntry =
108-
performance.getEntriesByType('navigation')[0] || getNavigationEntryFromPerformanceTiming();
112+
global.performance.getEntriesByType('navigation')[0] || getNavigationEntryFromPerformanceTiming();
109113

110114
metric.value = metric.delta = (navigationEntry as PerformanceNavigationTiming).responseStart;
111115

0 commit comments

Comments
 (0)