Skip to content

feat: Add Browser click event#2992

Closed
joaquin-diaz wants to merge 8 commits intoopen-telemetry:mainfrom
embrace-io:joaquin-diaz/feat/add-user-action-event
Closed

feat: Add Browser click event#2992
joaquin-diaz wants to merge 8 commits intoopen-telemetry:mainfrom
embrace-io:joaquin-diaz/feat/add-user-action-event

Conversation

@joaquin-diaz
Copy link
Copy Markdown

@joaquin-diaz joaquin-diaz commented Oct 28, 2025

Changes

Added a new event for browsers named user_action.click. This event captures the "click" action in browsers

Prototype instrumentation:
open-telemetry/opentelemetry-browser#35

Important

Pull requests acceptance are subject to the triage process as described in Issue and PR Triage Management.
PRs that do not follow the guidance above, may be automatically rejected and closed.

Merge requirement checklist

  • CONTRIBUTING.md guidelines followed.
  • Change log entry added, according to the guidelines in When to add a changelog entry.
    • If your PR does not need a change log, start the PR title with [chore]
  • Links to the prototypes or existing instrumentations (when adding or changing conventions)

Copy link
Copy Markdown
Contributor

@thompson-tomo thompson-tomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems too generic and instead I feel we should aim for tailored click, key etc events. Ideally at a mimum following https://www.w3schools.com/jsref/obj_events.asp but also potentially splitting a couple ie mouse & click. That way we can easily tailor attributes based on the trigger.

Also for click events Why not extend https://opentelemetry.io/docs/specs/semconv/app/app/#event-appwidgetclick but keep the same name?

Comment on lines +53 to +62
- id: browser.page.x
type: int
stability: development
brief: 'Click x (horizontal) coordinates (in pixels) relative to the entire document.'
examples: [10]
- id: browser.page.y
type: int
stability: development
brief: 'Click y (vertical) coordinates (in pixels) relative to the entire document.'
examples: [10]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +63 to +67
- id: browser.tag_name
type: string
stability: development
brief: 'Target element tag name obtained via event.target.tagName.'
examples: ['BUTTON']
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joaquin-diaz
Copy link
Copy Markdown
Author

This seems too generic and instead I feel we should aim for tailored click, key etc events. Ideally at a mimum following https://www.w3schools.com/jsref/obj_events.asp but also potentially splitting a couple ie mouse & click. That way we can easily tailor attributes based on the trigger.

Yeah.. I think having multiple events makes sense. It would make it easier to know which attributes to expect vs a bunch of mixed possible attributes depending on type

Also for click events Why not extend https://opentelemetry.io/docs/specs/semconv/app/app/#event-appwidgetclick but keep the same name?

I wasn't part of the original discussion but it seems they preferred to use browser terminology instead of translating e.g. event.pageX -> app.screen.coordinate.x.

Some of these app attributes as easy to translate from browser APIs but some are not as straight forward. app.widget.id and app.widget.name are hard to understand in a browsers perspective. Based on their definitions:

  • app.widget.id: An identifier that uniquely differentiates this widget from other widgets in the same application. Examples: f9bc787d-ff05-48ad-90e1-fca1d46130b3; submit_order_1829
  • app.widget.name: The name of an application widget. Examples submit; attack; Clear Cart

A widget is an application component, typically an on-screen visual GUI element.

Component is a loaded term in web, it can be confused for example with a React component that can be composed of multiple dom elements.

app.widget.id is marked as required in app.widget.click but there's no equivalent in the browser that is always present, you may have an id, but not always. You also have xpath but that can change if dom elements are added or removed. app.widget.name could be the element tag name

IMO I would like to have shared events between client SDKs (web and mobile) but they work for both cases, app.widget.click seems to be too tailored for mobile apps and it feels like a stretch to apply it here. I'll bring this up to the browser sig on Thursday and get their input

@thompson-tomo
Copy link
Copy Markdown
Contributor

I wasn't part of the original discussion but it seems they preferred to use browser terminology instead of translating e.g. event.pageX -> app.screen.coordinate.x.

So I have seen at https://www.w3schools.com/jsref/obj_mouseevent.asp and page/app are in effect different measurements so perhaps we go with app.page.coordinate.x.

Some of these app attributes as easy to translate from browser APIs but some are not as straight forward. app.widget.id and app.widget.name are hard to understand in a browsers perspective.

I agree but I think we can improve the description to resolve those issues and use the attribute notes to define how to source it. For widget id = html element id and fall back to xpath when not defined.

@thompson-tomo
Copy link
Copy Markdown
Contributor

Could someone from the browser sig or a maintainer add the triage accepted label so that the hw.mouse.button can be added to hardware namespace and not have this PR auto closed?

Comment on lines +83 to +100
- id: hw.mouse.button
type:
members:
- id: left
value: 'left'
brief: Left button
stability: development
- id: middle
value: 'middle'
brief: Middle button
stability: development
- id: right
value: 'right'
brief: Right button
stability: development
stability: development
brief: 'User friendly name of the mouse button pressed. See [MouseEvent.buttons](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons#value).'
examples: ["left"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be in the registry file in the hardware folder. But only make the change once the triage:accepted label has been added.

@joaquin-diaz joaquin-diaz changed the title feat: Add Browser UserAction Event feat: Add Browser click Event Oct 30, 2025
@joaquin-diaz joaquin-diaz changed the title feat: Add Browser click Event feat: Add Browser click event Oct 30, 2025
@tedsuo tedsuo moved this to In Progress in Browser: Phase 1 Oct 30, 2025
@joaopgrassi joaopgrassi moved this from Untriaged to Awaiting codeowners approval in Semantic Conventions Triage Oct 31, 2025
@github-actions
Copy link
Copy Markdown

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Nov 22, 2025
@thompson-tomo
Copy link
Copy Markdown
Contributor

@joaquin-diaz could you merge in main/rebase this branch followed by a regeneration of the docs?

@github-actions github-actions bot removed the Stale label Nov 29, 2025
@github-actions
Copy link
Copy Markdown

This PR has been labeled as stale due to lack of activity. It will be automatically closed if there is no further activity over the next 14 days.

@github-actions github-actions bot added the Stale label Dec 13, 2025
@github-actions github-actions bot closed this Dec 21, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in Browser: Phase 1 Dec 21, 2025
@martinkuba martinkuba reopened this Feb 5, 2026
@martinkuba martinkuba moved this from Done to In Progress in Browser: Phase 1 Feb 5, 2026
@scheler
Copy link
Copy Markdown
Contributor

scheler commented Feb 5, 2026

@joaquin-diaz @martinkuba the current span based instrumentation for click allows for linking the click to any xhr/fetch calls made from the click handler, which is helpful to know. The approach used there is to propagate trace context and use a common trace across click and all the xhr/fetch calls. This approach poses a problem that the same API calls are modeled different with and without RUM instrumentation, as these API calls get their own traceId when RUM is not involved. I prefer modeling them using independent traces. However, I do find it helpful to have the xhr/fetch calls linked to the click event.

a) is there a span.links equivalent for events where we can add related spans, events, etc?
b) is it possible to identify the xhr/fetch related to a click event without using trace context?

@github-actions github-actions bot removed the Stale label Feb 6, 2026
@thompson-tomo
Copy link
Copy Markdown
Contributor

a) is there a span.links equivalent for events where we can add related spans, events, etc?

An event can only be linked to 1 span but a span can have many events.

b) is it possible to identify the xhr/fetch related to a click event without using trace context?

My suggestion is that we should have an app interaction span which acts as the root span. This root span could then contain the navigation, http etc child spans.

@scheler
Copy link
Copy Markdown
Contributor

scheler commented Feb 6, 2026

@joaquin-diaz

My suggestion is that we should have an app interaction span which acts as the root span. This root span could then contain the navigation, http etc child spans.

This is what the current user-interaction instrumentation does today; however, it has the issue I described above. The trace context ends up propagating to the backend instrumentation, whose behavior then varies depending on whether the user interaction instrumentation is set up or not, and this is not ideal.

@thompson-tomo
Copy link
Copy Markdown
Contributor

Are we not solving that by having the attributes on the root span for the span initiator hence removing the need for inference based on the parent span?

@github-actions
Copy link
Copy Markdown

This PR has been labeled as stale due to lack of activity. It will be automatically closed if there is no further activity over the next 7 days.

@sandy2008
Copy link
Copy Markdown
Member

Thanks, this PR is very useful context for my proposal in open-telemetry/opentelemetry-specification#4975.

I agree the right direction is not to introduce a generic new “user action” family, but to build from existing app events where possible.

For native mobile, my intent is:

  • reuse existing click/tap-related app events as the basis where they already fit
  • only propose additions for clear gaps such as scroll / gesture, lifecycle composition, and session correlation
  • keep everything log-based and privacy-safe

So I’m treating #2992 as prior art rather than trying to redefine click from scratch.

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

Labels

Projects

Status: In Progress
Archived in project

Development

Successfully merging this pull request may close these issues.

8 participants