Conversation
packages/analytics-browser/src/plugins/form-interaction-tracking.ts
Outdated
Show resolved
Hide resolved
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| } | ||
| // left the page indicating | ||
| hasFormChanged = false; | ||
| }; |
There was a problem hiding this comment.
hasFormAbandoned never resets, blocking repeated abandon tracking
Medium Severity
hasFormAbandoned is set to true in trackFormAbandoned but is never reset to false. After an abandon event fires (e.g., beforeunload that gets canceled by another handler, or pagehide when the page enters bfcache and is later restored), the flag permanently prevents any future Form Abandoned events. Meanwhile, hasFormChanged is reset to false, so a subsequent form change triggers a new Form Started event — creating an asymmetry where forms can be "started" multiple times but only "abandoned" once. The change handler needs to reset hasFormAbandoned when re-engaging with the form.


Summary
Checklist
Note
Medium Risk
Adds new form-abandonment autocapture that attaches
pagehide/beforeunloadlisteners and emits a new event, which could change event volume/behavior in production if enabled. Moderate risk due to new global listeners and new tracking path, but it is gated byshouldTrackAbandoned.Overview
Adds a new optional autocapture event,
[Amplitude] Form Abandoned, emitted when a started form is left without submission (triggered viapagehide/beforeunload) and exposed via the newformInteractions.shouldTrackAbandonedconfig.Updates the form interaction tracking plugin to register/remove window-level listeners and track abandonment once per started form, and extends coverage with new Jest tests plus a Playwright e2e page/spec for form-interactions.
Written by Cursor Bugbot for commit 4829e1c. This will update automatically on new commits. Configure here.