tonyxiao / react-native-analytics

React Native wrapper for SegmentIO's Analytics SDK
https://github.com/smore-inc/react-native-segment-io-analytics
MIT License
34 stars 19 forks source link

Track application lifecycle events. #16

Closed sesm closed 2 years ago

sesm commented 6 years ago

Add option to enable application lifecycle events tracking. The third argument to setup method is added as a Map, for future extensibility. Tested on both iOS and Android.

BenBach commented 6 years ago

Hi

I tried the same approach. The problem is that this won't work reliably.

This library is initialized in react native code which is sometimes too late to catch Application installed events (mainly on iOS). It's kind of a race condition. Once you init it and enable the application lifecycle config it might be already after the install event.

The way we solved this was by tracking these events ourselves in javascript. I can share the module with you if you are interested.

sesm commented 6 years ago

@BenBach That's interesting, could you please share the module with me? Thanks!

BenBach commented 6 years ago

@sesm Sorry for the delay.

I uploaded the code we are using to a new repository. There is still one bug that the Application Install event is fired twice this but should be easy to catch. We didn't bother with it much since we group by user id and anonymous id anyway

https://github.com/freework-gmbh/app-lifecycle

sesm commented 6 years ago

@BenBach thanks a lot!