@Test public void test_set_profile() throws Exception { MixPanelOutputConnector mixPanelOutputConnector = new MixPanelOutputConnector() { @Override protected MixpanelAPI getMixpanelAPI() { return new MixpanelAPI(null, mockMixpanelServer.getServerURL() + "/engage"); } }; mixPanelOutputConnector.setPipelineContext(getMockPipelineContext()); mockMixpanelServer.addRequestResponse(new RequestResponse() .setExpectedRequestURI(mockMixpanelServer.getServerURL() + "/engage") .setExpectedRequestParam("data", "W3siJHRpbWUiOjEyNDU2MTM4ODUwMDAsIiRkaXN0aW5jdF9pZCI6IjUwNDc5YjI0NjcxYmYiLCIkc2V0Ijp7Ik5hbWUiOiJNYXJrIERvd25lcyIsIkVtYWlsIjoibWRAeC5jb20ifSwiJGlwIjoiMTI3LjAuMC4xIn1d") .setResponsePayload("1") ); mixPanelOutputConnector.setUserProfile(new JSONObject(SAMPLE_SET_PROFILE)); mockMixpanelServer.waitForAllRequestsToComplete(); mockMixpanelServer.assertAllRequestsCompleteOK(); }
protected void setUserProfile(JSONObject payload) throws JSONException, IOException { JSONObject properties = payload.optJSONObject("properties"); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = payload.getString("distinct_id"); if (properties == null) { properties = new JSONObject(); } JSONObject mixPanelMessage = messageBuilder.set(distinct_id, properties); String ip = payload.optString("ip", null); if (ip != null) { JSONUtil.setValue(mixPanelMessage, ip, "message", "$ip"); } Long time = payload.optLong("time", 0L); if (time != 0L) { JSONUtil.setValue(mixPanelMessage, time, "message", "$time"); } sendMessageToMixpanel(mixpanel, mixPanelMessage); }
MixPanelOutputConnector extends AbstractPipelineComponent implements OutputConnector, Configurable<JSONObject> { protected void setUserProfile(JSONObject payload) throws JSONException, IOException { JSONObject properties = payload.optJSONObject("properties"); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = payload.getString("distinct_id"); if (properties == null) { properties = new JSONObject(); } JSONObject mixPanelMessage = messageBuilder.set(distinct_id, properties); String ip = payload.optString("ip", null); if (ip != null) { JSONUtil.setValue(mixPanelMessage, ip, "message", "$ip"); } Long time = payload.optLong("time", 0L); if (time != 0L) { JSONUtil.setValue(mixPanelMessage, time, "message", "$time"); } sendMessageToMixpanel(mixpanel, mixPanelMessage); } }
MixPanelOutputConnector extends AbstractPipelineComponent implements OutputConnector, Configurable<JSONObject> { protected void setUserProfile(JSONObject payload) throws JSONException, IOException { JSONObject properties = payload.optJSONObject("properties"); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = payload.getString("distinct_id"); if (properties == null) { properties = new JSONObject(); } JSONObject mixPanelMessage = messageBuilder.set(distinct_id, properties); String ip = payload.optString("ip", null); if (ip != null) { JSONUtil.setValue(mixPanelMessage, ip, "message", "$ip"); } Long time = payload.optLong("time", 0L); if (time != 0L) { JSONUtil.setValue(mixPanelMessage, time, "message", "$time"); } sendMessageToMixpanel(mixpanel, mixPanelMessage); }  }
MixPanelOutputConnector extends AbstractPipelineComponent implements OutputConnector, Configurable<JSONObject> { protected void setUserProfile(JSONObject payload) throws JSONException, IOException { JSONObject properties = payload.optJSONObject("properties"); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = payload.getString("distinct_id"); if (properties == null) { properties = new JSONObject(); } JSONObject mixPanelMessage = messageBuilder.set(distinct_id, properties); String ip = payload.optString("ip", null); if (ip != null) { JSONUtil.setValue(mixPanelMessage, ip, "message", "$ip"); } Long time = payload.optLong("time", 0L); if (time != 0L) { JSONUtil.setValue(mixPanelMessage, time, "message", "$time"); } sendMessageToMixpanel(mixpanel, mixPanelMessage); }  @Override void setConfiguration(JSONObject jsonObject); @Override Message send(Message message); }
MixPanelOutputConnector extends AbstractPipelineComponent implements OutputConnector, Configurable<JSONObject> { protected void setUserProfile(JSONObject payload) throws JSONException, IOException { JSONObject properties = payload.optJSONObject("properties"); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = payload.getString("distinct_id"); if (properties == null) { properties = new JSONObject(); } JSONObject mixPanelMessage = messageBuilder.set(distinct_id, properties); String ip = payload.optString("ip", null); if (ip != null) { JSONUtil.setValue(mixPanelMessage, ip, "message", "$ip"); } Long time = payload.optLong("time", 0L); if (time != 0L) { JSONUtil.setValue(mixPanelMessage, time, "message", "$time"); } sendMessageToMixpanel(mixpanel, mixPanelMessage); }  @Override void setConfiguration(JSONObject jsonObject); @Override Message send(Message message);  }