File tree Expand file tree Collapse file tree
packages/browser-utils/src/metrics/web-vitals Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { initMetric } from './lib/initMetric';
2020import { initUnique } from './lib/initUnique' ;
2121import { InteractionManager } from './lib/InteractionManager' ;
2222import { observe } from './lib/observe' ;
23+ import { onHidden } from './lib/onHidden' ;
2324import { initInteractionCountPolyfill } from './lib/polyfills/interactionCountPolyfill' ;
2425import { whenActivated } from './lib/whenActivated' ;
2526import { whenIdleOrHidden } from './lib/whenIdleOrHidden' ;
@@ -116,7 +117,10 @@ export const onINP = (onReport: (metric: INPMetric) => void, opts: INPReportOpts
116117 // where the first interaction is less than the `durationThreshold`.
117118 po . observe ( { type : 'first-input' , buffered : true } ) ;
118119
119- WINDOW . document ?. addEventListener ( 'visibilitychange' , ( ) => {
120+ // sentry: we use onHidden instead of directly listening to visibilitychange
121+ // because some browsers we still support (Safari <14.4) don't fully support
122+ // `visibilitychange` or have known bugs w.r.t the `visibilitychange` event.
123+ onHidden ( ( ) => {
120124 if ( WINDOW . document ?. visibilityState === 'hidden' ) {
121125 handleEntries ( po . takeRecords ( ) as INPMetric [ 'entries' ] ) ;
122126 report ( true ) ;
You can’t perform that action at this time.
0 commit comments