Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat(core): add journal navigation tracking (#8046)

pengx171cac2f6ccd28
diff --git a/packages/frontend/core/src/components/affine/reference-link/index.tsx b/packages/frontend/core/src/components/affine/reference-link/index.tsx
index 977635702d..bdf09246f1 100644
--- a/packages/frontend/core/src/components/affine/reference-link/index.tsx
+++ b/packages/frontend/core/src/components/affine/reference-link/index.tsx
@@ -1,5 +1,6 @@
import { useDocMetaHelper } from '@affine/core/hooks/use-block-suite-page-meta';
import { useJournalHelper } from '@affine/core/hooks/use-journal';
+import { track } from '@affine/core/mixpanel';
import {
PeekViewService,
useInsidePeekView,
@@ -123,9 +124,16 @@ export function AffinePageReference({
const peekView = useService(PeekViewService).peekView;
const isInPeekView = useInsidePeekView();
+ const isJournal = journalHelper.isPageJournal(pageId);
const onClick = useCallback(
(e: React.MouseEvent) => {
+ if (isJournal) {
+ track.doc.editor.pageRef.navigate({
+ to: 'journal',
+ });
+ }
+
if (e.shiftKey && ref.current) {
e.preventDefault();
e.stopPropagation();
@@ -141,7 +149,7 @@ export function AffinePageReference({
return;
},
- [isInPeekView, peekView]
+ [isInPeekView, isJournal, peekView]
);
const query = useMemo(() => {
diff --git a/packages/frontend/core/src/hooks/use-journal.ts b/packages/frontend/core/src/hooks/use-journal.ts
index 3bd7f07b59..9125e6a082 100644
--- a/packages/frontend/core/src/hooks/use-journal.ts
+++ b/packages/frontend/core/src/hooks/use-journal.ts
@@ -3,6 +3,7 @@ import { DocsService, initEmptyPage, useService } from '@toeverything/infra';
import dayjs from 'dayjs';
import { useCallback, useMemo } from 'react';
+import { track } from '../mixpanel';
import { WorkbenchService } from '../modules/workbench';
import type { DocCollection } from '../shared';
import { useCurrentWorkspacePropertiesAdapter } from './use-affine-adapter';
@@ -164,6 +165,9 @@ export const useJournalRouteHelper = (docCollection: DocCollection) => {
workbench.openDoc(page.id, {
at: newTab ? 'new-tab' : 'active',
});
+ track.$.navigationPanel.journal.navigate({
+ to: 'journal',
+ });
return page.id;
},
[getJournalByDate, workbench]
diff --git a/packages/frontend/core/src/mixpanel/events.ts b/packages/frontend/core/src/mixpanel/events.ts
index b7ef65e231..d06cc18bb0 100644
--- a/packages/frontend/core/src/mixpanel/events.ts
+++ b/packages/frontend/core/src/mixpanel/events.ts
@@ -221,6 +221,7 @@ const PageEvents = {
'openSettings',
],
profileAndBadge: ['openSettings'],
+ journal: ['navigate'],
},
aiOnboarding: {
dialog: ['viewPlans'],
@@ -263,6 +264,7 @@ const PageEvents = {
slashMenu: ['linkDoc', 'createDoc'],
atMenu: ['linkDoc'],
formatToolbar: ['bold'],
+ pageRef: ['navigate'],
},
inlineDocInfo: {
$: ['toggle'],