OfflineWeb
An offline storage extension that records analytics events in indexedDB when offline, and resyncs those events when back online. The extension adds a timestamp to each saved extension under the timeSaved
key.
Like all offline storage extensions, this extension expects that you're already storing a connectivity flag in your app's state.
Installation
Import
Usage
Step 1
The first step is to track the connection status in your state. Here's an example of how you would do so using browser's in-built offline and online events:
Step 2
Create a connectivity selector that accepts the state, and returns your app's connection status:
The connectivity selector should return a boolean:
true
when the app is onlinefalse
when the app is offline
Step 3
Initialize the extension and provide it when creating a middleware or meta reducer:
Now, whenever your app loses connection, your analytics events will now be saved offline until it regains its connection.
Last updated