Skip to content

Telemetry: capture middle-click CTA opens#3605

Open
reakaleek wants to merge 1 commit into
mainfrom
telemetry/cta-auxclick
Open

Telemetry: capture middle-click CTA opens#3605
reakaleek wants to merge 1 commit into
mainfrom
telemetry/cta-auxclick

Conversation

@reakaleek

Copy link
Copy Markdown
Member

Why

CTA click telemetry (cta_clicked) is emitted from a click listener on the CTA link. Per the DOM spec, middle-click ("open in new tab") fires auxclick, not click, 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 auxclick as well, gated to event.button === 1 so right-click (context menu) doesn't also count as an engagement. Left-click, Cmd/Ctrl+click, and keyboard activation are unaffected — they already fire click.

Test plan

  • prettier, tsc --noEmit, and eslint all pass (verified via husky pre-commit hooks)
  • Load a page with a right-gutter CTA, open DevTools Network filtered to /v1/o/l, middle-click the CTA → new tab opens and a cta_clicked log record is sent (previously nothing was sent)
  • Left-click and Cmd/Ctrl+click still emit cta_clicked as before

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>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f1125412-3c3d-4a28-af47-74fd501bee9a

📥 Commits

Reviewing files that changed from the base of the PR and between a636374 and 4f3cd42.

📒 Files selected for processing (1)
  • src/Elastic.Documentation.Site/Assets/main.ts

📝 Walkthrough

Walkthrough

The 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
Loading

Estimated code review effort: Medium

Suggested labels: frontend, analytics

Suggested reviewers: none identified from available context

Poem
A rabbit clicks with middle paw,
No click event, but auxclick's law!
One handler now does double duty,
Tracking clicks with extra beauty. 🐰🖱️

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: tracking middle-click CTA opens.
Description check ✅ Passed The description is directly related to the telemetry change and its implementation details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch telemetry/cta-auxclick

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

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants