Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Session] Experiment: Don't use withProxy (#4762)

* Reorder statements

* Remove withProxy() usage behind a gate

authored by

dan and committed by
GitHub
9b9e09d0 ce0bf867

+88 -31
+26 -9
src/components/ReportDialog/SubmitView.tsx
··· 6 6 7 7 import {getLabelingServiceTitle} from '#/lib/moderation' 8 8 import {ReportOption} from '#/lib/moderation/useReportOptions' 9 + import {useGate} from '#/lib/statsig/statsig' 9 10 import {useAgent} from '#/state/session' 10 11 import {CharProgress} from '#/view/com/composer/char-progress/CharProgress' 11 12 import * as Toast from '#/view/com/util/Toast' ··· 36 37 const t = useTheme() 37 38 const {_} = useLingui() 38 39 const agent = useAgent() 40 + const gate = useGate() 39 41 const [details, setDetails] = React.useState<string>('') 40 42 const [submitting, setSubmitting] = React.useState<boolean>(false) 41 43 const [selectedServices, setSelectedServices] = React.useState<string[]>([ ··· 60 62 reason: details, 61 63 } 62 64 const results = await Promise.all( 63 - selectedServices.map(did => 64 - agent 65 - .withProxy('atproto_labeler', did) 66 - .createModerationReport(report) 67 - .then( 68 - _ => true, 69 - _ => false, 70 - ), 71 - ), 65 + selectedServices.map(did => { 66 + if (gate('session_withproxy_fix')) { 67 + return agent 68 + .createModerationReport(report, { 69 + encoding: 'application/json', 70 + headers: { 71 + 'atproto-proxy': `${did}#atproto_labeler`, 72 + }, 73 + }) 74 + .then( 75 + _ => true, 76 + _ => false, 77 + ) 78 + } else { 79 + return agent 80 + .withProxy('atproto_labeler', did) 81 + .createModerationReport(report) 82 + .then( 83 + _ => true, 84 + _ => false, 85 + ) 86 + } 87 + }), 72 88 ) 73 89 74 90 setSubmitting(false) ··· 92 108 onSubmitComplete, 93 109 setError, 94 110 agent, 111 + gate, 95 112 ]) 96 113 97 114 return (
+30 -9
src/components/moderation/LabelsOnMeDialog.tsx
··· 7 7 8 8 import {useLabelInfo} from '#/lib/moderation/useLabelInfo' 9 9 import {makeProfileLink} from '#/lib/routes/links' 10 + import {useGate} from '#/lib/statsig/statsig' 10 11 import {sanitizeHandle} from '#/lib/strings/handles' 11 12 import {logger} from '#/logger' 12 13 import {useAgent, useSession} from '#/state/session' ··· 201 202 const [details, setDetails] = React.useState('') 202 203 const isAccountReport = 'did' in subject 203 204 const agent = useAgent() 205 + const gate = useGate() 204 206 205 207 const {mutate, isPending} = useMutation({ 206 208 mutationFn: async () => { 207 209 const $type = !isAccountReport 208 210 ? 'com.atproto.repo.strongRef' 209 211 : 'com.atproto.admin.defs#repoRef' 210 - await agent 211 - .withProxy('atproto_labeler', label.src) 212 - .createModerationReport({ 213 - reasonType: ComAtprotoModerationDefs.REASONAPPEAL, 214 - subject: { 215 - $type, 216 - ...subject, 212 + if (gate('session_withproxy_fix')) { 213 + await agent.createModerationReport( 214 + { 215 + reasonType: ComAtprotoModerationDefs.REASONAPPEAL, 216 + subject: { 217 + $type, 218 + ...subject, 219 + }, 220 + reason: details, 217 221 }, 218 - reason: details, 219 - }) 222 + { 223 + encoding: 'application/json', 224 + headers: { 225 + 'atproto-proxy': `${label.src}#atproto_labeler`, 226 + }, 227 + }, 228 + ) 229 + } else { 230 + await agent 231 + .withProxy('atproto_labeler', label.src) 232 + .createModerationReport({ 233 + reasonType: ComAtprotoModerationDefs.REASONAPPEAL, 234 + subject: { 235 + $type, 236 + ...subject, 237 + }, 238 + reason: details, 239 + }) 240 + } 220 241 }, 221 242 onError: err => { 222 243 logger.error('Failed to submit label appeal', {message: err})
+1
src/lib/statsig/gates.ts
··· 7 7 | 'new_user_progress_guide' 8 8 | 'onboarding_minimum_interests' 9 9 | 'request_notifications_permission_after_onboarding_v2' 10 + | 'session_withproxy_fix' 10 11 | 'show_avi_follow_button' 11 12 | 'show_follow_back_label_v2' 12 13 | 'suggested_feeds_interstitial'
+31 -13
src/state/feed-feedback.tsx
··· 5 5 6 6 import {PROD_DEFAULT_FEED} from '#/lib/constants' 7 7 import {logEvent} from '#/lib/statsig/statsig' 8 + import {useGate} from '#/lib/statsig/statsig' 8 9 import {logger} from '#/logger' 9 10 import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed' 10 11 import {getFeedPostSlice} from '#/view/com/posts/Feed' ··· 24 25 25 26 export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { 26 27 const agent = useAgent() 28 + const gate = useGate() 27 29 const enabled = isDiscoverFeed(feed) && hasSession 28 30 const queue = React.useRef<Set<string>>(new Set()) 29 31 const history = React.useRef< ··· 43 45 ) 44 46 45 47 const sendToFeedNoDelay = React.useCallback(() => { 46 - const proxyAgent = agent.withProxy( 47 - // @ts-ignore TODO need to update withProxy() to support this key -prf 48 - 'bsky_fg', 49 - // TODO when we start sending to other feeds, we need to grab their DID -prf 50 - 'did:web:discover.bsky.app', 51 - ) as BskyAgent 52 - 53 48 const interactions = Array.from(queue.current).map(toInteraction) 54 49 queue.current.clear() 55 50 56 51 // Send to the feed 57 - proxyAgent.app.bsky.feed 58 - .sendInteractions({interactions}) 59 - .catch((e: any) => { 60 - logger.warn('Failed to send feed interactions', {error: e}) 61 - }) 52 + if (gate('session_withproxy_fix')) { 53 + agent.app.bsky.feed 54 + .sendInteractions( 55 + {interactions}, 56 + { 57 + encoding: 'application/json', 58 + headers: { 59 + // TODO when we start sending to other feeds, we need to grab their DID -prf 60 + 'atproto-proxy': 'did:web:discover.bsky.app#bsky_fg', 61 + }, 62 + }, 63 + ) 64 + .catch((e: any) => { 65 + logger.warn('Failed to send feed interactions', {error: e}) 66 + }) 67 + } else { 68 + const proxyAgent = agent.withProxy( 69 + // @ts-ignore TODO need to update withProxy() to support this key -prf 70 + 'bsky_fg', 71 + // TODO when we start sending to other feeds, we need to grab their DID -prf 72 + 'did:web:discover.bsky.app', 73 + ) as BskyAgent 74 + proxyAgent.app.bsky.feed 75 + .sendInteractions({interactions}) 76 + .catch((e: any) => { 77 + logger.warn('Failed to send feed interactions', {error: e}) 78 + }) 79 + } 62 80 63 81 // Send to Statsig 64 82 if (aggregatedStats.current === null) { ··· 66 84 } 67 85 sendOrAggregateInteractionsForStats(aggregatedStats.current, interactions) 68 86 throttledFlushAggregatedStats() 69 - }, [agent, throttledFlushAggregatedStats]) 87 + }, [agent, gate, throttledFlushAggregatedStats]) 70 88 71 89 const sendToFeed = React.useMemo( 72 90 () =>