mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-19 23:37:15 +08:00
feat(core): all docs tracks (#12556)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added enhanced tracking for user interactions across document lists, navigation, display menus, quick actions, and collection operations. - User actions such as opening documents, editing collections, toggling favorites, changing view modes, and navigating collections are now logged for analytics. - **Chores** - Expanded internal event tracking capabilities to support more detailed analytics on user interactions throughout the interface. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -2,6 +2,7 @@ import { Divider, MenuItem } from '@affine/component';
|
||||
import type { GroupByParams } from '@affine/core/modules/collection-rules/types';
|
||||
import { WorkspacePropertyService } from '@affine/core/modules/workspace-property';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import { DoneIcon } from '@blocksuite/icons/rc';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
@@ -128,6 +129,10 @@ const GroupByListItem = ({
|
||||
<MenuItem
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
track.allDocs.header.displayMenu.editDisplayMenu({
|
||||
control: 'groupBy',
|
||||
type: property.systemProperty?.type ?? 'custom-property',
|
||||
});
|
||||
if (value) {
|
||||
onChange?.(value);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { MenuItem } from '@affine/component';
|
||||
import type { OrderByParams } from '@affine/core/modules/collection-rules/types';
|
||||
import { WorkspacePropertyService } from '@affine/core/modules/workspace-property';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import { SortDownIcon, SortUpIcon } from '@blocksuite/icons/rc';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { cssVarV2 } from '@toeverything/theme/v2';
|
||||
@@ -125,6 +126,10 @@ const OrderByListItem = ({
|
||||
<MenuItem
|
||||
onClick={e => {
|
||||
e.preventDefault();
|
||||
track.allDocs.header.displayMenu.editDisplayMenu({
|
||||
control: 'orderBy',
|
||||
type: property.systemProperty?.type ?? 'custom-property',
|
||||
});
|
||||
if (value) {
|
||||
onChange?.(value);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Button, Divider } from '@affine/component';
|
||||
import { WorkspacePropertyService } from '@affine/core/modules/workspace-property';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import { useLiveData, useService } from '@toeverything/infra';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
@@ -160,7 +161,13 @@ const PropertyRenderer = ({
|
||||
<Button
|
||||
key={key}
|
||||
data-show={isActive}
|
||||
onClick={() => handlePropertyClick(key)}
|
||||
onClick={() => {
|
||||
track.allDocs.header.displayMenu.editDisplayMenu({
|
||||
control: 'displayProperties',
|
||||
type: systemProperty?.type ?? 'custom-property',
|
||||
});
|
||||
handlePropertyClick(key);
|
||||
}}
|
||||
className={styles.property}
|
||||
data-key={key}
|
||||
>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Checkbox, MenuItem, MenuSub } from '@affine/component';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { type QuickAction, quickActions } from '../quick-actions.constants';
|
||||
@@ -27,6 +28,10 @@ export const QuickActionsConfig = ({
|
||||
action={action}
|
||||
active={displayPreference[`${action.key}`] ?? false}
|
||||
onClick={() => {
|
||||
track.allDocs.header.displayMenu.editDisplayMenu({
|
||||
control: 'quickActions',
|
||||
type: action.key,
|
||||
});
|
||||
onDisplayPreferenceChange({
|
||||
...displayPreference,
|
||||
[action.key]: !displayPreference[action.key],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { RadioGroup, type RadioItem } from '@affine/component';
|
||||
import track from '@affine/track';
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import {
|
||||
@@ -34,6 +35,9 @@ export const ViewToggle = ({
|
||||
}) => {
|
||||
const handleViewChange = useCallback(
|
||||
(view: DocListItemView) => {
|
||||
track.allDocs.header.viewMode.editDisplayMenu({
|
||||
type: view,
|
||||
});
|
||||
onViewChange(view);
|
||||
},
|
||||
[onViewChange]
|
||||
|
||||
@@ -10,6 +10,7 @@ import { DocDisplayMetaService } from '@affine/core/modules/doc-display-meta';
|
||||
import { WorkbenchLink } from '@affine/core/modules/workbench';
|
||||
import type { AffineDNDData } from '@affine/core/types/dnd';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import {
|
||||
AutoTidyUpIcon,
|
||||
PropertyIcon,
|
||||
@@ -139,6 +140,7 @@ export const DocListItem = ({ ...props }: DocListItemProps) => {
|
||||
return;
|
||||
} else {
|
||||
// as link
|
||||
track.allDocs.list.doc.openDoc();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ const ToggleFavorite = ({ docId }: DocOperationProps) => {
|
||||
|
||||
const toggleFavorite = useCallback(() => {
|
||||
favAdapter.toggle(docId, 'doc');
|
||||
track.allDocs.list.docMenu.toggleFavorite();
|
||||
}, [docId, favAdapter]);
|
||||
|
||||
return (
|
||||
@@ -66,7 +67,7 @@ const DocInfo = ({ docId }: DocOperationProps) => {
|
||||
|
||||
const onOpenInfoModal = useCallback(() => {
|
||||
if (docId) {
|
||||
track.$.docInfoPanel.$.open();
|
||||
track.allDocs.list.docMenu.openDocInfo();
|
||||
workspaceDialogService.open('doc-info', { docId });
|
||||
}
|
||||
}, [docId, workspaceDialogService]);
|
||||
@@ -85,6 +86,8 @@ const NewTab = ({ docId }: DocOperationProps) => {
|
||||
const t = useI18n();
|
||||
const workbench = useService(WorkbenchService).workbench;
|
||||
const onOpenInNewTab = useCallback(() => {
|
||||
track.allDocs.list.doc.openDoc();
|
||||
track.allDocs.list.docMenu.openInNewTab();
|
||||
workbench.openDoc(docId, { at: 'new-tab' });
|
||||
}, [docId, workbench]);
|
||||
|
||||
@@ -103,6 +106,7 @@ const SplitView = ({ docId }: DocOperationProps) => {
|
||||
const workbench = useService(WorkbenchService).workbench;
|
||||
|
||||
const onOpenInSplitView = useCallback(() => {
|
||||
track.allDocs.list.doc.openDoc();
|
||||
track.allDocs.list.docMenu.openInSplitView();
|
||||
workbench.openDoc(docId, { at: 'tail' });
|
||||
}, [docId, workbench]);
|
||||
|
||||
@@ -45,6 +45,7 @@ export const QuickFavorite = memo(function QuickFavorite({
|
||||
onClick?.(e);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
track.allDocs.list.docMenu.toggleFavorite();
|
||||
favAdapter.toggle(doc.id, 'doc');
|
||||
},
|
||||
[doc.id, favAdapter, onClick]
|
||||
@@ -77,6 +78,8 @@ export const QuickTab = memo(function QuickTab({
|
||||
onClick?.(e);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
track.allDocs.list.doc.openDoc();
|
||||
track.allDocs.list.docMenu.openInNewTab();
|
||||
workbench.openDoc(doc.id, { at: 'new-tab' });
|
||||
},
|
||||
[doc.id, onClick, workbench]
|
||||
@@ -109,6 +112,7 @@ export const QuickSplit = memo(function QuickSplit({
|
||||
onClick?.(e);
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
track.allDocs.list.doc.openDoc();
|
||||
track.allDocs.list.docMenu.openInSplitView();
|
||||
workbench.openDoc(doc.id, { at: 'tail' });
|
||||
},
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { WorkbenchLink } from '@affine/core/modules/workbench';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
|
||||
import * as styles from './navigation.css';
|
||||
|
||||
@@ -37,6 +38,11 @@ export const ExplorerNavigation = ({ active }: { active: NavigationKey }) => {
|
||||
data-testid={item.testId}
|
||||
data-active={active === item.value}
|
||||
to={item.to}
|
||||
onClick={() => {
|
||||
track.allDocs.header.navigation.navigateAllDocsRouter({
|
||||
control: item.value,
|
||||
});
|
||||
}}
|
||||
className={styles.item}
|
||||
>
|
||||
{t[item.label]()}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||
import { CompatibleFavoriteItemsAdapter } from '@affine/core/modules/favorite';
|
||||
import { WorkbenchService } from '@affine/core/modules/workbench';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import {
|
||||
DeleteIcon,
|
||||
EditIcon,
|
||||
@@ -71,6 +72,7 @@ export const CollectionOperations = ({
|
||||
}, [openRenameModal, openPromptModal, t, service, collection]);
|
||||
|
||||
const showEdit = useCallback(() => {
|
||||
track.collection.collection.$.editCollection();
|
||||
workspaceDialogService.open('collection-editor', {
|
||||
collectionId: collection.id,
|
||||
});
|
||||
|
||||
@@ -106,6 +106,7 @@ export const useNavigationPanelCollectionNodeOperations = (
|
||||
|
||||
const handleShowEdit = useCallback(() => {
|
||||
onOpenEdit();
|
||||
track.$.navigationPanel.collections.editCollection();
|
||||
}, [onOpenEdit]);
|
||||
|
||||
return useMemo(
|
||||
|
||||
@@ -251,6 +251,9 @@ export const NavigationPanelDocNode = ({
|
||||
setCollapsed={setCollapsed}
|
||||
canDrop={handleCanDrop}
|
||||
to={`/${docId}`}
|
||||
onClick={() => {
|
||||
track.$.navigationPanel.docs.openDoc();
|
||||
}}
|
||||
active={active}
|
||||
postfix={
|
||||
referencesLoading &&
|
||||
|
||||
@@ -105,6 +105,7 @@ export const useNavigationPanelDocNodeOperations = (
|
||||
workbenchService.workbench.openDoc(docId, {
|
||||
at: 'new-tab',
|
||||
});
|
||||
track.$.navigationPanel.docs.openDoc();
|
||||
track.$.navigationPanel.organize.openInNewTab({
|
||||
type: 'doc',
|
||||
});
|
||||
@@ -114,6 +115,7 @@ export const useNavigationPanelDocNodeOperations = (
|
||||
workbenchService.workbench.openDoc(docId, {
|
||||
at: 'beside',
|
||||
});
|
||||
track.$.navigationPanel.docs.openDoc();
|
||||
track.$.navigationPanel.organize.openInSplitView({
|
||||
type: 'doc',
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import type { FilterParams } from '@affine/core/modules/collection-rules';
|
||||
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import {
|
||||
CloseIcon,
|
||||
CollectionsIcon,
|
||||
@@ -102,10 +103,15 @@ export const PinnedCollections = ({
|
||||
<div
|
||||
className={styles.item}
|
||||
data-active={activeCollectionId === null ? 'true' : undefined}
|
||||
onClick={() =>
|
||||
onClick={() => {
|
||||
// only fire onActiveAll if the collection is not already active
|
||||
activeCollectionId !== null ? onActiveAll() : undefined
|
||||
}
|
||||
if (activeCollectionId !== null) {
|
||||
track.allDocs.header.navigation.navigatePinedCollectionRouter({
|
||||
control: 'all',
|
||||
});
|
||||
onActiveAll();
|
||||
}
|
||||
}}
|
||||
role="button"
|
||||
>
|
||||
{t['com.affine.all-docs.pinned-collection.all']()}
|
||||
@@ -115,12 +121,15 @@ export const PinnedCollections = ({
|
||||
key={record.collectionId}
|
||||
record={record}
|
||||
isActive={activeCollectionId === record.collectionId}
|
||||
onClick={() =>
|
||||
onClick={() => {
|
||||
// only fire onActiveCollection if the collection is not already active
|
||||
activeCollectionId !== record.collectionId
|
||||
? onActiveCollection(record.collectionId)
|
||||
: undefined
|
||||
}
|
||||
if (activeCollectionId !== record.collectionId) {
|
||||
track.allDocs.header.navigation.navigatePinedCollectionRouter({
|
||||
control: 'user-custom-collection',
|
||||
});
|
||||
onActiveCollection(record.collectionId);
|
||||
}
|
||||
}}
|
||||
onClickRemove={() => {
|
||||
const nextCollectionId = pinnedCollections[index - 1]?.collectionId;
|
||||
if (nextCollectionId) {
|
||||
@@ -144,11 +153,12 @@ export const PinnedCollections = ({
|
||||
<IconButton
|
||||
size="16"
|
||||
className={styles.editIconButton}
|
||||
onClick={() =>
|
||||
onClick={() => {
|
||||
track.allDocs.header.collection.editCollection();
|
||||
workspaceDialogService.open('collection-editor', {
|
||||
collectionId: activeCollectionId,
|
||||
})
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
<EditIcon />
|
||||
</IconButton>
|
||||
@@ -228,6 +238,7 @@ export const AddPinnedCollectionMenuContent = ({
|
||||
prefixIcon={<CollectionsIcon />}
|
||||
suffixIcon={<PlusIcon />}
|
||||
onClick={() => {
|
||||
track.allDocs.header.collection.addPinnedCollection();
|
||||
onPinCollection(meta.id);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -10,6 +10,7 @@ import type { DocRecord } from '@affine/core/modules/doc';
|
||||
import { WorkbenchLink } from '@affine/core/modules/workbench';
|
||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import track from '@affine/track';
|
||||
import type { DocMode } from '@blocksuite/affine/model';
|
||||
import { ViewLayersIcon } from '@blocksuite/icons/rc';
|
||||
import { useLiveData, useServices } from '@toeverything/infra';
|
||||
@@ -31,6 +32,7 @@ export const CollectionListHeader = ({
|
||||
});
|
||||
|
||||
const handleEdit = useCallback(() => {
|
||||
track.collection.collection.$.editCollection();
|
||||
workspaceDialogService.open('collection-editor', {
|
||||
collectionId: collection.id,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user