Add stable ID to discover requests

This commit is contained in:
Eric Bailey
2026-02-11 14:43:01 -06:00
parent ff4512bede
commit 17117abe11
2 changed files with 29 additions and 6 deletions
+19
View File
@@ -3,6 +3,7 @@ import {type LocationGeocodedAddress} from 'expo-location'
import {IS_ANDROID} from '#/env' import {IS_ANDROID} from '#/env'
import {logger} from '#/geolocation/logger' import {logger} from '#/geolocation/logger'
import {type Geolocation} from '#/geolocation/types' import {type Geolocation} from '#/geolocation/types'
import {device} from '#/storage'
/** /**
* Maps full US region names to their short codes. * Maps full US region names to their short codes.
@@ -125,3 +126,21 @@ export function mergeGeolocations(
}) })
return geolocation return geolocation
} }
/**
* Get's the merged geolocation as a string in the format of
* "countryCode-regionCode", or just "countryCode" if regionCode is not
* available.
*/
export function getGeolocationString() {
const geo = device.get(['mergedGeolocation'])
if (!geo) return
const {countryCode, regionCode} = geo
if (countryCode) {
if (regionCode) {
return `${countryCode}-${regionCode}`
} else {
return countryCode
}
}
}
+10 -6
View File
@@ -9,6 +9,7 @@ import {
getAppLanguageAsContentLanguage, getAppLanguageAsContentLanguage,
getContentLanguages, getContentLanguages,
} from '#/state/preferences/languages' } from '#/state/preferences/languages'
import {getDeviceId} from '#/analytics/identifiers'
import {type FeedAPI, type FeedAPIResponse} from './types' import {type FeedAPI, type FeedAPIResponse} from './types'
import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils' import {createBskyTopicsHeader, isBlueskyOwnedFeed} from './utils'
@@ -62,12 +63,15 @@ export class CustomFeedAPI implements FeedAPI {
limit, limit,
}, },
{ {
headers: { headers: isBlueskyOwned
...(isBlueskyOwned ? {
? createBskyTopicsHeader(this.userInterests) ...createBskyTopicsHeader(this.userInterests),
: {}), 'X-Bsky-Stable-Id': getDeviceId(),
'Accept-Language': contentLangs, 'Accept-Language': contentLangs,
}, }
: {
'Accept-Language': contentLangs,
},
}, },
) )
: await loggedOutFetch({...this.params, cursor, limit}) : await loggedOutFetch({...this.params, cursor, limit})