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

Commit

Permalink
Merge pull request #76 from MozillaSocial/fix/post-creation-interactions
Browse files Browse the repository at this point in the history
fix(post): post creation interactions [MOSOWEB-46]
  • Loading branch information
jpezninjo authored Nov 8, 2023
2 parents 9f4385a + 7662006 commit 23b5c2b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
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'
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" feed-name="home.feed" />
</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,
}

0 comments on commit 23b5c2b

Please sign in to comment.