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

Constants
long SCHEDULE_SEND_DELAY_SECONDS Minimum amount of delay when uploadEvents() is called.
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 and analyticsEnabled is set to true, otherwise false.
void recordLocation(Location location)
Records a location.
void recordLocation(Location location, LocationRequestOptions options, int updateType)
Records a location.
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 tearDown()
Tear down the manager.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final long SCHEDULE_SEND_DELAY_SECONDS

Minimum amount of delay when uploadEvents() is called.

Constant Value: 10 (0x000000000000000a)

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 and analyticsEnabled is set to true, 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 recordLocation (Location location)

Records a location.

Parameters
location The location to record.

public void recordLocation (Location location, LocationRequestOptions options, int updateType)

Records a location.

Parameters
location The new location.
options The location request options.
updateType The update type.

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 tearDown ()

Tear down the manager. Called in UAirship during land.