From e07c7a7cfc4482f7f76ce30443359305116c8417 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Wed, 27 Dec 2023 18:41:27 +0000 Subject: [PATCH] Add exra guard for PerformanceEventTiming not existing (#403) --- src/onINP.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/onINP.ts b/src/onINP.ts index cf857de5..ac23c2fe 100644 --- a/src/onINP.ts +++ b/src/onINP.ts @@ -220,7 +220,10 @@ export const onINP = (onReport: INPReportCallback, opts?: ReportOpts) => { // If browser supports interactionId (and so supports INP), also // observe entries of type `first-input`. This is useful in cases // where the first interaction is less than the `durationThreshold`. - if ('interactionId' in PerformanceEventTiming.prototype) { + if ( + 'PerformanceEventTiming' in window && + 'interactionId' in PerformanceEventTiming.prototype + ) { po.observe({type: 'first-input', buffered: true}); }