com.brsanthu.googleanalytics
Class GoogleAnalytics
java.lang.Object
com.brsanthu.googleanalytics.GoogleAnalytics
public class GoogleAnalytics
- extends Object
This is the main class of this library that accepts the requests from clients and
sends the events to Google Analytics (GA).
Clients needs to instantiate this object with GoogleAnalyticsConfig and DefaultRequest.
Configuration contains sensible defaults so one could just initialize using one of the convenience constructors.
This object is ThreadSafe and it is intended that clients create one instance of this for each GA Tracker Id
and reuse each time an event needs to be posted.
This object contains resources which needs to be shutdown/disposed. So close() method is called
to release all resources. Once close method is called, this instance cannot be reused so create new instance
if required.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GoogleAnalytics
public GoogleAnalytics(String trackingId)
GoogleAnalytics
public GoogleAnalytics(GoogleAnalyticsConfig config,
String trackingId)
GoogleAnalytics
public GoogleAnalytics(String trackingId,
String appName,
String appVersion)
GoogleAnalytics
public GoogleAnalytics(GoogleAnalyticsConfig config,
String trackingId,
String appName,
String appVersion)
GoogleAnalytics
public GoogleAnalytics(GoogleAnalyticsConfig config,
DefaultRequest defaultRequest)
getConfig
public GoogleAnalyticsConfig getConfig()
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()
getDefaultRequest
public DefaultRequest getDefaultRequest()
setDefaultRequest
public void setDefaultRequest(DefaultRequest request)
setHttpClient
public void setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient)
post
public GoogleAnalyticsResponse post(GoogleAnalyticsRequest request)
postAsync
public Future<GoogleAnalyticsResponse> postAsync(RequestProvider requestProvider)
postAsync
public Future<GoogleAnalyticsResponse> postAsync(GoogleAnalyticsRequest request)
close
public void close()
deriveSystemParameters
protected DefaultRequest deriveSystemParameters(GoogleAnalyticsConfig config,
DefaultRequest request)
createHttpClient
protected org.apache.http.impl.client.CloseableHttpClient createHttpClient(GoogleAnalyticsConfig config)
getDefaultMaxPerRoute
protected int getDefaultMaxPerRoute(GoogleAnalyticsConfig config)
getExecutor
protected ThreadPoolExecutor getExecutor()
createExecutor
protected ThreadPoolExecutor createExecutor(GoogleAnalyticsConfig config)
getUserAgentString
protected String getUserAgentString()
appendProperty
protected void appendProperty(StringBuilder sb,
String property)
createThreadFactory
protected ThreadFactory createThreadFactory()
getStats
public GoogleAnalyticsStats getStats()
resetStats
public void resetStats()
Copyright © Sep 2013–2013 brsanthu Inc. All rights reserved.