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 disabled by default. It can be enabled in TrackerConfiguration
like in the example below:
const tracker = createTracker(
'appTracker',
{
endpoint: COLLECTOR_URL,
},
{
trackerConfig: {
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.