From 713a423dc181d7b37c520e35e5519e180741f8cd Mon Sep 17 00:00:00 2001 From: Joseph Perez Date: Tue, 31 Oct 2023 23:38:02 -0700 Subject: [PATCH 1/2] fix(publish): post creation events --- components/publish/PublishWidget.vue | 13 ++++++++++++- components/publish/PublishWidgetFull.client.vue | 2 +- components/timeline/TimelineHome.vue | 2 +- telemetry/engagementDetails.ts | 12 ++++++++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue index cc56b9b053..a8abd62eec 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<{ @@ -171,8 +175,15 @@ async function toggleSensitive() { async function publish() { const status = await publishDraft() - if (status) + if (status) { + const analyticsId = 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(() => {
- +
diff --git a/components/timeline/TimelineHome.vue b/components/timeline/TimelineHome.vue index 05cff3225f..3c5963185f 100644 --- a/components/timeline/TimelineHome.vue +++ b/components/timeline/TimelineHome.vue @@ -17,7 +17,7 @@ function onPublish(status) { diff --git a/telemetry/engagementDetails.ts b/telemetry/engagementDetails.ts index bafb1c5626..67ebddd615 100644 --- a/telemetry/engagementDetails.ts +++ b/telemetry/engagementDetails.ts @@ -35,5 +35,17 @@ export const engagementDetails: EngagementDetails = { 'nav.login': { engagement_type: 'general', }, + 'home.post.create': { + engagement_type: 'post', + }, + 'post.create': { + engagement_type: 'post', + }, + 'post.edit': { + engagement_type: 'post', + }, + 'post.reply': { + engagement_type: 'post', + }, ...profileEvents, } From f7316bde3ad12742a9597b8233d5b3795fb1a60e Mon Sep 17 00:00:00 2001 From: Joseph Perez Date: Tue, 31 Oct 2023 23:47:12 -0700 Subject: [PATCH 2/2] fix(publish): edit and reply --- components/publish/PublishWidget.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/publish/PublishWidget.vue b/components/publish/PublishWidget.vue index a8abd62eec..7344ddc1e0 100644 --- a/components/publish/PublishWidget.vue +++ b/components/publish/PublishWidget.vue @@ -174,9 +174,14 @@ async function toggleSensitive() { } async function publish() { + const isEditing = draft.editingStatus // need to save this before publishDraft const status = await publishDraft() if (status) { - const analyticsId = feedName ? `${feedName}.post.create` : 'post.create' + 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,