mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-07 01:09:54 +08:00
chore(editor): add event tracking to highlighter tool (#11232)
Closes: [BS-2947](https://linear.app/affine-design/issue/BS-2947/埋点相关)
This commit is contained in:
@@ -154,14 +154,6 @@ export class HighlighterTool extends BaseTool {
|
|||||||
points,
|
points,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.std.getOptional(TelemetryProvider)?.track('CanvasElementAdded', {
|
|
||||||
control: 'canvas:draw',
|
|
||||||
page: 'whiteboard editor',
|
|
||||||
module: 'toolbar',
|
|
||||||
segment: 'toolbar',
|
|
||||||
type: CanvasElementType.HIGHLIGHTER,
|
|
||||||
});
|
|
||||||
|
|
||||||
const element = this.gfx.getElementById(id) as HighlighterElementModel;
|
const element = this.gfx.getElementById(id) as HighlighterElementModel;
|
||||||
|
|
||||||
element.stash('points');
|
element.stash('points');
|
||||||
@@ -174,6 +166,16 @@ export class HighlighterTool extends BaseTool {
|
|||||||
this._draggingPathPressures = [e.pressure];
|
this._draggingPathPressures = [e.pressure];
|
||||||
this._lastPopLength = 0;
|
this._lastPopLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override activate() {
|
||||||
|
this.std.getOptional(TelemetryProvider)?.track('EdgelessToolPicked', {
|
||||||
|
page: 'whiteboard editor',
|
||||||
|
module: 'global toolbar',
|
||||||
|
segment: 'global toolbar',
|
||||||
|
control: 'drawing',
|
||||||
|
type: CanvasElementType.HIGHLIGHTER,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module '@blocksuite/block-std/gfx' {
|
declare module '@blocksuite/block-std/gfx' {
|
||||||
|
|||||||
@@ -23,6 +23,10 @@ import {
|
|||||||
import { BlockFlavourIdentifier } from '@blocksuite/block-std';
|
import { BlockFlavourIdentifier } from '@blocksuite/block-std';
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
|
|
||||||
|
const trackBaseProps = {
|
||||||
|
category: 'highlighter',
|
||||||
|
};
|
||||||
|
|
||||||
export const highlighterToolbarConfig = {
|
export const highlighterToolbarConfig = {
|
||||||
actions: [
|
actions: [
|
||||||
{
|
{
|
||||||
@@ -44,6 +48,11 @@ export const highlighterToolbarConfig = {
|
|||||||
.get(EdgelessCRUDIdentifier)
|
.get(EdgelessCRUDIdentifier)
|
||||||
.updateElement(model.id, { lineWidth });
|
.updateElement(model.id, { lineWidth });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx.track('CanvasElementUpdated', {
|
||||||
|
...trackBaseProps,
|
||||||
|
control: 'line width',
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
@@ -91,9 +100,16 @@ export const highlighterToolbarConfig = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isStartEvent = e.type === 'start';
|
||||||
for (const model of models) {
|
for (const model of models) {
|
||||||
model[e.type === 'start' ? 'stash' : 'pop'](field);
|
model[isStartEvent ? 'stash' : 'pop'](field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isStartEvent) return;
|
||||||
|
ctx.track('CanvasElementUpdated', {
|
||||||
|
...trackBaseProps,
|
||||||
|
control: 'color picker',
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import type {
|
|||||||
EdgelessToolPickedEvent,
|
EdgelessToolPickedEvent,
|
||||||
ElementCreationEvent,
|
ElementCreationEvent,
|
||||||
ElementLockEvent,
|
ElementLockEvent,
|
||||||
|
ElementUpdatedEvent,
|
||||||
LinkedDocCreatedEvent,
|
LinkedDocCreatedEvent,
|
||||||
MindMapCollapseEvent,
|
MindMapCollapseEvent,
|
||||||
TelemetryEvent,
|
TelemetryEvent,
|
||||||
@@ -23,6 +24,7 @@ export type TelemetryEventMap = OutDatabaseAllEvents &
|
|||||||
LinkedDocCreated: LinkedDocCreatedEvent;
|
LinkedDocCreated: LinkedDocCreatedEvent;
|
||||||
SplitNote: TelemetryEvent;
|
SplitNote: TelemetryEvent;
|
||||||
CanvasElementAdded: ElementCreationEvent;
|
CanvasElementAdded: ElementCreationEvent;
|
||||||
|
CanvasElementUpdated: ElementUpdatedEvent;
|
||||||
EdgelessElementLocked: ElementLockEvent;
|
EdgelessElementLocked: ElementLockEvent;
|
||||||
ExpandedAndCollapsed: MindMapCollapseEvent;
|
ExpandedAndCollapsed: MindMapCollapseEvent;
|
||||||
AttachmentUploadedEvent: AttachmentUploadedEvent;
|
AttachmentUploadedEvent: AttachmentUploadedEvent;
|
||||||
|
|||||||
@@ -75,5 +75,14 @@ export interface EdgelessToolPickedEvent extends TelemetryEvent {
|
|||||||
segment: 'global toolbar';
|
segment: 'global toolbar';
|
||||||
module: 'global toolbar';
|
module: 'global toolbar';
|
||||||
control: 'drawing';
|
control: 'drawing';
|
||||||
type: 'brush';
|
type: 'brush' | 'highlighter';
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ElementUpdatedEvent extends TelemetryEvent {
|
||||||
|
page: 'whiteboard editor';
|
||||||
|
segment: 'toolbar';
|
||||||
|
module: 'toolbar';
|
||||||
|
category: string;
|
||||||
|
control: string;
|
||||||
|
type?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user