/** * Send a detailed arbitrary analytics event, with noun/verb pairs and extra data if needed * * @param category the category of event, make your own but use a constant so reporting is good * @param action the action the user performed * @param value A value for the event, Integer.MIN_VALUE signifies caller shouldn't send the value * @param label A label for the event, may be null */ @SuppressWarnings("WeakerAccess") public static void sendAnalyticsEvent(@NonNull String category, @NonNull String action, int value, String label) { Timber.d("sendAnalyticsEvent() category/action/value/label: %s/%s/%s/%s", category, action, value, label); if (!getOptIn()) { return; } EventHit event = sAnalytics.event().eventCategory(category).eventAction(action); if (label != null) { event.eventLabel(label); } if (value > Integer.MIN_VALUE) { event.eventValue(value); } event.sendAsync(); }
@Override public EventHit event() { return (EventHit) new EventHit().setExecutor(this); }
public String eventCategory() { return getString(EVENT_CATEGORY); }
public Integer eventValue() { return getInteger(EVENT_VALUE); } }
@Override public EventHit event() { return (EventHit) new EventHit().setExecutor(this); }
public String eventLabel() { return getString(EVENT_LABEL); }
public Integer eventValue() { return getInteger(EVENT_VALUE); } }
public EventHit(String eventCategory, String eventAction, String eventLabel, Integer eventValue) { super(HIT_EVENT); eventCategory(eventCategory); eventAction(eventAction); eventLabel(eventLabel); eventValue(eventValue); }
public String eventCategory() { return getString(EVENT_CATEGORY); }
public EventHit(String eventCategory, String eventAction, String eventLabel, Integer eventValue) { super(HIT_EVENT); eventCategory(eventCategory); eventAction(eventAction); eventLabel(eventLabel); eventValue(eventValue); }
public String eventAction() { return getString(EVENT_ACTION); }
@Override public void sendMicroserviceUptime(IMicroservice<?> microservice) throws SiteWhereException { try { getGoogleAnalytics().event().eventCategory("Microservice_" + microservice.getIdentifier().getShortName()) .eventAction("Uptime").eventLabel(microservice.getVersion().getVersionIdentifier()) .eventValue((int) microservice.getCurrentState().getUptime()).send(); } catch (Throwable t) { microservice.getLogger().warn("Unable to send Google Analytics uptime event.", t); } }
public String eventAction() { return getString(EVENT_ACTION); }
@Override public void sendMicroserviceStopped(IMicroservice<?> microservice) throws SiteWhereException { try { getGoogleAnalytics().event().eventCategory("Microservice_" + microservice.getIdentifier().getShortName()) .eventAction("Stopped").eventLabel(microservice.getVersion().getVersionIdentifier()).send(); } catch (Throwable t) { microservice.getLogger().warn("Unable to send Google Analytics stopped event.", t); } }
public String eventLabel() { return getString(EVENT_LABEL); }
@Override public void sendMicroserviceStarted(IMicroservice<?> microservice) throws SiteWhereException { try { getGoogleAnalytics().event().eventCategory("Microservice_" + microservice.getIdentifier().getShortName()) .eventAction("Started").eventLabel(microservice.getVersion().getVersionIdentifier()).send(); } catch (Throwable t) { microservice.getLogger().warn("Unable to send Google Analytics started event.", t); } }