# Class LoggingAnalyticsProvider

java.lang.Object
com.codename1.analytics.AbstractAnalyticsProvider
com.codename1.analytics.LoggingAnalyticsProvider

All Implemented Interfaces:
  `AnalyticsProvider`

public class LoggingAnalyticsProvider extends AbstractAnalyticsProvider
A provider that simply logs every call (and records them in memory) instead of sending data anywhere. It is the recommended default in the simulator and is used as the backing provider in unit tests, where `getLog()` lets a test assert exactly which calls were made.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LoggingAnalyticsProvider()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clearLog()`
  Clears the recorded call log.
  `void`
  `flush()`
  Flushes any buffered events to the backend.
  `List<String>`
  `getLog()`
  The in-memory record of calls received by this provider, in order.
  `String`
  `getName()`
  A short, stable, human readable name for this provider (used in logs and diagnostics).
  `void`
  `onConsentChanged(AnalyticsConsent consent)`
  Notifies the provider that the user's consent has changed so it can enable, disable or reconfigure collection accordingly.
  `void`
  `reportCrash(AnalyticsCrashReport report)`
  Reports a crash or handled exception.
  `void`
  `setUserId(String id)`
  Associates subsequent activity with a user identifier.
  `void`
  `setUserProperty(String key, String value)`
  Sets a user-level property / custom dimension.
  `boolean`
  `supports(AnalyticsCapability capability)`
  Indicates whether the provider supports a given capability.
  `void`
  `trackEvent(AnalyticsEvent event)`
  Records a named event.
  `void`
  `trackScreen(String name, String referrer)`
  Records a screen / page view.

  ### Methods inherited from class AbstractAnalyticsProvider

  `getContext, init`

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LoggingAnalyticsProvider

    public LoggingAnalyticsProvider()

- ## Method Details

  - ### getName

    public String getName()
    Description copied from interface: `AnalyticsProvider`

    A short, stable, human readable name for this provider (used in logs and diagnostics).

    ###### Returns

    the provider name

    Specified by:
      `getName` in interface `AnalyticsProvider`
    Specified by:
      `getName` in class `AbstractAnalyticsProvider`

  - ### getLog

    public List<String> getLog()

    The in-memory record of calls received by this provider, in order. Each entry is a short description such as `"screen:Home"` or `"event:purchase"`.

    ###### Returns

    the recorded call log

  - ### clearLog

    public void clearLog()
    Clears the recorded call log.

  - ### trackScreen

    public void trackScreen(String name, String referrer)
    Description copied from interface: `AnalyticsProvider`

    Records a screen / page view.

    ###### Parameters

    - `name`: the screen name

    - `referrer`: the previous screen name, may be null

    Specified by:
      `trackScreen` in interface `AnalyticsProvider`
    Overrides:
      `trackScreen` in class `AbstractAnalyticsProvider`

  - ### trackEvent

    public void trackEvent(AnalyticsEvent event)
    Description copied from interface: `AnalyticsProvider`

    Records a named event.

    ###### Parameters

    - `event`: the event
    Specified by:
      `trackEvent` in interface `AnalyticsProvider`
    Overrides:
      `trackEvent` in class `AbstractAnalyticsProvider`

  - ### setUserId

    public void setUserId(String id)
    Description copied from interface: `AnalyticsProvider`

    Associates subsequent activity with a user identifier.

    ###### Parameters

    - `id`: the user id, or null to clear
    Specified by:
      `setUserId` in interface `AnalyticsProvider`
    Overrides:
      `setUserId` in class `AbstractAnalyticsProvider`

  - ### setUserProperty

    public void setUserProperty(String key, String value)
    Description copied from interface: `AnalyticsProvider`

    Sets a user-level property / custom dimension.

    ###### Parameters

    - `key`: the property name

    - `value`: the property value

    Specified by:
      `setUserProperty` in interface `AnalyticsProvider`
    Overrides:
      `setUserProperty` in class `AbstractAnalyticsProvider`

  - ### reportCrash

    public void reportCrash(AnalyticsCrashReport report)
    Description copied from interface: `AnalyticsProvider`

    Reports a crash or handled exception.

    ###### Parameters

    - `report`: the crash report
    Specified by:
      `reportCrash` in interface `AnalyticsProvider`
    Overrides:
      `reportCrash` in class `AbstractAnalyticsProvider`

  - ### onConsentChanged

    public void onConsentChanged(AnalyticsConsent consent)
    Description copied from interface: `AnalyticsProvider`

    Notifies the provider that the user's consent has changed so it can enable, disable or reconfigure collection accordingly.

    ###### Parameters

    - `consent`: the new consent state
    Specified by:
      `onConsentChanged` in interface `AnalyticsProvider`
    Overrides:
      `onConsentChanged` in class `AbstractAnalyticsProvider`

  - ### flush

    public void flush()
    Description copied from interface: `AnalyticsProvider`
    Flushes any buffered events to the backend.
    Specified by:
      `flush` in interface `AnalyticsProvider`
    Overrides:
      `flush` in class `AbstractAnalyticsProvider`

  - ### supports

    public boolean supports(AnalyticsCapability capability)
    Description copied from interface: `AnalyticsProvider`

    Indicates whether the provider supports a given capability.

    ###### Parameters

    - `capability`: the capability to query

    ###### Returns

    true if supported

    Specified by:
      `supports` in interface `AnalyticsProvider`
    Overrides:
      `supports` in class `AbstractAnalyticsProvider`