Only expose known-likers experiment when there's something to show

Fetch the likers sample for everyone signed in, then check the feature gate only if the viewer follows one of the likers. This keeps people who'd see no difference out of the test.

Note: this means app.bsky.feed.getLikes will be called on every thread page view for signed-in users for posts with at least 1 like
This commit is contained in:
Alex Benzer
2026-07-09 21:37:38 -07:00
parent 6ad19850ce
commit d072291559
+18 -23
View File
@@ -39,16 +39,8 @@ export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
const ax = useAnalytics()
const likeCount = post.likeCount ?? 0
/*
* Check the gate last: GrowthBook logs an exposure per evaluation, so only
* evaluate for viewers who could actually see the treatment.
*/
const knownLikersEnabled =
hasSession &&
likeCount > 0 &&
ax.features.enabled(ax.features.PostThreadKnownLikersEnable)
const {data} = useLikedBySampleQuery({
uri: knownLikersEnabled ? post.uri : undefined,
uri: hasSession && likeCount > 0 ? post.uri : undefined,
})
if (likeCount === 0) return null
@@ -56,21 +48,24 @@ export function LikesStat({post}: {post: AppBskyFeedDefs.PostView}) {
const urip = new AtUri(post.uri)
const likesHref = makeProfileLink(post.author, 'post', urip.rkey, 'liked-by')
const knownLikers =
knownLikersEnabled && moderationOpts
? (data?.likes ?? [])
.map(like => like.actor)
.filter(
actor =>
actor.did !== currentAccount?.did &&
actor.viewer?.following &&
!actor.viewer.muted &&
!actor.viewer.blocking &&
!actor.viewer.blockedBy,
)
: []
const knownLikers = moderationOpts
? (data?.likes ?? [])
.map(like => like.actor)
.filter(
actor =>
actor.did !== currentAccount?.did &&
actor.viewer?.following &&
!actor.viewer.muted &&
!actor.viewer.blocking &&
!actor.viewer.blockedBy,
)
: []
if (knownLikers.length === 0) {
const showKnownLikers =
knownLikers.length > 0 &&
ax.features.enabled(ax.features.PostThreadKnownLikersEnable)
if (!showKnownLikers) {
return (
<Link to={likesHref} label={l`Likes on this post`}>
<Text