From 710ab620320103d20b2dc34b14b731d23401cafc Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Mon, 27 Nov 2023 11:28:47 +0000 Subject: [PATCH] Add exra guard for PerformanceEventTiming not existing --- 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}); }