trackEvent does not handle null values in JSONObject
See original GitHub issueIf I call trackEvent
in MixPanelAPI
with a JSONObject containing a null value the method throws an exception. This is caught internally but the result is that the event is not logged to MixPanel.
Line in question is here. properties.get(key)
will throw a JSONException
if the value is null. The caller to this method could validate input but it seems preferable to handle the nulls and track the event instead of swallowing the exception and not logging the event.
E/MixpanelAPI: Exception tracking event test-event
org.json.JSONException: No value for key_with_null_value
at org.json.JSONObject.get(JSONObject.java:354)
Oddly enough, I can only make it throw an exception on devices running Android 4.3 (I used a HTC One). Anything higher than that works, which is perplexing but maybe something changed in implementations somewhere along the way.
Thank you!
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Unable to put null values in JSON object - Stack Overflow
Right there in the documentation, in the first paragraph: Values may not be null , NaN s, infinities, or of any type not...
Read more >Pendo Help Center
Looking up a field that does not exist in a row results in null . Values may be extracted from list by using...
Read more >How do you deal with NULL values while creating JsonObject?
In a JSON "object" (aka dictionary), there are two ways to represent absent values: Either have no key/value pair at all, or have...
Read more >Tracking HTTP API: API Reference - Develop Matomo
This section lists the various query parameters that are supported by the Tracking API. The data for some of these fields will not...
Read more >To restrict entering null values in JSON object - ServiceNow
I am getting JSON object output with null values as well which I want not to include while building. Can anyone help.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This has been fixed in the latest release 👍
@yinfeiru Awesome! Thank you!