Skip to content

Allow opt-in bubble-phase form tracking#1457

Merged
Jethro Nederhof (jethron) merged 1 commit intosnowplow:release/4.6.8from
jethron:fix/CSTMR-1776-form-bubbling
Oct 21, 2025
Merged

Allow opt-in bubble-phase form tracking#1457
Jethro Nederhof (jethron) merged 1 commit intosnowplow:release/4.6.8from
jethron:fix/CSTMR-1776-form-bubbling

Conversation

@jethron
Copy link
Contributor

In v4 we switched to document-level listeners in the Form Tracking plugin to avoid needing to periodically re-call enableFormTracking when new forms have been added to the DOM for them to be tracked (and also less listeners theoretically has better performance).

As part of this change, we also switched to using capture-phase events.
This was for two main reasons:

  • The focus event doesn't actually bubble, so if we weren't using capture phase the tracking just doesn't work for this event
  • Several users had reported not being able to track events because their framework/platform (e.g. Salesforce) was calling stopImmediatePropagation which meant our target/bubble phase listeners never got called and so they could not track some events at all; since capture phase goes first we could track the events before propagation was stopped so this was more reliable

The downside of firing in the earlier phase is that if you require some kind of state to change in the target/bubble phase (e.g. form validation) and you rely on that in your transform/filter functions, those operations will no longer occur in time for you to depend on them.

Such a situation was reported in CSTMR-1776.

This change allows opt-in disabling capture phase for the change/submit events to go back to the old bubble-phase behavior. This lets you choose less reliable event detection in exchange for running later if needed, via a useCapture: false option.

The default remains using capture-phase, and capture-phase is hard-coded for the focus event since it would fail to work otherwise.

Not sure who is best to review on your team Costas Kotsokalis (@cksnp) so just assigning to you for now. :)

@jethron Jethro Nederhof (jethron) merged commit d88eb99 into snowplow:release/4.6.8 Oct 21, 2025
1 check failed
@jethron Jethro Nederhof (jethron) deleted the fix/CSTMR-1776-form-bubbling branch October 21, 2025 01:01
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