department-of-veterans-affairs / va.gov-team

Public resources for building on and in support of VA.gov. Visit complete Knowledge Hub:
https://depo-platform-documentation.scrollhelp.site/index.html
281 stars 202 forks source link

Datadog tracks "go back to previous" link clicks on MHV Home #86178

Closed wesrowe closed 3 months ago

wesrowe commented 3 months ago

Description

User story

As a Cartography team member, I want DD to track the three "go back" link click actions on MHV Home separately, as well as the one on the temporary MR landing page, so that we can understand what area/content a Veteran was engaged with when they went back to MHV Classic.

Notes

Possible tasks:

Acceptance criteria

dcloud commented 3 months ago

I have a meeting on 6/18 to discuss "missing clicks" with a Datadog technical support engineer

dcloud commented 3 months ago

As part of the support investigation with Datadog, it was suggested that we upgrade from v4 to v5, and I've been peeking at that. Currently Datadog is implemented platform/sitewide, so upgrading would either require:

Some notes on upgrading

names of deprecated things

I put these lines in a file to grep for with rg (ripgrep)

removeUser
addRumGlobalContext
removeRumGlobalContext
getRumGlobalContext
setRumGlobalContext
addLoggerGlobalContext
removeLoggerGlobalContext
getLoggerGlobalContext
setLoggerGlobalContext
addContext
removeContext
proxyUrl
sampleRate
allowedTracingOrigins
tracingSampleRate
trackInteractions
premiumSampleRate
replaySampleRate
beforeSend

trackInteractions --> trackUserInteractions

Looks like many apps use the v5 name, usually alongside the v4 name…

delta -s --color-only <(rg trackUserInteractions -l vets-website | sort) <(rg trackInteractions $(rg -l trackUserInteractions vets-website) -l | sort)

Intake domains

https://browser-intake-ddog-gov.com is in devops, so I think we're good here

dcloud commented 3 months ago

Saving the DDG session search that shows the Prod events for the medical records card: @action.type:click "Medical Records Card":

image
dcloud commented 3 months ago

Also: @action.type:click @action.name:*Medical\ Records\ Card*, where the backslash escapes spaces and so we can perform a wildcard search on the action name. As opposed to the version in my previous comment which searches multiple fields, not just the action name

dcloud commented 3 months ago

Per support, going to switch from the attribute to a function call:

Next, from the screen recording, I see the data-dd-action-name attribute on the tag, but maybe we can try using the datadogRum.addAction() function here to add the custom click action. https://docs.datadoghq.com/real_user_monitoring/guide/send-rum-custom-actions/?tab=npm#instrument-your-code

dcloud commented 3 months ago

I forgot to move this into code review, but this got reviewed and is merged. Should be in staging shortly

dcloud commented 3 months ago

Seeing custom actions in DDG for staging, e.g. this event for "Click on Landing Page: Intro - Go back to the previous version of My HealtheVet"

dcloud commented 3 months ago

Not seeing actions recorded for the MR Transitional page aka "Click on Medical Records: Coming Soon…" link so far

dcloud commented 3 months ago

After merging the RUM config move to app-entry file, seeing the coming soon click action

@action.name:*Medical\ Records*
dcloud commented 3 months ago

It also looks like that config change may have fixed the bug with getting DD_RUM to output info in the console. I can run DD_RUM.getInitConfiguration() to see the config or DD_RUM.getInternalContext()?.session_id to get the session id

dcloud commented 3 months ago

While https://github.com/department-of-veterans-affairs/vets-website/pull/30605 appears to have made some of the console functions work, making it possible/easy to grab a session_id via DD_RUM.getInternalContext()?.session_id, there are remaining issues:

Per my clicking around in staging - @session.id:2c298dca-f11a-4a8d-a42b-f53e4e1eb0d1

These observations should probably be put into a "Datadog debug" ticket if we need to continue to fix things with DD_RUM

wesrowe commented 3 months ago

@dcloud, did you make a "debug DD" ticket yet? I feel the work to add a custom action is a small price to pay for actions that make sense to anyone who looks! I would like to get @kat and @fmccaf1 thoughts on how these custom actions (to replace the buggy ones) should be labeled.