feat(core): workspace embedding tracking (#12409)

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

- **New Features**
  - Added event tracking for workspace embedding settings, including toggling embedding, uploading attachments, and selecting ignored documents. This enhances visibility into user interactions within the embedding settings panel.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
yoyoyohamapi
2025-05-21 06:50:09 +00:00
parent 6029c4d09b
commit 8038ab97e6
2 changed files with 45 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import {
import { Upload } from '@affine/core/components/pure/file-upload';
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
import { useI18n } from '@affine/i18n';
import track from '@affine/track';
import { useLiveData, useService } from '@toeverything/infra';
import type React from 'react';
import { useCallback, useEffect, useMemo } from 'react';
@@ -43,6 +44,11 @@ export const EmbeddingSettings: React.FC<EmbeddingSettingsProps> = () => {
const handleEmbeddingToggle = useCallback(
(checked: boolean) => {
track.$.settingsPanel.indexerEmbedding.toggleWorkspaceEmbedding({
type: 'Embedding',
control: 'Workspace embedding',
option: checked ? 'on' : 'off',
});
embeddingService.embedding.setEnabled(checked);
},
[embeddingService.embedding]
@@ -50,6 +56,11 @@ export const EmbeddingSettings: React.FC<EmbeddingSettingsProps> = () => {
const handleAttachmentUpload = useCallback(
(file: File) => {
track.$.settingsPanel.indexerEmbedding.addAdditionalDocs({
type: 'Embedding',
control: 'Select doc',
docType: file.type,
});
embeddingService.embedding.addAttachments([file]);
},
[embeddingService.embedding]
@@ -86,6 +97,11 @@ export const EmbeddingSettings: React.FC<EmbeddingSettingsProps> = () => {
if (selectedIds === undefined) {
return;
}
track.$.settingsPanel.indexerEmbedding.addIgnoredDocs({
type: 'Embedding',
control: 'Additional docs',
result: 'success',
});
const add = selectedIds.filter(id => !initialIds?.includes(id));
const remove = initialIds?.filter(id => !selectedIds.includes(id));
embeddingService.embedding.updateIgnoredDocs({ add, remove });

View File

@@ -182,6 +182,13 @@ type MeetingEvents =
type MentionEvents = 'mentionMember' | 'noAccessPrompted';
// END SECTION
// SECTION: workspace embedding
type WorkspaceEmbeddingEvents =
| 'toggleWorkspaceEmbedding'
| 'addAdditionalDocs'
| 'addIgnoredDocs';
// END SECTION
type UserEvents =
| GeneralEvents
| AppEvents
@@ -204,7 +211,8 @@ type UserEvents =
| NotificationEvents
| IntegrationEvents
| MeetingEvents
| MentionEvents;
| MentionEvents
| WorkspaceEmbeddingEvents;
interface PageDivision {
[page: string]: {
@@ -283,6 +291,11 @@ interface PageEvents extends PageDivision {
'completeIntegrationImport',
];
meetings: ['toggleMeetingFeatureFlag'];
indexerEmbedding: [
'toggleWorkspaceEmbedding',
'addAdditionalDocs',
'addIgnoredDocs',
];
};
cmdk: {
recent: ['recentDocs'];
@@ -724,6 +737,21 @@ export type EventArgs = {
time: number;
success: boolean;
};
toggleWorkspaceEmbedding: {
type: 'Embedding';
control: 'Workspace embedding';
option: 'on' | 'off';
};
addAdditionalDocs: {
type: 'Embedding';
control: 'Select doc';
docType: string;
};
addIgnoredDocs: {
type: 'Embedding';
control: 'Additional docs';
result: 'success' | 'failure';
};
};
// for type checking