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

fix(posts): Post Button interactions (Like, Boost, Respond, Share, Report) [MOSOWEB-44] #75

Merged
merged 24 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
d0b303d
fix(posts): analytics for home.feed.post.reply, good starting point
jpezninjo Oct 30, 2023
7aecd40
fix(posts): setup for standalone posts
jpezninjo Oct 30, 2023
034c76a
fix(posts): reblog
jpezninjo Oct 30, 2023
171056d
fix(posts): recordEngagement function
jpezninjo Oct 30, 2023
4ab3c49
fix(posts): favorite
jpezninjo Oct 30, 2023
32bb7b2
fix(posts): favorite
jpezninjo Oct 30, 2023
3472e20
fix(posts): mastodon_status_id
jpezninjo Oct 30, 2023
b44088e
fix(posts): engagement types for the 8 events so far, set up postEven…
jpezninjo Oct 30, 2023
82d4989
fix(posts): report
jpezninjo Oct 30, 2023
df64fbb
fix(posts): favorites feed
jpezninjo Oct 30, 2023
cc37101
fix(posts): bookmarks feed
jpezninjo Oct 31, 2023
86c6a98
fix(posts): local and federated feeds
jpezninjo Oct 31, 2023
e8a6aa1
fix(posts): whoops, missed engagement_type on bookmarks feed, favorit…
jpezninjo Oct 31, 2023
8538808
fix(posts): rename 'thing' to something actually appropriate
jpezninjo Oct 31, 2023
333b6fd
fix(posts): make feedName optional in StatusActionsMore
jpezninjo Oct 31, 2023
a77f933
fix(posts): update reply ui_identifier to avoid conflicting to actual…
jpezninjo Nov 2, 2023
e0b5ea7
fix(posts): make feedName for StatusCards option
jpezninjo Nov 7, 2023
4f190f3
fix(posts): feedname for account feed, make prop in TimelinePaginator…
jpezninjo Nov 7, 2023
39e3647
fix(posts): change post reply 'reply' to 'open-reply'
jpezninjo Nov 7, 2023
503c6ba
fix(posts): account feed events engagement_type's
jpezninjo Nov 7, 2023
ac60309
Merge branch 'main' into fix/posts-buttons-engagement-events
jpezninjo Nov 7, 2023
1b49549
fix(posts): do separate events for undo actions
jpezninjo Nov 7, 2023
f5e732d
fix(posts): bad merge
jpezninjo Nov 7, 2023
90acbfb
Merge branch 'main' into fix/posts-buttons-engagement-events
jpezninjo Nov 8, 2023
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
33 changes: 29 additions & 4 deletions components/status/StatusActions.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { engagement } from '~~/telemetry/generated/ui'
import { engagementDetails } from '~~/telemetry/engagementDetails'

const props = defineProps<{
status: mastodon.v1.Status
feedName?: string
Copy link
Author

Choose a reason for hiding this comment

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

optional prop bc used by StatusCard and StatusDetail

details?: boolean
command?: boolean
}>()

const focusEditor = inject<typeof noop>('focus-editor', noop)

const { details, command } = $(props)
const { details, command, feedName } = $(props)

const userSettings = useUserSettings()
const useStarFavoriteIcon = usePreferences('useStarFavoriteIcon')
Expand All @@ -23,14 +26,36 @@ const {
toggleReblog,
} = $(useStatusActions(props))

function recordEngagement(engagementAction: String) {
const analyticsId = feedName ? `${feedName}.post.${engagementAction}` : `post.${engagementAction}`
Copy link
Author

Choose a reason for hiding this comment

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

Kinda messy ternary. I am open to suggestions here.

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

function reply() {
recordEngagement('reply')

if (!checkLogin())
return
if (details)
focusEditor()
else
navigateToStatus({ status, focusReply: true })
}

function reblog() {
recordEngagement('reblog')
toggleReblog()
}
Copy link

@wtfluckey wtfluckey Nov 7, 2023

Choose a reason for hiding this comment

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

Do you know if data/product wants to have events for undoing a reblog, favorite or bookmark? Since these functions are toggles, if you un-reblog/favorite/bookmark something it just sends the same engagement event and I'm curious if anyone has mentioned wanting to have the false toggle cases tracked too

Copy link
Author

Choose a reason for hiding this comment

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

Me and Aly talked to Kirill. We are going to use separate ui_identifiers and for the "undo" actions, the engagement_type will be general


function favourite() {
Copy link
Author

@jpezninjo jpezninjo Oct 31, 2023

Choose a reason for hiding this comment

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

using the UK English version of "favorite" to match the called toggleFavourite, even though there's a useStarFavoriteIcon elsewhere in this file 😠

Choose a reason for hiding this comment

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

grumble grumble, i really dislike that these have been mixed throughout the entire repo but one problem at a time i suppose

recordEngagement('favorite')
toggleFavourite()
}

function bookmark() {
recordEngagement('bookmark')
toggleBookmark()
}
</script>

<template>
Expand Down Expand Up @@ -63,7 +88,7 @@ function reply() {
:active="!!status.reblogged"
:disabled="isLoading.reblogged || !canReblog"
:command="command"
@click="toggleReblog()"
@click="reblog"
>
<template v-if="status.reblogsCount && !getPreferences(userSettings, 'hideBoostCount')" #text>
<CommonLocalizedNumber
Expand All @@ -86,7 +111,7 @@ function reply() {
:active="!!status.favourited"
:disabled="isLoading.favourited"
:command="command"
@click="toggleFavourite()"
@click="favourite"
>
<template v-if="status.favouritesCount && !getPreferences(userSettings, 'hideFavoriteCount')" #text>
<CommonLocalizedNumber
Expand All @@ -108,7 +133,7 @@ function reply() {
:active="!!status.bookmarked"
:disabled="isLoading.bookmarked"
:command="command"
@click="toggleBookmark()"
@click="bookmark"
/>
</div>
</div>
Expand Down
14 changes: 12 additions & 2 deletions components/status/StatusActionsMore.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
<script setup lang="ts">
import type { mastodon } from 'masto'
import { toggleBlockAccount, toggleMuteAccount, useRelationship } from '~~/composables/masto/relationship'
import { engagement } from '~~/telemetry/generated/ui'
import { engagementDetails } from '~~/telemetry/engagementDetails'

const props = defineProps<{
status: mastodon.v1.Status
details?: boolean
command?: boolean
feedName?: string
Copy link
Author

Choose a reason for hiding this comment

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

optional prop bc used by StatusCard and StatusDetail

}>()

const emit = defineEmits<{
(event: 'afterEdit'): void
}>()

const { details, command } = $(props)
const { details, command, feedName } = $(props)

const {
status,
Expand Down Expand Up @@ -120,6 +123,13 @@ async function editStatus() {
function showFavoritedAndBoostedBy() {
openFavoridedBoostedByDialog(status.id)
}

function report() {
const analyticsId = feedName ? `${feedName}.post.report` : 'post.report'
engagement.record({ ui_identifier: analyticsId, mastodon_status_id: status.id, ...engagementDetails[analyticsId] })

openReportDialog(status.account, status)
}
</script>

<template>
Expand Down Expand Up @@ -317,7 +327,7 @@ function showFavoritedAndBoostedBy() {
:text="$t('menu.report_account', [`@${status.account.acct}`])"
icon="i-ri:flag-2-line"
:command="command"
@click="openReportDialog(status.account, status)"
@click="report"
/>
</template>
</template>
Expand Down
5 changes: 3 additions & 2 deletions components/status/StatusCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const props = withDefaults(
hover?: boolean
inNotification?: boolean
isPreview?: boolean
feedName: string

// If we know the prev and next status in the timeline, we can simplify the card
older?: mastodon.v1.Status
Expand Down Expand Up @@ -171,7 +172,7 @@ const forceShow = ref(false)
</div>
</div>
</div>
<StatusActionsMore v-if="actions !== false" :status="status" me--2 />
<StatusActionsMore v-if="actions !== false" :status="status" me--2 :feed-name="feedName" />
</div>

<!-- Content -->
Expand All @@ -183,7 +184,7 @@ const forceShow = ref(false)
:in-notification="inNotification"
mb2 :class="{ 'mt-2 mb1': isDM }"
/>
<StatusActions v-if="actions !== false" v-show="!getPreferences(userSettings, 'zenMode')" :status="status" />
<StatusActions v-if="actions !== false" v-show="!getPreferences(userSettings, 'zenMode')" :status="status" :feed-name="feedName" />
</div>
</template>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/timeline/TimelineBookmarks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ const paginator = useMastoClient().v1.bookmarks.list()
</script>

<template>
<TimelinePaginator end-message="common.no_bookmarks" :paginator="paginator" />
<TimelinePaginator end-message="common.no_bookmarks" :paginator="paginator" feed-name="bookmarks.feed" />
</template>
2 changes: 1 addition & 1 deletion components/timeline/TimelineFavourites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ const paginator = useMastoClient().v1.favourites.list()
</script>

<template>
<TimelinePaginator end-message="common.no_favourites" :paginator="paginator" />
<TimelinePaginator end-message="common.no_favourites" :paginator="paginator" feed-name="favorites.feed" />
</template>
2 changes: 1 addition & 1 deletion components/timeline/TimelineHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ function onPublish(status) {
<template>
<div>
<PublishWidget draft-key="home" border="b base" @published="onPublish" />
<TimelinePaginator ref="homePaginator" v-bind="{ paginator, stream }" :preprocess="reorderAndFilter" context="home" />
<TimelinePaginator ref="homePaginator" v-bind="{ paginator, stream }" :preprocess="reorderAndFilter" context="home" feed-name="home.feed" />
</div>
</template>
5 changes: 3 additions & 2 deletions components/timeline/TimelinePaginator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const { paginator, stream, account, buffer = 10, endMessage = true } = definePro
preprocess?: (items: mastodon.v1.Status[]) => mastodon.v1.Status[]
buffer?: number
endMessage?: boolean | string
feedName: string
}>()

const commonPaginator = ref(null)
Expand Down Expand Up @@ -43,11 +44,11 @@ const showOriginSite = $computed(() =>
<template #default="{ item, older, newer, active }">
<template v-if="virtualScroller">
<DynamicScrollerItem :item="item" :active="active" tag="article">
<StatusCard :status="item" :context="context" :older="older" :newer="newer" />
<StatusCard :status="item" :context="context" :older="older" :newer="newer" :feed-name="feedName" />
</DynamicScrollerItem>
</template>
<template v-else>
<StatusCard :status="item" :context="context" :older="older" :newer="newer" />
<StatusCard :status="item" :context="context" :older="older" :newer="newer" :feed-name="feedName" />
</template>
</template>
<template v-if="context === 'account' " #done="{ items }">
Expand Down
2 changes: 1 addition & 1 deletion components/timeline/TimelinePublic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ function reorderAndFilter(items: mastodon.v1.Status[]) {

<template>
<div>
<TimelinePaginator v-bind="{ paginator, stream }" :preprocess="reorderAndFilter" context="public" />
<TimelinePaginator v-bind="{ paginator, stream }" :preprocess="reorderAndFilter" context="public" feed-name="federated.feed" />
</div>
</template>
2 changes: 1 addition & 1 deletion components/timeline/TimelinePublicLocal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ const stream = useStreaming(client => client.v1.stream.streamCommunityTimeline()

<template>
<div>
<TimelinePaginator v-bind="{ paginator, stream }" context="public" />
<TimelinePaginator v-bind="{ paginator, stream }" context="public" feed-name="local.feed" />
</div>
</template>
2 changes: 2 additions & 0 deletions telemetry/engagementDetails.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { profileEvents } from './engagementProfileEvents'
import { postEvents } from './engagementPostEvents'

interface EngagementDetails {
[propName: string]: {
Expand Down Expand Up @@ -36,4 +37,5 @@ export const engagementDetails: EngagementDetails = {
engagement_type: 'general',
},
...profileEvents,
...postEvents,
}
98 changes: 98 additions & 0 deletions telemetry/engagementPostEvents.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
export const postEvents = {
// Standalone post
'post.reply': {
engagement_type: 'reply',
},
'post.reblog': {
engagement_type: 'boost',
},
'post.favorite': {
engagement_type: 'favorite',
},
'post.bookmark': {
engagement_type: 'bookmark',
},
'post.report': {
engagement_type: 'general',
},
// Home feed
'home.feed.post.reply': {
engagement_type: 'reply',
},
'home.feed.post.reblog': {
engagement_type: 'boost',
},
'home.feed.post.favorite': {
engagement_type: 'favorite',
},
'home.feed.post.bookmark': {
engagement_type: 'bookmark',
},
'home.feed.post.report': {
engagement_type: 'general',
},
// Favorites feed
'favorites.feed.post.reply': {
engagement_type: 'reply',
},
'favorites.feed.post.reblog': {
engagement_type: 'boost',
},
'favorites.feed.post.favorite': {
engagement_type: 'favorite',
},
'favorites.feed.post.bookmark': {
engagement_type: 'bookmark',
},
'favorites.feed.post.report': {
engagement_type: 'general',
},
// Bookmarks feed
'bookmarks.feed.post.reply': {
engagement_type: 'reply',
},
'bookmarks.feed.post.reblog': {
engagement_type: 'boost',
},
'bookmarks.feed.post.favorite': {
engagement_type: 'favorite',
},
'bookmarks.feed.post.bookmark': {
engagement_type: 'bookmark',
},
'bookmarks.feed.post.report': {
engagement_type: 'general',
},
// Local feed
'local.feed.post.reply': {
engagement_type: 'reply',
},
'local.feed.post.reblog': {
engagement_type: 'boost',
},
'local.feed.post.favorite': {
engagement_type: 'favorite',
},
'local.feed.post.bookmark': {
engagement_type: 'bookmark',
},
'local.feed.post.report': {
engagement_type: 'general',
},
// Federated feed
'federated.feed.post.reply': {
engagement_type: 'reply',
},
'federated.feed.post.reblog': {
engagement_type: 'boost',
},
'federated.feed.post.favorite': {
engagement_type: 'favorite',
},
'federated.feed.post.bookmark': {
engagement_type: 'bookmark',
},
'federated.feed.post.report': {
engagement_type: 'general',
},
}