chore(core): add event tracking for attachments (#9198)

Part of: [AF-1678](https://linear.app/affine-design/issue/AF-1678/添加埋点)
This commit is contained in:
fundon
2024-12-20 02:43:11 +00:00
parent 7ff24e9c1c
commit d7983c50e3
4 changed files with 74 additions and 18 deletions
@@ -17,6 +17,7 @@ import {
Scroller,
ScrollSeekPlaceholder,
} from '@affine/core/modules/pdf/views';
import track from '@affine/track';
import type { AttachmentBlockModel } from '@blocksuite/affine/blocks';
import { CollapseIcon, ExpandIcon } from '@blocksuite/icons/rc';
import { useLiveData, useService } from '@toeverything/infra';
@@ -202,6 +203,12 @@ const PDFViewerInner = ({ pdf, state }: PDFViewerInnerProps) => {
function PDFViewerStatus({ pdf }: { pdf: PDF }) {
const state = useLiveData(pdf.state$);
useEffect(() => {
if (state.status !== PDFStatus.Error) return;
track.$.attachment.$.openPDFRendererFail();
}, [state]);
if (state?.status !== PDFStatus.Opened) {
return <LoadingSvg />;
}