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

Commit

Permalink
fix(publish): post creation events
Browse files Browse the repository at this point in the history
  • Loading branch information
jpezninjo committed Nov 2, 2023
1 parent 0c395a2 commit 713a423
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
13 changes: 12 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 @@ -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) => {
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 @@ -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,
}

0 comments on commit 713a423

Please sign in to comment.