pocket-casts-ios icon indicating copy to clipboard operation
pocket-casts-ios copied to clipboard

End of Year: sync Listening History

Open leandroalonso opened this issue 2 years ago • 0 comments

📘 Project: #376

If we identify the user doesn't have the entire 2022 listening history, we sync this with the server adding the missing episodes.

This is a case that might happen for a very active user that switched devices during this year — given we only sync the latest 100 items.

How do we identify if a user needs a sync?

We look at their listening history. If they have an episode from last year, we assume that their 2022 listening history is complete.

A much more bulletproof strategy would be to call the endpoint to check the number of items for the user, and sync if needed, just once. But I'm not sure what would be the impact of such a call on the backend (@Ferdev curious to hear your thoughts about it).

To test

You'll need an account with more than 100 items. Please ping me and I can provide one.

  1. Enable the endOfYear flag in FeatureFlag.swift
  2. Do a clean run of the app in Staging mode (Schemes > pocketcasts > change "Build Configuration" to Staging)
  3. Login with an account with more than 100 items
  4. Check your listening history, you should see just ~40 items
  5. Put a breakpoint on EndOfYearStoriesBuilder.swift line 39
  6. Check your EoY stories
  7. ✅ The hitpoint should be hit, proceed with execution
  8. ✅ You should see the spinner for a few seconds
  9. ✅ The stories should appear
  10. Dismiss the stories
  11. Check your Listening History
  12. ✅ You should have more than 100 items there now (the oldest episode is an archived episode called "39. Mother"
  13. Check your stories again
  14. ✅ The endpoint should not be hit (2022 sync happens just once)

Checklist

  • [x] I have considered if this change warrants user-facing release notes and have added them to CHANGELOG.md if necessary.
  • [x] I have considered adding unit tests for my changes.
  • [x] I have updated (or requested that someone edit) the spreadsheet to reflect any new or changed analytics.

leandroalonso avatar Nov 04 '22 14:11 leandroalonso