How to test offline events in android

Based on the following statement from the document.
caching events in a SQLite database in order to avoid losing events to network related issues..

I tried to test for android offline events. Steps followed.

  1. Started android application.
  2. removed the internet connection.
  3. tried to send events by clicking some buttons on activity.
  4. opened the SQLite DB file and queried events table. zero rows found.

Not sure how to test this functionality.
Have the following questions:

  1. Do we need to wait for some time to reflect events in DB?
  2. I believe the tracker will take care of these offline messages automatically to send to emitter without adding any extra code. am I correct?
  3. if my assumption in question 2 Yes, then will it delete all the stored offline events from DB automatically?

I think having a look at the tests for the event store might be a good start to get an idea of how the functionality persists events. Events should be persisted in the event store before being removed when sent.

Hi @Llazarusjohn,
Your steps are correct and you should be able to see some rows in the db.
You could try a test with our Demo app.

  1. Started demo app
  2. Set wrong collector address
  3. Pushed β€œStart” button (it sends a bunch of events)
  4. Below the β€œStart” button there are some details about tracker state. You should see that DB size increased as the tracker is not able to send events successfully.
  5. Killed the app from Android Studio
  6. From Android Studio: View > Tool Window > Device File Explorer
  7. Get sqlite files from: snowplowtrackerdemo > databases
  8. Browsing the db the number of stored events should be the same reported by the app (at point 4)

About the questions:

  1. The tracker handle the events in separate threads but the time needed to store the event in the db is really short.
  2. No extra code needed. This is fully managed by the tracker.
  3. The tracker store always the event in the db. Once the event is successfully sent to the collector it takes charge of deleting the event from the db.
1 Like

Thank you for your response. Working fine through the Test app. I could see all entries as a Blob( Not sure how to read as a text). But it works thank again.

1 Like