com.brsanthu.googleanalytics
Class GoogleAnalyticsConfig

java.lang.Object
  extended by com.brsanthu.googleanalytics.GoogleAnalyticsConfig

public class GoogleAnalyticsConfig
extends Object

Properties that can be configured in this library. These would include any properties that are required to process the tracking request or enhance the tracking request (but not specified in measurement protocol like User agent).

Most of the properties are initialization level and request level. If a property is a initialization level property, it should be set at the time of GoogleAnalytics object initialization. If a property is a request level property, it can be set any time and it will be effective.

All properties of this config object supports method chaining. So for example, you could do, new GoogleAnalyticsConfig().setMaxThreads(2).setThreadNameFormat("name");

Author:
Santhosh Kumar

Constructor Summary
GoogleAnalyticsConfig()
           
 
Method Summary
 String getHttpsUrl()
           
 String getHttpUrl()
           
 int getMaxThreads()
          Maximum threads to use to process the asynchronous event posting and Http client connection pooling.
 String getProxyHost()
           
 String getProxyPassword()
           
 int getProxyPort()
           
 String getProxyUserName()
           
 String getThreadNameFormat()
           
 String getUserAgent()
           
 boolean isDeriveSystemParameters()
           
 boolean isEnabled()
           
 boolean isGatherStats()
           
 boolean isUseHttps()
           
 boolean isValidate()
           
static String mask(String value)
           
 GoogleAnalyticsConfig setDeriveSystemParameters(boolean deriveSystemProperties)
          If true, derives the system properties (User Language, Region, Country, Screen Size, Color Depth, and File encoding) and adds to the default request.
 GoogleAnalyticsConfig setEnabled(boolean enabled)
          Enables or disables the GoogleAnalytics posting.
 void setGatherStats(boolean gatherStats)
          If set to true, GoogleAnalytics will collect the basic stats about successful event postings for various hit types and keeps a copy of GoogleAnalyticsStats, which can be retrieved using GoogleAnalytics.getStats()
 GoogleAnalyticsConfig setHttpsUrl(String httpsUrl)
          URL to use when posting the event in https mode.
 GoogleAnalyticsConfig setHttpUrl(String httpUrl)
          URL to use when posting the event in http mode.
 GoogleAnalyticsConfig setMaxThreads(int maxThreads)
           
 GoogleAnalyticsConfig setProxyHost(String proxyHost)
          Sets the host name of the proxy server, to connect to Google analytics.
 GoogleAnalyticsConfig setProxyPassword(String proxyPassword)
          Sets the password which should be used to authenticate to the proxy server.
 GoogleAnalyticsConfig setProxyPort(int proxyPort)
          Sets the host name of the proxy server, to connect to Google analytics.
 GoogleAnalyticsConfig setProxyUserName(String proxyUserName)
          Sets the user name which should be used to authenticate to the proxy server.
 GoogleAnalyticsConfig setThreadNameFormat(String threadNameFormat)
          Sets the thread name format that should be while creating the threads.
 GoogleAnalyticsConfig setUseHttps(boolean useHttps)
          Instructs to use https url to send the events.
 GoogleAnalyticsConfig setUserAgent(String userAgent)
          Sets the user agent string that should be sent while making the http request.
 GoogleAnalyticsConfig setValidate(boolean validate)
          If set, validates the request before sending to Google Analytics.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GoogleAnalyticsConfig

public GoogleAnalyticsConfig()
Method Detail

isGatherStats

public boolean isGatherStats()

setGatherStats

public void setGatherStats(boolean gatherStats)
If set to true, GoogleAnalytics will collect the basic stats about successful event postings for various hit types and keeps a copy of GoogleAnalyticsStats, which can be retrieved using GoogleAnalytics.getStats()

Parameters:
gatherStats -

setThreadNameFormat

public GoogleAnalyticsConfig setThreadNameFormat(String threadNameFormat)
Sets the thread name format that should be while creating the threads.

Default is "googleanalytics-thread-{0}" where {0} is the thread counter. If you specify a custom format, make sure {0} is there somewhere otherwise all threads will be nameed same and can be an issue for troubleshooting.

Parameters:
threadNameFormat - non-null string for thread name.

getThreadNameFormat

public String getThreadNameFormat()

setDeriveSystemParameters

public GoogleAnalyticsConfig setDeriveSystemParameters(boolean deriveSystemProperties)
If true, derives the system properties (User Language, Region, Country, Screen Size, Color Depth, and File encoding) and adds to the default request.

This is initialization level configuration (must be set while creating GoogleAnalytics object).


isDeriveSystemParameters

public boolean isDeriveSystemParameters()

setProxyUserName

public GoogleAnalyticsConfig setProxyUserName(String proxyUserName)
Sets the user name which should be used to authenticate to the proxy server. This is applicable only if setProxyHost(String) is not empty.

This is initialization level configuration (must be set while creating GoogleAnalytics object).


getProxyUserName

public String getProxyUserName()

getProxyPassword

public String getProxyPassword()

setProxyPassword

public GoogleAnalyticsConfig setProxyPassword(String proxyPassword)
Sets the password which should be used to authenticate to the proxy server. This is applicable only if setProxyHost(String) and setProxyUserName(String) is not empty.

This is initialization level configuration (must be set while creating GoogleAnalytics object).


getProxyHost

public String getProxyHost()

setProxyHost

public GoogleAnalyticsConfig setProxyHost(String proxyHost)
Sets the host name of the proxy server, to connect to Google analytics.

This is initialization level configuration (must be set while creating GoogleAnalytics object).


getProxyPort

public int getProxyPort()

setProxyPort

public GoogleAnalyticsConfig setProxyPort(int proxyPort)
Sets the host name of the proxy server, to connect to Google analytics.

This is initialization level configuration (must be set while creating GoogleAnalytics object).


getUserAgent

public String getUserAgent()

setUserAgent

public GoogleAnalyticsConfig setUserAgent(String userAgent)
Sets the user agent string that should be sent while making the http request. Default is Apache Http Client's user agent, which looks something similar to this. Apache-HttpClient/release (java 1.5)

This is initialization level configuration (must be set while creating GoogleAnalytics object).


isEnabled

public boolean isEnabled()

setEnabled

public GoogleAnalyticsConfig setEnabled(boolean enabled)
Enables or disables the GoogleAnalytics posting. If disabled, library will continue to accept the send/post requests but silently skips sending the event and returns successful response. Default is false.

This is request level configuration (can be changed any time).


getMaxThreads

public int getMaxThreads()
Maximum threads to use to process the asynchronous event posting and Http client connection pooling. Default is 1.

This is initialization level configuration (must be set while creating GoogleAnalytics object).


setMaxThreads

public GoogleAnalyticsConfig setMaxThreads(int maxThreads)

isUseHttps

public boolean isUseHttps()

setUseHttps

public GoogleAnalyticsConfig setUseHttps(boolean useHttps)
Instructs to use https url to send the events. Default is true.

This is request level configuration (can be changed any time).


isValidate

public boolean isValidate()

setValidate

public GoogleAnalyticsConfig setValidate(boolean validate)
If set, validates the request before sending to Google Analytics. If any errors found, GoogleAnalyticsException will be thrown with details. Default is false. Note that, if you are sending the event in async mode, then request is always validated and logged to log file as warnings irrespective of this flag.

This is request level configuration (can be changed any time).


getHttpUrl

public String getHttpUrl()

setHttpUrl

public GoogleAnalyticsConfig setHttpUrl(String httpUrl)
URL to use when posting the event in http mode. This url is Google Analytics service url and usually not updated by the clients.

This is request level configuration (can be changed any time).


getHttpsUrl

public String getHttpsUrl()

setHttpsUrl

public GoogleAnalyticsConfig setHttpsUrl(String httpsUrl)
URL to use when posting the event in https mode. This url is Google Analytics service url and usually not updated by the clients.

This is request level configuration (can be changed any time).


toString

public String toString()
Overrides:
toString in class Object

mask

public static String mask(String value)


Copyright © Sep 2013–2013 brsanthu Inc. All rights reserved.