fix(editor): update embed iframe block event tracker (#11736)
Close [BS-3151](https://linear.app/affine-design/issue/BS-3151/埋一下-reload-link-成功失败)
This commit is contained in:
@@ -209,9 +209,9 @@ export class EmbedIframeErrorCard extends WithDisposable(LitElement) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly _handleRetry = (e: MouseEvent) => {
|
private readonly _handleRetry = async (e: MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.onRetry();
|
const success = await this.onRetry();
|
||||||
|
|
||||||
// track retry event
|
// track retry event
|
||||||
this.telemetryService?.track('ReloadLink', {
|
this.telemetryService?.track('ReloadLink', {
|
||||||
@@ -220,6 +220,7 @@ export class EmbedIframeErrorCard extends WithDisposable(LitElement) {
|
|||||||
segment: 'editor',
|
segment: 'editor',
|
||||||
module: 'embed block',
|
module: 'embed block',
|
||||||
control: 'reload button',
|
control: 'reload button',
|
||||||
|
result: success ? 'success' : 'failure',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -301,7 +302,7 @@ export class EmbedIframeErrorCard extends WithDisposable(LitElement) {
|
|||||||
accessor error: Error | null = null;
|
accessor error: Error | null = null;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor onRetry!: () => void;
|
accessor onRetry!: () => Promise<boolean>;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
accessor model!: EmbedIframeBlockModel;
|
accessor model!: EmbedIframeBlockModel;
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export class EmbedIframeLinkEditPopup extends SignalWatcher(
|
|||||||
segment: 'editor',
|
segment: 'editor',
|
||||||
module: 'embed block',
|
module: 'embed block',
|
||||||
control: 'edit button',
|
control: 'edit button',
|
||||||
other: status,
|
result: status,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ export class EmbedIframeLinkInputPopup extends EmbedIframeLinkInputBase {
|
|||||||
segment: this.options?.telemetrySegment ?? 'editor',
|
segment: this.options?.telemetrySegment ?? 'editor',
|
||||||
module: 'embed block',
|
module: 'embed block',
|
||||||
control: 'confirm embed link',
|
control: 'confirm embed link',
|
||||||
other: status,
|
result: status,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -299,12 +299,19 @@ export const builtinToolbarConfig = {
|
|||||||
icon: ResetIcon(),
|
icon: ResetIcon(),
|
||||||
run(ctx) {
|
run(ctx) {
|
||||||
const component = ctx.getCurrentBlockByType(EmbedIframeBlockComponent);
|
const component = ctx.getCurrentBlockByType(EmbedIframeBlockComponent);
|
||||||
component?.refreshData().catch(console.error);
|
component
|
||||||
|
?.refreshData()
|
||||||
ctx.track('ReloadLink', {
|
.then(success => {
|
||||||
...trackBaseProps,
|
ctx.track('ReloadLink', {
|
||||||
control: 'reload link',
|
type: 'embed iframe block',
|
||||||
});
|
page: 'doc editor',
|
||||||
|
segment: 'doc',
|
||||||
|
module: 'toolbar',
|
||||||
|
control: 'reload link',
|
||||||
|
result: success ? 'success' : 'failure',
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ export class EmbedIframeBlockComponent extends CaptionedBlockComponent<EmbedIfra
|
|||||||
const { url } = this.model.props;
|
const { url } = this.model.props;
|
||||||
if (!url) {
|
if (!url) {
|
||||||
this.status$.value = 'idle';
|
this.status$.value = 'idle';
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set loading status
|
// set loading status
|
||||||
@@ -188,11 +188,13 @@ export class EmbedIframeBlockComponent extends CaptionedBlockComponent<EmbedIfra
|
|||||||
|
|
||||||
// set success status
|
// set success status
|
||||||
this.status$.value = 'success';
|
this.status$.value = 'success';
|
||||||
|
return true;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// set error status
|
// set error status
|
||||||
this.status$.value = 'error';
|
this.status$.value = 'error';
|
||||||
this.error$.value = err instanceof Error ? err : new Error(String(err));
|
this.error$.value = err instanceof Error ? err : new Error(String(err));
|
||||||
console.error('Failed to refresh iframe data:', err);
|
console.error('Failed to refresh iframe data:', err);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -284,7 +286,7 @@ export class EmbedIframeBlockComponent extends CaptionedBlockComponent<EmbedIfra
|
|||||||
};
|
};
|
||||||
|
|
||||||
private readonly _handleRetry = async () => {
|
private readonly _handleRetry = async () => {
|
||||||
await this.refreshData();
|
return await this.refreshData();
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly _renderIframe = () => {
|
private readonly _renderIframe = () => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { TelemetryEvent } from './types.js';
|
import type { LinkEvent } from './types.js';
|
||||||
|
|
||||||
export type LinkEventType =
|
export type LinkEventType =
|
||||||
| 'CopiedLink'
|
| 'CopiedLink'
|
||||||
@@ -16,4 +16,4 @@ export type LinkEventType =
|
|||||||
| 'EditLink'
|
| 'EditLink'
|
||||||
| 'ReloadLink';
|
| 'ReloadLink';
|
||||||
|
|
||||||
export type LinkToolbarEvents = Record<LinkEventType, TelemetryEvent>;
|
export type LinkToolbarEvents = Record<LinkEventType, LinkEvent>;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import type {
|
|||||||
ElementLockEvent,
|
ElementLockEvent,
|
||||||
ElementUpdatedEvent,
|
ElementUpdatedEvent,
|
||||||
LinkedDocCreatedEvent,
|
LinkedDocCreatedEvent,
|
||||||
|
LinkEvent,
|
||||||
MindMapCollapseEvent,
|
MindMapCollapseEvent,
|
||||||
TelemetryEvent,
|
TelemetryEvent,
|
||||||
} from './types.js';
|
} from './types.js';
|
||||||
@@ -32,7 +33,7 @@ export type TelemetryEventMap = OutDatabaseAllEvents &
|
|||||||
AttachmentUploadedEvent: AttachmentUploadedEvent;
|
AttachmentUploadedEvent: AttachmentUploadedEvent;
|
||||||
BlockCreated: BlockCreationEvent;
|
BlockCreated: BlockCreationEvent;
|
||||||
EdgelessToolPicked: EdgelessToolPickedEvent;
|
EdgelessToolPicked: EdgelessToolPickedEvent;
|
||||||
CreateEmbedBlock: TelemetryEvent;
|
CreateEmbedBlock: LinkEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface TelemetryService {
|
export interface TelemetryService {
|
||||||
|
|||||||
@@ -86,3 +86,7 @@ export interface ElementUpdatedEvent extends TelemetryEvent {
|
|||||||
control: string;
|
control: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LinkEvent extends TelemetryEvent {
|
||||||
|
result?: 'success' | 'failure';
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user