Skip to content

ref: Drop Safari 14 support - remove navigationStart fallback and pagehide listeners#21293

Open
eddie333016 wants to merge 1 commit into
getsentry:developfrom
eddie333016:eddie333016/drop-safari-14-support
Open

ref: Drop Safari 14 support - remove navigationStart fallback and pagehide listeners#21293
eddie333016 wants to merge 1 commit into
getsentry:developfrom
eddie333016:eddie333016/drop-safari-14-support

Conversation

@eddie333016
Copy link
Copy Markdown

Summary

Closes #18707

Drops Safari 14 compatibility code by removing the performance.timing.navigationStart fallback and pagehide event listeners from the vendored web-vitals code.

Changes

Core timing (packages/core/src/utils/time.ts):

  • Removed performance.timing?.navigationStart fallback in getBrowserTimeOrigin() — Safari 15+ supports performance.timeOrigin natively
  • Updated JSDoc to reflect the simplified fallback chain

Web-vitals vendored code (packages/browser-utils/src/metrics/web-vitals/lib/):

  • onHidden.ts: Removed pagehide event listener, now only listens to visibilitychange
  • getVisibilityWatcher.ts: Removed pagehide event listener, removed isPageHidden() helper, simplified onVisibilityUpdate to only check document.visibilityState
  • whenIdleOrHidden.ts: Removed pagehide add/remove listener pairs

Integration tests:

  • Updated hidePage() helpers to dispatch visibilitychange (with document.visibilityState = 'hidden') instead of pagehide
  • Updated inline pagehide dispatches to use the same pattern
  • Kept sentry.report_event: 'pagehide' data labels unchanged (backend-facing API contract)

Bundle size impact

Saves ~100 bytes by removing unnecessary fallback code paths and event listeners.

…rt fallback and pagehide listeners

Safari 15+ has full performance.timeOrigin support and reliable
visibilitychange events. This removes:

- performance.timing?.navigationStart fallback in getBrowserTimeOrigin()
- pagehide event listeners in web-vitals vendored code (onHidden, getVisibilityWatcher, whenIdleOrHidden)
- isPageHidden() helper that checked for pagehide event type
- Updated integration tests to use visibilitychange instead of pagehide

This saves ~100 bytes of unnecessary browser compatibility code.

Closes getsentry#18707
@eddie333016 eddie333016 requested a review from a team as a code owner June 2, 2026 13:04
@eddie333016 eddie333016 requested review from logaretm and mydea and removed request for a team June 2, 2026 13:04
Copy link
Copy Markdown
Member

@logaretm logaretm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Safari 14/pagehide removal is fine for v11, but the PR needs to clean up the stale tests.

At any case, this PR won't be merged at the moment until v11 is being prepared for release given its breaking changes nature.

Comment on lines -117 to -123
const navigationStart = performance.timing?.navigationStart;
if (typeof navigationStart === 'number') {
const navigationStartDelta = Math.abs(navigationStart + performanceNow - dateNow);
if (navigationStartDelta < threshold) {
return navigationStart;
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests still assert the navigationStart. Those tests will fail.

@logaretm logaretm requested a review from Lms24 June 2, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop Support for Safari 14

2 participants