ryer.io

Debugging Date Handling in App Cohort Content Update

TL;DR

  • Tested cohort content update by changing device date settings.
  • Confirmed backend uses server’s timezone for date calculation.
  • Realized need for client control over local timezone date.
  • Aimed to synchronize date display by allowing client-sent date.
  • Debugged useCallback issue causing refresh function not to execute.

In my latest debugging session, I was addressing an issue where the app was returning a different value than expected in relation to the cohort content update based on the user’s date. Using my mobile device, I tested the functionality by changing the system date settings to ensure that the value indeed changes from day to day.

Steps I Took:

  1. Initial Testing: I adjusted my device’s date settings and observed that although the device date changed, the backend cohort age in days did not change due to the use of a UTC timestamp calculation.

  2. Backend Timezone Handling: Realized the backend was adjusting the server’s UTC by the timezone value, hence relying on consistent timezone settings rather than local adjustments.

  3. Client Date Control: Decided to allow the client to send a date in ISO format to ensure the app reflects accurate local day content for users, considering fallbacks for unsupported clients.

  4. Debugging iOS Issue: On iOS, despite changing the date, the frontend didn’t refresh the data due to a missed network call. This led me to investigate logic checks and the useCallback hook used for memoization.

  5. Conclusion: Adjusted frontend logic to ensure refresh calls are adequately made. This confirmed that specific cohort content updates align better with user expectations by respecting client-local dates and ensuring backend compatibility.

By solving these, the app should now reflect the correct cohort content based on a user’s actual local day.