package com.codename1.analytics
The analytics API tracks how your application is used in the field through a
generic provider SPI. Register one or more AnalyticsProvider
implementations with the Analytics facade and
report screen views, events, user properties and crashes; the facade fans
each call out to every provider once the relevant consent has been granted.
Built-in providers include the first-party
CodenameOneAnalyticsProvider (reporting into
the Codename One cloud, with capabilities gated by your subscription tier),
GoogleAnalyticsProvider (Google Analytics 4),
MatomoAnalyticsProvider (privacy-first, self
hostable), FirebaseAnalyticsProvider and the
LoggingAnalyticsProvider used in the
simulator and tests.
Consent is configurable and defaults to opt-in
(ConsentMode.OPT_IN): nothing is collected or
transmitted until the application records a choice via
Analytics.setConsent(com.codename1.analytics.AnalyticsConsent),
helping you comply with GDPR / CCPA. The pseudonymous client id is not
derived from any hardware identifier and can be cleared with
Analytics.resetClientId() to honour erasure
requests.
The previous AnalyticsService entry point is
retained, deprecated, and now delegates to this API.
Types
class AbstractAnalyticsProvider | Convenience base class for AnalyticsProvider implementations. |
class Analytics | The application-facing entry point for analytics. |
enum AnalyticsCapability | Enumerates the analytics features a provider (or a server-side subscription tier) may support. |
class AnalyticsConsent | An immutable snapshot of the consent the user has granted, broken down by category so that an application can honour granular choices (for example allowing crash reporting while declining behavioural analytics). |
class AnalyticsContext | Immutable bundle of ambient information shared with every provider through AnalyticsProvider.init(AnalyticsContext). |
class AnalyticsCrashReport | A crash / exception report routed to providers that advertise AnalyticsCapability.CRASH_REPORTING. |
class AnalyticsEvent | An immutable analytics event: a named action with an optional category and an ordered set of parameters. |
interface AnalyticsProvider | The analytics service provider interface (SPI). |
class AnalyticsService | The legacy analytics entry point, retained for backward compatibility. |
class CodenameOneAnalyticsProvider | The Codename One first-party analytics provider. |
enum ConsentMode | Controls the default behaviour of Analytics before the application has recorded an explicit consent choice from the user. |
class FirebaseAnalyticsProvider | A provider that forwards analytics to the native Firebase Analytics SDK. |
class GoogleAnalyticsProvider | A provider for Google Analytics 4 using the Measurement Protocol (v2). |
class LegacyAnalyticsProviderAdapter | Bridges a legacy AnalyticsService subclass into the new AnalyticsProvider SPI so that custom analytics implementations written against the deprecated API can participate in the Analytics facade alongside modern providers. |
class LoggingAnalyticsProvider | A provider that simply logs every call (and records them in memory) instead of sending data anywhere. |
class MatomoAnalyticsProvider | A privacy-first provider targeting Matomo (formerly Piwik) through its HTTP Tracking API. |