From d9517f992d4a5e9ead97c2b5480163ebe270a32d Mon Sep 17 00:00:00 2001 From: Rakov Date: Fri, 12 May 2023 14:32:16 +0300 Subject: [PATCH] fix(#593): send user id to ga --- src/features/App/index.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/features/App/index.tsx b/src/features/App/index.tsx index d65ffd0a..21812be1 100644 --- a/src/features/App/index.tsx +++ b/src/features/App/index.tsx @@ -32,13 +32,24 @@ setClientTitleAndDescription(client.title, client.description) const Main = () => { const [isToken, setIsToken] = useState(false) - const { userInfo } = useAuthStore() + const { user, userInfo } = useAuthStore() const queryClient = new QueryClient() useEffect(() => { if (userInfo) readToken() && setIsToken(true) }, [userInfo]) + // отправляем идентификаторы пользователей в гугл аналитику + useEffect(() => { + if (user) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (window as any)?.dataLayer.push({ + event: 'userData', + userId: user.profile?.sub, + }) + } + }, [user]) + // имеется действующий токен return isToken ? (