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 AbstractAnalyticsProviderConvenience base class for AnalyticsProvider implementations.
class AnalyticsThe application-facing entry point for analytics.
enum AnalyticsCapabilityEnumerates the analytics features a provider (or a server-side subscription tier) may support.
class AnalyticsConsentAn 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 AnalyticsContextImmutable bundle of ambient information shared with every provider through AnalyticsProvider.init(AnalyticsContext).
class AnalyticsCrashReportA crash / exception report routed to providers that advertise AnalyticsCapability.CRASH_REPORTING.
class AnalyticsEventAn immutable analytics event: a named action with an optional category and an ordered set of parameters.
interface AnalyticsProviderThe analytics service provider interface (SPI).
class AnalyticsServiceThe legacy analytics entry point, retained for backward compatibility.
class CodenameOneAnalyticsProviderThe Codename One first-party analytics provider.
enum ConsentModeControls the default behaviour of Analytics before the application has recorded an explicit consent choice from the user.
class FirebaseAnalyticsProviderA provider that forwards analytics to the native Firebase Analytics SDK.
class GoogleAnalyticsProviderA provider for Google Analytics 4 using the Measurement Protocol (v2).
class LegacyAnalyticsProviderAdapterBridges 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 LoggingAnalyticsProviderA provider that simply logs every call (and records them in memory) instead of sending data anywhere.
class MatomoAnalyticsProviderA privacy-first provider targeting Matomo (formerly Piwik) through its HTTP Tracking API.