From 10778a727b35d291fbcabeab7b2c8e916faba3d6 Mon Sep 17 00:00:00 2001 From: pt2302 <1553279+pt2302@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:04:36 -0400 Subject: [PATCH] Fix PostHog identify if user is not logged in (#2306) --- static/js/lib/util.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/js/lib/util.ts b/static/js/lib/util.ts index ea96bbe82..8150c3554 100644 --- a/static/js/lib/util.ts +++ b/static/js/lib/util.ts @@ -22,7 +22,10 @@ if (SETTINGS.posthog_api_host && SETTINGS.posthog_project_api_key) { }, }) // @ts-expect-error: SETTINGS.user is intentionally untyped - posthog.identify(SETTINGS.user.email) + if (SETTINGS.user) { + // @ts-expect-error: SETTINGS.user is intentionally untyped + posthog.identify(SETTINGS.user.email) + } } export const isErrorStatusCode = (statusCode: number): boolean =>