public class

Analytics

extends AirshipComponent
java.lang.Object
   ↳ com.urbanairship.AirshipComponent
     ↳ com.urbanairship.analytics.Analytics

Class Overview

This class is the primary interface to the Airship Analytics API.

Summary

Public Constructors
Analytics(Context context, PreferenceDataStore dataStore, AirshipRuntimeConfig runtimeConfig, AirshipChannel channel)
Public Methods
void addAnalyticsListener(AnalyticsListener analyticsListener)
Adds an AnalyticsListener for analytics events.
void addEvent(Event event)
Adds an analytics event.
AssociatedIdentifiers.Editor editAssociatedIdentifiers()
Edits the currently stored associated identifiers.
AssociatedIdentifiers getAssociatedIdentifiers()
Returns the device's current associated identifiers.
String getConversionSendId()
Returns the last stored send Id from when a push conversion was detected.
String getSessionId()
Gets the current environment Id.
boolean isAppInForeground()
Determines if the application is in the foreground.
boolean isEnabled()
Returns true if analytics is enabled, analyticsEnabled is set to true, and data collection is opted in, otherwise false.
void removeAnalyticsListener(AnalyticsListener analyticsListener)
Removes an AnalyticsListener for analytics events.
void setEnabled(boolean enabled)
Sets analytics enabled.
void trackScreen(String screen)
Initiates screen tracking for a specific app screen, must be called once per tracked screen.
void uploadEvents()
Uploads any pending events.
Protected Methods
void init()
Initialize the manager.
void onDataCollectionEnabledChanged(boolean isDataCollectionEnabled)
Called when the data collection enabled changes.
void tearDown()
Tear down the manager.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Analytics (Context context, PreferenceDataStore dataStore, AirshipRuntimeConfig runtimeConfig, AirshipChannel channel)

Public Methods

public void addAnalyticsListener (AnalyticsListener analyticsListener)

Adds an AnalyticsListener for analytics events.

Parameters
analyticsListener The AnalyticsListener.

public void addEvent (Event event)

Adds an analytics event.

Parameters
event The event to be triggered.

public AssociatedIdentifiers.Editor editAssociatedIdentifiers ()

Edits the currently stored associated identifiers. All changes made in the editor are batched, and not stored until you call apply(). Calling apply() on the editor will associate the identifiers with the device and add an event that will be sent up with other analytics events. See AssociatedIdentifiers.Editor

Returns
  • The AssociatedIdentifiers.Editor

public AssociatedIdentifiers getAssociatedIdentifiers ()

Returns the device's current associated identifiers.

Returns
  • The current associated identifiers.

public String getConversionSendId ()

Returns the last stored send Id from when a push conversion was detected.

Returns
  • A send Id String.

public String getSessionId ()

Gets the current environment Id.

Returns
  • A environment Id String.

public boolean isAppInForeground ()

Determines if the application is in the foreground.

Returns
  • true if the application is in the foreground, otherwise false.

public boolean isEnabled ()

Returns true if analytics is enabled, analyticsEnabled is set to true, and data collection is opted in, otherwise false.

Features that depend on analytics being enabled may not work properly if it's disabled (reports, region triggers, location segmentation, push to local time).

Returns
  • true if analytics is enabled, otherwise false.

public void removeAnalyticsListener (AnalyticsListener analyticsListener)

Removes an AnalyticsListener for analytics events.

Parameters
analyticsListener The AnalyticsListener.

public void setEnabled (boolean enabled)

Sets analytics enabled. When disabling analytics, any locally stored events will be deleted.

Features that depend on analytics being enabled may not work properly if it's disabled (reports, region triggers, location segmentation, push to local time).

Parameters
enabled true to enable analytics, false to disable.

public void trackScreen (String screen)

Initiates screen tracking for a specific app screen, must be called once per tracked screen.

Parameters
screen The screen's string identifier.

public void uploadEvents ()

Uploads any pending events. Events are batched and uploaded automatically to conserve battery life. Normally apps should not call this method directly.

Protected Methods

protected void init ()

Initialize the manager. Called in UAirship during takeoff.

protected void onDataCollectionEnabledChanged (boolean isDataCollectionEnabled)

Called when the data collection enabled changes.

Parameters
isDataCollectionEnabled The enabled state.

protected void tearDown ()

Tear down the manager. Called in UAirship during land.