Skip to content

Commit 1cac2f6

Browse files
committed
feat(core): add journal navigation tracking (#8046)
fix AF-1314
1 parent 06552a1 commit 1cac2f6

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

packages/frontend/core/src/components/affine/reference-link/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
22
import { useJournalHelper } from '@affine/core/hooks/use-journal';
3+
import { track } from '@affine/core/mixpanel';
34
import {
45
PeekViewService,
56
useInsidePeekView,
@@ -123,9 +124,16 @@ export function AffinePageReference({
123124

124125
const peekView = useService(PeekViewService).peekView;
125126
const isInPeekView = useInsidePeekView();
127+
const isJournal = journalHelper.isPageJournal(pageId);
126128

127129
const onClick = useCallback(
128130
(e: React.MouseEvent) => {
131+
if (isJournal) {
132+
track.doc.editor.pageRef.navigate({
133+
to: 'journal',
134+
});
135+
}
136+
129137
if (e.shiftKey && ref.current) {
130138
e.preventDefault();
131139
e.stopPropagation();
@@ -141,7 +149,7 @@ export function AffinePageReference({
141149

142150
return;
143151
},
144-
[isInPeekView, peekView]
152+
[isInPeekView, isJournal, peekView]
145153
);
146154

147155
const query = useMemo(() => {

packages/frontend/core/src/hooks/use-journal.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DocsService, initEmptyPage, useService } from '@toeverything/infra';
33
import dayjs from 'dayjs';
44
import { useCallback, useMemo } from 'react';
55

6+
import { track } from '../mixpanel';
67
import { WorkbenchService } from '../modules/workbench';
78
import type { DocCollection } from '../shared';
89
import { useCurrentWorkspacePropertiesAdapter } from './use-affine-adapter';
@@ -164,6 +165,9 @@ export const useJournalRouteHelper = (docCollection: DocCollection) => {
164165
workbench.openDoc(page.id, {
165166
at: newTab ? 'new-tab' : 'active',
166167
});
168+
track.$.navigationPanel.journal.navigate({
169+
to: 'journal',
170+
});
167171
return page.id;
168172
},
169173
[getJournalByDate, workbench]

packages/frontend/core/src/mixpanel/events.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ const PageEvents = {
221221
'openSettings',
222222
],
223223
profileAndBadge: ['openSettings'],
224+
journal: ['navigate'],
224225
},
225226
aiOnboarding: {
226227
dialog: ['viewPlans'],
@@ -263,6 +264,7 @@ const PageEvents = {
263264
slashMenu: ['linkDoc', 'createDoc'],
264265
atMenu: ['linkDoc'],
265266
formatToolbar: ['bold'],
267+
pageRef: ['navigate'],
266268
},
267269
inlineDocInfo: {
268270
$: ['toggle'],

0 commit comments

Comments
 (0)