mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 13:25:12 +00:00
chore(editor): add event track for html preview (#12592)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced tracking for code block interactions, including language selection and preview toggling. - Improved error reporting for HTML block preview failures, providing better visibility into issues. - **Bug Fixes** - Added explicit feedback and tracking when cross-origin isolation is not supported during code block preview setup. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import track from '@affine/track';
|
||||
import { CodeBlockPreviewExtension } from '@blocksuite/affine/blocks/code';
|
||||
import { SignalWatcher, WithDisposable } from '@blocksuite/affine/global/lit';
|
||||
import type { CodeBlockModel } from '@blocksuite/affine/model';
|
||||
@@ -87,7 +88,13 @@ export class HTMLPreview extends SignalWatcher(WithDisposable(LitElement)) {
|
||||
this.state = 'finish';
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Failed to link WebContainer:', error);
|
||||
const errorMessage = `Failed to link WebContainer: ${error}`;
|
||||
|
||||
console.error(errorMessage);
|
||||
track.doc.editor.codeBlock.htmlBlockPreviewFailed({
|
||||
type: errorMessage,
|
||||
});
|
||||
|
||||
this.state = 'error';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
|
||||
import track from '@affine/track';
|
||||
import {
|
||||
type ViewExtensionContext,
|
||||
ViewExtensionProvider,
|
||||
@@ -39,7 +40,13 @@ export class CodeBlockPreviewViewExtension extends ViewExtensionProvider {
|
||||
.value;
|
||||
if (!flag) return;
|
||||
|
||||
if (!window.crossOriginIsolated) return;
|
||||
if (!window.crossOriginIsolated) {
|
||||
track.doc.editor.codeBlock.htmlBlockPreviewFailed({
|
||||
type: 'cross-origin-isolated not supported',
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
context.register(CodeBlockHtmlPreview);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user