mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 21:48:48 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
type OrderType = 'desc' | 'asc';
|
||||
export type WithParams<Map, T> = { [K in keyof Map]: Map[K] & T };
|
||||
export type SortParams = {
|
||||
fieldId: string;
|
||||
fieldType: string;
|
||||
orderType: OrderType;
|
||||
orderIndex: number;
|
||||
};
|
||||
export type ViewParams = {
|
||||
viewId: string;
|
||||
viewType: string;
|
||||
};
|
||||
export type DatabaseParams = {
|
||||
blockId: string;
|
||||
};
|
||||
|
||||
export type DatabaseViewEvents = {
|
||||
DatabaseSortClear: {
|
||||
rulesCount: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type DatabaseEvents = {
|
||||
AddDatabase: {};
|
||||
};
|
||||
|
||||
export interface DatabaseAllSortEvents {
|
||||
DatabaseSortAdd: {};
|
||||
DatabaseSortRemove: {};
|
||||
DatabaseSortModify: {
|
||||
oldOrderType: OrderType;
|
||||
oldFieldType: string;
|
||||
oldFieldId: string;
|
||||
};
|
||||
DatabaseSortReorder: {
|
||||
prevFieldType: string;
|
||||
nextFieldType: string;
|
||||
newOrderIndex: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type DatabaseAllViewEvents = DatabaseViewEvents &
|
||||
WithParams<DatabaseAllSortEvents, SortParams>;
|
||||
|
||||
export type DatabaseAllEvents = DatabaseEvents &
|
||||
WithParams<DatabaseAllViewEvents, ViewParams>;
|
||||
|
||||
export type OutDatabaseAllEvents = WithParams<
|
||||
DatabaseAllEvents,
|
||||
DatabaseParams
|
||||
>;
|
||||
|
||||
export type EventTraceFn<Events> = <K extends keyof Events>(
|
||||
key: K,
|
||||
params: Events[K]
|
||||
) => void;
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from './database.js';
|
||||
export * from './link.js';
|
||||
export * from './telemetry-service.js';
|
||||
export * from './types.js';
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { TelemetryEvent } from './types.js';
|
||||
|
||||
export type LinkEventType =
|
||||
| 'CopiedLink'
|
||||
| 'OpenedAliasPopup'
|
||||
| 'SavedAlias'
|
||||
| 'ResetedAlias'
|
||||
| 'OpenedViewSelector'
|
||||
| 'SelectedView'
|
||||
| 'OpenedCaptionEditor'
|
||||
| 'OpenedCardStyleSelector'
|
||||
| 'SelectedCardStyle'
|
||||
| 'OpenedCardScaleSelector'
|
||||
| 'SelectedCardScale';
|
||||
|
||||
export type LinkToolbarEvents = Record<LinkEventType, TelemetryEvent>;
|
||||
@@ -0,0 +1,35 @@
|
||||
import { createIdentifier } from '@blocksuite/global/di';
|
||||
|
||||
import type { OutDatabaseAllEvents } from './database.js';
|
||||
import type { LinkToolbarEvents } from './link.js';
|
||||
import type {
|
||||
AttachmentUploadedEvent,
|
||||
DocCreatedEvent,
|
||||
ElementCreationEvent,
|
||||
ElementLockEvent,
|
||||
MindMapCollapseEvent,
|
||||
TelemetryEvent,
|
||||
} from './types.js';
|
||||
|
||||
export type TelemetryEventMap = OutDatabaseAllEvents &
|
||||
LinkToolbarEvents & {
|
||||
DocCreated: DocCreatedEvent;
|
||||
Link: TelemetryEvent;
|
||||
LinkedDocCreated: TelemetryEvent;
|
||||
SplitNote: TelemetryEvent;
|
||||
CanvasElementAdded: ElementCreationEvent;
|
||||
EdgelessElementLocked: ElementLockEvent;
|
||||
ExpandedAndCollapsed: MindMapCollapseEvent;
|
||||
AttachmentUploadedEvent: AttachmentUploadedEvent;
|
||||
};
|
||||
|
||||
export interface TelemetryService {
|
||||
track<T extends keyof TelemetryEventMap>(
|
||||
eventName: T,
|
||||
props: TelemetryEventMap[T]
|
||||
): void;
|
||||
}
|
||||
|
||||
export const TelemetryProvider = createIdentifier<TelemetryService>(
|
||||
'AffineTelemetryService'
|
||||
);
|
||||
@@ -0,0 +1,63 @@
|
||||
export type ElementCreationSource =
|
||||
| 'shortcut'
|
||||
| 'toolbar:general'
|
||||
| 'toolbar:dnd'
|
||||
| 'canvas:drop'
|
||||
| 'canvas:draw'
|
||||
| 'canvas:dbclick'
|
||||
| 'canvas:paste'
|
||||
| 'context-menu'
|
||||
| 'ai'
|
||||
| 'internal'
|
||||
| 'conversation'
|
||||
| 'manually save';
|
||||
|
||||
export interface TelemetryEvent {
|
||||
page?: string;
|
||||
segment?: string;
|
||||
module?: string;
|
||||
control?: string;
|
||||
type?: string;
|
||||
category?: string;
|
||||
other?: unknown;
|
||||
}
|
||||
|
||||
export interface DocCreatedEvent extends TelemetryEvent {
|
||||
page?: 'doc editor' | 'whiteboard editor';
|
||||
segment?: 'whiteboard' | 'note' | 'doc';
|
||||
module?:
|
||||
| 'slash commands'
|
||||
| 'format toolbar'
|
||||
| 'edgeless toolbar'
|
||||
| 'inline @';
|
||||
category?: 'page' | 'whiteboard';
|
||||
}
|
||||
|
||||
export interface ElementCreationEvent extends TelemetryEvent {
|
||||
segment?: 'toolbar' | 'whiteboard' | 'right sidebar';
|
||||
page?: 'doc editor' | 'whiteboard editor';
|
||||
module?: 'toolbar' | 'canvas' | 'ai chat panel';
|
||||
control?: ElementCreationSource;
|
||||
}
|
||||
|
||||
export interface ElementLockEvent extends TelemetryEvent {
|
||||
page: 'whiteboard editor';
|
||||
segment: 'element toolbar';
|
||||
module: 'element toolbar';
|
||||
control: 'lock' | 'unlock' | 'group-lock';
|
||||
}
|
||||
|
||||
export interface MindMapCollapseEvent extends TelemetryEvent {
|
||||
page: 'whiteboard editor';
|
||||
segment: 'mind map';
|
||||
type: 'expand' | 'collapse';
|
||||
}
|
||||
|
||||
export interface AttachmentUploadedEvent extends TelemetryEvent {
|
||||
page: 'doc editor' | 'whiteboard editor';
|
||||
segment: 'attachment';
|
||||
module: 'attachment';
|
||||
control: 'uploader';
|
||||
type: string; // file type
|
||||
category: 'success' | 'failure';
|
||||
}
|
||||
Reference in New Issue
Block a user