Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INTENG-21262 Fix for Duplicate purchase events (cached). #1433

Merged
merged 5 commits into from
Sep 24, 2024

Conversation

NidhiDixit09
Copy link
Collaborator

Reference

https://branch.atlassian.net/browse/INTENG-21262

Summary

Issue : SDK sends Duplicate purchase events on cold launch of app if network request processing failed in previous launches.

SDK archives a copy of its Request Queue on Disk. Its a txt file (BNCServerRequestQueue)stored inside the Application Support folder of the data container of app. This archived copy is updated at regular intervals using a timer.
When app is cold launched, SDK reads this file and adds requests left unprocessed from last run in its Request Queue.
Because of a bug in SDK, this archived file was not deleted from disk if current request queue is empty. As a result, SDK keeps sending these cached requests on every cold launch of app.

Steps for reproducing bug :

  1. Turn off WIFI / internet
  2. Send any Standard or custom Event.
  3. Quit App.
  4. Turn On WIFI / Internet
  5. Launch App. (Cold launch is required for reproducing this issue)
  6. On Launch app will send all failed events. This is expected behavior.
  7. Quit App
  8. Re-Launch again
  9. On Launch app will send all failed events again. These events are not cleared from cache and SDK keeps sending them.

Type Of Change

  • Bug fix (non-breaking change which fixes an issue)

Testing Instructions

-> Check all unit tests pass.
-> Verify fix -
- Create BNCServerRequestQueue archive file using steps mentioned above (Steps 1-4). On my system its stored at path /Users/nidhi.dixit/Library/Developer/CoreSimulator/Devices/9C999B8A-A12B-4DDC-9A7E-A7F9DE201024/data/Containers/Data/Application/FD451857-78A8-4C5A-88C3-7CC9932D931C/Library/Application\ Support/io.branch. I am testing using simulator.
- Cold Lauch App and check all failed requests in previous launch are processed. BNCServerRequestQueue file is deleted / updated and it does not contain processed requests anymore.
- Cold Launch App again and check SDK is not sending duplicate purchase events.

cc @BranchMetrics/saas-sdk-devs for visibility.

-> Remove archived request file from disk when those req. are added in queue for processing on app launch.
-> When persist timer is fired and req queue is empty, delete cache file from disk. persistImmediately func was earlier returning without updating cache if req queue was empty.
-> Added check fileExistsAtPath before removing it in func removeSaveFile.
Copy link
Contributor

@nsingh-branch nsingh-branch left a comment

Choose a reason for hiding this comment

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

After testing with the current SDK and this branch, i was able to see the issue before but now it appears to be fixed.

@NidhiDixit09 NidhiDixit09 merged commit 66dfe77 into master Sep 24, 2024
14 checks passed
Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 50.96%. Comparing base (1836823) to head (dc6907f).
Report is 34 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1433      +/-   ##
==========================================
- Coverage   51.10%   50.96%   -0.14%     
==========================================
  Files          66       66              
  Lines       10158    10273     +115     
  Branches     3724     3775      +51     
==========================================
+ Hits         5191     5236      +45     
- Misses       4707     4777      +70     
  Partials      260      260              
Flag Coverage Δ
50.96% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@NidhiDixit09 NidhiDixit09 changed the title [IN PROGRESS] INTENG-21262 Fix for Duplicate purchase events (cached). INTENG-21262 Fix for Duplicate purchase events (cached). Sep 24, 2024
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