Skip to content

feat(audience): add page-unload flush to MessageQueue#2815

Open
nattb8 wants to merge 2 commits intomainfrom
feat/sdk-43-page-unload-flush
Open

feat(audience): add page-unload flush to MessageQueue#2815
nattb8 wants to merge 2 commits intomainfrom
feat/sdk-43-page-unload-flush

Conversation

@nattb8
Copy link
Copy Markdown
Contributor

@nattb8 nattb8 commented Apr 3, 2026

Summary

  • Adds visibilitychange and pagehide listeners to MessageQueue that flush queued events via navigator.sendBeacon() on page unload, preventing event loss when users navigate away
  • Adds destroy() method for clean teardown (stops timer, removes listeners, flushes remaining events)
  • Falls back to async flush() if sendBeacon is unavailable or fails

SDK-43

🤖 Generated with Claude Code

Adds visibilitychange and pagehide listeners that flush queued events
via navigator.sendBeacon on page unload, preventing event loss when
users navigate away. Adds destroy() for clean teardown.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nattb8 nattb8 requested a review from a team as a code owner April 3, 2026 05:47
@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 3, 2026

View your CI Pipeline Execution ↗ for commit 7159188

Command Status Duration Result
nx affected -t build,lint,test ✅ Succeeded 7s View ↗
nx run-many -p @imtbl/sdk,@imtbl/checkout-widge... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-03 06:05:20 UTC

- Skip beacon if an async flush is already in flight (this.flushing guard)
- Add test for sendBeacon being unavailable (falls back to async flush)
- Add test for beacon skipped when async flush is in flight

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants