about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/screens/Log.tsx20
-rw-r--r--src/state/geolocation/config.ts22
-rw-r--r--src/state/geolocation/index.tsx8
3 files changed, 33 insertions, 17 deletions
diff --git a/src/screens/Log.tsx b/src/screens/Log.tsx
index 2dd7fe84c..aa31e2cea 100644
--- a/src/screens/Log.tsx
+++ b/src/screens/Log.tsx
@@ -87,7 +87,21 @@ export function LogScreen({}: NativeStackScreenProps<
                   ) : (
                     <CircleInfoIcon size="sm" />
                   )}
-                  <Text style={[a.flex_1]}>{String(entry.message)}</Text>
+                  <View
+                    style={[
+                      a.flex_1,
+                      a.flex_row,
+                      a.justify_start,
+                      a.align_center,
+                      a.gap_sm,
+                    ]}>
+                    {entry.context && (
+                      <Text style={[t.atoms.text_contrast_medium]}>
+                        ({String(entry.context)})
+                      </Text>
+                    )}
+                    <Text>{String(entry.message)}</Text>
+                  </View>
                   {entry.metadata &&
                     Object.keys(entry.metadata).length > 0 &&
                     (expanded.includes(entry.id) ? (
@@ -115,7 +129,9 @@ export function LogScreen({}: NativeStackScreenProps<
                       t.atoms.border_contrast_low,
                     ]}>
                     <View style={[a.px_sm, a.py_xs]}>
-                      <Text>{JSON.stringify(entry.metadata, null, 2)}</Text>
+                      <Text style={[a.leading_snug, {fontFamily: 'monospace'}]}>
+                        {JSON.stringify(entry.metadata, null, 2)}
+                      </Text>
                     </View>
                   </View>
                 )}
diff --git a/src/state/geolocation/config.ts b/src/state/geolocation/config.ts
index 1f7f2daf2..913b674cb 100644
--- a/src/state/geolocation/config.ts
+++ b/src/state/geolocation/config.ts
@@ -20,7 +20,7 @@ async function getGeolocationConfig(
   })
 
   if (!res.ok) {
-    throw new Error(`geolocation config: fetch failed ${res.status}`)
+    throw new Error(`config: fetch failed ${res.status}`)
   }
 
   const json = await res.json()
@@ -35,7 +35,7 @@ async function getGeolocationConfig(
       ageRestrictedGeos: json.ageRestrictedGeos ?? [],
       ageBlockedGeos: json.ageBlockedGeos ?? [],
     }
-    logger.debug(`geolocation config: success`)
+    logger.debug(`config: success`)
     return config
   } else {
     return undefined
@@ -85,7 +85,7 @@ export function beginResolveGeolocationConfig() {
     } catch (e: any) {
       success = false
 
-      logger.debug(`geolocation config: failed initial request`, {
+      logger.debug(`config: failed initial request`, {
         safeMessage: e.message,
       })
 
@@ -101,12 +101,12 @@ export function beginResolveGeolocationConfig() {
             success = true
           } else {
             // endpoint should throw on all failures, this is insurance
-            throw new Error(`geolocation config: nothing returned from retries`)
+            throw new Error(`config: nothing returned from retries`)
           }
         })
         .catch((e: any) => {
           // complete fail closed
-          logger.debug(`geolocation config: failed retries`, {
+          logger.debug(`config: failed retries`, {
             safeMessage: e.message,
           })
         })
@@ -123,21 +123,19 @@ export function beginResolveGeolocationConfig() {
  */
 export async function ensureGeolocationConfigIsResolved() {
   if (!geolocationConfigResolution) {
-    throw new Error(
-      `geolocation config: beginResolveGeolocationConfig not called yet`,
-    )
+    throw new Error(`config: beginResolveGeolocationConfig not called yet`)
   }
 
   const cached = device.get(['geolocation'])
   if (cached) {
-    logger.debug(`geolocation config: using cache`)
+    logger.debug(`config: using cache`)
   } else {
-    logger.debug(`geolocation config: no cache`)
+    logger.debug(`config: no cache`)
     const {success} = await geolocationConfigResolution
     if (success) {
-      logger.debug(`geolocation config: resolved`)
+      logger.debug(`config: resolved`)
     } else {
-      logger.info(`geolocation config: failed to resolve`)
+      logger.info(`config: failed to resolve`)
     }
   }
 }
diff --git a/src/state/geolocation/index.tsx b/src/state/geolocation/index.tsx
index d01e3f262..8bddb23fb 100644
--- a/src/state/geolocation/index.tsx
+++ b/src/state/geolocation/index.tsx
@@ -91,11 +91,13 @@ export function GeolocationStatusProvider({
 
   const configContext = React.useMemo(() => ({config}), [config])
   const statusContext = React.useMemo(() => {
-    if (deviceGeolocation) {
-      logger.debug('geolocation: has device geolocation available')
+    if (deviceGeolocation?.countryCode) {
+      logger.debug('has device geolocation available')
     }
     const geolocation = mergeGeolocation(deviceGeolocation, config)
     const status = computeGeolocationStatus(geolocation, config)
+    // ensure this remains debug and never leaves device
+    logger.debug('result', {deviceGeolocation, geolocation, status, config})
     return {location: geolocation, status}
   }, [config, deviceGeolocation])
 
@@ -117,7 +119,7 @@ export function Provider({children}: {children: React.ReactNode}) {
 
   const handleSetDeviceGeolocation = React.useCallback(
     (location: DeviceLocation) => {
-      logger.debug('geolocation: setting device geolocation')
+      logger.debug('setting device geolocation')
       setDeviceGeolocation({
         countryCode: location.countryCode ?? undefined,
         regionCode: location.regionCode ?? undefined,