feat(core): add track events for cmdk (#7668)

This commit is contained in:
JimmFly
2024-08-07 05:52:42 +00:00
parent 67dce9c97a
commit eb01e76426
13 changed files with 175 additions and 12 deletions
@@ -2,6 +2,7 @@ import {
PreconditionStrategy,
registerAffineCommand,
} from '@affine/core/commands';
import { track } from '@affine/core/mixpanel';
import { useService } from '@toeverything/infra';
import { useEffect } from 'react';
@@ -23,6 +24,8 @@ export function useRegisterNavigationCommands() {
binding: '$mod+[',
},
run() {
track.$.cmdk.general.goBack();
navigator.back();
},
})
@@ -38,6 +41,8 @@ export function useRegisterNavigationCommands() {
binding: '$mod+]',
},
run() {
track.$.cmdk.general.goForward();
navigator.forward();
},
})
@@ -1,3 +1,4 @@
import { track } from '@affine/core/mixpanel';
import type { DocsService } from '@toeverything/infra';
import { Service } from '@toeverything/infra';
@@ -47,6 +48,10 @@ export class CMDKQuickSearchService extends Service {
blockId?: string;
} = result.payload;
result.source === 'recent-doc' && track.$.cmdk.recent.recentDocs();
result.source === 'docs' &&
track.$.cmdk.results.searchResultsDocs();
this.workbenchService.workbench.openDoc({
docId: doc.docId,
blockId: doc.blockId,