feat(editor): add block creation tracking (#10294)

fix: PD-2090
This commit is contained in:
zzj3720
2025-02-20 02:25:28 +00:00
parent a0e3f9909c
commit ba91b36cc3
3 changed files with 19 additions and 4 deletions
@@ -5,6 +5,7 @@ import type { LinkToolbarEvents } from './link.js';
import type { NoteEvents } from './note.js';
import type {
AttachmentUploadedEvent,
BlockCreationEvent,
DocCreatedEvent,
ElementCreationEvent,
ElementLockEvent,
@@ -24,6 +25,7 @@ export type TelemetryEventMap = OutDatabaseAllEvents &
EdgelessElementLocked: ElementLockEvent;
ExpandedAndCollapsed: MindMapCollapseEvent;
AttachmentUploadedEvent: AttachmentUploadedEvent;
BlockCreated: BlockCreationEvent;
};
export interface TelemetryService {
@@ -51,6 +51,10 @@ export interface ElementLockEvent extends TelemetryEvent {
control: 'lock' | 'unlock' | 'group-lock';
}
export interface BlockCreationEvent extends TelemetryEvent {
blockType: string;
}
export interface MindMapCollapseEvent extends TelemetryEvent {
page: 'whiteboard editor';
segment: 'mind map';
@@ -274,6 +274,15 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
place: 'after',
removeEmptyLine: true,
})
.pipe(({ insertedTableBlockId }) => {
if (insertedTableBlockId) {
const telemetry =
rootComponent.std.getOptional(TelemetryProvider);
telemetry?.track('BlockCreated', {
blockType: 'affine:table',
});
}
})
.run();
},
},
@@ -612,8 +621,8 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
if (insertedDatabaseBlockId) {
const telemetry =
rootComponent.std.getOptional(TelemetryProvider);
telemetry?.track('AddDatabase', {
blockId: insertedDatabaseBlockId,
telemetry?.track('BlockCreated', {
blockType: 'affine:database',
});
}
})
@@ -675,8 +684,8 @@ export const defaultSlashMenuConfig: SlashMenuConfig = {
if (insertedDatabaseBlockId) {
const telemetry =
rootComponent.std.getOptional(TelemetryProvider);
telemetry?.track('AddDatabase', {
blockId: insertedDatabaseBlockId,
telemetry?.track('BlockCreated', {
blockType: 'affine:database',
});
}
})