diff --git a/src/components/ReportDialog/SubmitView.tsx b/src/components/ReportDialog/SubmitView.tsx index 3731617fd3..7ceece75b6 100644 --- a/src/components/ReportDialog/SubmitView.tsx +++ b/src/components/ReportDialog/SubmitView.tsx @@ -6,6 +6,7 @@ import {useLingui} from '@lingui/react' import {getLabelingServiceTitle} from '#/lib/moderation' import {ReportOption} from '#/lib/moderation/useReportOptions' +import {useGate} from '#/lib/statsig/statsig' import {useAgent} from '#/state/session' import {CharProgress} from '#/view/com/composer/char-progress/CharProgress' import * as Toast from '#/view/com/util/Toast' @@ -36,6 +37,7 @@ export function SubmitView({ const t = useTheme() const {_} = useLingui() const agent = useAgent() + const gate = useGate() const [details, setDetails] = React.useState('') const [submitting, setSubmitting] = React.useState(false) const [selectedServices, setSelectedServices] = React.useState([ @@ -60,15 +62,29 @@ export function SubmitView({ reason: details, } const results = await Promise.all( - selectedServices.map(did => - agent - .withProxy('atproto_labeler', did) - .createModerationReport(report) - .then( - _ => true, - _ => false, - ), - ), + selectedServices.map(did => { + if (gate('session_withproxy_fix')) { + return agent + .createModerationReport(report, { + encoding: 'application/json', + headers: { + 'atproto-proxy': `${did}#atproto_labeler`, + }, + }) + .then( + _ => true, + _ => false, + ) + } else { + return agent + .withProxy('atproto_labeler', did) + .createModerationReport(report) + .then( + _ => true, + _ => false, + ) + } + }), ) setSubmitting(false) @@ -92,6 +108,7 @@ export function SubmitView({ onSubmitComplete, setError, agent, + gate, ]) return ( diff --git a/src/components/moderation/LabelsOnMeDialog.tsx b/src/components/moderation/LabelsOnMeDialog.tsx index d0f0d4ea0a..c226fbbf75 100644 --- a/src/components/moderation/LabelsOnMeDialog.tsx +++ b/src/components/moderation/LabelsOnMeDialog.tsx @@ -7,6 +7,7 @@ import {useMutation} from '@tanstack/react-query' import {useLabelInfo} from '#/lib/moderation/useLabelInfo' import {makeProfileLink} from '#/lib/routes/links' +import {useGate} from '#/lib/statsig/statsig' import {sanitizeHandle} from '#/lib/strings/handles' import {logger} from '#/logger' import {useAgent, useSession} from '#/state/session' @@ -201,22 +202,42 @@ function AppealForm({ const [details, setDetails] = React.useState('') const isAccountReport = 'did' in subject const agent = useAgent() + const gate = useGate() const {mutate, isPending} = useMutation({ mutationFn: async () => { const $type = !isAccountReport ? 'com.atproto.repo.strongRef' : 'com.atproto.admin.defs#repoRef' - await agent - .withProxy('atproto_labeler', label.src) - .createModerationReport({ - reasonType: ComAtprotoModerationDefs.REASONAPPEAL, - subject: { - $type, - ...subject, + if (gate('session_withproxy_fix')) { + await agent.createModerationReport( + { + reasonType: ComAtprotoModerationDefs.REASONAPPEAL, + subject: { + $type, + ...subject, + }, + reason: details, }, - reason: details, - }) + { + encoding: 'application/json', + headers: { + 'atproto-proxy': `${label.src}#atproto_labeler`, + }, + }, + ) + } else { + await agent + .withProxy('atproto_labeler', label.src) + .createModerationReport({ + reasonType: ComAtprotoModerationDefs.REASONAPPEAL, + subject: { + $type, + ...subject, + }, + reason: details, + }) + } }, onError: err => { logger.error('Failed to submit label appeal', {message: err}) diff --git a/src/lib/statsig/gates.ts b/src/lib/statsig/gates.ts index 1c86d01da4..78e440d043 100644 --- a/src/lib/statsig/gates.ts +++ b/src/lib/statsig/gates.ts @@ -7,6 +7,7 @@ export type Gate = | 'new_user_progress_guide' | 'onboarding_minimum_interests' | 'request_notifications_permission_after_onboarding_v2' + | 'session_withproxy_fix' | 'show_avi_follow_button' | 'show_follow_back_label_v2' | 'suggested_feeds_interstitial' diff --git a/src/state/feed-feedback.tsx b/src/state/feed-feedback.tsx index 91ef4cc4bb..417e09a50a 100644 --- a/src/state/feed-feedback.tsx +++ b/src/state/feed-feedback.tsx @@ -5,6 +5,7 @@ import throttle from 'lodash.throttle' import {PROD_DEFAULT_FEED} from '#/lib/constants' import {logEvent} from '#/lib/statsig/statsig' +import {useGate} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed' import {getFeedPostSlice} from '#/view/com/posts/Feed' @@ -24,6 +25,7 @@ const stateContext = React.createContext({ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { const agent = useAgent() + const gate = useGate() const enabled = isDiscoverFeed(feed) && hasSession const queue = React.useRef>(new Set()) const history = React.useRef< @@ -46,17 +48,21 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { const interactions = Array.from(queue.current).map(toInteraction) queue.current.clear() - if (true) { - // Send to the feed + // Send to the feed + if (gate('session_withproxy_fix')) { agent.app.bsky.feed - .sendInteractions({ interactions }, { - encoding: 'application/json', - headers: { - 'atproto-proxy': 'did:web:discover.bsky.app#bsky_fg' - } - }) + .sendInteractions( + {interactions}, + { + encoding: 'application/json', + headers: { + // TODO when we start sending to other feeds, we need to grab their DID -prf + 'atproto-proxy': 'did:web:discover.bsky.app#bsky_fg', + }, + }, + ) .catch((e: any) => { - logger.warn('Failed to send feed interactions', { error: e }) + logger.warn('Failed to send feed interactions', {error: e}) }) } else { const proxyAgent = agent.withProxy( @@ -66,16 +72,10 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { 'did:web:discover.bsky.app', ) as BskyAgent - // Send to the feed proxyAgent.app.bsky.feed - .sendInteractions({ interactions }, { - encoding: 'application/json', - headers: { - 'atproto-proxy': 'did:web:discover.bsky.app#bsky_fg' - } - }) + .sendInteractions({interactions}) .catch((e: any) => { - logger.warn('Failed to send feed interactions', { error: e }) + logger.warn('Failed to send feed interactions', {error: e}) }) } @@ -85,7 +85,7 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { } sendOrAggregateInteractionsForStats(aggregatedStats.current, interactions) throttledFlushAggregatedStats() - }, [agent, throttledFlushAggregatedStats]) + }, [agent, gate, throttledFlushAggregatedStats]) const sendToFeed = React.useMemo( () =>