feat(editor): track citation events (#12664)

Closes: [BS-3551](https://linear.app/affine-design/issue/BS-3551/citation埋点)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Enhanced citation tracking across attachments, bookmarks, embedded documents, paragraphs, footnotes, rename modals, and toolbars for actions like editing, deleting, expanding, and hovering on citations.
  - Introduced a centralized citation service to unify citation detection and telemetry event management.
- **Chores**
  - Updated service exports and telemetry modules to include the new citation service and citation-related event types.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
donteatfriedrice
2025-06-05 03:09:24 +00:00
parent 053efb61f0
commit 1bdccdbd57
14 changed files with 249 additions and 11 deletions

View File

@@ -51,6 +51,7 @@ import { getSelectedModelsCommand } from '@blocksuite/affine/shared/commands';
import { ImageSelection } from '@blocksuite/affine/shared/selection';
import {
ActionPlacement,
CitationProvider,
GenerateDocUrlProvider,
isRemovedUserInfo,
OpenDocExtensionIdentifier,
@@ -462,6 +463,10 @@ function createExternalLinkableToolbarConfig(
(_std, _component, props) => {
ctx.store.updateBlock(model, props);
block.requestUpdate();
const citationService = ctx.std.get(CitationProvider);
if (citationService.isCitationModel(model)) {
citationService.trackEvent('Edit');
}
},
abortController
);
@@ -805,6 +810,10 @@ const embedLinkedDocToolbarConfig = {
(_std, _component, props) => {
ctx.store.updateBlock(model, props);
block.requestUpdate();
const citationService = ctx.std.get(CitationProvider);
if (citationService.isCitationModel(model)) {
citationService.trackEvent('Edit');
}
},
abortController
);