mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
chore: populate page prop for mixpanel (#7425)
This commit is contained in:
+6
@@ -24,6 +24,7 @@ import type { BlockSpec, WidgetElement } from '@blocksuite/block-std';
|
||||
import {
|
||||
type AffineReference,
|
||||
AffineSlashMenuWidget,
|
||||
EdgelessRootBlockComponent,
|
||||
EmbedLinkedDocBlockComponent,
|
||||
type ParagraphBlockService,
|
||||
type RootService,
|
||||
@@ -463,23 +464,28 @@ export function patchQuickSearchService(
|
||||
pageId: linkedDoc.id,
|
||||
},
|
||||
]);
|
||||
const isEdgeless =
|
||||
rootElement instanceof EdgelessRootBlockComponent;
|
||||
if (result.isNewDoc) {
|
||||
mixpanel.track('DocCreated', {
|
||||
control: 'linked doc',
|
||||
module: 'slash commands',
|
||||
type: 'linked doc',
|
||||
category: 'doc',
|
||||
page: isEdgeless ? 'whiteboard editor' : 'page editor',
|
||||
});
|
||||
mixpanel.track('LinkedDocCreated', {
|
||||
control: 'new doc',
|
||||
module: 'slash commands',
|
||||
type: 'doc',
|
||||
page: isEdgeless ? 'whiteboard editor' : 'page editor',
|
||||
});
|
||||
} else {
|
||||
mixpanel.track('LinkedDocCreated', {
|
||||
control: 'linked doc',
|
||||
module: 'slash commands',
|
||||
type: 'doc',
|
||||
page: isEdgeless ? 'whiteboard editor' : 'page editor',
|
||||
});
|
||||
}
|
||||
} else if ('userInput' in result) {
|
||||
|
||||
@@ -110,18 +110,20 @@ export const PageHeaderMenuButton = ({
|
||||
duplicate(pageId);
|
||||
mixpanel.track('DocCreated', {
|
||||
segment: 'editor header',
|
||||
page: doc.mode$.value === 'page' ? 'page editor' : 'edgeless editor',
|
||||
module: 'header menu',
|
||||
control: 'copy doc',
|
||||
type: 'doc duplicate',
|
||||
category: 'doc',
|
||||
});
|
||||
}, [duplicate, pageId]);
|
||||
}, [doc.mode$.value, duplicate, pageId]);
|
||||
|
||||
const onImportFile = useAsyncCallback(async () => {
|
||||
const options = await importFile();
|
||||
if (options.isWorkspaceFile) {
|
||||
mixpanel.track('WorkspaceCreated', {
|
||||
segment: 'editor header',
|
||||
page: doc.mode$.value === 'page' ? 'page editor' : 'edgeless editor',
|
||||
module: 'header menu',
|
||||
control: 'import button',
|
||||
type: 'imported workspace',
|
||||
@@ -129,12 +131,13 @@ export const PageHeaderMenuButton = ({
|
||||
} else {
|
||||
mixpanel.track('DocCreated', {
|
||||
segment: 'editor header',
|
||||
page: doc.mode$.value === 'page' ? 'page editor' : 'edgeless editor',
|
||||
module: 'header menu',
|
||||
control: 'import button',
|
||||
type: 'imported doc',
|
||||
});
|
||||
}
|
||||
}, [importFile]);
|
||||
}, [doc.mode$.value, importFile]);
|
||||
|
||||
const showResponsiveMenu = hideShare;
|
||||
const ResponsiveMenuItems = (
|
||||
|
||||
@@ -102,6 +102,7 @@ export const PageOperationCell = ({
|
||||
control: 'copy doc',
|
||||
type: 'doc duplicate',
|
||||
category: 'doc',
|
||||
page: 'doc library',
|
||||
});
|
||||
}, [duplicate, page.id]);
|
||||
|
||||
|
||||
+7
-1
@@ -1,6 +1,7 @@
|
||||
import { IconButton } from '@affine/component/ui/button';
|
||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||
import { FavoriteItemsAdapter } from '@affine/core/modules/properties';
|
||||
import { TelemetryWorkspaceContextService } from '@affine/core/modules/telemetry/services/telemetry';
|
||||
import { mixpanel } from '@affine/core/utils';
|
||||
import { PlusIcon } from '@blocksuite/icons/rc';
|
||||
import { useService, useServices, WorkspaceService } from '@toeverything/infra';
|
||||
@@ -19,8 +20,11 @@ export const AddFavouriteButton = ({ pageId }: AddFavouriteButtonProps) => {
|
||||
workspaceService.workspace.docCollection
|
||||
);
|
||||
const favAdapter = useService(FavoriteItemsAdapter);
|
||||
const telemetry = useService(TelemetryWorkspaceContextService);
|
||||
const handleAddFavorite = useAsyncCallback(
|
||||
async e => {
|
||||
const page = telemetry.getPageContext();
|
||||
|
||||
if (pageId) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
@@ -32,6 +36,7 @@ export const AddFavouriteButton = ({ pageId }: AddFavouriteButtonProps) => {
|
||||
control: 'new fav sub doc',
|
||||
type: 'doc',
|
||||
category: 'page',
|
||||
page: page,
|
||||
});
|
||||
} else {
|
||||
const page = createPage();
|
||||
@@ -44,10 +49,11 @@ export const AddFavouriteButton = ({ pageId }: AddFavouriteButtonProps) => {
|
||||
control: 'new fav doc',
|
||||
type: 'doc',
|
||||
category: 'page',
|
||||
page: page,
|
||||
});
|
||||
}
|
||||
},
|
||||
[pageId, createLinkedPage, createPage, favAdapter]
|
||||
[telemetry, pageId, createLinkedPage, createPage, favAdapter]
|
||||
);
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||
import { TelemetryWorkspaceContextService } from '@affine/core/modules/telemetry/services/telemetry';
|
||||
import { mixpanel } from '@affine/core/utils';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { ImportIcon } from '@blocksuite/icons/rc';
|
||||
import { useService } from '@toeverything/infra';
|
||||
|
||||
import type { DocCollection } from '../../shared';
|
||||
import { MenuItem } from '../app-sidebar';
|
||||
@@ -10,12 +12,14 @@ import { usePageHelper } from '../blocksuite/block-suite-page-list/utils';
|
||||
const ImportPage = ({ docCollection }: { docCollection: DocCollection }) => {
|
||||
const t = useI18n();
|
||||
const { importFile } = usePageHelper(docCollection);
|
||||
const telemetry = useService(TelemetryWorkspaceContextService);
|
||||
|
||||
const onImportFile = useAsyncCallback(async () => {
|
||||
const options = await importFile();
|
||||
const page = telemetry.getPageContext();
|
||||
if (options.isWorkspaceFile) {
|
||||
mixpanel.track('WorkspaceCreated', {
|
||||
page: 'doc library',
|
||||
page,
|
||||
segment: 'navigation panel',
|
||||
module: 'doc list header',
|
||||
control: 'import button',
|
||||
@@ -23,7 +27,7 @@ const ImportPage = ({ docCollection }: { docCollection: DocCollection }) => {
|
||||
});
|
||||
} else {
|
||||
mixpanel.track('DocCreated', {
|
||||
page: 'doc library',
|
||||
page,
|
||||
segment: 'navigation panel',
|
||||
module: 'doc list header',
|
||||
control: 'import button',
|
||||
@@ -31,7 +35,7 @@ const ImportPage = ({ docCollection }: { docCollection: DocCollection }) => {
|
||||
// category
|
||||
});
|
||||
}
|
||||
}, [importFile]);
|
||||
}, [importFile, telemetry]);
|
||||
|
||||
return (
|
||||
<MenuItem icon={<ImportIcon />} onClick={onImportFile}>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { AnimatedDeleteIcon } from '@affine/component';
|
||||
import { getDNDId } from '@affine/core/hooks/affine/use-global-dnd-helper';
|
||||
import { useAsyncCallback } from '@affine/core/hooks/affine-async-hooks';
|
||||
import { CollectionService } from '@affine/core/modules/collection';
|
||||
import { TelemetryWorkspaceContextService } from '@affine/core/modules/telemetry/services/telemetry';
|
||||
import { mixpanel } from '@affine/core/utils';
|
||||
import { apis, events } from '@affine/electron-api';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
@@ -103,6 +104,8 @@ export const RootAppSidebar = memo(
|
||||
)
|
||||
);
|
||||
|
||||
const telemetry = useService(TelemetryWorkspaceContextService);
|
||||
|
||||
const allPageActive = currentPath === '/all';
|
||||
|
||||
const trashActive = currentPath === '/trash';
|
||||
@@ -112,14 +115,14 @@ export const RootAppSidebar = memo(
|
||||
page.load();
|
||||
openPage(page.id);
|
||||
mixpanel.track('DocCreated', {
|
||||
page: allPageActive ? 'all' : trashActive ? 'trash' : 'other',
|
||||
page: telemetry.getPageContext(),
|
||||
segment: 'navigation panel',
|
||||
module: 'bottom button',
|
||||
control: 'new doc button',
|
||||
category: 'page',
|
||||
type: 'doc',
|
||||
});
|
||||
}, [allPageActive, createPage, openPage, trashActive]);
|
||||
}, [createPage, openPage, telemetry]);
|
||||
|
||||
const navigateHelper = useNavigateHelper();
|
||||
// Listen to the "New Page" action from the menu
|
||||
|
||||
Reference in New Issue
Block a user