Skip to content
Merged
Changes from all commits
Commits
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
28 changes: 27 additions & 1 deletion packages/shared/src/components/post/PostContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<PostContentProps, 'post'> & { post: Post };

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -258,6 +281,9 @@ export function PostContentRaw({
post={post}
/>
)}
{showCommunitySentiment && (
<CommunitySentiment data={communitySentimentData} className="mb-6" />
)}
</BasePostContent>
</PostContainer>
);
Expand Down
Loading