chore(editor): add track event for latex (#12541)

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

## Summary by CodeRabbit

- **New Features**
  - Enhanced telemetry tracking for LaTeX and equation creation actions, capturing detailed context such as editor mode and location within the app.
- **Chores**
  - Expanded telemetry event types to include LaTeX-specific actions for improved analytics and observability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Flrande
2025-05-26 11:10:32 +00:00
parent 9343e29fea
commit 5d28657d76
5 changed files with 105 additions and 14 deletions
@@ -1,3 +1,7 @@
import {
DocModeProvider,
TelemetryProvider,
} from '@blocksuite/affine-shared/services';
import type { Command, TextSelection } from '@blocksuite/std';
export const insertInlineLatex: Command<{
@@ -37,6 +41,21 @@ export const insertInlineLatex: Command<{
length: 1,
});
const mode = ctx.std.get(DocModeProvider).getEditorMode() ?? 'page';
const ifEdgelessText = blockComponent.closest('affine-edgeless-text');
ctx.std.getOptional(TelemetryProvider)?.track('Latex', {
from:
mode === 'page'
? 'doc'
: ifEdgelessText
? 'edgeless text'
: 'edgeless note',
page: mode === 'page' ? 'doc' : 'edgeless',
segment: mode === 'page' ? 'doc' : 'whiteboard',
module: 'inline equation',
control: 'create inline equation',
});
inlineEditor
.waitForUpdate()
.then(async () => {