Skip to content

Conversation

@jethron
Copy link
Contributor

@jethron jethron commented Oct 17, 2025

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 @cksnp so just assigning to you for now. :)

@jethron jethron requested a review from cksnp October 17, 2025 01:18
@jethron jethron force-pushed the fix/CSTMR-1776-form-bubbling branch from aef5165 to eea8198 Compare October 17, 2025 01:22
@jethron jethron requested review from matus-tomlein and removed request for cksnp October 17, 2025 07:35
@jethron jethron merged commit d88eb99 into snowplow:release/4.6.8 Oct 21, 2025
1 check failed
@jethron 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants