/** * Send an exception event out for aggregation/analysis * * @param description API limited to 100 characters, truncated here to 100 if needed * @param fatal whether it was fatal or not */ @SuppressWarnings("WeakerAccess") public static void sendAnalyticsException(@NonNull String description, boolean fatal) { Timber.d("sendAnalyticsException() description/fatal: %s/%s", description, fatal); if (!sOptIn) { return; } sAnalytics.exception().exceptionDescription(description).exceptionFatal(fatal).sendAsync(); } }
/** * 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(); }
/** * Submit a screen display with a synthetic name for aggregation / analysis * Intended for use if your class handles multiple screens you want to track separately * * @param screenName screenName the name to show in analysis reports */ public static void sendAnalyticsScreenView(String screenName) { Timber.d("sendAnalyticsScreenView(): %s", screenName); if (!getOptIn()) { return; } sAnalytics.screenView().screenName(screenName).sendAsync(); }
.withTrackingId(getAnalyticsTag(context)) .withConfig(gaConfig) .withDefaultRequest(new DefaultRequest() .applicationName(context.getString(R.string.app_name)) .applicationVersion(Integer.toString(BuildConfig.VERSION_CODE)) .applicationId(BuildConfig.APPLICATION_ID) .trackingId(getAnalyticsTag(context)) .clientId(Installation.id(context)) .anonymizeIp(context.getResources().getBoolean(R.bool.ga_anonymizeIp))
ExceptionHit spyHit = Mockito.spy(new ExceptionHit()); Mockito.doReturn(spyHit).when(mAnalytics).exception(); Mockito.verify(childException).getCause(); Mockito.verify(mAnalytics).exception(); Mockito.verify(spyHit).exceptionDescription(ArgumentMatchers.anyString()); Mockito.verify(spyHit).sendAsync(); Assert.assertEquals(spyHit.exceptionDescription(), "child exception toString()");
public ExceptionHit(String exceptionDescription, Boolean fatal) { super(HIT_EXCEPTION); exceptionDescription(exceptionDescription); exceptionFatal(fatal); }
public TransactionHit(String txId, String txAffiliation, Double txRevenue, Double txShipping, Double txTax, String currencyCode) { super(HIT_TXN); txId(txId); txAffiliation(txAffiliation); txRevenue(txRevenue); txShipping(txShipping); txTax(txTax); currencyCode(currencyCode); }
public PageViewHit(String url, String title, String description) { super(HIT_PAGEVIEW); documentUrl(url); documentTitle(title); contentDescription(description); } }
public SocialHit(String socialNetwork, String socialAction, String socialTarget) { super(HIT_SOCIAL); socialAction(socialAction); socialNetwork(socialNetwork); socialActionTarget(socialTarget); }
public ScreenViewHit(String appName, String screenName) { super(HIT_SCREENVIEW); screenName(screenName); applicationName(appName); }
/** * User Agent Override parameter: &ua Should be a User Agent reported by the browser. Note: We have libraries to * identify real user agents. Hand crafting your own agent could break at any time. example: * &ua=Opera%2F9.80%20(Windows%20NT%206.0)%20Presto%2F2.12.388%20Version%2F12.14 */ public T userAgent(String value) { setString(GoogleAnalyticsParameter.USER_AGENT, value); return (T) this; }
public EventHit(String eventCategory, String eventAction, String eventLabel, Integer eventValue) { super(HIT_EVENT); eventCategory(eventCategory); eventAction(eventAction); eventLabel(eventLabel); eventValue(eventValue); }
public ExceptionHit(String exceptionDescription, Boolean fatal) { super(HIT_EXCEPTION); exceptionDescription(exceptionDescription); exceptionFatal(fatal); }
public PageViewHit(String url, String title, String description) { super(HIT_PAGEVIEW); documentUrl(url); documentTitle(title); contentDescription(description); } }
public SocialHit(String socialNetwork, String socialAction, String socialTarget) { super(HIT_SOCIAL); socialAction(socialAction); socialNetwork(socialNetwork); socialActionTarget(socialTarget); }
/** * IP Override parameter: uip Should be a valid IP address. This will always be anonymized just as though &aip * (anonymize IP) had been used. example: &uip=1.2.3.4 */ public T userIp(String value) { setString(GoogleAnalyticsParameter.USER_IP, value); return (T) this; }
public EventHit(String eventCategory, String eventAction, String eventLabel, Integer eventValue) { super(HIT_EVENT); eventCategory(eventCategory); eventAction(eventAction); eventLabel(eventLabel); eventValue(eventValue); }
/** * GeoId Override parameter: geoid The geographical ID should be a two letter country code or a criteria ID * representing a city or region example: geoid=US */ public T geoid(String value) { setString(GoogleAnalyticsParameter.GEOID, value); return (T) this; }
/** * IP Override parameter: uip Should be a valid IP address. This will always be anonymized just as though &aip * (anonymize IP) had been used. example: &uip=1.2.3.4 */ public T userIp(String value) { setString(GoogleAnalyticsParameter.USER_IP, value); return (T) this; }
/** * User Agent Override parameter: &ua Should be a User Agent reported by the browser. Note: We have libraries to * identify real user agents. Hand crafting your own agent could break at any time. example: * &ua=Opera%2F9.80%20(Windows%20NT%206.0)%20Presto%2F2.12.388%20Version%2F12.14 */ public T userAgent(String value) { setString(GoogleAnalyticsParameter.USER_AGENT, value); return (T) this; }