Skip to content

Commit

Permalink
Met à jour l'identifiant de tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-rutkowski committed Jan 7, 2025
1 parent bd1824d commit 628e939
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
SignInWithPasswordCredentials,
User,
} from '@supabase/supabase-js';
import { usePostHog } from 'posthog-js/react';
import {
createContext,
ReactNode,
Expand Down Expand Up @@ -109,6 +110,8 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {

const { data: userData = null } = useUserData(session);

const posthog = usePostHog();

useEffect(() => {
// écoute les changements d'état (connecté, déconnecté, etc.)
const {
Expand Down Expand Up @@ -139,12 +142,22 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
if (window.location.href.includes('localhost'))
environment = 'development';

if (posthog) {
posthog.identify(userData.id, {
email: userData.email,
user_id: userData.id,
});
}

if (environment === 'production' || environment === 'test') {
// @ts-expect-error - StonlyWidget is not defined
window.StonlyWidget('identify', userData.user_id);
}
} else {
clearCrispUserData();
if (posthog) {
posthog.reset();
}
}
}, [userData]);

Expand Down

0 comments on commit 628e939

Please sign in to comment.