public static JsonPayload createPayload(PayloadType type, String json) throws JSONException { switch (type) { case message: return MessageFactory.fromJson(json); case event: return new EventPayload(json); case device: return new DevicePayload(json); case sdk: //return new SdkPayload(json); // TODO: FIXME return null; case app_release: //return new AppReleasePayload(json); return null; case person: return new PersonPayload(json); case survey: return new SurveyResponsePayload(json); default: throw new IllegalArgumentException("Unexpected payload type: " + type); } } }
if (config.isMetricsEnabled()) { ApptentiveLog.v(UTIL, "Sending Error Metric: %s, data: %s", type.getLabelName(), data.toString()); EventPayload event = new EventPayload(type.getLabelName(), data); sendEvent(event);
public static void sendMetric(final EventPayload.EventLabel type, final String trigger, final Map<String, String> data) { if (!isConversationQueue()) { dispatchOnConversationQueue(new DispatchTask() { @Override protected void execute() { sendMetric(type, trigger, data); } }); return; } Configuration config = Configuration.load(); if (config.isMetricsEnabled()) { ApptentiveLog.v(UTIL, "Sending Metric: %s, trigger: %s, data: %s", type.getLabelName(), trigger, data != null ? data.toString() : "null"); EventPayload event = new EventPayload(type.getLabelName(), trigger); event.putData(data); sendEvent(event); } }
public static synchronized boolean engage(Context context, Conversation conversation, String vendor, String interaction, String interactionId, String eventName, String data, Map<String, Object> customData, ExtendedData... extendedData) { checkConversationQueue(); if (context == null) { throw new IllegalArgumentException("Context is null"); } if (conversation == null) { throw new IllegalArgumentException("Conversation is null"); } Assert.assertTrue(ApptentiveInternal.isApptentiveRegistered()); if (!ApptentiveInternal.isApptentiveRegistered()) { return false; } try { String eventLabel = generateEventLabel(vendor, interaction, eventName); ApptentiveLog.i(INTERACTIONS, "Engage event: '%s'", eventLabel); String versionName = ApptentiveInternal.getInstance().getApplicationVersionName(); int versionCode = ApptentiveInternal.getInstance().getApplicationVersionCode(); conversation.getEventData().storeEventForCurrentAppVersion(Util.currentTimeSeconds(), versionCode, versionName, eventLabel); conversation.addPayload(new EventPayload(eventLabel, interactionId, data, customData, extendedData)); return doEngage(conversation, context, eventLabel); } catch (Exception e) { ApptentiveLog.e(INTERACTIONS, e, "Exception while engaging event '%s'", eventName); logException(e); } return false; }
ApptentiveLog.e("testExtendedDataEvents()"); try { EventPayload expected = new EventPayload(loadTextAssetAsString(TEST_DATA_DIR + "testExtendedDataEvents.json")); EventPayload actual = new EventPayload("event_label", null, data, customData, commerce, time, location); actual.setClientCreatedAt(1.406316991967E9); actual.setNonce("4579c403-e8c5-4e6b-8826-f3d61e6ebb98");