chore(editor): add tracking events to attachments (#12317)
Closes: [BS-3483](https://linear.app/affine-design/issue/BS-3483/event-tracking-loading-block)
This commit is contained in:
@@ -17,7 +17,9 @@ import {
|
||||
AttachmentBlockStyles,
|
||||
} from '@blocksuite/affine-model';
|
||||
import {
|
||||
DocModeProvider,
|
||||
FileSizeLimitProvider,
|
||||
TelemetryProvider,
|
||||
ThemeProvider,
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import { humanFileSize } from '@blocksuite/affine-shared/utils';
|
||||
@@ -187,6 +189,22 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
|
||||
@click=${(event: MouseEvent) => {
|
||||
event.stopPropagation();
|
||||
onOverFileSize?.();
|
||||
|
||||
{
|
||||
const mode =
|
||||
this.std.get(DocModeProvider).getEditorMode() ?? 'page';
|
||||
const segment = mode === 'page' ? 'doc' : 'whiteboard';
|
||||
this.std
|
||||
.getOptional(TelemetryProvider)
|
||||
?.track('AttachmentUpgradedEvent', {
|
||||
segment,
|
||||
page: `${segment} editor`,
|
||||
module: 'attachment',
|
||||
control: 'upgrade',
|
||||
category: 'card',
|
||||
type: this.model.props.name.split('.').pop() ?? '',
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
${UpgradeIcon()} Upgrade
|
||||
@@ -202,6 +220,22 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
|
||||
@click=${(event: MouseEvent) => {
|
||||
event.stopPropagation();
|
||||
this.refreshData();
|
||||
|
||||
{
|
||||
const mode =
|
||||
this.std.get(DocModeProvider).getEditorMode() ?? 'page';
|
||||
const segment = mode === 'page' ? 'doc' : 'whiteboard';
|
||||
this.std
|
||||
.getOptional(TelemetryProvider)
|
||||
?.track('AttachmentReloadedEvent', {
|
||||
segment,
|
||||
page: `${segment} editor`,
|
||||
module: 'attachment',
|
||||
control: 'reload',
|
||||
category: 'card',
|
||||
type: this.model.props.name.split('.').pop() ?? '',
|
||||
});
|
||||
}
|
||||
}}
|
||||
>
|
||||
${ResetIcon()} Reload
|
||||
|
||||
@@ -264,6 +264,12 @@ const builtinToolbarConfig = {
|
||||
run(ctx) {
|
||||
const block = ctx.getCurrentBlockByType(AttachmentBlockComponent);
|
||||
block?.reload();
|
||||
|
||||
ctx.track('AttachmentReloadedEvent', {
|
||||
...trackBaseProps,
|
||||
control: 'reload',
|
||||
type: block?.model.props.name.split('.').pop() ?? '',
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -130,7 +130,7 @@ async function buildPropsWith(
|
||||
std.getOptional(TelemetryProvider)?.track('AttachmentUploadedEvent', {
|
||||
page: `${mode} editor`,
|
||||
module: 'attachment',
|
||||
segment: 'attachment',
|
||||
segment: mode,
|
||||
control: 'uploader',
|
||||
type,
|
||||
category,
|
||||
|
||||
Reference in New Issue
Block a user