public abstract class AbstractAnalyticsProvider

  1. Object
  2. AbstractAnalyticsProvider

ImplementsAnalyticsProvider

Known subtypesCodenameOneAnalyticsProvider, FirebaseAnalyticsProvider, GoogleAnalyticsProvider, LegacyAnalyticsProviderAdapter, LoggingAnalyticsProvider, MatomoAnalyticsProvider

Convenience base class for AnalyticsProvider implementations. Every SPI method has an empty / no-op body so a concrete provider only overrides the calls it actually supports. The AnalyticsContext handed to init(AnalyticsContext) is retained and exposed via getContext(); supports(AnalyticsCapability) returns false for every capability and should be overridden.

Constructors

public AbstractAnalyticsProvider()

Methods

public abstract String getName()A short, stable, human readable name for this provider (used in logs and diagnostics).
public void init(AnalyticsContext context)Called once when the provider is registered with the facade, supplying ambient application context.
protected AnalyticsContext getContext()The context supplied at init(AnalyticsContext) time.
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

AbstractAnalyticsProvider

public AbstractAnalyticsProvider()

Method details

getName

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

Returns

the provider name

init

public void init(AnalyticsContext context)
Called once when the provider is registered with the facade, supplying ambient application context.

Parameters

context AnalyticsContext
the analytics context

getContext

protected AnalyticsContext getContext()
The context supplied at init(AnalyticsContext) time.

Returns

the context, or null if not yet initialised

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