protected GoogleAnalyticsResponse postSingle(GoogleAnalyticsRequest<?> gaReq) { HttpRequest httpReq = createHttpRequest(gaReq); HttpResponse httpResp = httpClient.post(httpReq); GoogleAnalyticsResponse response = new GoogleAnalyticsResponse(); response.setStatusCode(httpResp.getStatusCode()); response.setRequestParams(httpReq.getBodyParams()); if (config.isGatherStats()) { gatherStats(gaReq); } return response; }
protected GoogleAnalyticsResponse postBatch(GoogleAnalyticsRequest<?> gaReq) { GoogleAnalyticsResponse resp = new GoogleAnalyticsResponse(); HttpRequest httpReq = createHttpRequest(gaReq); resp.setRequestParams(httpReq.getBodyParams()); if (config.isGatherStats()) { gatherStats(gaReq); } synchronized (currentBatch) { currentBatch.add(httpReq); } // If the batch size has reached the configured max, // then send the batch to google then clear the batch to start a new batch submitBatch(false); return resp; }
@Override public GoogleAnalyticsResponse post(GoogleAnalyticsRequest<?> gaReq) { GoogleAnalyticsResponse response = new GoogleAnalyticsResponse(); if (!config.isEnabled()) { return response; } try { if (config.isBatchingEnabled()) { response = postBatch(gaReq); } else { response = postSingle(gaReq); } } catch (Exception e) { logger.warn("Exception while sending the Google Analytics tracker request " + gaReq, e); } return response; }
protected GoogleAnalyticsResponse postBatch(GoogleAnalyticsRequest<?> gaReq) { GoogleAnalyticsResponse resp = new GoogleAnalyticsResponse(); HttpRequest httpReq = createHttpRequest(gaReq); resp.setRequestParams(httpReq.getBodyParams()); if (config.isGatherStats()) { gatherStats(gaReq); } synchronized (currentBatch) { currentBatch.add(httpReq); } // If the batch size has reached the configured max, // then send the batch to google then clear the batch to start a new batch submitBatch(false); return resp; }
@Override public GoogleAnalyticsResponse post(GoogleAnalyticsRequest<?> gaReq) { GoogleAnalyticsResponse response = new GoogleAnalyticsResponse(); if (!config.isEnabled()) { return response; } try { if (config.isBatchingEnabled()) { response = postBatch(gaReq); } else { response = postSingle(gaReq); } } catch (Exception e) { logger.warn("Exception while sending the Google Analytics tracker request " + gaReq, e); } return response; }
protected GoogleAnalyticsResponse postSingle(GoogleAnalyticsRequest<?> gaReq) { HttpRequest httpReq = createHttpRequest(gaReq); HttpResponse httpResp = httpClient.post(httpReq); GoogleAnalyticsResponse response = new GoogleAnalyticsResponse(); response.setStatusCode(httpResp.getStatusCode()); response.setRequestParams(httpReq.getBodyParams()); if (config.isGatherStats()) { gatherStats(gaReq); } return response; }