diff --git a/packages/shared/src/components/post/PostContent.tsx b/packages/shared/src/components/post/PostContent.tsx index 9baf47f812..f35ba3a38c 100644 --- a/packages/shared/src/components/post/PostContent.tsx +++ b/packages/shared/src/components/post/PostContent.tsx @@ -18,7 +18,12 @@ import YoutubeVideo from '../video/YoutubeVideo'; import { useTrackPostView } from '../../hooks/post/useTrackPostView'; import { TruncateText } from '../utilities'; import { useFeature } from '../GrowthBookProvider'; -import { feature } from '../../lib/featureManagement'; +import { useConditionalFeature } from '../../hooks/useConditionalFeature'; +import { + feature, + featureCommunitySentiment, +} from '../../lib/featureManagement'; +import { isDevelopment } from '../../lib/constants'; import { LazyImage } from '../LazyImage'; import { cloudinaryPostImageCoverPlaceholder } from '../../lib/image'; import { withPostById } from './withPostById'; @@ -27,6 +32,10 @@ import { useSmartTitle } from '../../hooks/post/useSmartTitle'; import { PostTagList } from './tags/PostTagList'; import PostSourceInfo from './PostSourceInfo'; import { useReaderInstallPromptGate } from '../../hooks/useReaderInstallPromptGate'; +import { + CommunitySentiment, + mapCommunitySentimentPost, +} from './focus/CommunitySentiment'; type PostContentRawProps = Omit & { post: Post }; @@ -104,6 +113,20 @@ export function PostContentRaw({ }; const showCodeSnippets = useFeature(feature.showCodeSnippets); const { title } = useSmartTitle(post); + const communitySentimentData = post.communitySentiment + ? mapCommunitySentimentPost(post.communitySentiment) + : undefined; + // Conditional enrollment: only evaluate (and log exposure for) the + // community_sentiment experiment on posts that actually have a take, so + // take-less posts don't dilute the treatment/control split. + const { value: communitySentimentEnabled } = useConditionalFeature({ + feature: featureCommunitySentiment, + shouldEvaluate: !!communitySentimentData, + }); + const showCommunitySentiment = + isPostPage && + !!communitySentimentData && + (communitySentimentEnabled || isDevelopment); const hasNavigation = !!onPreviousPost || !!onNextPost; const isVideoType = isVideoPost(post); const hasToc = (post.toc?.length ?? 0) > 0; @@ -258,6 +281,9 @@ export function PostContentRaw({ post={post} /> )} + {showCommunitySentiment && ( + + )} );