Class AnalyticsService
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddecorateVisitPageRequest(String page, String referer, ConnectionRequest request) Deprecated.decorate the request inside a customAnalyticsProviderstatic voidDeprecated.useAnalyticsand a customAnalyticsProviderstatic voidDeprecated.useAnalyticswith aGoogleAnalyticsProviderprotected booleanDeprecated.Indicates if the analytics is enabled, subclasses must override this method to process their informationstatic booleanDeprecated.useAnalyticsstatic booleanDeprecated.useAnalyticsstatic booleanDeprecated.useAnalyticsstatic voidsendCrashReport(Throwable t, String message, boolean fatal) Deprecated.static voidsetAppsMode(boolean aAppsMode) Deprecated.useAnalyticsstatic voidsetFailSilently(boolean aFailSilently) Deprecated.useAnalyticsstatic voidsetReadTimeout(int ms) Deprecated.useAnalyticsstatic voidsetTimeout(int ms) Deprecated.useAnalyticsstatic voidDeprecated.protected voidDeprecated.Subclasses may override this method to track page visits.
-
Constructor Details
-
AnalyticsService
public AnalyticsService()Deprecated.
-
-
Method Details
-
isFailSilently
Deprecated.useAnalyticsIndicates whether analytics server failures should brodcast an error event
Returns
the failSilently
-
setFailSilently
Deprecated.useAnalyticsIndicates whether analytics server failures should brodcast an error event
Parameters
aFailSilently: the failSilently to set
-
isAppsMode
Deprecated.useAnalyticsApps mode allows improved analytics using the newer google analytics API designed for apps
Returns
the appsMode
-
setAppsMode
Deprecated.useAnalyticsApps 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.useAnalyticsRetained for source compatibility; no longer affects behaviour.
Parameters
ms: Milliseconds timeout.
-
setReadTimeout
Deprecated.useAnalyticsRetained for source compatibility; no longer affects behaviour.
Parameters
ms: Milliseconds read timeout.
-
isEnabled
Deprecated.useAnalyticsIndicates whether analytics is enabled for this application
Returns
true if analytics is enabled
-
init
Deprecated.useAnalyticswith aGoogleAnalyticsProviderInitializes analytics for this application using the modern Google Analytics 4 protocol. The
agentis 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.useAnalyticsand a customAnalyticsProviderAllows installing an analytics service other than the default. The custom implementation's
visitPagehook is invoked for page views.Parameters
i: the analytics service implementation.
-
visit
Deprecated.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.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 customAnalyticsProviderRetained 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
-
Analyticsand anAnalyticsProvider