feat: add more tracking events (#6866)

Added most tracking events

what is missing:
- still need a way to track events in blocksuite
- some events may not 100% accurate of the one defined in the PRD
This commit is contained in:
pengx17
2024-05-13 03:36:32 +00:00
parent bd1733b2a9
commit 3e23878e0f
37 changed files with 433 additions and 69 deletions

View File

@@ -8,6 +8,7 @@ import { EMPTY, mergeMap, switchMap } from 'rxjs';
import { RouteLogic, useNavigateHelper } from '../hooks/use-navigate-helper';
import { AuthService, SubscriptionService } from '../modules/cloud';
import { mixpanel } from '../utils';
import { container } from './subscribe.css';
export const Component = () => {
@@ -68,6 +69,16 @@ export const Component = () => {
});
setMessage('Redirecting...');
location.href = checkout;
mixpanel.track('PlanChangeSucceeded', {
type: plan,
category: recurring,
});
if (plan) {
mixpanel.people.set({
[SubscriptionPlan.AI === plan ? 'ai plan' : plan]: plan,
recurring: recurring,
});
}
} catch (err) {
console.error(err);
setError('Something went wrong. Please try again.');

View File

@@ -6,6 +6,8 @@ import {
} from '@affine/core/components/page-list';
import { Header } from '@affine/core/components/pure/header';
import { WorkspaceModeFilterTab } from '@affine/core/components/pure/workspace-mode-filter-tab';
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
import { mixpanel } from '@affine/core/utils';
import type { Filter } from '@affine/env/filter';
import { PlusIcon } from '@blocksuite/icons';
import { useService, WorkspaceService } from '@toeverything/infra';
@@ -27,6 +29,28 @@ export const AllPageHeader = ({
workspace.docCollection
);
const onImportFile = useAsyncCallback(async () => {
const options = await importFile();
if (options.isWorkspaceFile) {
mixpanel.track('WorkspaceCreated', {
page: 'doc library',
segment: 'all page',
module: 'doc list header',
control: 'import button',
type: 'imported workspace',
});
} else {
mixpanel.track('DocCreated', {
page: 'doc library',
segment: 'all page',
module: 'doc list header',
control: 'import button',
type: 'imported doc',
// category
});
}
}, [importFile]);
return (
<Header
left={
@@ -46,7 +70,7 @@ export const AllPageHeader = ({
)}
onCreateEdgeless={createEdgeless}
onCreatePage={createPage}
onImportFile={importFile}
onImportFile={onImportFile}
>
<PlusIcon />
</PageListNewPageButton>