App lifecycle tracking
The tracker can capture application lifecycle state changes. In particular, when the app changes state from foreground to background and vice versa.
The lifecycle tracking is enabled by default (since v6.0.0). It can be configured in TrackerConfiguration
like in the example below:
- iOS
- Android (Kotlin)
- Android (Java)
let trackerConfig = TrackerConfiguration()
.lifecycleAutotracking(true)
val trackerConfig = TrackerConfiguration("appId")
.lifecycleAutotracking(true)
TrackerConfiguration trackerConfig = new TrackerConfiguration("appId")
.lifecycleAutotracking(true);
Once enabled, the tracker will automatically track a Background
event when the app is moved to background and a Foreground
event when the app moves back to foreground (becomes visible in the screen).
The tracker attaches a LifecycleEntity
to all the events tracked by the tracker reporting if the app was visible (foreground state) when the event was tracked.
The LifecycleEntity
value is conditioned by the internal state of the tracker only. To make an example, if the app is in foreground state but the developer tracks a Background
event intentionally, it would force the generation of a LifecycleEntity
that mark the app as non visible, even if it's actually visible in the device.