Skip to content

Conversation

@justanotheratom
Copy link
Contributor

Summary

This PR adds a ping endpoint call after login to measure backend latency and log it to PostHog with network metadata.

Changes

  • ✅ Added PING endpoint to SafeEatsEndpoint enum
  • ✅ Created NetworkInfo utility for network detection (wifi/cellular/other, cellular generation, carrier)
  • ✅ Created PingRepository for measuring backend latency
  • ✅ Integrated ping call in LoginAuthViewModel after successful login
  • ✅ Added trackEdgePing() to Analytics for PostHog logging
  • ✅ Added comprehensive logging throughout the ping flow
  • ✅ Ensures ping is called only once per app lifecycle (non-blocking)

Testing

  • ✅ Build successful
  • ✅ Installed and tested on emulator
  • ✅ Verified ping endpoint is called after login
  • ✅ Verified latency is measured correctly (1740ms in test)
  • ✅ Verified all metadata is collected:
    • client_latency_ms
    • app_version
    • device_model
    • network_type
    • cellular_generation
    • carrier (when on cellular)
  • ✅ Verified PostHog event 'edge_ping' is sent with all properties
  • ✅ Verified once-per-lifecycle behavior works correctly

Metadata Example

From test run:

  • client_latency_ms: 1740
  • app_version: 1.2.1
  • device_model: sdk_gphone64_arm64
  • network_type: wifi
  • cellular_generation: none
  • carrier: null (on wifi)

Matches iOS implementation behavior.

- Add PING endpoint to SafeEatsEndpoint enum
- Create NetworkInfo utility for network type, cellular generation, and carrier detection
- Create PingRepository for measuring backend latency
- Integrate ping call after successful login (once per app lifecycle)
- Add trackEdgePing() to Analytics for PostHog logging
- Add comprehensive logging throughout ping flow
- Log latency and metadata (app_version, device_model, network_type, cellular_generation, carrier) to PostHog

The ping endpoint is called non-blocking after device registration completes.
All metadata is collected and logged to PostHog with event name 'edge_ping'.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Remove detailed debug logging from NetworkInfo, PingRepository, LoginAuthViewModel, and Analytics
- Keep essential error logging for debugging failures
- Clean up code for production readiness
- Replace SharedPreferences persistence with in-memory @volatile flag
- Ping flag now resets on app restart (true once-per-lifecycle behavior)
- Remove KEY_PING_CALLED from AppConstants (no longer needed)
- Remove ping flag preservation logic from signOut methods

Previously, the ping flag persisted across app restarts via SharedPreferences,
causing ping to be skipped on every subsequent app launch after the first.
Now the flag is stored in-memory only and resets when the app process restarts.
@iAmVishal16 iAmVishal16 merged commit d964406 into main Nov 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants