public class AnalyticsService extends Object
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 init(java.lang.String, 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 and Description |
---|
AnalyticsService() |
Modifier and Type | Method and Description |
---|---|
protected void |
decorateVisitPageRequest(String page,
String referer,
ConnectionRequest request)
Decorates the ConnectionRequest to be sent to the server before the request is sent.
|
static void |
init(AnalyticsService i)
Allows installing an analytics service other than the default
|
static void |
init(String agent,
String domain)
Initializes google analytics for this application
|
protected boolean |
isAnalyticsEnabled()
Indicates if the analytics is enabled, subclasses must override this method to process their information
|
static boolean |
isAppsMode()
Apps mode allows improved analytics using the newer google analytics API designed for apps
|
static boolean |
isEnabled()
Indicates whether analytics is enabled for this application
|
static boolean |
isFailSilently()
Indicates whether analytics server failures should brodcast an error event
|
static void |
sendCrashReport(Throwable t,
String message,
boolean fatal)
In apps mode we can send information about an exception to the analytics server
|
static void |
setAppsMode(boolean aAppsMode)
Apps mode allows improved analytics using the newer google analytics API designed for apps.
|
static void |
setFailSilently(boolean aFailSilently)
Indicates whether analytics server failures should brodcast an error event
|
static void |
setReadTimeout(int ms)
Sets read timeout for HTTP requests to Google Analytics services.
|
static void |
setTimeout(int ms)
Sets timeout for HTTP requests to Google Analytics service.
|
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.
|
protected void |
visitPage(String page,
String referer)
Subclasses should override this method to track page visits
|
public static boolean isFailSilently()
public static void setFailSilently(boolean aFailSilently)
aFailSilently
- the failSilently to setpublic static boolean isAppsMode()
public static void setTimeout(int ms)
ms
- Milliseconds timeout.public static void setReadTimeout(int ms)
ms
- Milliseconds read timeout.public static void setAppsMode(boolean aAppsMode)
true
.aAppsMode
- the appsMode to setpublic static boolean isEnabled()
protected boolean isAnalyticsEnabled()
public static void init(String agent, String domain)
agent
- the google analytics tracking agentdomain
- 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)public static void init(AnalyticsService i)
i
- the analytics service implementation.public static void visit(String page, String referer)
page
- the page viewedreferer
- the source pageprotected void decorateVisitPageRequest(String page, String referer, ConnectionRequest request)
If using Google Analytics, the current you can see the available POST parameters that the server accepts here.
page
- The page visitedreferer
- The page from which the user came.request
- The ConnectionRequestprotected void visitPage(String page, String referer)
page
- the page visitedreferer
- the page from which the user came