Edit in GitHubLog an issue

Lifecycle

Sessions contain information about the app's current lifecycle, such as the device information, the application install or upgrade information, the session start and pause times, the number of application launches, and additional context data that is provided by the developer through the LifecycleStart API. Session data is persisted, so it is available across application launches.

Add Lifecycle to your app

  1. Add the Lifecycle extension and its dependency, the Mobile Core extension to your project using the app's Gradle file.

Kotlin

Copied to your clipboard
implementation(platform("com.adobe.marketing.mobile:sdk-bom:3.+"))
implementation("com.adobe.marketing.mobile:core")
implementation("com.adobe.marketing.mobile:lifecycle")

Groovy

Copied to your clipboard
implementation platform('com.adobe.marketing.mobile:sdk-bom:3.+')
implementation 'com.adobe.marketing.mobile:core'
implementation 'com.adobe.marketing.mobile:lifecycle'
  1. Import the Lifecycle and MobileCore extensions in your application's main activity.
Copied to your clipboard
import com.adobe.marketing.mobile.MobileCore;
import com.adobe.marketing.mobile.Lifecycle;

Register Lifecycle with Mobile Core and add appropriate Start/Pause calls

Java

  1. Register the Lifecycle extension:
Copied to your clipboard
public class MobileApp extends Application {
@Override
public void onCreate() {
super.onCreate();
MobileCore.setApplication(this);
List<Class<? extends Extension>> extensions = Arrays.asList(Lifecycle.EXTENSION, ...);
MobileCore.registerExtensions(extensions, o -> {
// Any other post registration processing
});
}
}
  1. In the onResume function, start the lifecycle data collection:
Copied to your clipboard
@Override
public void onResume() {
MobileCore.setApplication(getApplication());
MobileCore.lifecycleStart(null);
}

Setting the application is only necessary on activities that are entry points for your application. However, setting the application on each Activity has no negative impact and ensures that the SDK always has the necessary reference to your application. We recommend that you call setApplicationin each of your activities.

  1. In the onPause function, pause the lifecycle data collection:
Copied to your clipboard
@Override
public void onPause() {
MobileCore.lifecyclePause();
}

To ensure accurate session and crash reporting, this call must be added to every activity.

Lifecycle metrics

The following is a complete list of all of the metrics provided on your user's app lifecycle.

Application Context

MetricKeyDescription
App ID
a.AppID
Stores the application name and version in the following format: AppName BundleVersion (app version code). An example of this format is MyAppName 1.1(1).
Device name
a.DeviceName
Stores the device name.
Operating system version
a.OSVersion
Stores the operating system name and version.
Carrier name
a.carrierName
Stores the name of the mobile service provider as provided by the device.

This metric is not automatically stored in an Analytics variable. You must create a processing rule to copy this value to an Analytics variable for reporting.
Resolution
a.Resolution
The width x height in pixels.
Locale
a.Locale
The locale set for this device. For example, this value can be en-US.

Install

MetricKeyDescription
First Launches
a.InstallEvent
Triggered at the first run after installation or re-installation.
Install Date
a.InstallDate
Date of first launch after installation. The format is M/d/yyyy, and an example is 5/3/2017.

Upgrade

MetricKeyDescription
Upgrades
a.UpgradeEvent
Triggered at the first run after upgrade or when the version number changes.
Launches since last upgrade
a.LaunchesSinceUpgrade
Number of days since the application version number changed.
Days since last upgrade
a.DaysSinceLastUpgrade
Number of launches since the application version number changed.

Launch

MetricKeyDescription
Daily Engaged Users
a.DailyEngUserEvent
Triggered when the application is used on a particular day. Important: This metric is not automatically stored in an Analytics metric. You must create a processing rule that sets a custom event to capture this metric.
Monthly Engaged Users
a.MonthlyEngUserEvent
Triggered when the application is used during a particular month. Important: This metric is not automatically stored in an Analytics metric. You must create a processing rule that sets a custom event to capture this metric.
Launches
a.LaunchEvent
Triggered on every run, including crashes and installs. Also triggered when the app is resumed from the background after the lifecycle session timeout is exceeded.
Previous Session Length
a.PrevSessionLength
Reports the number of seconds that a previous application session lasted based on how long the application was open and in the foreground.
Ignored Session Length
a.ignoredSessionLength
If the last session is set to last longer than lifecycle.sessionTimeout, that session length is ignored and recorded here.
Launch Number
a.Launches
Number of times the application was launched or brought out of the background.
Days since first use
a.DaysSinceFirstUse
Number of days since first run.
Days since last use
a.DaysSinceLastUse
Number of days since last use.
Hour of Day
a.HourOfDay
Measures the hour the app was launched and uses the 24-hour numerical format. Used for time parting to determine peak usage times.
Day of Week
a.DayOfWeek
Measures the day of the week the app was launched.

Crash

MetricKeyDescription
Crashes
a.CrashEvent
Triggered when the application crashed before closing. The event is sent when the application is started again after the crash.

Device information

MetricKeyDescription
App ID
a.AppId
Stores the application name and version in the AppName BundleVersion (app version code) format.

An example of this format is MyAppName 1.1(1).
Device name
a.DeviceName
Stores the device name.
Operating system version
a.OSVersion
Stores the operating system name and version.
Carrier name
a.CarrierName
Stores the name of the mobile service provider as provided by the devices.

This metric is not automatically saved in an Analytics variable. For reporting, you must create a processing rule to copy this value to an Analytics variable.
Resolution
a.Resolution
The width x height in pixels.
Locale
a.Locale
The locale set for this device. For example, this can be en-US.

If you need to programmatically update your SDK configuration, use the following information to change your Lifecycle configuration values:

KeyDescription
lifecycle.sessionTimeout
Number of seconds that must elapse between the app entering the background and subsequently re-entering the foreground in order for the SDK to create a new session.

The default value is 300 seconds (5 minutes).
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.