···11+import {Platform} from 'react-native'
12import {type AppBskyAgeassuranceBegin, AtpAgent} from '@atproto/api'
23import {useMutation} from '@tanstack/react-query'
34···89 PUBLIC_APPVIEW_DID,
910} from '#/lib/constants'
1011import {isNetworkError} from '#/lib/hooks/useCleanError'
1111-import {logger} from '#/logger'
1212import {useAgent} from '#/state/session'
1313import {usePatchAgeAssuranceServerState} from '#/ageAssurance'
1414+import {logger} from '#/ageAssurance/logger'
1415import {BLUESKY_PROXY_DID} from '#/env'
1516import {useGeolocation} from '#/geolocation'
1617···2930 'countryCode' | 'regionCode'
3031 >,
3132 ) {
3232- const countryCode = geolocation?.countryCode
3333- const regionCode = geolocation?.regionCode
3333+ const countryCode = geolocation?.countryCode?.toUpperCase()
3434+ const regionCode = geolocation?.regionCode?.toUpperCase()
3435 if (!countryCode) {
3536 throw new Error(`Geolocation not available, cannot init age assurance.`)
3637 }
···4748 appView.sessionManager.session.accessJwt = token
4849 appView.sessionManager.session.refreshJwt = ''
49505151+ logger.metric(
5252+ 'ageAssurance:api:begin',
5353+ {
5454+ platform: Platform.OS,
5555+ countryCode,
5656+ regionCode,
5757+ },
5858+ {statsig: false},
5959+ )
6060+5061 /*
5162 * 2s wait is good actually. Email sending takes a hot sec and this helps
5263 * ensure the email is ready for the user once they open their inbox.
···5566 2e3,
5667 appView.app.bsky.ageassurance.begin({
5768 ...props,
5858- countryCode: countryCode.toUpperCase(),
5959- regionCode: regionCode ? regionCode.toUpperCase() : undefined,
6969+ countryCode,
7070+ regionCode,
6071 }),
6172 )
6273
+18-4
src/geolocation/util.ts
···11import {type LocationGeocodedAddress} from 'expo-location'
2233+import {isAndroid} from '#/platform/detection'
34import {logger} from '#/geolocation/logger'
45import {type Geolocation} from '#/geolocation/types'
56···7576 location: LocationGeocodedAddress,
7677): Geolocation {
7778 let {isoCountryCode, region} = location
7979+ let regionCode: string | undefined = region ?? undefined
78807979- if (region) {
8080- if (isoCountryCode === 'US') {
8181- region = USRegionNameToRegionCode[region] ?? region
8181+ /*
8282+ * Android doesn't give us ISO 3166-2 short codes. We need these for US
8383+ */
8484+ if (isAndroid) {
8585+ if (region && isoCountryCode === 'US') {
8686+ /*
8787+ * We need short codes for US states. If we can't remap it, just drop it
8888+ * entirely for now.
8989+ */
9090+ regionCode = USRegionNameToRegionCode[region] ?? undefined
9191+ } else {
9292+ /*
9393+ * Outside the US, we don't need regionCodes for now, so just drop it.
9494+ */
9595+ regionCode = undefined
8296 }
8397 }
84988599 return {
86100 countryCode: isoCountryCode ?? undefined,
8787- regionCode: region ?? undefined,
101101+ regionCode,
88102 }
89103}
90104