about summary refs log tree commit diff
path: root/src/state
diff options
context:
space:
mode:
Diffstat (limited to 'src/state')
-rw-r--r--src/state/feed-feedback.tsx44
1 files changed, 31 insertions, 13 deletions
diff --git a/src/state/feed-feedback.tsx b/src/state/feed-feedback.tsx
index 0a6c1d585..59b4bf78a 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<StateContext>({
 
 export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
   const agent = useAgent()
+  const gate = useGate()
   const enabled = isDiscoverFeed(feed) && hasSession
   const queue = React.useRef<Set<string>>(new Set())
   const history = React.useRef<
@@ -43,22 +45,38 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
   )
 
   const sendToFeedNoDelay = React.useCallback(() => {
-    const proxyAgent = agent.withProxy(
-      // @ts-ignore TODO need to update withProxy() to support this key -prf
-      'bsky_fg',
-      // TODO when we start sending to other feeds, we need to grab their DID -prf
-      'did:web:discover.bsky.app',
-    ) as BskyAgent
-
     const interactions = Array.from(queue.current).map(toInteraction)
     queue.current.clear()
 
     // Send to the feed
-    proxyAgent.app.bsky.feed
-      .sendInteractions({interactions})
-      .catch((e: any) => {
-        logger.warn('Failed to send feed interactions', {error: e})
-      })
+    if (gate('session_withproxy_fix')) {
+      agent.app.bsky.feed
+        .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})
+        })
+    } else {
+      const proxyAgent = agent.withProxy(
+        // @ts-ignore TODO need to update withProxy() to support this key -prf
+        'bsky_fg',
+        // TODO when we start sending to other feeds, we need to grab their DID -prf
+        'did:web:discover.bsky.app',
+      ) as BskyAgent
+      proxyAgent.app.bsky.feed
+        .sendInteractions({interactions})
+        .catch((e: any) => {
+          logger.warn('Failed to send feed interactions', {error: e})
+        })
+    }
 
     // Send to Statsig
     if (aggregatedStats.current === null) {
@@ -66,7 +84,7 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) {
     }
     sendOrAggregateInteractionsForStats(aggregatedStats.current, interactions)
     throttledFlushAggregatedStats()
-  }, [agent, throttledFlushAggregatedStats])
+  }, [agent, gate, throttledFlushAggregatedStats])
 
   const sendToFeed = React.useMemo(
     () =>