Skip to content

Telemetry: add event.name and url.full to CTA events#3604

Merged
reakaleek merged 1 commit into
mainfrom
thundering-jaxartosaurus
Jul 1, 2026
Merged

Telemetry: add event.name and url.full to CTA events#3604
reakaleek merged 1 commit into
mainfrom
thundering-jaxartosaurus

Conversation

@reakaleek

Copy link
Copy Markdown
Member

Why

cta_viewed/cta_clicked currently carry their event identity only in the OTel log body, a text field. Filtering these events in Elasticsearch means a fuzzy text match instead of an exact keyword lookup, which makes dashboards and ES|QL queries awkward.

What

Adds event.name as a proper log record attribute (mirroring the body) on both CTA events, following the OTel semantic convention, so they can be filtered with:

FROM logs-generic.otel-*
| WHERE attributes.event.name IN ("cta_viewed", "cta_clicked")

Also adds url.full (the full page URL) alongside the existing url.path, so the page the user was on can be distinguished from the CTA's destination (cta.url).

Test plan

  • tsc --noEmit passes
  • eslint passes
  • Full jest suite passes (104/104)
  • Manually verify in DevTools Network that emitted OTLP log records for cta_viewed/cta_clicked include attributes.event.name and attributes.url.full

cta_viewed/cta_clicked previously only carried their event name in the
log body (a text field), making them hard to filter on with an exact
keyword query. Adds event.name per OTel semantic conventions, plus
url.full to distinguish the page the user was on from the CTA's
destination (cta.url).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@reakaleek reakaleek requested a review from a team as a code owner July 1, 2026 16:42
@reakaleek reakaleek requested a review from Mpdreamz July 1, 2026 16:42
@reakaleek reakaleek temporarily deployed to integration-tests July 1, 2026 16:42 — with GitHub Actions Inactive
@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: e6d88b9f-9348-442a-8555-5877463ee063

📥 Commits

Reviewing files that changed from the base of the PR and between 012c708 and d90245a.

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

📝 Walkthrough

Walkthrough

This PR refactors CTA telemetry logging in main.ts by introducing a logCtaEvent helper function that centralizes event emission using logInfo with an ATTR_EVENT_NAME attribute. The CTA attribute payload is extended to include ATTR_URL_FULL (window.location.href). The cta_viewed and cta_clicked log calls now route through this new helper instead of calling logInfo directly. The semconv module was updated to re-export ATTR_URL_FULL from @opentelemetry/semantic-conventions.

Sequence Diagram(s)

sequenceDiagram
  participant Observer as IntersectionObserver
  participant ClickHandler as Document click handler
  participant logCtaEvent
  participant logInfo

  Observer->>logCtaEvent: logCtaEvent('cta_viewed', cta)
  ClickHandler->>logCtaEvent: logCtaEvent('cta_clicked', cta)
  logCtaEvent->>logInfo: logInfo(eventName, {ATTR_EVENT_NAME, ...ctaAttributes, ATTR_URL_FULL})
Loading

Estimated code review effort: 2 out of 5

Related PRs: None found.

Suggested labels: enhancement, telemetry, frontend

Suggested reviewers: None identified.

🐰 A rabbit hops through code so neat,
Logging CTAs with URL complete,
One helper now to call them all,
Viewed and clicked, they heed its call!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding event.name and url.full to CTA telemetry.
Description check ✅ Passed The description matches the changeset and explains the telemetry attributes added to CTA events.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 thundering-jaxartosaurus

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.

@reakaleek reakaleek merged commit a636374 into main Jul 1, 2026
25 of 26 checks passed
@reakaleek reakaleek deleted the thundering-jaxartosaurus branch July 1, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant