public class CodenameOneAnalyticsProvider
- Object
- AbstractAnalyticsProvider
- CodenameOneAnalyticsProvider
ImplementsAnalyticsProvider
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());
Constructors
public CodenameOneAnalyticsProvider() |
Methods
public void setEndpoint(String url) | Overrides the ingest endpoint URL. |
public void setBatchSize(int size) | Sets the number of events buffered before an automatic flush. |
public String getName() | A short, stable, human readable name for this provider (used in logs and diagnostics). |
public void trackScreen(String name, String referrer) | Records a screen / page view. |
public void trackEvent(AnalyticsEvent event) | Records a named event. |
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 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
CodenameOneAnalyticsProvider
public CodenameOneAnalyticsProvider()Method details
setEndpoint
public void setEndpoint(String url)Overrides the ingest endpoint URL. By default the provider posts to the
Codename One cloud (honouring the
cloudServerURL display property).Parameters
urlString- the full ingest URL
setBatchSize
public void setBatchSize(int size)Sets the number of events buffered before an automatic flush.
Parameters
sizeint- the batch size, values below 1 are clamped to 1
getName
public String getName()A short, stable, human readable name for this provider (used in logs and
diagnostics).
Returns
the provider name
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
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
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