aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.43k stars 2.13k forks source link

Cached Analytics Data while Offline #834

Open zjullion opened 6 years ago

zjullion commented 6 years ago

Do you want to request a feature or report a bug? Feature Request

What is the current behavior? Analytics data (via Pinpoint) is not being cached while offline. If the device is not online when Analytics.record() is called, the data is simply lost.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than AWS Amplify.

What is the expected behavior? Analytics data is cached until the device comes online.

Which versions of Amplify, and which browser / OS are affected by this issue? Did this work in previous versions?

You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.

Extra info: On this page https://aws.amazon.com/mobileanalytics/faqs/, under 'Q: Is data cached when a user’s device is offline?', it states that analytics data is cached while offline. Apparently this functionality is no longer available with Pinpoint.

mbahar commented 6 years ago

I think this is a feature request. Currently, Analytics category doesn't have an offline to online strategy implemented.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

harrysolovay commented 4 years ago

There are many ways to handle the retry logic and invalidation. This is out-of-scope for now.

If you'd like to submit a PR, we're more than happy to review it!

cwomack commented 1 year ago

Hey @zjullion 👋. I know this has been open for a few years, but have you found a way to get offline user/Analytics data cached and then pushed to Pinpoint when the device is back online?

While there's no guidance in our docs on how to access offline Analytics data specifically, you may be able to utilize the Amplify service worker in combination with the cache module if you stored the user data in localStorage. The Hub utility was also added more recently than this issue was opened as well, which would allow for listening to specific events to trigger/add logic for when that cached data should then be sent to Pinpoint.

Leaving this as a feature request for now, but we'd welcome any community PR's that can implement this reliably.