Skip to content

Commit

Permalink
enable tracking null property value
Browse files Browse the repository at this point in the history
  • Loading branch information
zihejia committed Apr 22, 2021
1 parent 5b25285 commit 84c7ef2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ protected AnalyticsMessages getAnalyticsMessages() {
JSONObject jsonObj2 = new JSONObject();
JSONObject jsonObj3 = new JSONObject();
JSONObject jsonObj4 = new JSONObject();
JSONObject jsonObj5 = new JSONObject();
Map<String, Object> mapObj1 = new HashMap<>();
Map<String, Object> mapObj2 = new HashMap<>();
Map<String, Object> mapObj3 = new HashMap<>();
Expand All @@ -210,6 +211,7 @@ protected AnalyticsMessages getAnalyticsMessages() {
jsonObj2.put("TRACK JSON INT", 1);
jsonObj3.put("TRACK JSON STRING ONCE", "TRACK JSON STRING ONCE VALUE");
jsonObj4.put("TRACK JSON STRING ONCE", "SHOULD NOT SEE ME");
jsonObj5.put("TRACK JSON NULL", JSONObject.NULL);

mapObj1.put("TRACK MAP STRING", "TRACK MAP STRING VALUE");
mapObj2.put("TRACK MAP INT", 1);
Expand Down Expand Up @@ -269,6 +271,12 @@ protected AnalyticsMessages getAnalyticsMessages() {
assertEquals("event7", message.getString("event"));
properties = message.getJSONObject("properties");
assertFalse(properties.has("TRACK JSON STRING ONCE"));

mixpanel.track("event8", jsonObj5);
message = messages.poll(POLL_WAIT_SECONDS, TimeUnit.SECONDS);
assertEquals("event8", message.getString("event"));
properties = message.getJSONObject("properties");
assertEquals(jsonObj5.get("TRACK JSON NULL"), properties.get("TRACK JSON NULL"));
} catch (InterruptedException e) {
fail("Unexpected interruption");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2883,9 +2883,7 @@ protected void track(String eventName, JSONObject properties, boolean isAutomati
final Iterator<?> propIter = properties.keys();
while (propIter.hasNext()) {
final String key = (String) propIter.next();
if (!properties.isNull(key)) {
messageProps.put(key, properties.get(key));
}
messageProps.put(key, properties.get(key));
}
}

Expand Down

0 comments on commit 84c7ef2

Please sign in to comment.