Skip to content

[Feature] User readable dom element selectors in breadcrumbs #3604

@HazAT

Description

@HazAT

Right now it's hard to identify elements a user clicked on when trying to follow breadcrumb trails see:
E2U6dwfWQAAwAUp

Because the way we serialize dom elements doesn't work well with autogenerated class names.
It would be cool if users could define an attribute name we prefer when serializing dom elements.

So how it could work is that we extend BreadcrumbsOptions so
dom: boolean | { serializeAttribute: string } and take this attribute instead of the classname / id
https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L163

Ref:
https://forum.sentry.io/t/dom-interactions-selectors/3592
https://forum.sentry.io/t/ui-click-dom-events-with-a-custom-sentry-html-tag/1084

The trail to follow how to implement:
https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/integrations/breadcrumbs.ts#L163
->

export function htmlTreeAsString(elem: unknown): string {

->
function _htmlElementAsString(el: unknown): string {

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions