Class CodenameOneAnalyticsProvider
- All Implemented Interfaces:
AnalyticsProvider
The Codename One first-party analytics provider. It batches events and
posts them as JSON to the Codename One cloud
(/api/v2/analytics/events), where they are stored and aggregated for the
reports shown in the developer console. The capabilities you actually get
(screen views, custom events, retention window, raw export) are gated
server-side by your subscription tier.
App identity is read from the build-injected Display properties
(build_key, package_name, AppName, AppVersion, OSVer) -- the same
mechanism the on-device crash client uses -- so no API key needs to be
embedded in the app. Events are buffered in memory and flushed when the
batch fills up or when flush() is called.
Analytics.addProvider(new CodenameOneAnalyticsProvider());
Analytics.setConsent(AnalyticsConsent.granted());
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidflush()Flushes any buffered events to the backend.getName()A short, stable, human readable name for this provider (used in logs and diagnostics).voidreportCrash(AnalyticsCrashReport report) Reports a crash or handled exception.voidsetBatchSize(int size) Sets the number of events buffered before an automatic flush.voidsetEndpoint(String url) Overrides the ingest endpoint URL.voidsetUserProperty(String key, String value) Sets a user-level property / custom dimension.booleansupports(AnalyticsCapability capability) Indicates whether the provider supports a given capability.voidtrackEvent(AnalyticsEvent event) Records a named event.voidtrackScreen(String name, String referrer) Records a screen / page view.Methods inherited from class AbstractAnalyticsProvider
getContext, init, onConsentChanged, setUserId
-
Constructor Details
-
CodenameOneAnalyticsProvider
public CodenameOneAnalyticsProvider()
-
-
Method Details
-
setEndpoint
Overrides the ingest endpoint URL. By default the provider posts to the Codename One cloud (honouring the
cloudServerURLdisplay property).Parameters
url: the full ingest URL
-
setBatchSize
public void setBatchSize(int size) Sets the number of events buffered before an automatic flush.
Parameters
size: the batch size, values below 1 are clamped to 1
-
getName
Description copied from interface:AnalyticsProviderA short, stable, human readable name for this provider (used in logs and diagnostics).
Returns
the provider name
- Specified by:
getNamein interfaceAnalyticsProvider- Specified by:
getNamein classAbstractAnalyticsProvider
-
trackScreen
Description copied from interface:AnalyticsProviderRecords a screen / page view.
Parameters
-
name: the screen name -
referrer: the previous screen name, may be null
- Specified by:
trackScreenin interfaceAnalyticsProvider- Overrides:
trackScreenin classAbstractAnalyticsProvider
-
-
trackEvent
Description copied from interface:AnalyticsProviderRecords a named event.
Parameters
event: the event
- Specified by:
trackEventin interfaceAnalyticsProvider- Overrides:
trackEventin classAbstractAnalyticsProvider
-
setUserProperty
Description copied from interface:AnalyticsProviderSets a user-level property / custom dimension.
Parameters
-
key: the property name -
value: the property value
- Specified by:
setUserPropertyin interfaceAnalyticsProvider- Overrides:
setUserPropertyin classAbstractAnalyticsProvider
-
-
reportCrash
Description copied from interface:AnalyticsProviderReports a crash or handled exception.
Parameters
report: the crash report
- Specified by:
reportCrashin interfaceAnalyticsProvider- Overrides:
reportCrashin classAbstractAnalyticsProvider
-
flush
public void flush()Description copied from interface:AnalyticsProviderFlushes any buffered events to the backend.- Specified by:
flushin interfaceAnalyticsProvider- Overrides:
flushin classAbstractAnalyticsProvider
-
supports
Description copied from interface:AnalyticsProviderIndicates whether the provider supports a given capability.
Parameters
capability: the capability to query
Returns
true if supported
- Specified by:
supportsin interfaceAnalyticsProvider- Overrides:
supportsin classAbstractAnalyticsProvider
-