mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-03 02:20:19 +08:00
chore(core): add mixpanel track (#6202)
This commit is contained in:
@@ -3,8 +3,7 @@ import { WorkspaceManager } from '@toeverything/infra';
|
||||
import { useService } from '@toeverything/infra/di';
|
||||
import { useLiveData } from '@toeverything/infra/livedata';
|
||||
import { useAtom } from 'jotai';
|
||||
import type { ReactElement } from 'react';
|
||||
import { lazy, Suspense, useCallback } from 'react';
|
||||
import { lazy, type ReactElement, Suspense, useCallback } from 'react';
|
||||
|
||||
import {
|
||||
authAtom,
|
||||
@@ -19,6 +18,7 @@ import { useAsyncCallback } from '../hooks/affine-async-hooks';
|
||||
import { useNavigateHelper } from '../hooks/use-navigate-helper';
|
||||
import { CurrentWorkspaceService } from '../modules/workspace/current-workspace';
|
||||
import { WorkspaceSubPath } from '../shared';
|
||||
import { mixpanel } from '../utils';
|
||||
import { signOutCloud } from '../utils/cloud-utils';
|
||||
|
||||
const SettingModal = lazy(() =>
|
||||
@@ -218,6 +218,8 @@ export const SignOutConfirmModal = () => {
|
||||
setOpen(false);
|
||||
await signOutCloud();
|
||||
|
||||
mixpanel.reset();
|
||||
|
||||
// if current workspace is affine cloud, switch to local workspace
|
||||
if (currentWorkspace?.flavour === WorkspaceFlavour.AFFINE_CLOUD) {
|
||||
const localWorkspace = workspaces.find(
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
} from 'react';
|
||||
|
||||
import { useOnceSignedInEvents } from '../atoms/event';
|
||||
import { mixpanel } from '../utils';
|
||||
|
||||
export const CloudSessionProvider = (props: PropsWithChildren) => {
|
||||
const session = useSession();
|
||||
@@ -28,6 +29,12 @@ export const CloudSessionProvider = (props: PropsWithChildren) => {
|
||||
).postMessage(1);
|
||||
}, [onceSignedInEvents]);
|
||||
|
||||
useEffect(() => {
|
||||
if (session.user?.id) {
|
||||
mixpanel.identify(session.user.id);
|
||||
}
|
||||
}, [session]);
|
||||
|
||||
useEffect(() => {
|
||||
if (prevSession.current !== session && session.status !== 'loading') {
|
||||
// unauthenticated -> authenticated
|
||||
|
||||
Reference in New Issue
Block a user