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

SDK losts events in offline mode #271

Closed
sergeyYuriev opened this issue Nov 8, 2019 · 3 comments
Closed

SDK losts events in offline mode #271

sergeyYuriev opened this issue Nov 8, 2019 · 3 comments
Assignees
Labels

Comments

@sergeyYuriev
Copy link

SDK losts events in offline mode

SCENARIO TO REPRODUCE ISSUE:
Tracker instance must be singleton.

  1. Disable network
  2. Start an android app
  3. Produce some matomo events more than cache size
  4. Enable network. Matomo events go to the server.
  5. Disable network
  6. Produce some matomo events.
  7. Enable network.
  8. ISSUE> NEW events does not send to the server!

ENV / AND CACHE CONFIGURATION:
Android version - 8 (api 26)
Matomo SDK version - 1.4.0
Dispatch Mode - DispatchMode.ALWAYS
Dispatch Interval - 0 Milliseconds
Offline Cache Age - 1440 hours
Offline Cache Size - 1Kb

Technical DESCRIPTION:
SDK doesn't refresh value of "mCurrentSize" variable in class "EventDiskCache" after it sends events to the server (when deletes all cache files in the file system). Files doesn't exist on file system, but SDK think that file system is full and deletes new matomo events. (new matomo events are lost)

Could you fix or explain the workaround for this issue?

@d4rken d4rken added the bug label Nov 9, 2019
@d4rken
Copy link
Member

d4rken commented Nov 9, 2019

Just did a quick look at the code and I think you are right. Will have to find some time to further look into it. Maybe someone else can submit a PR with a bugfix and tests for this?

Workarounds:

  • Disable the size limit by setting it to 0
  • Supply your own disk cache instance

Good report btw 👌

@sergeyYuriev
Copy link
Author

Thank you for quick response. I will try your workaround suggestions.

@d4rken
Copy link
Member

d4rken commented Dec 6, 2019

mCurrentSize is being updated but the order is the issue.

Caching new data:

  • Check current limits, if necessary, delete stuff
  • Store new data

After storing new data we may be over the current limits!

Uncaching data

  • Check limits, if necessary, delete stuff. If the previous caching put us over the limits, we delete data here before returning it.
  • Return new events

@d4rken d4rken self-assigned this Dec 6, 2019
d4rken added a commit to d4rken/piwik-sdk-android that referenced this issue Dec 6, 2019
@d4rken d4rken closed this as completed in fe4c0f2 Dec 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants