chore(core): add mixpanel track (#6202)

This commit is contained in:
Brooooooklyn
2024-03-22 09:24:40 +00:00
parent 10af0ab48d
commit 150c22936d
21 changed files with 229 additions and 67 deletions

View File

@@ -18,6 +18,7 @@ import { useCallback } from 'react';
import { useCurrentLoginStatus } from '../../../hooks/affine/use-current-login-status';
import { useMutation } from '../../../hooks/use-mutation';
import { mixpanel } from '../../../utils';
import { emailRegex } from '../../../utils/email-regex';
import type { AuthPanelProps } from './index';
import { OAuth } from './oauth';
@@ -97,6 +98,10 @@ export const SignIn: FC<AuthPanelProps> = ({
if (res?.status === 403 && res?.url === INTERNAL_BETA_URL) {
return setAuthState('noAccess');
}
// TODO, should always get id from user
if ('id' in user) {
mixpanel.identify(user.id);
}
setAuthState('afterSignInSendEmail');
}
} else {

View File

@@ -9,6 +9,8 @@ import bytes from 'bytes';
import { useAtom, useSetAtom } from 'jotai';
import { useCallback, useEffect, useMemo } from 'react';
import { mixpanel } from '../../../utils';
export const CloudQuotaModal = () => {
const t = useAFFiNEI18N();
const currentWorkspace = useService(Workspace);
@@ -70,6 +72,14 @@ export const CloudQuotaModal = () => {
};
}, [currentWorkspace.engine.blob, setOpen, workspaceQuota.blobLimit]);
useEffect(() => {
if (userQuota?.humanReadable) {
mixpanel.people.set({
plan: userQuota.humanReadable.name,
});
}
}, [userQuota]);
return (
<ConfirmModal
open={open}