diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue index cc56b9b053..7344ddc1e0 100644 --- a/components/publish/PublishWidget.vue +++ b/components/publish/PublishWidget.vue @@ -2,6 +2,8 @@ import { EditorContent } from '@tiptap/vue-3' import stringLength from 'string-length' import type { mastodon } from 'masto' +import { engagement } from '~~/telemetry/generated/ui' +import { engagementDetails } from '~~/telemetry/engagementDetails' import type { Draft } from '~/types' const { @@ -10,6 +12,7 @@ const { expanded = false, placeholder, dialogLabelledBy, + feedName, } = defineProps<{ draftKey?: string initial?: () => Draft @@ -18,6 +21,7 @@ const { inReplyToVisibility?: mastodon.v1.StatusVisibility expanded?: boolean dialogLabelledBy?: string + feedName?: string }>() const emit = defineEmits<{ @@ -170,9 +174,21 @@ async function toggleSensitive() { } async function publish() { + const isEditing = draft.editingStatus // need to save this before publishDraft const status = await publishDraft() - if (status) + if (status) { + const analyticsId = isEditing + ? 'post.edit' + : draft.params.inReplyToId + ? 'post.reply' + : feedName ? `${feedName}.post.create` : 'post.create' + engagement.record({ + ui_identifier: analyticsId, + mastodon_status_id: status.id, + ...engagementDetails[analyticsId], + }) emit('published', status) + } } useWebShareTarget(async ({ data: { data, action } }: any) => { diff --git a/components/publish/PublishWidgetFull.client.vue b/components/publish/PublishWidgetFull.client.vue index f70198c12d..8661195e59 100644 --- a/components/publish/PublishWidgetFull.client.vue +++ b/components/publish/PublishWidgetFull.client.vue @@ -64,7 +64,7 @@ onDeactivated(() => {