diff --git a/blocksuite/affine/shared/src/services/telemetry-service/telemetry-service.ts b/blocksuite/affine/shared/src/services/telemetry-service/telemetry-service.ts index 24652b0c50..daafeba8e7 100644 --- a/blocksuite/affine/shared/src/services/telemetry-service/telemetry-service.ts +++ b/blocksuite/affine/shared/src/services/telemetry-service/telemetry-service.ts @@ -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 { diff --git a/blocksuite/affine/shared/src/services/telemetry-service/types.ts b/blocksuite/affine/shared/src/services/telemetry-service/types.ts index 69de843526..652a72b3e0 100644 --- a/blocksuite/affine/shared/src/services/telemetry-service/types.ts +++ b/blocksuite/affine/shared/src/services/telemetry-service/types.ts @@ -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'; diff --git a/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts b/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts index 062995e8f3..095e512f20 100644 --- a/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts +++ b/blocksuite/blocks/src/root-block/widgets/slash-menu/config.ts @@ -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', }); } })