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

(spike) added user to rum #28214

Merged
merged 12 commits into from Mar 11, 2024
2 changes: 1 addition & 1 deletion src/applications/mhv/secure-messaging/containers/App.jsx
Expand Up @@ -56,7 +56,7 @@ const App = () => {
trackLongTasks: true,
defaultPrivacyLevel: 'mask-user-input',
};
useDatadogRum(datadogRumConfig);
useDatadogRum(datadogRumConfig, user);

if (featureTogglesLoading) {
return (
Expand Down
11 changes: 8 additions & 3 deletions src/applications/mhv/shared/hooks/useDatadogRum.jsx
Expand Up @@ -6,7 +6,7 @@ import environment from '@department-of-veterans-affairs/platform-utilities/envi
const initializeDatadogRum = config => {
if (
// Prevent RUM from running on local/CI environments.
environment.BASE_URL.indexOf('localhost') < 0 &&
// environment.BASE_URL.indexOf('localhost') < 0 &&
mdewey marked this conversation as resolved.
Show resolved Hide resolved
// Prevent re-initializing the SDK.
!window.DD_RUM?.getInitConfiguration() &&
!window.Mocha
Expand All @@ -20,12 +20,17 @@ const initializeDatadogRum = config => {
}
};

const useDatadogRum = config => {
const useDatadogRum = (config, user) => {
useEffect(
() => {
initializeDatadogRum(config);
if (user?.login?.currentlyLoggedIn) {
datadogRum.setUser({
id: user.profile.accountUUid,
mdewey marked this conversation as resolved.
Show resolved Hide resolved
});
}
},
[config],
[config, user],
);
};

Expand Down