@@ -16,26 +16,16 @@ import {
1616import { getStoredPushToken } from "@/features/diagnostics/pushTokenStore" ;
1717import { checkNativeStatus } from "@/service/checkNativeStatus" ;
1818
19- // We treat each foreground activation as a potential "app open", but throttle pings so a user
20- // quickly toggling in and out of the app doesn't flood the pipeline. time_since_last_open is the
21- // gap since the previous ping, which for a normally-used app is the day-to-day open cadence.
2219const LAST_OPEN_KEY = "diagnostics.lastOpenAt" ;
23- const PING_THROTTLE_MS = 30 * 60 * 1000 ; // 30 minutes
20+ const PING_THROTTLE_MS = 30 * 60 * 1000 ;
2421
25- /**
26- * Periodically reports a diagnostics snapshot (app version, OTA bundle, push state, etc.) to the
27- * backend's CheckNativeStatus endpoint. Fires on cold start and on each background→foreground
28- * transition, throttled to at most once per PING_THROTTLE_MS.
29- *
30- * Everything here is best-effort and fire-and-forget: a failed or skipped ping must never affect
31- * app startup or the user.
32- */
22+ // Reports a diagnostics snapshot to CheckNativeStatus on cold start and each foreground
23+ // transition, throttled to at most once per PING_THROTTLE_MS. Best-effort and fire-and-forget.
3324export function useNativeDiagnostics ( ) : void {
3425 const { authenticated } = useAuthContext ( ) ;
3526 const { i18n } = useTranslation ( ) ;
3627
37- // Read auth/locale via refs so the AppState listener always sees current values without
38- // re-subscribing on every change.
28+ // Refs so the AppState listener sees current values without re-subscribing.
3929 const authenticatedRef = useRef ( authenticated ) ;
4030 authenticatedRef . current = authenticated ;
4131 const localeRef = useRef ( i18n . language ) ;
@@ -92,9 +82,7 @@ export function useNativeDiagnostics(): void {
9282
9383 await AsyncStorage . setItem ( LAST_OPEN_KEY , String ( now ) ) ;
9484
95- // TODO: surface a force-update / soft-update UI when the backend asks the client to update.
96- // For now the server always returns permissive defaults; once the decision logic exists
97- // we'll wire result.updateRequired / updateAvailable into a modal here.
85+ // TODO: wire result.updateRequired / updateAvailable into a force-update UI.
9886 if ( result . updateRequired || result . updateAvailable ) {
9987 console . log ( "Native status update prompt:" , result ) ;
10088 }
@@ -103,10 +91,8 @@ export function useNativeDiagnostics(): void {
10391 }
10492 }
10593
106- // Cold start.
10794 maybeReport ( ) ;
10895
109- // Subsequent background→foreground transitions.
11096 const subscription = AppState . addEventListener (
11197 "change" ,
11298 ( state : AppStateStatus ) => {
0 commit comments