Repository navigation
Add onAfterSubmit timing demo for the feedback widget - #800
Open
tinsmith-dev[bot] wants to merge 3 commits into
Open
tinsmith-dev[bot] wants to merge 3 commits into
tinsmith-dev[bot] wants to merge 3 commits into
Conversation
Adds a runnable demo that opens the real feedback widget against a local mock API with configurable latency, to make visible the gap between a user submitting feedback and onAfterSubmit firing. A "navigate away mid-submit" scenario proves the callback never survives a closed tab, and that the SDK's feedback POST isn't sent with `keepalive`.
- gone.html always redirects back to its own index page instead of a caller-supplied "return" URL, closing an open-redirect/XSS sink. - server.mjs validates the requested delay with a strict range check instead of clamping, so CodeQL can see the timer duration is bounded.
Formatting-only (line wrap, import order); no behavior change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#798 raised a concern worth settling with evidence rather than argument:
onAfterSubmitonly fires after the feedback POST resolves, so there's a real window where closing the tab (or navigating away) could lose the callback. This adds a runnable demo that makes that window visible and then proves what actually happens to it.What's in it
packages/browser-sdk/example/feedback-after-submit-demo/— a small app that opens the real feedback widget (built from this branch'ssrc/, not a mock) against a local mock API with configurable artificial latency:onAfterSubmitso it's easy to watch.onAfterSubmitis still waiting on Send/close (by design), and green once the callback actually runs. A log shows exact timestamps for each step.feedback()call the widget's Send button makes, then navigates away before the response can arrive, simulating a closed tab. A persisted table cross-references the mock server's own receipt log (ground truth, independent of the tab) against whether anyonAfterSubmit-equivalent callback ran client-side.Confirmed findings from running it:
onAfterSubmitnever fires once the tab is gone — guaranteed, every time, regardless of network speed. There's no way around this: the page that would run the callback no longer exists.keepalive, so on a slower connection than localhost, the data itself (not just the callback) can be lost outright. The demo'skeepalivecheckbox (bypassing the SDK, since it doesn't expose that option) shows what addressing that half would look like.See the demo's own README for how to run it and what to look at.
Notes for the reviewer
This only adds a new example directory — no changes to
src/. It's independent of #798 (built here against currentmain); the same gap exists either way since #798 doesn't change the fundamental await-then-notify timing, only when the callback fires exactly once.🤖 Generated with Claude Code