From 26ff00eb2c895af5fb15fc6b5bf2e72c25cb9c14 Mon Sep 17 00:00:00 2001 From: Hannah Purcell Date: Tue, 10 Dec 2024 19:10:08 -0500 Subject: [PATCH] tweak: move userUuid querySelector into utility --- assets/src/app.tsx | 7 ++----- assets/src/util/userUuid.ts | 2 ++ 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 assets/src/util/userUuid.ts diff --git a/assets/src/app.tsx b/assets/src/app.tsx index 62cd21653..a4cc4d515 100644 --- a/assets/src/app.tsx +++ b/assets/src/app.tsx @@ -20,6 +20,7 @@ import AppStateWrapper from "./components/appStateWrapper" import { tagManagerIdentify } from "./helpers/googleTagManager" import { fullStoryInit } from "./helpers/fullStory" import inTestGroup, { TestGroups } from "./userInTestGroup" +import { userUuid } from "./util/userUuid" document.documentElement.dataset.demoMode = inTestGroup( TestGroups.DemoMode @@ -37,11 +38,7 @@ sentryInit( window.sentryInitialization?.orgSlug ) -const userUuid = document - .querySelector("meta[name=user-uuid]") - ?.getAttribute("content") - -tagManagerIdentify(userUuid) +tagManagerIdentify(userUuid()) // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const root = createRoot(document.getElementById("app")!) diff --git a/assets/src/util/userUuid.ts b/assets/src/util/userUuid.ts new file mode 100644 index 000000000..fd14e07af --- /dev/null +++ b/assets/src/util/userUuid.ts @@ -0,0 +1,2 @@ +export const userUuid = (): string | null | undefined => + document.querySelector("meta[name=user-uuid]")?.getAttribute("content")