flurry / react-native-flurry-sdk

React Native Flurry SDK
Apache License 2.0
45 stars 13 forks source link

:bug: Use getReactApplicationContext to build agent #3

Closed CubeSugar closed 5 years ago

CubeSugar commented 5 years ago

According to the comment of getCurrentActivity method, current Activity is not suitable context for flurry agent initialization.

poting-oath commented 5 years ago

Great catch! Flurry native library internally converts the passing in context to Application context at the initializing time. Yes, to be more consistent with the Flurry APIs, we will update this for the next release. Thanks!

poting-oath commented 5 years ago

This fix is in release 1.5.0. Due to our company's policy, we will need to merge the commit internally. Thanks for your support!

poting-oath commented 5 years ago

By using Application context here will cause "D FlurryAgent: There is no active Flurry session. Adding this event to deferred queue and flush them when the session initializes. Event: Some Event".

When React Native starts the main JS (index.js), an Android Activity already started. At this time, when passing an Application context to Flurry, Flurry will not start session immediately. Flurry will use Android's Activity Lifecycle listener to wait for the next Activity resumed and starts the new session. Hence cause this issue.

We will revert the change for the next release. BTW, Flurry will not keep the Context, no memory leak issue here.