feat(analytics): identify TMDB users by username via OpenPanel profileId

This commit is contained in:
ner committed 2026-09-29 13:23:35 +03:00
1 parent 69814bcc68
commit 73eb8943b3
3 files changed
+41 -2

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
import { useEffect, useRef } from 'react';
import { identify } from '@/lib/analytics';
import useAccount from './useAccount';
const useIdentify = () => {
const account = useAccount();
const sentRef = useRef<string | undefined>(undefined);
useEffect(() => {
if (!account) {
sentRef.current = undefined;
return;
}
const profileId = `tmdb:${account.username || account.id}`;
if (sentRef.current === profileId) return;
sentRef.current = profileId;
identify({
profileId,
username: account.username,
name: account.name
});
}, [account]);
};
export default useIdentify;