Skip to content

Commit 8e96db1

Browse files
nimrodkraclaude
andauthored
chore: clean up upvote_count_threshold experiment (#5843)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 28c3f46 commit 8e96db1

17 files changed

Lines changed: 7 additions & 615 deletions

packages/extension/src/companion/CompanionEngagements.spec.tsx

Lines changed: 0 additions & 60 deletions
This file was deleted.

packages/extension/src/companion/CompanionEngagements.tsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
import type { ReactElement } from 'react';
22
import React from 'react';
33
import type { PostBootData } from '@dailydotdev/shared/src/lib/boot';
4-
import { UserVote } from '@dailydotdev/shared/src/graphql/posts';
54
import { ClickableText } from '@dailydotdev/shared/src/components/buttons/ClickableText';
6-
import { useAuthContext } from '@dailydotdev/shared/src/contexts/AuthContext';
75
import { useQueryClient } from '@tanstack/react-query';
86
import { useRawBackgroundRequest } from '@dailydotdev/shared/src/hooks/companion';
9-
import { useConditionalFeature } from '@dailydotdev/shared/src/hooks/useConditionalFeature';
107
import { largeNumberFormat } from '@dailydotdev/shared/src/lib';
11-
import { featureUpvoteCountThreshold } from '@dailydotdev/shared/src/lib/featureManagement';
12-
import { getUpvoteCountDisplay } from '@dailydotdev/shared/src/lib/post';
138

149
interface CompanionEngagementsProps {
1510
post: PostBootData;
@@ -20,8 +15,6 @@ export function CompanionEngagements({
2015
post,
2116
onUpvotesClick,
2217
}: CompanionEngagementsProps): ReactElement | null {
23-
const { user } = useAuthContext();
24-
const isLoggedIn = !!user;
2518
const client = useQueryClient();
2619
useRawBackgroundRequest(({ res, key }) => {
2720
if (!Array.isArray(key)) {
@@ -35,34 +28,20 @@ export function CompanionEngagements({
3528
client.setQueryData(key, res);
3629
});
3730

38-
const { value: upvoteThresholdConfig } = useConditionalFeature({
39-
feature: featureUpvoteCountThreshold,
40-
shouldEvaluate: isLoggedIn,
41-
});
42-
4331
if (!post) {
4432
return null;
4533
}
4634

4735
const upvotes = post.numUpvotes ?? 0;
4836
const comments = post.numComments ?? 0;
49-
const userHasUpvoted = post.userState?.vote === UserVote.Up;
50-
const { showCount } = getUpvoteCountDisplay(
51-
upvotes,
52-
upvoteThresholdConfig.threshold,
53-
upvoteThresholdConfig.belowThresholdLabel,
54-
userHasUpvoted,
55-
post.createdAt,
56-
upvoteThresholdConfig.newWindowHours,
57-
);
5837

5938
return (
6039
<div
6140
className="flex items-center gap-x-4 py-1 text-text-tertiary typo-callout"
6241
data-testid="statsBar"
6342
>
6443
{upvotes <= 0 && <span>Be the first to upvote</span>}
65-
{showCount && (
44+
{upvotes > 0 && (
6645
<ClickableText onClick={onUpvotesClick}>
6746
{largeNumberFormat(upvotes)} Upvote
6847
{upvotes > 1 ? 's' : ''}

packages/shared/src/components/cards/SimilarPosts/PostEngagementCounts.tsx

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,19 @@ import React from 'react';
33
import classNames from 'classnames';
44
import { separatorCharacter } from '../common/common';
55
import { largeNumberFormat } from '../../../lib';
6-
import { useConditionalFeature } from '../../../hooks/useConditionalFeature';
7-
import { featureUpvoteCountThreshold } from '../../../lib/featureManagement';
8-
import { getUpvoteCountDisplay } from '../../../lib/post';
96

107
interface PostEngagementCountsProps {
118
upvotes: number;
129
comments: number;
13-
createdAt?: string;
1410
className?: string;
15-
userHasUpvoted?: boolean;
16-
shouldEvaluateFeature?: boolean;
1711
}
1812

1913
export function PostEngagementCounts({
2014
upvotes,
2115
comments,
22-
createdAt,
2316
className,
24-
userHasUpvoted = false,
25-
shouldEvaluateFeature = false,
2617
}: PostEngagementCountsProps): ReactElement {
27-
const { value: upvoteThresholdConfig } = useConditionalFeature({
28-
feature: featureUpvoteCountThreshold,
29-
shouldEvaluate: shouldEvaluateFeature,
30-
});
31-
const { showCount, belowThresholdLabel } = getUpvoteCountDisplay(
32-
upvotes,
33-
upvoteThresholdConfig.threshold,
34-
upvoteThresholdConfig.belowThresholdLabel,
35-
userHasUpvoted,
36-
createdAt,
37-
upvoteThresholdConfig.newWindowHours,
38-
);
39-
40-
const upvoteText = showCount
41-
? `${largeNumberFormat(upvotes)} Upvotes`
42-
: belowThresholdLabel || '';
18+
const upvoteText = upvotes > 0 ? `${largeNumberFormat(upvotes)} Upvotes` : '';
4319
const hasUpvoteText = !!upvoteText;
4420

4521
return (

packages/shared/src/components/cards/common/ActionButtons.tsx

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import {
1111
} from '../../icons';
1212
import { ButtonColor, ButtonSize, ButtonVariant } from '../../buttons/Button';
1313
import { useFeedPreviewMode } from '../../../hooks';
14-
import { useConditionalFeature } from '../../../hooks/useConditionalFeature';
15-
import { featureUpvoteCountThreshold } from '../../../lib/featureManagement';
16-
import { getUpvoteCountDisplay } from '../../../lib/post';
1714
import { UpvoteButtonIcon } from './UpvoteButtonIcon';
1815
import { BookmarkButton } from '../../buttons';
1916
import { IconSize } from '../../Icon';
@@ -22,7 +19,6 @@ import PostAwardAction from '../../post/PostAwardAction';
2219
import ConditionalWrapper from '../../ConditionalWrapper';
2320
import { PostTagsPanel } from '../../post/block/PostTagsPanel';
2421
import { LinkWithTooltip } from '../../tooltips/LinkWithTooltip';
25-
import { useAuthContext } from '../../../contexts/AuthContext';
2622
import { useCardActions } from '../../../hooks/cards/useCardActions';
2723

2824
export type ActionButtonsVariant = 'grid' | 'list' | 'signal';
@@ -79,8 +75,6 @@ const ActionButtons = ({
7975
}: ActionButtonsProps): ReactElement | null => {
8076
const config = variantConfig[variant];
8177
const isFeedPreview = useFeedPreviewMode();
82-
const { user } = useAuthContext();
83-
const isLoggedIn = !!user;
8478

8579
const {
8680
isUpvoteActive,
@@ -99,28 +93,13 @@ const ActionButtons = ({
9993
closeTagsPanelOnUpvote: variant === 'list',
10094
});
10195

102-
const { value: upvoteThresholdConfig } = useConditionalFeature({
103-
feature: featureUpvoteCountThreshold,
104-
shouldEvaluate: isLoggedIn,
105-
});
106-
10796
if (isFeedPreview) {
10897
return null;
10998
}
11099

111100
const commentCount = post.numComments ?? 0;
112101
const upvoteCount = post.numUpvotes ?? 0;
113102

114-
const { showCount: showUpvoteCount, belowThresholdLabel: upvoteLabel } =
115-
getUpvoteCountDisplay(
116-
upvoteCount,
117-
upvoteThresholdConfig.threshold,
118-
upvoteThresholdConfig.belowThresholdLabel,
119-
isUpvoteActive,
120-
post.createdAt,
121-
upvoteThresholdConfig.newWindowHours,
122-
);
123-
124103
const commentButton = config.useCommentLink ? (
125104
<LinkWithTooltip
126105
tooltip={{ content: 'Comment' }}
@@ -200,25 +179,14 @@ const ActionButtons = ({
200179
/>
201180
}
202181
>
203-
{showUpvoteCount ? (
182+
{upvoteCount > 0 && (
204183
<InteractionCounter
205184
className={classNames(
206185
'tabular-nums',
207186
variant === 'grid' && 'typo-footnote',
208187
)}
209188
value={upvoteCount}
210189
/>
211-
) : (
212-
!!upvoteLabel && (
213-
<span
214-
className={classNames(
215-
'tabular-nums',
216-
variant === 'grid' && 'typo-footnote',
217-
)}
218-
>
219-
{upvoteLabel}
220-
</span>
221-
)
222190
)}
223191
</QuaternaryButton>
224192
</Tooltip>

packages/shared/src/components/cards/common/PostMetadata.spec.tsx

Lines changed: 0 additions & 59 deletions
This file was deleted.

packages/shared/src/components/cards/common/PostMetadata.tsx

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import { Separator } from './common';
66
import type { Post } from '../../../graphql/posts';
77
import { formatReadTime, DateFormat } from '../../utilities';
88
import { largeNumberFormat } from '../../../lib';
9-
import { useAuthContext } from '../../../contexts/AuthContext';
10-
import { useConditionalFeature } from '../../../hooks/useConditionalFeature';
11-
import { featureUpvoteCountThreshold } from '../../../lib/featureManagement';
12-
import { getUpvoteCountDisplay } from '../../../lib/post';
139
import { useFeedCardContext } from '../../../features/posts/FeedCardContext';
1410
import { Tooltip } from '../../tooltip/Tooltip';
1511
import type { PollMetadataProps } from './PollMetadata';
@@ -24,8 +20,6 @@ interface PostMetadataProps
2420
isVideoType?: boolean;
2521
domain?: ReactNode;
2622
pollMetadata?: PollMetadataProps;
27-
userHasUpvoted?: boolean;
28-
showBelowThresholdLabel?: boolean;
2923
}
3024

3125
export default function PostMetadata({
@@ -38,31 +32,13 @@ export default function PostMetadata({
3832
isVideoType,
3933
domain,
4034
pollMetadata,
41-
userHasUpvoted = false,
42-
showBelowThresholdLabel = true,
4335
}: PostMetadataProps): ReactElement {
4436
const hasUpvoteCount = typeof numUpvotes === 'number';
4537
const upvoteCount = numUpvotes ?? 0;
4638
const readTimeValue = readTime ?? 0;
4739
const timeActionContent = isVideoType ? 'watch' : 'read';
4840
const showReadTime = isVideoType ? Number.isInteger(readTime) : !!readTime;
4941
const { boostedBy } = useFeedCardContext();
50-
const { user } = useAuthContext();
51-
const isLoggedIn = !!user;
52-
53-
const { value: upvoteThresholdConfig } = useConditionalFeature({
54-
feature: featureUpvoteCountThreshold,
55-
shouldEvaluate: isLoggedIn,
56-
});
57-
const { showCount: showUpvoteCount, belowThresholdLabel: upvoteLabel } =
58-
getUpvoteCountDisplay(
59-
upvoteCount,
60-
upvoteThresholdConfig.threshold,
61-
upvoteThresholdConfig.belowThresholdLabel,
62-
userHasUpvoted,
63-
createdAt,
64-
upvoteThresholdConfig.newWindowHours,
65-
);
6642

6743
const promotedText = useScrambler('Promoted');
6844
const promotedByTooltip = useScrambler(
@@ -98,21 +74,14 @@ export default function PostMetadata({
9874
},
9975
!!showReadTime && domain && { key: 'domain', node: domain },
10076
hasUpvoteCount &&
101-
showUpvoteCount && {
77+
upvoteCount > 0 && {
10278
key: 'upvotes',
10379
node: (
10480
<span data-testid="numUpvotes">
10581
{largeNumberFormat(upvoteCount)} upvote{upvoteCount > 1 ? 's' : ''}
10682
</span>
10783
),
10884
},
109-
hasUpvoteCount &&
110-
!showUpvoteCount &&
111-
!!upvoteLabel &&
112-
showBelowThresholdLabel && {
113-
key: 'upvotes',
114-
node: <span data-testid="numUpvotes">{upvoteLabel}</span>,
115-
},
11685
].filter(Boolean) as { key: string; node: ReactNode }[];
11786

11887
return (

0 commit comments

Comments
 (0)