From 63cd560f177bb9a80ce5099aeb5d2fda1311822a Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 17 Jan 2025 11:15:27 -0800 Subject: [PATCH 1/4] add did --- src/lib/constants.ts | 3 +++ src/state/feed-feedback.tsx | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 566edf69db..1c049ea818 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -63,6 +63,9 @@ export function IS_PROD_SERVICE(url?: string) { export const PROD_DEFAULT_FEED = (rkey: string) => `at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/${rkey}` +export const STAGING_DEFAULT_FEED = (rkey: string) => + `at://did:plc:yofh3kx63drvfljkibw5zuxo/app.bsky.feed.generator/${rkey}` + export const POST_IMG_MAX = { width: 2000, height: 2000, diff --git a/src/state/feed-feedback.tsx b/src/state/feed-feedback.tsx index 02f98ad145..c92f8455d9 100644 --- a/src/state/feed-feedback.tsx +++ b/src/state/feed-feedback.tsx @@ -3,7 +3,7 @@ import {AppState, AppStateStatus} from 'react-native' import {AppBskyFeedDefs} from '@atproto/api' import throttle from 'lodash.throttle' -import {PROD_DEFAULT_FEED} from '#/lib/constants' +import {PROD_DEFAULT_FEED, STAGING_DEFAULT_FEED} from '#/lib/constants' import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed' @@ -155,7 +155,11 @@ export function useFeedFeedbackContext() { // place, we're hardcoding it to the discover feed. // -prf function isDiscoverFeed(feed: FeedDescriptor) { - return feed === `feedgen|${PROD_DEFAULT_FEED('whats-hot')}` + return ( + feed === `feedgen|${PROD_DEFAULT_FEED('whats-hot')}` || + feed === `feedgen|${PROD_DEFAULT_FEED('thevides')}` || + feed === `feedgen|${STAGING_DEFAULT_FEED('thevids')}` + ) } function toString(interaction: AppBskyFeedDefs.Interaction): string { From 990bd39e360f4ac9eee91f646d477ca209d14fa3 Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 17 Jan 2025 11:25:20 -0800 Subject: [PATCH 2/4] use correct did --- src/lib/constants.ts | 6 ++++-- src/state/feed-feedback.tsx | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 1c049ea818..24830e8cd0 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -60,11 +60,13 @@ export function IS_PROD_SERVICE(url?: string) { return url && url !== STAGING_SERVICE && !url.startsWith(LOCAL_DEV_SERVICE) } +export const PROD_DEFAULT_FEED_DID = 'did:plc:z72i7hdynmk6r22z27h6tvur' export const PROD_DEFAULT_FEED = (rkey: string) => - `at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/${rkey}` + `at://${PROD_DEFAULT_FEED_DID}/app.bsky.feed.generator/${rkey}` +export const STAGING_DEFAULT_FEED_DID = 'did:plc:yofh3kx63drvfljkibw5zuxo' export const STAGING_DEFAULT_FEED = (rkey: string) => - `at://did:plc:yofh3kx63drvfljkibw5zuxo/app.bsky.feed.generator/${rkey}` + `at://${STAGING_DEFAULT_FEED_DID}/app.bsky.feed.generator/${rkey}` export const POST_IMG_MAX = { width: 2000, diff --git a/src/state/feed-feedback.tsx b/src/state/feed-feedback.tsx index c92f8455d9..456ab730d4 100644 --- a/src/state/feed-feedback.tsx +++ b/src/state/feed-feedback.tsx @@ -3,7 +3,11 @@ import {AppState, AppStateStatus} from 'react-native' import {AppBskyFeedDefs} from '@atproto/api' import throttle from 'lodash.throttle' -import {PROD_DEFAULT_FEED, STAGING_DEFAULT_FEED} from '#/lib/constants' +import { + PROD_DEFAULT_FEED, + STAGING_DEFAULT_FEED, + STAGING_DEFAULT_FEED_DID, +} from '#/lib/constants' import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed' @@ -25,6 +29,7 @@ const stateContext = React.createContext({ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { const agent = useAgent() const enabled = isDiscoverFeed(feed) && hasSession + const queue = React.useRef>(new Set()) const history = React.useRef< // Use a WeakSet so that we don't need to clear it. @@ -46,6 +51,11 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { const interactions = Array.from(queue.current).map(toInteraction) queue.current.clear() + let proxyDid = 'did:web:discover.bsky.app' + if (feed.includes(STAGING_DEFAULT_FEED_DID)) { + proxyDid = 'did:web:algo.pop2.bsky.app' + } + // Send to the feed agent.app.bsky.feed .sendInteractions( @@ -54,7 +64,7 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { 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', + 'atproto-proxy': `${proxyDid}#bsky_fg`, }, }, ) @@ -68,7 +78,7 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { } sendOrAggregateInteractionsForStats(aggregatedStats.current, interactions) throttledFlushAggregatedStats() - }, [agent, throttledFlushAggregatedStats]) + }, [agent, throttledFlushAggregatedStats, feed]) const sendToFeed = React.useMemo( () => From f61a9626de7ded24f9aaff32e453580fa02fbc6a Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 17 Jan 2025 11:27:13 -0800 Subject: [PATCH 3/4] typo --- src/state/feed-feedback.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state/feed-feedback.tsx b/src/state/feed-feedback.tsx index 456ab730d4..c7fdd15224 100644 --- a/src/state/feed-feedback.tsx +++ b/src/state/feed-feedback.tsx @@ -167,7 +167,7 @@ export function useFeedFeedbackContext() { function isDiscoverFeed(feed: FeedDescriptor) { return ( feed === `feedgen|${PROD_DEFAULT_FEED('whats-hot')}` || - feed === `feedgen|${PROD_DEFAULT_FEED('thevides')}` || + feed === `feedgen|${PROD_DEFAULT_FEED('thevids')}` || feed === `feedgen|${STAGING_DEFAULT_FEED('thevids')}` ) } From db73978470661053392d8c74a85b4749a6045520 Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 17 Jan 2025 12:08:09 -0800 Subject: [PATCH 4/4] tweak --- src/lib/constants.ts | 18 ++++++++++++++---- src/state/feed-feedback.tsx | 14 +++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 24830e8cd0..5ae000f729 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -60,13 +60,23 @@ export function IS_PROD_SERVICE(url?: string) { return url && url !== STAGING_SERVICE && !url.startsWith(LOCAL_DEV_SERVICE) } -export const PROD_DEFAULT_FEED_DID = 'did:plc:z72i7hdynmk6r22z27h6tvur' export const PROD_DEFAULT_FEED = (rkey: string) => - `at://${PROD_DEFAULT_FEED_DID}/app.bsky.feed.generator/${rkey}` + `at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/${rkey}` -export const STAGING_DEFAULT_FEED_DID = 'did:plc:yofh3kx63drvfljkibw5zuxo' export const STAGING_DEFAULT_FEED = (rkey: string) => - `at://${STAGING_DEFAULT_FEED_DID}/app.bsky.feed.generator/${rkey}` + `at://did:plc:yofh3kx63drvfljkibw5zuxo/app.bsky.feed.generator/${rkey}` + +export const PROD_FEEDS = [ + `feedgen|${PROD_DEFAULT_FEED('whats-hot')}`, + `feedgen|${PROD_DEFAULT_FEED('thevids')}`, +] + +export const STAGING_FEEDS = [ + `feedgen|${STAGING_DEFAULT_FEED('whats-hot')}`, + `feedgen|${STAGING_DEFAULT_FEED('thevids')}`, +] + +export const FEEDBACK_FEEDS = [...PROD_FEEDS, ...STAGING_FEEDS] export const POST_IMG_MAX = { width: 2000, diff --git a/src/state/feed-feedback.tsx b/src/state/feed-feedback.tsx index c7fdd15224..de5157a54e 100644 --- a/src/state/feed-feedback.tsx +++ b/src/state/feed-feedback.tsx @@ -3,11 +3,7 @@ import {AppState, AppStateStatus} from 'react-native' import {AppBskyFeedDefs} from '@atproto/api' import throttle from 'lodash.throttle' -import { - PROD_DEFAULT_FEED, - STAGING_DEFAULT_FEED, - STAGING_DEFAULT_FEED_DID, -} from '#/lib/constants' +import {FEEDBACK_FEEDS, STAGING_FEEDS} from '#/lib/constants' import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {FeedDescriptor, FeedPostSliceItem} from '#/state/queries/post-feed' @@ -52,7 +48,7 @@ export function useFeedFeedback(feed: FeedDescriptor, hasSession: boolean) { queue.current.clear() let proxyDid = 'did:web:discover.bsky.app' - if (feed.includes(STAGING_DEFAULT_FEED_DID)) { + if (STAGING_FEEDS.includes(feed)) { proxyDid = 'did:web:algo.pop2.bsky.app' } @@ -165,11 +161,7 @@ export function useFeedFeedbackContext() { // place, we're hardcoding it to the discover feed. // -prf function isDiscoverFeed(feed: FeedDescriptor) { - return ( - feed === `feedgen|${PROD_DEFAULT_FEED('whats-hot')}` || - feed === `feedgen|${PROD_DEFAULT_FEED('thevids')}` || - feed === `feedgen|${STAGING_DEFAULT_FEED('thevids')}` - ) + return FEEDBACK_FEEDS.includes(feed) } function toString(interaction: AppBskyFeedDefs.Interaction): string {