From 087862ea719746be522eb8ce0affa19037634f81 Mon Sep 17 00:00:00 2001 From: Niek Candaele Date: Sun, 15 Dec 2024 17:56:15 +0100 Subject: [PATCH] feat: identity users with Produktly --- packages/web-main/src/hooks/useAuth.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/web-main/src/hooks/useAuth.tsx b/packages/web-main/src/hooks/useAuth.tsx index ce379fc2af..8f3d4d0a79 100644 --- a/packages/web-main/src/hooks/useAuth.tsx +++ b/packages/web-main/src/hooks/useAuth.tsx @@ -34,6 +34,14 @@ export function AuthProvider({ children }: { children: React.ReactNode }) { email: session.user.email, domain: session.domain, }); + + // @ts-expect-error - We load Produktly via a script tag in the index... + window.Produktly.identifyUser(session.user.idpId, { + domain: session.domain, + createdAt: session.user.createdAt, + email: session.user.email, + permissions: session.user.roles.map((role) => role.role.permissions.map((p) => p.permission.permission)).flat(), + }); }, []); const getSession = async function (): Promise {