@Test public void test_event() throws Exception { MixPanelOutputConnector mixPanelOutputConnector = new MixPanelOutputConnector() { @Override protected MixpanelAPI getMixpanelAPI() { return new MixpanelAPI(mockMixpanelServer.getServerURL() + "/track", null); } }; mixPanelOutputConnector.setPipelineContext(getMockPipelineContext()); mockMixpanelServer.addRequestResponse(new RequestResponse() .setExpectedRequestURI(mockMixpanelServer.getServerURL() + "/track?ip=0") .setExpectedRequestParam("data", "W3siZXZlbnQiOiJnYW1lIiwicHJvcGVydGllcyI6eyJ0aW1lIjoxMjQ1NjEzODg1LCJkaXN0aW5jdF9pZCI6IjUwNDc5YjI0NjcxYmYiLCJ0b2tlbiI6ImUzYmM0MTAwMzMwYzM1NzIyNzQwZmI4YzZmNWFiZGRjIiwiYWN0aW9uIjoicGxheSIsIm1wX2xpYiI6ImpkayIsImlwIjoiMTIzLjEyMy4xMjMuMTIzIn19XQ==") .setResponsePayload("1") ); mixPanelOutputConnector.logActivity(new JSONObject(SAMPLE_EVENT)); mockMixpanelServer.waitForAllRequestsToComplete(); mockMixpanelServer.assertAllRequestsCompleteOK(); }
protected void logActivity(JSONObject payload) throws JSONException, IOException { String eventName = payload.getString("event"); JSONObject properties = payload.getJSONObject("properties"); Long time = properties.optLong("time", 0L); if (time == 0L) { time = System.currentTimeMillis(); } time = time/1000; properties.put("time", time); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = properties.getString("distinct_id"); JSONObject mixPanelMessage = messageBuilder.event(distinct_id, eventName, properties); sendMessageToMixpanel(mixpanel, mixPanelMessage); }
MixPanelOutputConnector extends AbstractPipelineComponent implements OutputConnector, Configurable<JSONObject> { protected void logActivity(JSONObject payload) throws JSONException, IOException { String eventName = payload.getString("event"); JSONObject properties = payload.getJSONObject("properties"); Long time = properties.optLong("time", 0L); if (time == 0L) { time = System.currentTimeMillis(); } time = time/1000; properties.put("time", time); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = properties.getString("distinct_id"); JSONObject mixPanelMessage = messageBuilder.event(distinct_id, eventName, properties); sendMessageToMixpanel(mixpanel, mixPanelMessage); } }
MixPanelOutputConnector extends AbstractPipelineComponent implements OutputConnector, Configurable<JSONObject> { protected void logActivity(JSONObject payload) throws JSONException, IOException { String eventName = payload.getString("event"); JSONObject properties = payload.getJSONObject("properties"); Long time = properties.optLong("time", 0L); if (time == 0L) { time = System.currentTimeMillis(); } time = time/1000; properties.put("time", time); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = properties.getString("distinct_id"); JSONObject mixPanelMessage = messageBuilder.event(distinct_id, eventName, properties); sendMessageToMixpanel(mixpanel, mixPanelMessage); }  }
MixPanelOutputConnector extends AbstractPipelineComponent implements OutputConnector, Configurable<JSONObject> { protected void logActivity(JSONObject payload) throws JSONException, IOException { String eventName = payload.getString("event"); JSONObject properties = payload.getJSONObject("properties"); Long time = properties.optLong("time", 0L); if (time == 0L) { time = System.currentTimeMillis(); } time = time/1000; properties.put("time", time); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = properties.getString("distinct_id"); JSONObject mixPanelMessage = messageBuilder.event(distinct_id, eventName, properties); sendMessageToMixpanel(mixpanel, mixPanelMessage); }  @Override void setConfiguration(JSONObject jsonObject); @Override Message send(Message message); }
MixPanelOutputConnector extends AbstractPipelineComponent implements OutputConnector, Configurable<JSONObject> { protected void logActivity(JSONObject payload) throws JSONException, IOException { String eventName = payload.getString("event"); JSONObject properties = payload.getJSONObject("properties"); Long time = properties.optLong("time", 0L); if (time == 0L) { time = System.currentTimeMillis(); } time = time/1000; properties.put("time", time); MixpanelAPI mixpanel = getMixpanelAPI(); MessageBuilder messageBuilder = new MessageBuilder(token); String distinct_id = properties.getString("distinct_id"); JSONObject mixPanelMessage = messageBuilder.event(distinct_id, eventName, properties); sendMessageToMixpanel(mixpanel, mixPanelMessage); }  @Override void setConfiguration(JSONObject jsonObject); @Override Message send(Message message);  }