@Scheduled(cron = "0 1 1 * * ?")
@Transactional
public void reportUsage() {
if (config.isUsageReportEnabled()) {
doRandomDelay();
GoogleAnalytic googleAnalytic = new GoogleAnalytic(ControllerConstants.GOOGLE_ANALYTICS_APP_NAME,
config.getVersion(), ControllerConstants.GOOGLE_ANALYTICS_TRACKING_ID);
MeasureProtocolRequest measureProtocolRequest = googleAnalytic.getMeasureProtocolRequest();
measureProtocolRequest.setEventCategory("usage");
measureProtocolRequest.setEventAction("executions");
String currentAddress = NetworkUtils.getLocalHostAddress();
Date yesterday = DateUtils.addDays(new Date(), -1);
Date start = DateUtils.truncate(yesterday, Calendar.DATE);
Date end = DateUtils.addMilliseconds(DateUtils.ceiling(yesterday, Calendar.DATE), -1);
googleAnalytic.sendStaticDataToUA(currentAddress, String.valueOf(getUsage(start, end)));
}
}