com.brsanthu.googleanalytics
Class GoogleAnalytics

java.lang.Object
  extended by 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.


Constructor Summary
GoogleAnalytics(GoogleAnalyticsConfig config, DefaultRequest defaultRequest)
           
GoogleAnalytics(GoogleAnalyticsConfig config, String trackingId)
           
GoogleAnalytics(GoogleAnalyticsConfig config, String trackingId, String appName, String appVersion)
           
GoogleAnalytics(String trackingId)
           
GoogleAnalytics(String trackingId, String appName, String appVersion)
           
 
Method Summary
protected  void appendProperty(StringBuilder sb, String property)
           
 void close()
           
protected  ThreadPoolExecutor createExecutor(GoogleAnalyticsConfig config)
           
protected  org.apache.http.impl.client.CloseableHttpClient createHttpClient(GoogleAnalyticsConfig config)
           
protected  ThreadFactory createThreadFactory()
           
protected  DefaultRequest deriveSystemParameters(GoogleAnalyticsConfig config, DefaultRequest request)
           
 GoogleAnalyticsConfig getConfig()
           
protected  int getDefaultMaxPerRoute(GoogleAnalyticsConfig config)
           
 DefaultRequest getDefaultRequest()
           
protected  ThreadPoolExecutor getExecutor()
           
 org.apache.http.client.HttpClient getHttpClient()
           
 GoogleAnalyticsStats getStats()
           
protected  String getUserAgentString()
           
 GoogleAnalyticsResponse post(GoogleAnalyticsRequest request)
           
 Future<GoogleAnalyticsResponse> postAsync(GoogleAnalyticsRequest request)
           
 Future<GoogleAnalyticsResponse> postAsync(RequestProvider requestProvider)
           
 void resetStats()
           
 void setDefaultRequest(DefaultRequest request)
           
 void setHttpClient(org.apache.http.impl.client.CloseableHttpClient httpClient)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

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)
Method Detail

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.