[APP-1805] Analytics tweaks and tracking callbacks (#9861)

This commit is contained in:
Eric Bailey
2026-02-19 15:31:35 -06:00
committed by GitHub
parent 1565e071c1
commit 4e3c3e9905
8 changed files with 89 additions and 22 deletions
+24
View File
@@ -3,6 +3,7 @@ import {type LocationGeocodedAddress} from 'expo-location'
import {IS_ANDROID} from '#/env'
import {logger} from '#/geolocation/logger'
import {type Geolocation} from '#/geolocation/types'
import {device} from '#/storage'
/**
* Maps full US region names to their short codes.
@@ -125,3 +126,26 @@ export function mergeGeolocations(
})
return geolocation
}
/**
* Gets the IP-based geolocation as a string in the format of
* "countryCode-regionCode", or just "countryCode" if regionCode is not
* available.
*
* IMPORTANT: this method should only return IP-based data, not the user's GPS
* based data. IP-based data we can already infer from requests, but for
* consistency between frontend and backend, we sometimes want to share the
* value we have on the frontend with the backend.
*/
export function getIPGeolocationString() {
const geo = device.get(['geolocationServiceResponse'])
if (!geo) return
const {countryCode, regionCode} = geo
if (countryCode) {
if (regionCode) {
return `${countryCode}-${regionCode}`
} else {
return countryCode
}
}
}