Skip to content

Analytics Android#

The Analytics module in the Inflight Android SDK is responsible for capturing user interactions within the airline’s In-Flight Entertainment and Connectivity (IFEC) system. It logs various data points, including screen transitions, application lifecycle events, and language changes, throughout the journey from flight origin to destination. All collected data is stored locally on the device and offloaded after the flight. This service is powered by Paxus (Passenger Usage Logging Software), a specialized software library used by airlines to record and offload IFEC usage data.


Step 1: Analytics Service Initialization#

This document outlines how to initialize the SDK and use the available APIs.

a. Property Declaration

Declare a variable to hold the Analytics service object, which will act as the interface for all analytics API calls.

 private AnalyticsV1 mAnalyticsV1; // Analytics service object

b. AnalyticsV1 Service Initialization

API Definition

initService(Context context, IInFlightCallback callback, InFlight inFlight)

Parameters:

  • context: The application context for service initialization.

  • callback: A callback interface (IInFlightCallback) that handles initialization results.

  • inFlight: An instance of the InFlight system for service connectivity.

Callback Interface

  • onInitServiceComplete(Object serviceObject, String serviceName): Returns the initialized analytics service object on success.

  • onInitServiceFailed(String serviceName, Error error): Returns an error if initialization fails.

AnalyticsV1 mAnalyticsV1 ; // Initialize variable
InFlight inFlight = new InFlight(); // InFlight system instance
AnalyticsV1.initService(context, new IInFlightCallback() {
    @Override
    public void onInitServiceComplete(Object serviceObject, String serviceName) {
        mAnalyticsV1 = serviceObject; // Store initialized service
    }
    @Override
    public void onInitServiceFailed(String serviceName, InFlight.Error error) {
        // Handle initialization error (e.g., show error message)
        Log.e("AnalyticsV1Init", "Initialization failed: " + error.name());
    }
}, inFlight);

Step 2: Analytics API Usage#

2.1. Set App Name - (setAppName)#

Purpose:

Sets the name of the application for the analytic report. This is populated by default using the information provided by PackageManager.

Parameters:

appName - Name of application.

public void setAppName​(String appName)

Usage example:

When to Call:

  • Immediately after the app is launched and before logging any analytics events like applicationStart() or screenChange().

  • Typically in the application's onCreate() method or when navigating from the home screen to the selected app.

if (mAnalyticsV1 != null) {
    String appName = context.getApplicationInfo().loadLabel(context.getPackageManager()).toString();
    mAnalyticsV1.setAppName(appName);
}

2.2. Set App Version - (setAppVersion)#

Purpose:

Sets the version of the application for analytic report. This version information is logged alongside analytics events to help identify which version of the application generated the data.

This value is populated by default using the information provided by Packagemanager.

Parameters:

appVersion - Version of the application. Populated by default.

public void setAppVersion​(String appVersion)

Usage example:

When to Call:

  • During application initialization, typically in the onCreate() method of your main activity.

  • Before logging any analytics events, ensuring all events are tagged with the correct app version.

Example :

  • Passenger opens the Companion app.

  • The system retrieves the current app version from BuildConfig.VERSION_NAME or the app’s package info.

  • Then it sets the version in Analytics:

if (mAnalyticsV1 != null) {
    String appVersion = BuildConfig.VERSION_NAME;
    mAnalyticsV1.setAppVersion(appVersion);
}

2.3. Application Lifecycle Analytics Events#

This section outlines the implementation and usage of analytics events to track the start and stop of an application (or module) within the In-Flight Entertainment (IFE) system.

2.3.1. Application Start

Purpose:

This method logs the start of an application (or module) within the IFE system.

public void applicationStart()

When to Call:

  • When the first activity of the application starts (i.e., when the app comes to the foreground).

  • Typically triggered via ActivityLifecycleCallbacks in the onActivityStarted() method, when the activity count transitions from 0 to 1.

2.3.2. Application Stop

Purpose:

This method logs an event indicating that the current application has stopped. It marks the end of the user’s session within the app on the In-Flight Entertainment (IFE) system.

public void applicationStop()

When to Call:

  • When the last activity of the application stops (i.e., when the app goes to the background).

  • Typically triggered via ActivityLifecycleCallbacks in the onActivityStopped() method, when the activity count transitions from 1 to 0.

Example :

  1. Track application-level start and stop events for analytics by monitoring activity lifecycle transitions.

  2. Trigger an APPLICATION_START event when the first activity starts (i.e., when the app comes to the foreground).

  3. Trigger an APPLICATION_STOP event when the last activity stops (i.e., when the app goes to the background).

  4. Ensure accurate and consistent app usage tracking without modifying individual activity classes.

  5. Achieve this by implementing a centralized ActivityLifecycleCallbacks inside the Application class.

/**
 * LifecycleCallbacks to track Application Start and Stop events
*/
private static class LifecycleCallbacks implements ActivityLifecycleCallbacks {

    private final AnalyticsV1 analyticsV1;
    private int runningActivities = 0;

    public LifecycleCallbacks(AnalyticsV1 analyticsV1) {
        this.analyticsV1 = analyticsV1;
    }

    @Override
    public void onActivityStarted(Activity activity) {
        if (++runningActivities == 1) {
            // First activity started — Application Start event
            analyticsV1.applicationStart();
        }
    }

    @Override
    public void onActivityStopped(Activity activity) {
        if (--runningActivities == 0) {
            // All activities stopped — Application Stop event
            analyticsV1.applicationStop();
        }
    }
}

2.4. Screen Navigation Event#

This section defines methods to record screen transition events within the application for analytics purposes, capturing both basic and enriched navigation details.

2.4.1 Screen Change (Basic)

Purpose:

Records a navigation event when a user transitions from one screen to another.

public void screenChange(String requestedScreen,
                         String destinationScreen)

Parameters:

  • source: The name of the previous screen (can be null if unknown).

  • destination: The name of the screen the user has navigated to (must not be null).

Usage example :

When to Call:

  • Whenever a passenger navigates from one screen to another within an application.

  • Typically placed immediately after a screen transition is triggered by a user action.

Example:

  1. Passenger selects Top Gun: Maverick from the MovieList screen.

  2. The system navigates to the MovieDetails screen.

  3. The app logs this screen transition using:

if (mAnalyticsV1 != null ) {
    mAnalyticsV1.screenChange("MovieList", "MovieDetails");
}

This ensures the Analytics module records both the source and destination screens for precise user journey tracking within the app.

2.4.2. Screen Change (Enhanced)

Purpose:

Enhanced version of the basic screen transition API that logs additional contextual metadata about the screen being navigated to.

Parameters:

  • requestedScreen: The source or current screen. This field can be null.

  • destinationScreen: The requested or destination screen. This field cannot be null.

  • screenContent: The dynamic content being presented, e.g., a movie title. This field can be null.

  • screenCategory: Category of the current screen. This field can be null. SDK appends "_APP" to "screenCategory" parameter, if screenCategory is NOT null.

  • screenLanguageCode: ISO 639-2 language code of the current screen. This field can be null.

public void screenChange(String requestedScreen,
                         String destinationScreen,
                         String screenContent,
                         String screenCategory,
                         String screenLanguageCode)

Usage example :

When to Call:

  • Immediately after a screen transition occurs within the application.

  • Particularly when moving to a content-specific screen (like movie details, episode preview, etc.) to log contextual information about the user’s interaction.

Example :

  1. Passenger selects Top Gun: Maverick from the MovieList screen.

  2. The system navigates to the MovieDetails screen for the selected title.

  3. The app logs this screen transition along with the content name, category, and language code:

mAnalyticsV1.screenChange(
    "MovieList",
    "MovieDetails",
    "Top Gun: Maverick",
    "Movies",
    "en"
);

This ensures comprehensive analytics data capturing both navigation flow and contextual details for accurate user behaviour analysis.


2.5. Language change#

Purpose:

Tracks when a user changes the language setting of the IFE system.

Parameters:

language - Language the passenger selected.

public void languageChange​(String language)

Usage Scenario:

When to Call:

  • Immediately after the passenger selects a new language in the application’s language settings.

  • Before rendering UI or content updates in the selected language.

Example:

  1. Passenger opens the language settings in the Movies.

  2. Selects French as the preferred language.

  3. The app logs this language change:

if (mAnalyticsV1 != null) {
    mAnalyticsV1.languageChange("fr");  // 'fr' for French
}

Version 1.0