# Package com.codename1.analytics

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.

- Class
  Description
  AbstractAnalyticsProvider
  Convenience base class for `AnalyticsProvider` implementations.
  Analytics
  The application-facing entry point for analytics.
  AnalyticsCapability
  Enumerates the analytics features a provider (or a server-side subscription tier) may support.
  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).
  AnalyticsConsent.Builder
  Mutable builder for `AnalyticsConsent`.
  AnalyticsContext
  Immutable bundle of ambient information shared with every provider through `AnalyticsProvider.init(AnalyticsContext)`.
  AnalyticsCrashReport
  A crash / exception report routed to providers that advertise `AnalyticsCapability.CRASH_REPORTING`.
  AnalyticsCrashReport.Builder
  Mutable builder for `AnalyticsCrashReport`.
  AnalyticsEvent
  An immutable analytics event: a named action with an optional category and an ordered set of parameters.
  AnalyticsEvent.Builder
  Mutable builder for `AnalyticsEvent`.
  AnalyticsProvider
  The analytics service provider interface (SPI).
  AnalyticsService
  Deprecated.
  use `Analytics` and an `AnalyticsProvider`
  CodenameOneAnalyticsProvider
  The Codename One first-party analytics provider.
  ConsentMode
  Controls the default behaviour of `Analytics` before the application has recorded an explicit consent choice from the user.
  FirebaseAnalyticsProvider
  A provider that forwards analytics to the native Firebase Analytics SDK.
  FirebaseAnalyticsProvider.Bridge
  The platform's connection to the native Firebase SDK.
  GoogleAnalyticsProvider
  A provider for Google Analytics 4 using the Measurement Protocol (v2).
  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.
  LoggingAnalyticsProvider
  A provider that simply logs every call (and records them in memory) instead of sending data anywhere.
  MatomoAnalyticsProvider
  A privacy-first provider targeting Matomo (formerly Piwik) through its HTTP Tracking API.