Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

fix(post): post creation interactions [MOSOWEB-46] #76

Merged
merged 5 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion components/publish/PublishWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -10,6 +12,7 @@ const {
expanded = false,
placeholder,
dialogLabelledBy,
feedName,
} = defineProps<{
draftKey?: string
initial?: () => Draft
Expand All @@ -18,6 +21,7 @@ const {
inReplyToVisibility?: mastodon.v1.StatusVisibility
expanded?: boolean
dialogLabelledBy?: string
feedName?: string
}>()

const emit = defineEmits<{
Expand Down Expand Up @@ -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'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This nested ternary makes me sad but I get the necessity of it

engagement.record({
ui_identifier: analyticsId,
mastodon_status_id: status.id,
...engagementDetails[analyticsId],
})
emit('published', status)
}
}

useWebShareTarget(async ({ data: { data, action } }: any) => {
Expand Down
2 changes: 1 addition & 1 deletion components/publish/PublishWidgetFull.client.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ onDeactivated(() => {
</VDropdown>
</div>
<div>
<PublishWidget :key="draftKey" expanded class="min-h-100!" :draft-key="draftKey" @published="onPublish" />
<PublishWidget :key="draftKey" expanded class="min-h-100!" :draft-key="draftKey" feed-name="" @published="onPublish" />
</div>
</div>
</template>
2 changes: 1 addition & 1 deletion components/timeline/TimelineHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function onPublish(status) {

<template>
<div>
<PublishWidget draft-key="home" border="b base" @published="onPublish" />
<PublishWidget draft-key="home" border="b base" feed-name="home" @published="onPublish" />
<TimelinePaginator ref="homePaginator" v-bind="{ paginator, stream }" :preprocess="reorderAndFilter" context="home" />
</div>
</template>
12 changes: 12 additions & 0 deletions telemetry/engagementDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ 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',
},
...postEvents,
...profileEvents,
}
Loading