public class CodenameOneAnalyticsProvider

  1. Object
  2. AbstractAnalyticsProvider
  3. 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

url String
the full ingest URL

setBatchSize

public void setBatchSize(int size)
Sets the number of events buffered before an automatic flush.

Parameters

size int
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

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

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

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