chore(electron): split view tracking events (#9896)

fix AF-2037
This commit is contained in:
pengx17
2025-01-27 02:40:08 +00:00
parent d6bfb761fe
commit a5c8356376
4 changed files with 62 additions and 7 deletions

View File

@@ -16,6 +16,7 @@ import { RecentDocsService } from '@affine/core/modules/quicksearch';
import { ViewService } from '@affine/core/modules/workbench';
import { WorkspaceService } from '@affine/core/modules/workspace';
import { isNewTabTrigger } from '@affine/core/utils';
import track from '@affine/track';
import { RefNodeSlotsProvider } from '@blocksuite/affine/blocks';
import {
type Disposable,
@@ -190,6 +191,15 @@ const DetailPageImpl = memo(function DetailPageImpl() {
event && isNewTabTrigger(event)
? 'open-in-new-tab'
: 'open-in-active-view';
if (openMode === 'open-in-new-view') {
track.doc.editor.toolbar.openInSplitView();
} else if (openMode === 'open-in-center-peek') {
track.doc.editor.toolbar.openInPeekView();
} else if (openMode === 'open-in-new-tab') {
track.doc.editor.toolbar.openInNewTab();
}
if (openMode !== 'open-in-center-peek') {
const at = (() => {
if (openMode === 'open-in-active-view') {

View File

@@ -7,6 +7,7 @@ import {
} from '@affine/component';
import type { AffineDNDData } from '@affine/core/types/dnd';
import { useI18n } from '@affine/i18n';
import track from '@affine/track';
import {
CloseIcon,
ExpandFullIcon,
@@ -183,6 +184,10 @@ export const SplitViewPanel = memo(function SplitViewPanel({
}
setDraggingView(null);
setDraggingOverView(null);
track.$.splitViewIndicator.$.splitViewAction({
control: 'indicator',
action: 'move',
});
},
onDragStart() {
setDraggingView({
@@ -292,18 +297,33 @@ const SplitViewMenu = ({
const viewIndex = views.findIndex(v => v === view);
const handleClose = useCallback(
() => workbench.close(view),
[view, workbench]
);
const handleClose = useCallback(() => {
workbench.close(view);
track.$.splitViewIndicator.$.splitViewAction({
control: 'menu',
action: 'close',
});
}, [view, workbench]);
const handleMoveLeft = useCallback(() => {
onMove(viewIndex, viewIndex - 1);
track.$.splitViewIndicator.$.splitViewAction({
control: 'menu',
action: 'move',
});
}, [onMove, viewIndex]);
const handleMoveRight = useCallback(() => {
onMove(viewIndex, viewIndex + 1);
track.$.splitViewIndicator.$.splitViewAction({
control: 'menu',
action: 'move',
});
}, [onMove, viewIndex]);
const handleCloseOthers = useCallback(() => {
workbench.closeOthers(view);
track.$.splitViewIndicator.$.splitViewAction({
control: 'menu',
action: 'closeOthers',
});
}, [view, workbench]);
const CloseItem =

View File

@@ -1,6 +1,7 @@
import { useDndMonitor } from '@affine/component';
import { useAppSettingHelper } from '@affine/core/components/hooks/affine/use-app-setting-helper';
import type { AffineDNDData } from '@affine/core/types/dnd';
import track from '@affine/track';
import { useService } from '@toeverything/infra';
import clsx from 'clsx';
import { useSetAtom } from 'jotai';
@@ -121,7 +122,10 @@ export const SplitView = ({
const entity = data.source.data.entity;
const from = data.source.data.from;
if (dropTarget?.at === 'workbench:resize-handle') {
if (
dropTarget?.at === 'workbench:resize-handle' &&
entity?.type !== 'custom-property'
) {
const { edge, viewId } = dropTarget;
const index = views.findIndex(v => v.id === viewId);
const at = (() => {
@@ -148,6 +152,10 @@ export const SplitView = ({
if (to) {
workbench.createView(at, to);
track.$.splitViewIndicator.$.openInSplitView({
type: entity?.type,
route: to,
});
}
}
},