public abstract class AbstractAnalyticsProvider
- Object
- 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
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
contextAnalyticsContext- 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
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