-
Notifications
You must be signed in to change notification settings - Fork 7
fix(posts): Post Button interactions (Like, Boost, Respond, Share, Report) [MOSOWEB-44] #75
Changes from 17 commits
d0b303d
7aecd40
034c76a
171056d
4ab3c49
32bb7b2
3472e20
b44088e
82d4989
df64fbb
cc37101
86c6a98
e8a6aa1
8538808
333b6fd
a77f933
e0b5ea7
4f190f3
39e3647
503c6ba
ac60309
1b49549
f5e732d
90acbfb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
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') | ||
|
@@ -23,14 +26,36 @@ const { | |
toggleReblog, | ||
} = $(useStatusActions(props)) | ||
|
||
function recordEngagement(engagementAction: String) { | ||
const analyticsId = feedName ? `${feedName}.post.${engagementAction}` : `post.${engagementAction}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Me and Aly talked to Kirill. We are going to use separate |
||
|
||
function favourite() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using the UK English version of "favorite" to match the called There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -108,7 +133,7 @@ function reply() { | |
:active="!!status.bookmarked" | ||
:disabled="isLoading.bookmarked" | ||
:command="command" | ||
@click="toggleBookmark()" | ||
@click="bookmark" | ||
/> | ||
</div> | ||
</div> | ||
|
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
@@ -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> | ||
|
@@ -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> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
export const postEvents = { | ||
// Standalone post | ||
'post.open-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.open-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.open-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.open-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.open-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.open-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', | ||
}, | ||
} |
There was a problem hiding this comment.
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