koa-health / mixpanel_analytics

A dart wrapper on the mixpanel REST API to be used in Flutter applications.
https://pub.dev/packages/mixpanel_analytics
MIT License
19 stars 26 forks source link

SharedPreferences as an optional dependency #29

Open venkatd opened 3 years ago

venkatd commented 3 years ago

For our app, SharedPreferences is a heavy dependency. It would be nice to make this an optional dependency so we can use whatever store we're already interested in. For example, we are using IndexedDB on our web platform and get_storage on mobile for improved performance.

Maybe you can pass in the following callbacks and in the README provide for a few lines to integrate with SharedPreferences? You can default to doing this in-memory so others can customize how they want to handle the persistence.

Future<void> putString(String key, String value);
Future<String?> getString(String key);
venkatd commented 3 years ago

@robertohuertasm we have a pending PR for mixpanel using this library. Is this change a you and your team agree with?

If so, would you be open to me issuing a PR?

The main downside is that the default behavior would no longer be persisting sentry requests between app runs. These would get cached in memory. To get this, someone would need to paste some code from the README into their app to get persistence.

robertohuertasm commented 3 years ago

Hi @venkatd, sorry for not coming back to you sooner. The thing is that I don't think this change is going to be easy from our side... which translates in this not being a quick change for us to implement. Let me see if I can find some time next week to handle this.

venkatd commented 3 years ago

@robertohuertasm no problem, there's no rush :)

To demonstrate what I had in mind, I've submitted a draft PR. Let me know what you think when you get a chance.