File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
packages/browser-utils/src/metrics/web-vitals Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import { initMetric } from './lib/initMetric';
20
20
import { initUnique } from './lib/initUnique' ;
21
21
import { InteractionManager } from './lib/InteractionManager' ;
22
22
import { observe } from './lib/observe' ;
23
+ import { onHidden } from './lib/onHidden' ;
23
24
import { initInteractionCountPolyfill } from './lib/polyfills/interactionCountPolyfill' ;
24
25
import { whenActivated } from './lib/whenActivated' ;
25
26
import { whenIdleOrHidden } from './lib/whenIdleOrHidden' ;
@@ -116,7 +117,10 @@ export const onINP = (onReport: (metric: INPMetric) => void, opts: INPReportOpts
116
117
// where the first interaction is less than the `durationThreshold`.
117
118
po . observe ( { type : 'first-input' , buffered : true } ) ;
118
119
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 ( ( ) => {
120
124
if ( WINDOW . document ?. visibilityState === 'hidden' ) {
121
125
handleEntries ( po . takeRecords ( ) as INPMetric [ 'entries' ] ) ;
122
126
report ( true ) ;
You can’t perform that action at this time.
0 commit comments