Files
AFFiNE-Mirror/blocksuite/affine/shared/src/services/telemetry-service/telemetry-service.ts
Flrande f610d7b8af chore(editor): add event track for html preview (#12592)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Enhanced tracking for code block interactions, including language selection and preview toggling.
  - Improved error reporting for HTML block preview failures, providing better visibility into issues.
- **Bug Fixes**
  - Added explicit feedback and tracking when cross-origin isolation is not supported during code block preview setup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 10:08:19 +00:00

71 lines
2.0 KiB
TypeScript

import { createIdentifier } from '@blocksuite/global/di';
import type { ExtensionType } from '@blocksuite/store';
import type { CodeBlockEvents } from './code-block.js';
import type { OutDatabaseAllEvents } from './database.js';
import type { LinkToolbarEvents } from './link.js';
import type { NoteEvents } from './note.js';
import type { SlashMenuEvents } from './slash-menu.js';
import type {
AttachmentReloadedEvent,
AttachmentReloadedEventInToolbar,
AttachmentUpgradedEvent,
AttachmentUploadedEvent,
BlockCreationEvent,
DocCreatedEvent,
EdgelessToolPickedEvent,
ElementCreationEvent,
ElementLockEvent,
ElementUpdatedEvent,
LatexEvent,
LinkedDocCreatedEvent,
LinkEvent,
MindMapCollapseEvent,
TelemetryEvent,
} from './types.js';
export type TelemetryEventMap = OutDatabaseAllEvents &
LinkToolbarEvents &
SlashMenuEvents &
CodeBlockEvents &
NoteEvents & {
DocCreated: DocCreatedEvent;
Link: TelemetryEvent;
LinkedDocCreated: LinkedDocCreatedEvent;
SplitNote: TelemetryEvent;
CanvasElementAdded: ElementCreationEvent;
CanvasElementUpdated: ElementUpdatedEvent;
EdgelessElementLocked: ElementLockEvent;
ExpandedAndCollapsed: MindMapCollapseEvent;
AttachmentReloadedEvent:
| AttachmentReloadedEvent
| AttachmentReloadedEventInToolbar;
AttachmentUpgradedEvent: AttachmentUpgradedEvent;
AttachmentUploadedEvent: AttachmentUploadedEvent;
BlockCreated: BlockCreationEvent;
EdgelessToolPicked: EdgelessToolPickedEvent;
CreateEmbedBlock: LinkEvent;
Latex: LatexEvent;
};
export interface TelemetryService {
track<T extends keyof TelemetryEventMap>(
eventName: T,
props: TelemetryEventMap[T]
): void;
}
export const TelemetryProvider = createIdentifier<TelemetryService>(
'AffineTelemetryService'
);
export const TelemetryExtension = (
service: TelemetryService
): ExtensionType => {
return {
setup: di => {
di.override(TelemetryProvider, () => service);
},
};
};