Class AnalyticsService

java.lang.Object
com.codename1.analytics.AnalyticsService

@Deprecated public class AnalyticsService extends Object
Deprecated.

The legacy analytics entry point, retained for backward compatibility. New code should use the Analytics facade together with one or more AnalyticsProvider implementations, which adds a generic provider SPI, GDPR/CCPA consent handling and modern backends (GA4, Matomo, Firebase and the first-party Codename One service).

This class now delegates to Analytics: init(String, String) registers a GoogleAnalyticsProvider (Google Analytics 4, replacing the retired Measurement Protocol v1 that this class used to target) and visit(String, String) / sendCrashReport(Throwable, String, boolean) route through the facade.

To preserve the historical "always on" behaviour of this deprecated API -- which predates the consent model -- init(String, String) and init(AnalyticsService) switch the facade to ConsentMode.OPT_OUT. Applications that need opt-in / GDPR behaviour should migrate to the Analytics API and call Analytics.setConsent(AnalyticsConsent).

  • Constructor Details

    • AnalyticsService

      public AnalyticsService()
      Deprecated.
  • Method Details

    • isFailSilently

      @Deprecated public static boolean isFailSilently()
      Deprecated.

      Indicates whether analytics server failures should brodcast an error event

      Returns

      the failSilently

    • setFailSilently

      @Deprecated public static void setFailSilently(boolean aFailSilently)
      Deprecated.

      Indicates whether analytics server failures should brodcast an error event

      Parameters
      • aFailSilently: the failSilently to set
    • isAppsMode

      @Deprecated public static boolean isAppsMode()
      Deprecated.

      Apps mode allows improved analytics using the newer google analytics API designed for apps

      Returns

      the appsMode

    • setAppsMode

      @Deprecated public static void setAppsMode(boolean aAppsMode)
      Deprecated.

      Apps mode allows improved analytics using the newer google analytics API designed for apps. This setting is retained for source compatibility but no longer affects behaviour; the modern GA4 protocol is always used.

      Parameters
      • aAppsMode: the appsMode to set
    • setTimeout

      @Deprecated public static void setTimeout(int ms)
      Deprecated.

      Retained for source compatibility; no longer affects behaviour.

      Parameters
      • ms: Milliseconds timeout.
    • setReadTimeout

      @Deprecated public static void setReadTimeout(int ms)
      Deprecated.

      Retained for source compatibility; no longer affects behaviour.

      Parameters
      • ms: Milliseconds read timeout.
    • isEnabled

      @Deprecated public static boolean isEnabled()
      Deprecated.

      Indicates whether analytics is enabled for this application

      Returns

      true if analytics is enabled

    • init

      @Deprecated public static void init(String agent, String domain)
      Deprecated.

      Initializes analytics for this application using the modern Google Analytics 4 protocol. The agent is used as the GA4 measurement id.

      Parameters
      • agent: the google analytics tracking agent / measurement id

      • domain: a domain to represent your application, commonly your package name as a URL (e.g. com.mycompany.myapp should become: myapp.mycompany.com)

    • init

      @Deprecated public static void init(AnalyticsService i)
      Deprecated.
      use Analytics and a custom AnalyticsProvider

      Allows installing an analytics service other than the default. The custom implementation's visitPage hook is invoked for page views.

      Parameters
      • i: the analytics service implementation.
    • visit

      @Deprecated public static void visit(String page, String referer)

      Sends an asynchronous notice to the server regarding a page in the application being viewed, notice that you don't need to append the URL prefix to the page string.

      Parameters
      • page: the page viewed

      • referer: the source page

    • sendCrashReport

      @Deprecated public static void sendCrashReport(Throwable t, String message, boolean fatal)

      Reports information about an exception to the analytics server.

      Parameters
      • t: the exception

      • message: up to 150 character message,

      • fatal: is the exception fatal

    • isAnalyticsEnabled

      protected boolean isAnalyticsEnabled()
      Deprecated.

      Indicates if the analytics is enabled, subclasses must override this method to process their information

      Returns

      true if analytics is enabled

    • decorateVisitPageRequest

      @Deprecated protected void decorateVisitPageRequest(String page, String referer, ConnectionRequest request)
      Deprecated.
      decorate the request inside a custom AnalyticsProvider

      Retained for source compatibility with subclasses written against the previous Google Analytics v1 implementation. It is no longer invoked by the default page-view path, which now delegates to Analytics.

      Parameters
      • page: The page visited

      • referer: The page from which the user came.

      • request: The ConnectionRequest

    • visitPage

      protected void visitPage(String page, String referer)
      Deprecated.

      Subclasses may override this method to track page visits. The default implementation routes the visit to the Analytics facade.

      Parameters
      • page: the page visited

      • referer: the page from which the user came