public class LoggingAnalyticsProvider
- Object
- AbstractAnalyticsProvider
- 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
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
nameString- the screen name
referrerString- the previous screen name, may be null
trackEvent
public void trackEvent(AnalyticsEvent event)Records a named event.
Parameters
eventAnalyticsEvent- the event
setUserId
public void setUserId(String id)Associates subsequent activity with a user identifier.
Parameters
idString- the user id, or null to clear
setUserProperty
public void setUserProperty(String key, String value)Sets a user-level property / custom dimension.
Parameters
keyString- the property name
valueString- the property value
reportCrash
public void reportCrash(AnalyticsCrashReport report)Reports a crash or handled exception.
Parameters
reportAnalyticsCrashReport- 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
consentAnalyticsConsent- 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
capabilityAnalyticsCapability- the capability to query
Returns
true if supported