matomo-org / matomo-sdk-ios

Matomo iOS, tvOS and macOS SDK: a Matomo tracker written in Swift
MIT License
390 stars 164 forks source link

Are events/screenviews occuring while the user is offline tracked when the user comes back online? #200

Closed mattab closed 6 years ago

mattab commented 6 years ago

Hi @brototyp

wondering if the events/screenviews occuring while the user is offline are then tracked when the user comes back online?

FYI: By default Piwik accepts "events in the past" for up to 24 hours in the past.

It would be great to support this :+1:

(Refs https://github.com/piwik/piwik-sdk-ios/issues/100)

brototyp commented 6 years ago

Hi @mattab,

that is already the case since the start of the Swift version. All events/screenviews are tracked in this order:

  1. Create an Event and stored it in a queue
  2. When the Event dispatcher ist dispatching it will take X (currently 20) Events and send them to the Backend
  3. If the Events were send properly, they will be removed from the queue and the next events are sent. If it failed to dispatch the events due to failed internet connection, the dispatcher will sleep and try later.

But: Currently the event queue is in memory only, so if the app is terminated all non dispatched events are lost. (#137)

mattab commented 6 years ago

Thanks for the notes @brototyp

-> Would be great to add a description of the feature in the readme, so people looking for "offline" for example will directly see it's supported :+1:

brototyp commented 6 years ago

I added a paragraph to the readme.