feat: add isNewDoc flag to quick search api (#7232)

This commit is contained in:
pengx17
2024-06-18 04:07:55 +00:00
parent e3bd8562b8
commit 006c260e5f
3 changed files with 22 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ import type {
} from '@affine/core/modules/cmdk';
import type { PeekViewService } from '@affine/core/modules/peek-view';
import type { ActivePeekView } from '@affine/core/modules/peek-view/entities/peek-view';
import { mixpanel } from '@affine/core/utils';
import { DebugLogger } from '@affine/debug';
import type { BlockSpec, WidgetElement } from '@blocksuite/block-std';
import {
@@ -413,6 +414,25 @@ export function patchQuickSearchService(
pageId: linkedDoc.id,
},
]);
if (result.isNewDoc) {
mixpanel.track('DocCreated', {
control: 'linked doc',
module: 'slash commands',
type: 'linked doc',
category: 'doc',
});
mixpanel.track('LinkedDocCreated', {
control: 'new doc',
module: 'slash commands',
type: 'doc',
});
} else {
mixpanel.track('LinkedDocCreated', {
control: 'linked doc',
module: 'slash commands',
type: 'doc',
});
}
} else if ('userInput' in result) {
const embedOptions = service.getEmbedBlockOptions(
result.userInput

View File

@@ -13,6 +13,7 @@ export type SearchCallbackResult =
| {
docId: string;
blockId?: string;
isNewDoc?: boolean;
}
| {
query: string;

View File

@@ -384,11 +384,7 @@ export const useSearchCallbackCommands = () => {
const page = pageHelper.createPage('page', false);
page.load();
pageMetaHelper.setDocTitle(page.id, query);
mixpanel.track('DocCreated', {
control: 'cmdk',
type: 'doc',
});
onSelectPage({ docId: page.id });
onSelectPage({ docId: page.id, isNewDoc: true });
},
icon: <PageIcon />,
});