Use HubSpot postMessage API for form submission tracking#17
Conversation
- Listen for hsFormCallback messages instead of submit events, which HubSpot forms fire via postMessage after successful submission - Extract formGuid and conversionId from the message data - Derive form ID from data-form-id attr, hs_form_id hidden input, or form element id - Key form state by form ID string instead of DOM element reference - Include form_id in all emitted events - Clean up message listener on destroy
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThe pull request introduces git hook infrastructure and substantially refactors the HubSpot form tracking implementation. A new pre-push hook script runs format checks, configured via a prepare npm script. The HubSpot tracker implementation is redesigned to identify forms by ID string rather than DOM elements, introduces a global window message listener to handle HubSpot postMessage events, and augments emitted events with form_id fields. Test coverage is significantly expanded with comprehensive validation of form lifecycle events, message handler edge cases, abandonment timeout clearing, and payload robustness. Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.42.1)src/__tests__/presets/hubspot.test.ts[ ... [truncated 43018 characters] ... ] Comment |
Summary
hsFormCallbackmessages instead of submit eventsformGuidandconversionIdfrom the message datadata-form-idattr,hs_form_idhidden input, or element idform_idin all emitted eventsTest plan
Summary by CodeRabbit
Chores
Tests
Refactor