Skip to content

Tracker: count a tagged form once per submission - #231

Merged
velixio merged 1 commit into
mainfrom
fix/tracker-form-double-count
Nov 24, 2026
Merged

velixio merged 1 commit into
mainfrom
fix/tracker-form-double-count

Conversation

@velixio

@velixio velixio commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Problem

A form tagged with data-supermetry-event (or a supermetry-event-* class) was counted twice per submission: the click on its submit button bubbled up to the form and fired the event, and the submit event fired it again. A tagged element wrapping a form had the same problem.

Fix

tracker.extensions.js (full bundle) and tracker.clicks.js (per-site script): while handling a click, the handler stops walking up the DOM when it reaches a <form>, leaving the form and its tagged ancestors to the submit event. A tagged button inside a form still counts on click. The minified bundles are regenerated.

Tests

  • tracker_runtime_test.js: a tagged form and a tagged wrapper around a form each count once per click + submit, in both the full build and tracker.clicks.js. A tagged button inside a form counts once.
  • The harness gains a modules option for loading the per-site scripts.
  • node tracker_runtime_test.js, go test ./internal/tracker/ ./internal/api/..., go vet all pass.

A click on a submit button bubbled up to the tagged form and fired the
event, then the submit event fired it again. Click handling now stops at
a form and leaves it, and any tagged ancestor, to the submit event.
Tagged buttons inside forms still count on click.
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Click handling now stops when ancestor scanning reaches a form in both tracker implementations. Form tracking continues through submit handling. Runtime tests check form event counts and confirm that a tagged button inside a form still records its click.

Changes: Form click tracking

Layer / File(s) Summary
Skip form ancestors during click handling
internal/tracker/tracker.clicks.js, internal/tracker/tracker.extensions.js
Both custom handlers stop processing a click when ancestor scanning reaches a form.
Test form and button event tracking
internal/tracker/tracker_runtime_test.js
The runtime harness can load named tracker modules. Tests check form event counts across click and submit handling, and verify that a tagged button inside a form still records its click.
Merge Risk: Minimal · up to 7e84c · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: tagged forms are now counted once per submission. It is specific and matches the objectives and the changeset. It is short and in one sentence.
Description check Passed The description covers the problem, the fix, and the tests, so it is mostly complete. It follows the template's intent, with a 'What and why' equivalent under Problem and Fix, and a 'How it was tested…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description covers the problem, the fix, and the tests, so it is mostly complete. It follows the template's intent, with a 'What and why' equivalent under Problem and Fix, and a 'How it was tested' equivalent under Tests. The template's Screenshots section is not needed for this non-UI change. The Checklist is not addressed. The description does not state whether docs were updated, and it does not confirm that no secrets or visitor data are in the diff. It also does not link an issue, though the template only asks for one if it exists.

Resolution

Optionally add a Checklist section that confirms: tests were updated (done), docs were reviewed (docs/ or OpenAPI, if behaviour changed), and no secrets or visitor data are in the diff. Optionally link the related issue if one exists. Also consider noting that the Screenshots section is not applicable.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 5263b3f and 7e84c4e.

Files ignored due to path filters: 2

  • internal/tracker/tracker.clicks.min.js is excluded by !**/*.min.js
  • internal/tracker/tracker.full.min.js is excluded by !**/*.min.js
Files selected for processing: 3

  • internal/tracker/tracker.clicks.js
  • internal/tracker/tracker.extensions.js
  • internal/tracker/tracker_runtime_test.js

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@velixio
velixio merged commit 7972104 into main Nov 24, 2026
22 checks passed
@velixio
velixio deleted the fix/tracker-form-double-count branch November 24, 2026 17:50
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.

1 participant