diff --git a/src/api/resources/User.ts b/src/api/resources/User.ts index 34e5e88..17fd629 100644 --- a/src/api/resources/User.ts +++ b/src/api/resources/User.ts @@ -174,6 +174,7 @@ export interface ICreateAuthorizePayload { export interface ICreateAuthorizeResponse { token: string; + userId?: string; } export const createAuthorizeRequest = (data: ICreateAuthorizePayload): Request => { diff --git a/src/hooks/authentication/use-authentication.ts b/src/hooks/authentication/use-authentication.ts index ced36ca..fbf89db 100644 --- a/src/hooks/authentication/use-authentication.ts +++ b/src/hooks/authentication/use-authentication.ts @@ -114,7 +114,13 @@ export const useAuthentication = () => { try { setIsLoading(true); const payload = getAuthorizationPayload(email, source); - const { token } = await api.authorization(payload); + const { token, userId } = await api.authorization(payload); + if (userId?.length && !!window.ym) { + window.ym(95799066, 'userParams', { + UserID: userId + }) + window.ym(95799066, 'setUserID', userId); + } const { user } = await api.getUser({ token }); signUp(token, user); setToken(token); diff --git a/src/types.ts b/src/types.ts index c664802..6adc00a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -22,3 +22,11 @@ export interface SignupForm { } export type UserStatus = "lead" | "registred" | "subscribed" | "unsubscribed"; + +declare global { + interface Window { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + ym: any; + } +} +