at-internet / atinternet-android-sdk

AT Internet mobile analytics solution for Android
http://www.atinternet.com/
MIT License
9 stars 10 forks source link

Hits are not being sent anymore but stored into database #19

Closed UBaggeler closed 4 years ago

UBaggeler commented 5 years ago

We recently became aware of a problem where the AT Internet backend is receiving less and less traffic from our Android app. The traffic continuously decreased after upgrading to SDK version 2.12.1. Investigating this problem further revealed a serious issue regarding the implementation of the offline mode.

A change in version 2.12.0 (6e598ee718b0e77f143a8ef92d83ad7d7e3aa90e) introduced a bug which resulted in hits being stored erroneously to the database, even for trackers configured with storage: never (which is the default case). This could happen once the network connectivity was determined to be offline while trying to send a hit. From then on, all future hits (View, Click,...) were never sent to the backend anymore but only stored to the local database (even if network connectivity was back online).

This issue was partially rectified in version 2.13.1 with commit https://github.com/at-internet/atinternet-android-sdk/commit/612c5fef22979f85ca42feeefcde200515920b87, but unfortunately only for apps which did not have any hits stored in the database until then. For apps with offline hits stored in the database, all new hits are still being added to the database and not sent to the backend.

TLDR: From version 2.12.0 up to 2.13.1, trackers configured with storage: never are not sending hits anymore if the device was offline during the time when at least one hit was being sent. This was only fixed partially in 2.13.1, namely for apps without offline hits during the use of the previous SDK version.

BenDz commented 5 years ago

Hey @UBaggeler, thank you for this report and the PR. We just merged it and deployed the v2.13.3.

BenDz commented 5 years ago

Hey @UBaggeler, we discussed about your issue, in order to better understand what happened in your case. It seems that this issue only appears when you switch the offline mode configuration between never and required/always in your app. If you set it to never, there should never be any hit stored, then the case should not happen. Do you have something like this in your app? Thanks

UBaggeler commented 5 years ago

No, unfortunately this is not true. We always had the offline mode configured with never and never touched this setting.

Because of this bug introduced in version 2.12.0, the SDK stored events into the database when the app was determined to be offline. Even worse, once one (1) event was in the database, it continued to add new events to the database even if the user was back online, and never recovered from this.

It didn't (and still doesn't) try to send any of the events stored in the database to the server, because offline mode is set to never and in this case the SDK skips sending any offline events (includeOfflineHits of Sender.send() is set to tracker.getOfflineMode() != Tracker.OfflineMode.never).

Our PR fixes the problem in the way that newly generated events are again sent to the server but does not change the behaviour of sending out previously stored events. In our case, there are some months of data offline stored. If we want to send out all local events, we can use Tracker.Offline().dispatch();, but this might cause quite a high load on your servers as this is not batched and does not seem to be any delay between sending each stored event.

nsagnett commented 4 years ago

Sorry for the delay but it's fixed since v2.13.3

Thanks for your help on this topic