From 76bd33296aa47927ee51dc69e108e980d39db64d Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 31 Aug 2026 16:49:38 +0000 Subject: [PATCH] Add even more features to feature usage counter (#40340) --- .../mastodon/components/account/index.tsx | 3 ++- .../components/account_header/buttons.tsx | 8 +++++++- .../components/account_list_item/index.tsx | 12 ++++++++---- .../mastodon/components/display_name/index.tsx | 6 ++++-- .../mastodon/components/hover_card_account.tsx | 9 ++++++--- .../components/hover_card_controller.tsx | 11 ++++++++++- app/javascript/mastodon/components/status.jsx | 1 + .../components/status/handled_link.tsx | 3 ++- .../mastodon/components/status/header.tsx | 1 + .../features/account_featured/index.tsx | 5 ++++- .../collections/detail/accounts_list.tsx | 1 + .../explore/components/author_link.tsx | 1 + .../features/explore/components/card.tsx | 6 +++++- .../mastodon/features/favourites/index.jsx | 2 +- .../features/followers/components/list.tsx | 2 ++ .../components/inline_follow_suggestions.tsx | 18 ++++++++++++++++-- .../mastodon/features/reblogs/index.jsx | 2 +- .../status/components/detailed_status.tsx | 6 +++++- app/lib/feature_usage_tracker.rb | 4 ++++ 19 files changed, 81 insertions(+), 20 deletions(-) diff --git a/app/javascript/mastodon/components/account/index.tsx b/app/javascript/mastodon/components/account/index.tsx index 047249383ab..f24be9f0ebf 100644 --- a/app/javascript/mastodon/components/account/index.tsx +++ b/app/javascript/mastodon/components/account/index.tsx @@ -309,8 +309,9 @@ export const Account: React.FC = ({
{account ? ( diff --git a/app/javascript/mastodon/components/account_header/buttons.tsx b/app/javascript/mastodon/components/account_header/buttons.tsx index 81e6b5041ab..a4db87e044d 100644 --- a/app/javascript/mastodon/components/account_header/buttons.tsx +++ b/app/javascript/mastodon/components/account_header/buttons.tsx @@ -3,6 +3,8 @@ import type { FC } from 'react'; import { defineMessages, useIntl } from 'react-intl'; +import { useLocation } from 'react-router-dom'; + import { followAccount } from '@/mastodon/actions/accounts'; import { useAccount } from '@/mastodon/hooks/useAccount'; import { getAccountHidden } from '@/mastodon/selectors/accounts'; @@ -81,6 +83,10 @@ const AccountButtonsOther: FC< }); } }, [accountUrl]); + const { state } = useLocation<{ + reference?: string; + } | null>(); + const reference = state?.reference ?? 'profile'; if (!account) { return null; @@ -96,7 +102,7 @@ const AccountButtonsOther: FC< accountId={accountId} className={classes.followButton} labelLength='long' - reference='profile' + reference={reference} /> )} {isFollowing && ( diff --git a/app/javascript/mastodon/components/account_list_item/index.tsx b/app/javascript/mastodon/components/account_list_item/index.tsx index 31f0fd8b9b3..af654e75ec3 100644 --- a/app/javascript/mastodon/components/account_list_item/index.tsx +++ b/app/javascript/mastodon/components/account_list_item/index.tsx @@ -27,6 +27,7 @@ import classes from './styles.module.scss'; export interface RenderButtonOptions { accountId: string | undefined; relationship: Relationship | null | undefined; + reference?: string; } type Stat = 'followers' | 'following' | 'posts' | 'joined' | 'last-active'; @@ -38,6 +39,7 @@ interface Props { withBorder?: boolean; badge?: ReactNode; renderButton?: (options: RenderButtonOptions) => React.ReactNode; + reference?: string; } const DEFAULT_STATS: Stat[] = ['followers', 'posts', 'last-active']; @@ -56,6 +58,7 @@ export const AccountListItem: React.FC = ({ withBorder = true, badge: badgeProp, renderButton = defaultRenderButton, + reference, }) => { const intl = useIntl(); const account = useAccount(accountId); @@ -83,13 +86,14 @@ export const AccountListItem: React.FC = ({ icon={} sideContent={ - {renderButton({ accountId, relationship })} + {renderButton({ accountId, relationship, reference })} } > {handle}} > = ({ ); }; -const defaultRenderButton = ({ accountId }: RenderButtonOptions) => ( - +const defaultRenderButton = ({ accountId, reference }: RenderButtonOptions) => ( + ); export const AccountListItemFollowButton: React.FC<{ diff --git a/app/javascript/mastodon/components/display_name/index.tsx b/app/javascript/mastodon/components/display_name/index.tsx index 3eb38943e81..3965d115147 100644 --- a/app/javascript/mastodon/components/display_name/index.tsx +++ b/app/javascript/mastodon/components/display_name/index.tsx @@ -29,8 +29,9 @@ export const DisplayName: FC< export const LinkedDisplayName: FC< Omit & { displayProps: DisplayNameProps & ComponentPropsWithoutRef<'span'>; + reference?: string; } -> = ({ displayProps, children, ...linkProps }) => { +> = ({ displayProps, reference, children, ...linkProps }) => { const { account } = displayProps; if (!account) { return ; @@ -38,10 +39,11 @@ export const LinkedDisplayName: FC< return ( {children} diff --git a/app/javascript/mastodon/components/hover_card_account.tsx b/app/javascript/mastodon/components/hover_card_account.tsx index da9d465af30..f46bc81ceb0 100644 --- a/app/javascript/mastodon/components/hover_card_account.tsx +++ b/app/javascript/mastodon/components/hover_card_account.tsx @@ -25,8 +25,8 @@ import { useAppSelector, useAppDispatch } from 'mastodon/store'; export const HoverCardAccount = forwardRef< HTMLDivElement, - { accountId?: string } ->(({ accountId }, ref) => { + { accountId?: string; reference?: string } +>(({ accountId, reference }, ref) => { const dispatch = useAppDispatch(); const account = useAppSelector((state) => @@ -171,7 +171,10 @@ export const HoverCardAccount = forwardRef< )}
- + )} diff --git a/app/javascript/mastodon/components/hover_card_controller.tsx b/app/javascript/mastodon/components/hover_card_controller.tsx index 34e36ab7d7f..934623f16d2 100644 --- a/app/javascript/mastodon/components/hover_card_controller.tsx +++ b/app/javascript/mastodon/components/hover_card_controller.tsx @@ -21,6 +21,7 @@ const isHoverCardAnchor = (element: HTMLElement) => export const HoverCardController: React.FC = () => { const [open, setOpen] = useState(false); const [accountId, setAccountId] = useState(); + const [reference, setReference] = useState(); const [anchor, setAnchor] = useState(null); const cardRef = useRef(null); const [setLeaveTimeout, cancelLeaveTimeout] = useTimeout(); @@ -53,6 +54,9 @@ export const HoverCardController: React.FC = () => { setOpen(true); setAnchor(target); setAccountId(target.getAttribute('data-hover-card-account') ?? undefined); + setReference( + target.getAttribute('data-hover-card-reference') ?? undefined, + ); }; const close = () => { @@ -61,6 +65,7 @@ export const HoverCardController: React.FC = () => { setOpen(false); setAnchor(null); setAccountId(undefined); + setReference(undefined); }; const handleTouchStart = () => { @@ -216,7 +221,11 @@ export const HoverCardController: React.FC = () => { > {({ props }) => (
- +
)} diff --git a/app/javascript/mastodon/components/status.jsx b/app/javascript/mastodon/components/status.jsx index 93a70c18d06..3112d352fb7 100644 --- a/app/javascript/mastodon/components/status.jsx +++ b/app/javascript/mastodon/components/status.jsx @@ -432,6 +432,7 @@ class Status extends ImmutablePureComponent { variant: 'simple' }} className='status__display-name muted' + reference='status' /> ) diff --git a/app/javascript/mastodon/components/status/handled_link.tsx b/app/javascript/mastodon/components/status/handled_link.tsx index 9f0adc2ab6c..e571edfea6d 100644 --- a/app/javascript/mastodon/components/status/handled_link.tsx +++ b/app/javascript/mastodon/components/status/handled_link.tsx @@ -53,9 +53,10 @@ export const HandledLink: FC> = ({ return ( {children} diff --git a/app/javascript/mastodon/components/status/header.tsx b/app/javascript/mastodon/components/status/header.tsx index 15fca480e9f..a88ffe1b354 100644 --- a/app/javascript/mastodon/components/status/header.tsx +++ b/app/javascript/mastodon/components/status/header.tsx @@ -118,6 +118,7 @@ const StatusDisplayName: FC<{
= ({ aria-posinset={index + 1} aria-setsize={featuredAccountIds.size} > - + ))} diff --git a/app/javascript/mastodon/features/collections/detail/accounts_list.tsx b/app/javascript/mastodon/features/collections/detail/accounts_list.tsx index 4a81f5eff93..38465c364e7 100644 --- a/app/javascript/mastodon/features/collections/detail/accounts_list.tsx +++ b/app/javascript/mastodon/features/collections/detail/accounts_list.tsx @@ -197,6 +197,7 @@ export const CollectionAccountsList: React.FC<{ withBorder={!isLastElement} badge={item.state === 'pending' ? : null} renderButton={renderAccountItemButton} + reference='collection' /> ), diff --git a/app/javascript/mastodon/features/explore/components/author_link.tsx b/app/javascript/mastodon/features/explore/components/author_link.tsx index a4667693a59..d3a0a6c2d57 100644 --- a/app/javascript/mastodon/features/explore/components/author_link.tsx +++ b/app/javascript/mastodon/features/explore/components/author_link.tsx @@ -15,6 +15,7 @@ export const AuthorLink: FC<{ accountId: string }> = ({ accountId }) => { diff --git a/app/javascript/mastodon/features/explore/components/card.tsx b/app/javascript/mastodon/features/explore/components/card.tsx index a0e28869aee..e36a698eac7 100644 --- a/app/javascript/mastodon/features/explore/components/card.tsx +++ b/app/javascript/mastodon/features/explore/components/card.tsx @@ -97,8 +97,12 @@ export const Card: React.FC<{ id: string; source: SuggestionSource }> = ({
{accountIds.map(id => - , + , )} diff --git a/app/javascript/mastodon/features/followers/components/list.tsx b/app/javascript/mastodon/features/followers/components/list.tsx index 98e4065348d..0dbcd74ddf9 100644 --- a/app/javascript/mastodon/features/followers/components/list.tsx +++ b/app/javascript/mastodon/features/followers/components/list.tsx @@ -60,6 +60,7 @@ export const AccountList: FC = ({ accountId={followerId} withBio={false} badge={withoutFollowsYouBadge ? false : null} + reference='profile' /> )) ?? []; @@ -70,6 +71,7 @@ export const AccountList: FC = ({ accountId={prependAccountId} withBio={false} badge={withoutFollowsYouBadge ? false : null} + reference='profile' />, ); } diff --git a/app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.tsx b/app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.tsx index 86634dc5334..4c945280e6f 100644 --- a/app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.tsx +++ b/app/javascript/mastodon/features/home_timeline/components/inline_follow_suggestions.tsx @@ -142,13 +142,27 @@ const Card: React.FC<{ />
- +
- + {firstVerifiedField ? ( diff --git a/app/javascript/mastodon/features/reblogs/index.jsx b/app/javascript/mastodon/features/reblogs/index.jsx index bb3ef1a0152..9f48b10265d 100644 --- a/app/javascript/mastodon/features/reblogs/index.jsx +++ b/app/javascript/mastodon/features/reblogs/index.jsx @@ -88,7 +88,7 @@ class Reblogs extends ImmutablePureComponent { bindToDocument={!multiColumn} > {accountIds.map(id => - , + , )} diff --git a/app/javascript/mastodon/features/status/components/detailed_status.tsx b/app/javascript/mastodon/features/status/components/detailed_status.tsx index 53365940910..393618f7a88 100644 --- a/app/javascript/mastodon/features/status/components/detailed_status.tsx +++ b/app/javascript/mastodon/features/status/components/detailed_status.tsx @@ -441,8 +441,12 @@ export const DetailedStatus: React.FC<{
)}
diff --git a/app/lib/feature_usage_tracker.rb b/app/lib/feature_usage_tracker.rb index e36d0e2ce3e..aac45f8c4ab 100644 --- a/app/lib/feature_usage_tracker.rb +++ b/app/lib/feature_usage_tracker.rb @@ -8,11 +8,15 @@ class FeatureUsageTracker ).freeze REF_VALUES = %w( + author_attribution collection + featured_account + hover_card inline_suggestions onboarding profile search + status suggestions ).freeze