Telemetry: capture middle-click CTA opens#3605
Conversation
Middle-click ("open in new tab") on a CTA link fires the DOM
auxclick event, not click, so those engagements were never
emitted as cta_clicked. Bind the existing handler to auxclick
(button 1 only) alongside click.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe CTA click tracking logic in main.ts was refactored to extract the click handling into a named function, handleCtaActivation, which is now used for both the standard click listener and a new auxclick listener. The auxclick listener triggers the same handler only when the middle mouse button (button === 1) is used, enabling tracking of middle-click CTA activations that don't fire a standard click event. Sequence Diagram(s)sequenceDiagram
participant User
participant Document
participant handleCtaActivation
participant Telemetry
User->>Document: click on a[data-cta]
Document->>handleCtaActivation: click event
handleCtaActivation->>Telemetry: emit cta_clicked
User->>Document: middle-click on a[data-cta]
Document->>handleCtaActivation: auxclick event (button===1)
handleCtaActivation->>Telemetry: emit cta_clicked
Estimated code review effort: Medium Suggested labels: frontend, analytics Suggested reviewers: none identified from available context Poem 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches✨ Simplify code
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. Comment |
Why
CTA click telemetry (
cta_clicked) is emitted from aclicklistener on the CTA link. Per the DOM spec, middle-click ("open in new tab") firesauxclick, notclick, so those engagements were silently going untracked — undercounting CTA click-through rate for anyone opening links in a background tab.What
Bind the existing CTA activation handler to
auxclickas well, gated toevent.button === 1so right-click (context menu) doesn't also count as an engagement. Left-click, Cmd/Ctrl+click, and keyboard activation are unaffected — they already fireclick.Test plan
prettier,tsc --noEmit, andeslintall pass (verified via husky pre-commit hooks)/v1/o/l, middle-click the CTA → new tab opens and acta_clickedlog record is sent (previously nothing was sent)cta_clickedas before