Class AnalyticsService
The analytics service allows an application to report its usage, it is seamlessly invoked by GUI builder applications if analytics is enabled for your application but can work just as well for handcoded apps!
To enable analytics just use the java.lang.String)
method of the analytics service. For most typical usage you should also invoke the
#setAppsMode(boolean) method with true. If you are
not using the GUI builder invoke the visit method whenever you would like to log a
page view event.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddecorateVisitPageRequest(String page, String referer, ConnectionRequest request) Decorates the ConnectionRequest to be sent to the server before the request is sent.static voidAllows installing an analytics service other than the defaultstatic voidInitializes google analytics for this applicationprotected booleanIndicates if the analytics is enabled, subclasses must override this method to process their informationstatic booleanApps mode allows improved analytics using the newer google analytics API designed for appsstatic booleanIndicates whether analytics is enabled for this applicationstatic booleanIndicates whether analytics server failures should brodcast an error eventstatic voidsendCrashReport(Throwable t, String message, boolean fatal) In apps mode we can send information about an exception to the analytics serverstatic voidsetAppsMode(boolean aAppsMode) Apps mode allows improved analytics using the newer google analytics API designed for apps.static voidsetFailSilently(boolean aFailSilently) Indicates whether analytics server failures should brodcast an error eventstatic voidsetReadTimeout(int ms) Sets read timeout for HTTP requests to Google Analytics services.static voidsetTimeout(int ms) Sets timeout for HTTP requests to Google Analytics service.static voidSends 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.protected voidSubclasses should override this method to track page visits
-
Constructor Details
-
AnalyticsService
public AnalyticsService()
-
-
Method Details
-
isFailSilently
public static boolean isFailSilently()Indicates whether analytics server failures should brodcast an error event
Returns
the failSilently
-
setFailSilently
public static void setFailSilently(boolean aFailSilently) Indicates whether analytics server failures should brodcast an error event
Parameters
aFailSilently: the failSilently to set
-
isAppsMode
public static boolean isAppsMode()Apps mode allows improved analytics using the newer google analytics API designed for apps
Returns
the appsMode
-
setAppsMode
public static void setAppsMode(boolean aAppsMode) Apps mode allows improved analytics using the newer google analytics API designed for apps. Most developers should invoke this method with
true.Parameters
aAppsMode: the appsMode to set
-
setTimeout
public static void setTimeout(int ms) Sets timeout for HTTP requests to Google Analytics service.
Parameters
ms: Milliseconds timeout.
Since
7.0
-
setReadTimeout
public static void setReadTimeout(int ms) Sets read timeout for HTTP requests to Google Analytics services.
Parameters
ms: Milliseconds read timeout.
Since
7.0
-
isEnabled
public static boolean isEnabled()Indicates whether analytics is enabled for this application
Returns
true if analytics is enabled
-
init
Initializes google analytics for this application
Parameters
-
agent: the google analytics tracking agent -
domain: @param domain a domain to represent your application, commonly you should use your package name as a URL (e.g. com.mycompany.myapp should become: myapp.mycompany.com)
-
-
init
Allows installing an analytics service other than the default
Parameters
i: the analytics service implementation.
-
visit
-
sendCrashReport
-
isAnalyticsEnabled
protected boolean isAnalyticsEnabled()Indicates if the analytics is enabled, subclasses must override this method to process their information
Returns
true if analytics is enabled
-
decorateVisitPageRequest
Decorates the ConnectionRequest to be sent to the server before the request is sent. This can be overridden to add additional request parameters to the service, and hence provide additional analytics data.
If using Google Analytics, the current you can see the available POST parameters that the server accepts here.
Parameters
-
page: The page visited -
referer: The page from which the user came. -
request: The ConnectionRequest
Since
7.0
-
-
visitPage
-