feat(core): ai intelligence track (#13187)

Close [AI-335](https://linear.app/affine-design/issue/AI-335)

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

* **New Features**
* Added support for an "independent mode" and document-specific context
in AI chat components, allowing enhanced context handling and tracking.
* Introduced new tracking options to distinguish between current
document and general document actions in chat interactions.

* **Improvements**
* More flexible property handling for independent mode and document
context across chat-related components for consistent behavior and
tracking.
* Enhanced tracking system to support additional event categories and
methods for more granular analytics.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Wu Yue
2025-07-14 14:43:06 +08:00
committed by GitHub
parent d9e8ce802f
commit 65453c31c6
11 changed files with 56 additions and 22 deletions

View File

@@ -442,6 +442,9 @@ interface PageEvents extends PageDivision {
chatPanel: {
chatPanelInput: ['addEmbeddingDoc'];
};
intelligence: {
chatPanelInput: ['addEmbeddingDoc'];
};
commentPanel: {
$: ['createComment', 'editComment', 'deleteComment', 'resolveComment'];
};
@@ -720,7 +723,7 @@ export type EventArgs = {
addEmbeddingDoc: {
type?: 'page' | 'edgeless';
control: 'addButton' | 'atMenu';
method: 'doc' | 'file' | 'tags' | 'collections' | 'suggestion';
method: 'doc' | 'cur-doc' | 'file' | 'tags' | 'collections' | 'suggestion';
};
openAttachmentInFullscreen: AttachmentEventArgs;
openAttachmentInNewTab: AttachmentEventArgs;

View File

@@ -1,10 +1,10 @@
import { enableAutoTrack, makeTracker } from './auto';
import { type Events } from './events';
import { type EventArgs, type Events } from './events';
import { mixpanel } from './mixpanel';
import { sentry } from './sentry';
export const track = makeTracker((event, props) => {
mixpanel.track(event, props);
});
export { enableAutoTrack, type Events, mixpanel, sentry };
export { enableAutoTrack, type EventArgs, type Events, mixpanel, sentry };
export default track;