@Override public void identify(IdentifyPayload identify) { super.identify(identify); String userId = identify.userId(); amplitude.setUserId(userId); log.verbose("AmplitudeClient.getInstance().setUserId(%s);", userId); JSONObject traits = identify.traits().toJsonObject(); amplitude.setUserProperties(traits); log.verbose("AmplitudeClient.getInstance().setUserProperties(%s);", traits); }
@Override public void flush() { super.flush(); amplitude.uploadEvents(); log.verbose("AmplitudeClient.getInstance().uploadEvents();"); }
@Override public void initialize(Analytics analytics, ValueMap settings) throws IllegalStateException { log = analytics.getLogger().newLogger(AMPLITUDE_KEY); trackAllPages = settings.getBoolean("trackAllPages", false); trackCategorizedPages = settings.getBoolean("trackCategorizedPages", false); trackNamedPages = settings.getBoolean("trackNamedPages", false); boolean trackSessionEvents = settings.getBoolean("trackSessionEvents", false); String apiKey = settings.getString("apiKey"); amplitude = provider.get(); amplitude.initialize(analytics.getApplication(), apiKey); log.verbose("AmplitudeClient.getInstance().initialize(context, %s);", apiKey); amplitude.enableForegroundTracking(analytics.getApplication()); log.verbose("AmplitudeClient.getInstance().enableForegroundTracking(context);"); amplitude.trackSessionEvents(trackSessionEvents); log.verbose("AmplitudeClient.getInstance().trackSessionEvents(%s);", trackSessionEvents); }
private void event(String name, Properties properties) { JSONObject propertiesJSON = properties.toJsonObject(); amplitude.logEvent(name, propertiesJSON); log.verbose("AmplitudeClient.getInstance().logEvent(%s, %s);", name, propertiesJSON); double revenue = properties.getDouble("revenue", -1); if (revenue == -1) { return; } String productId = properties.getString("productId"); int quantity = properties.getInt("quantity", 0); String receipt = properties.getString("receipt"); String receiptSignature = properties.getString("receiptSignature"); amplitude.logRevenue(productId, quantity, revenue, receipt, receiptSignature); log.verbose( "AmplitudeClient.getInstance().logRevenue(%s, %s, %s, %s, %s);", productId, quantity, revenue, receipt, receiptSignature); }
@Override public AmplitudeClient get() { return AmplitudeClient.getInstance(); }