Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event being dropped if property value is custom object #798

Merged
merged 1 commit into from
Sep 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,25 @@ protected AnalyticsMessages getAnalyticsMessages() {
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<>();
Map<String, Object> mapObj4 = new HashMap<>();
Map<String, Object> mapObj5 = new HashMap<>();

jsonObj1.put("TRACK JSON STRING", "TRACK JSON STRING VALUE");
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);
mapObj3.put("TRACK MAP STRING ONCE", "TRACK MAP STRING ONCE VALUE");
mapObj4.put("TRACK MAP STRING ONCE", "SHOULD NOT SEE ME");
mapObj5.put("TRACK MAP CUSTOM OBJECT", mixpanel);

try {
JSONObject message;
Expand Down Expand Up @@ -287,13 +291,15 @@ protected AnalyticsMessages getAnalyticsMessages() {
assertEquals("event8", message.getString("event"));
properties = message.getJSONObject("properties");
assertEquals(jsonObj5.get("TRACK JSON NULL"), properties.get("TRACK JSON NULL"));

mixpanel.trackMap("event contains custom object", mapObj5);
message = messages.poll(POLL_WAIT_SECONDS, TimeUnit.SECONDS);
assertEquals("event contains custom object", message.getString("event"));
} catch (InterruptedException e) {
fail("Unexpected interruption");
}
}



@Test
public void testPeopleMessageOperations() throws JSONException {
final List<AnalyticsMessages.PeopleDescription> messages = new ArrayList<AnalyticsMessages.PeopleDescription>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2314,7 +2314,7 @@ protected void track(String eventName, JSONObject properties, boolean isAutomati
final Iterator<?> propIter = properties.keys();
while (propIter.hasNext()) {
final String key = (String) propIter.next();
messageProps.put(key, properties.get(key));
messageProps.put(key, properties.opt(key));
}
}

Expand Down