public interface AnalyticsProvider
Known subtypesAbstractAnalyticsProvider, CodenameOneAnalyticsProvider, FirebaseAnalyticsProvider, GoogleAnalyticsProvider, LegacyAnalyticsProviderAdapter, LoggingAnalyticsProvider, MatomoAnalyticsProvider
The analytics service provider interface (SPI). Implement this to plug an
analytics backend into the Analytics facade. Several providers can
be registered at once; the facade fans every call out to all of them after
the relevant consent has been satisfied.
Providers are registered by explicit instantiation
(Analytics.addProvider(new MyProvider())) – no reflection or service
lookup is used, which keeps the mechanism safe under the obfuscation applied
to shipped builds. Most implementations should extend
AbstractAnalyticsProvider and override only the calls they support.
Methods
Method details
getName
public abstract String getName()Returns
init
public abstract void init(AnalyticsContext context)Parameters
contextAnalyticsContext- the analytics context
trackScreen
public abstract void trackScreen(String name, String referrer)Parameters
nameString- the screen name
referrerString- the previous screen name, may be null
trackEvent
public abstract void trackEvent(AnalyticsEvent event)Parameters
eventAnalyticsEvent- the event
setUserId
public abstract void setUserId(String id)Parameters
idString- the user id, or null to clear
setUserProperty
public abstract void setUserProperty(String key, String value)Parameters
keyString- the property name
valueString- the property value
reportCrash
public abstract void reportCrash(AnalyticsCrashReport report)Parameters
reportAnalyticsCrashReport- the crash report
onConsentChanged
public abstract void onConsentChanged(AnalyticsConsent consent)Parameters
consentAnalyticsConsent- the new consent state
flush
public abstract void flush()supports
public abstract boolean supports(AnalyticsCapability capability)Parameters
capabilityAnalyticsCapability- the capability to query