public class GoogleAnalyticsImpl extends Object implements GoogleAnalytics, GoogleAnalyticsExecutor
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.| Modifier and Type | Field and Description |
|---|---|
protected GoogleAnalyticsConfig |
config |
protected List<HttpRequest> |
currentBatch |
protected DefaultRequest |
defaultRequest |
protected HttpClient |
httpClient |
protected boolean |
inSample |
protected static org.slf4j.Logger |
logger |
protected GoogleAnalyticsStatsImpl |
stats |
| Constructor and Description |
|---|
GoogleAnalyticsImpl(GoogleAnalyticsConfig config,
DefaultRequest defaultRequest,
HttpClient httpClient) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbuilderprotected static final org.slf4j.Logger logger
protected final GoogleAnalyticsConfig config
protected final DefaultRequest defaultRequest
protected final HttpClient httpClient
protected boolean inSample
protected GoogleAnalyticsStatsImpl stats
protected List<HttpRequest> currentBatch
public GoogleAnalyticsImpl(GoogleAnalyticsConfig config, DefaultRequest defaultRequest, HttpClient httpClient)
public boolean performSamplingElection()
performSamplingElection in interface GoogleAnalyticspublic boolean inSample()
inSample in interface GoogleAnalyticspublic GoogleAnalyticsConfig getConfig()
getConfig in interface GoogleAnalyticspublic DefaultRequest getDefaultRequest()
public GoogleAnalyticsResponse post(GoogleAnalyticsRequest<?> request)
post in interface GoogleAnalyticsExecutorpublic java8.util.concurrent.CompletableFuture<GoogleAnalyticsResponse> postAsync(GoogleAnalyticsRequest<?> gaReq)
postAsync in interface GoogleAnalyticsExecutorprotected GoogleAnalyticsResponse postBatch(GoogleAnalyticsRequest<?> gaReq)
protected java8.util.concurrent.CompletableFuture<GoogleAnalyticsResponse> postSingle(GoogleAnalyticsRequest<?> gaReq)
protected void processParameters(GoogleAnalyticsRequest<?> request, HttpRequest req)
protected void processCustomDimensionParameters(GoogleAnalyticsRequest<?> request, HttpRequest req)
request - req - protected void processCustomMetricParameters(GoogleAnalyticsRequest<?> request, HttpRequest req)
request - req - protected void gatherStats(GoogleAnalyticsRequest<?> request)
public void close()
close in interface AutoCloseablepublic GoogleAnalyticsStats getStats()
getStats in interface GoogleAnalyticspublic void resetStats()
resetStats in interface GoogleAnalyticspublic EventHit event()
event in interface GoogleAnalyticspublic ExceptionHit exception()
exception in interface GoogleAnalyticspublic ItemHit item()
item in interface GoogleAnalyticspublic PageViewHit pageView()
pageView in interface GoogleAnalyticspublic PageViewHit pageView(String url, String title)
pageView in interface GoogleAnalyticspublic PageViewHit pageView(String url, String title, String description)
pageView in interface GoogleAnalyticspublic ScreenViewHit screenView()
screenView in interface GoogleAnalyticspublic ScreenViewHit screenView(String appName, String screenName)
screenView in interface GoogleAnalyticspublic SocialHit social()
social in interface GoogleAnalyticspublic SocialHit social(String socialNetwork, String socialAction, String socialTarget)
social in interface GoogleAnalyticspublic TimingHit timing()
timing in interface GoogleAnalyticspublic TransactionHit transaction()
transaction in interface GoogleAnalyticspublic void ifEnabled(Runnable runnable)
ifEnabled in interface GoogleAnalyticspublic void flush()
flush in interface GoogleAnalyticsCopyright © Sep 2013–2018 Mike Hardy. All rights reserved.