public class LoggingAnalyticsProvider

  1. Object
  2. AbstractAnalyticsProvider
  3. LoggingAnalyticsProvider

ImplementsAnalyticsProvider

A provider that simply logs every call (and records them in memory) instead of sending data anywhere. It is the recommended default in the simulator and is used as the backing provider in unit tests, where getLog() lets a test assert exactly which calls were made.

Constructors

public LoggingAnalyticsProvider()

Methods

public String getName()A short, stable, human readable name for this provider (used in logs and diagnostics).
public List<String> getLog()The in-memory record of calls received by this provider, in order.
public void clearLog()Clears the recorded call log.
public void trackScreen(String name, String referrer)Records a screen / page view.
public void trackEvent(AnalyticsEvent event)Records a named event.
public void setUserId(String id)Associates subsequent activity with a user identifier.
public void setUserProperty(String key, String value)Sets a user-level property / custom dimension.
public void reportCrash(AnalyticsCrashReport report)Reports a crash or handled exception.
public void onConsentChanged(AnalyticsConsent consent)Notifies the provider that the user’s consent has changed so it can enable, disable or reconfigure collection accordingly.
public void flush()Flushes any buffered events to the backend.
public boolean supports(AnalyticsCapability capability)Indicates whether the provider supports a given capability.

Inherited methods

Constructor details

LoggingAnalyticsProvider

public LoggingAnalyticsProvider()

Method details

getName

public String getName()
A short, stable, human readable name for this provider (used in logs and diagnostics).

Returns

the provider name

getLog

public List<String> getLog()
The in-memory record of calls received by this provider, in order. Each entry is a short description such as "screen:Home" or "event:purchase".

Returns

the recorded call log

clearLog

public void clearLog()
Clears the recorded call log.

trackScreen

public void trackScreen(String name, String referrer)
Records a screen / page view.

Parameters

name String
the screen name
referrer String
the previous screen name, may be null

trackEvent

public void trackEvent(AnalyticsEvent event)
Records a named event.

Parameters

event AnalyticsEvent
the event

setUserId

public void setUserId(String id)
Associates subsequent activity with a user identifier.

Parameters

id String
the user id, or null to clear

setUserProperty

public void setUserProperty(String key, String value)
Sets a user-level property / custom dimension.

Parameters

key String
the property name
value String
the property value

reportCrash

public void reportCrash(AnalyticsCrashReport report)
Reports a crash or handled exception.

Parameters

report AnalyticsCrashReport
the crash report

onConsentChanged

public void onConsentChanged(AnalyticsConsent consent)
Notifies the provider that the user’s consent has changed so it can enable, disable or reconfigure collection accordingly.

Parameters

consent AnalyticsConsent
the new consent state

flush

public void flush()
Flushes any buffered events to the backend.

supports

public boolean supports(AnalyticsCapability capability)
Indicates whether the provider supports a given capability.

Parameters

capability AnalyticsCapability
the capability to query

Returns

true if supported