Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

va-link, etc. don't provide innerText, cause issues with recording actions in Datadog #3001

Open
2 of 6 tasks
dcloud opened this issue Jul 10, 2024 · 6 comments
Open
2 of 6 tasks
Labels
bug Something isn't working platform-design-system-team

Comments

@dcloud
Copy link

dcloud commented Jul 10, 2024

Bug Report or Design System update

  • I’ve searched for any related issues and avoided creating a duplicate issue.

What happened

Datadog is recording unexpected or unhelpful action names for clicks on VADS web components.

While investigating issues with Datadog, I noticed that two VADS web components, va-link and va-alert-expandable, provide empty strings for element.innerText or element.textContent, so DDG goes up the DOM tree looking for something that can provide an action name.

Adding a data-dd-action-name might fix this given Datadog can find that attribute if set on a web component, but that would require every engineer to add this attribute to va-link to get the expected "out-of-the-box" behavior for element.innerText.

What I expected to happen

I expected a va-link clicks to record the link text like a normal a would.

Reproducing

  • Formation version: Whatever vets-website is currently using
  • Device: Macbook Pro
  • Browser: Firefox

Steps to reproduce:

  1. Click on a va-link component and observe what Datadog records. It won't be the link text!

OR

  1. Interact with a va-link element in console, run element.innerText and see that it returns an empty string.

Urgency

How urgent is this request? Please select the appropriate option below and/or provide details

  • This bug is blocking work currently in progress
  • This bug is affecting work currently in progress but we have a workaround
  • This bug is blocking work planned within the next few sprints
  • This bug is not blocking any work
  • Other

Details

I have some notes in department-of-veterans-affairs/va.gov-team#87625 from looking at how Datadog RUM looks for action names.

Originally created department-of-veterans-affairs/va.gov-team#88060 due to looking at that repo's "Create Issue" templates first.

@caw310
Copy link
Contributor

caw310 commented Jul 10, 2024

@dcloud
Copy link
Author

dcloud commented Jul 10, 2024

Wrote introtext when I meant va-alert-expandable, fixing the description

@micahchiang
Copy link
Contributor

@dcloud - Thanks for raising this. I think element.innerText being empty is weirdly expected behavior for components that use the shadow dom because they aren't technically HTMLElement interfaces, but instead ShadowRoot interfaces. The ShadowRoot interface doesn't have an innerText instance property.

Instead, adding a datadog ID to the internals of the components you need may be a way forward similar to this pull request - https://github.com/department-of-veterans-affairs/component-library/pull/936/files

@dcloud
Copy link
Author

dcloud commented Jul 11, 2024

@micahchiang Thanks for the explanation, that makes sense from a technical viewpoint.

I think people would expect a <va-link /> to behave like an <a />, which does response to innerText. I'd think anything that can qualify as phrasing content should return a non-empty string for innerText (or textContent).

That said, having looked at how datadog searches for action names, having VADS components automatically set the data-dd-action-name attribute sounds reasonable, particularly for components like va-alert-expandable which has a clickable link embedded within its ShadowRoot.

@wesrowe
Copy link

wesrowe commented Jul 12, 2024

@caw310, do you think this is something your team will prioritize?

@caw310
Copy link
Contributor

caw310 commented Jul 15, 2024

We will add this to our backlog but not sure exactly when we will get to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working platform-design-system-team
Projects
None yet
Development

No branches or pull requests

4 participants