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 1, 2023
1 parent 333b6fd commit cf65167
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 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" 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',
},
...profileEvents,
...postEvents,
}
12 changes: 6 additions & 6 deletions telemetry/engagementPostEvents.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const postEvents = {
// Standalone post
'post.reply': {
'post.open-reply': {
engagement_type: 'reply',
},
'post.reblog': {
Expand All @@ -16,7 +16,7 @@ export const postEvents = {
engagement_type: 'general',
},
// Home feed
'home.feed.post.reply': {
'home.feed.post.open-reply': {
engagement_type: 'reply',
},
'home.feed.post.reblog': {
Expand All @@ -32,7 +32,7 @@ export const postEvents = {
engagement_type: 'general',
},
// Favorites feed
'favorites.feed.post.reply': {
'favorites.feed.post.open-reply': {
engagement_type: 'reply',
},
'favorites.feed.post.reblog': {
Expand All @@ -48,7 +48,7 @@ export const postEvents = {
engagement_type: 'general',
},
// Bookmarks feed
'bookmarks.feed.post.reply': {
'bookmarks.feed.post.open-reply': {
engagement_type: 'reply',
},
'bookmarks.feed.post.reblog': {
Expand All @@ -64,7 +64,7 @@ export const postEvents = {
engagement_type: 'general',
},
// Local feed
'local.feed.post.reply': {
'local.feed.post.open-reply': {
engagement_type: 'reply',
},
'local.feed.post.reblog': {
Expand All @@ -80,7 +80,7 @@ export const postEvents = {
engagement_type: 'general',
},
// Federated feed
'federated.feed.post.reply': {
'federated.feed.post.open-reply': {
engagement_type: 'reply',
},
'federated.feed.post.reblog': {
Expand Down

0 comments on commit cf65167

Please sign in to comment.