question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

trackEvent does not handle null values in JSONObject

See original GitHub issue

If 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:closed
  • Created 6 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
pateditcommented, Jan 4, 2018

This has been fixed in the latest release 👍

0reactions
markcerqueiracommented, Dec 14, 2017

@yinfeiru Awesome! Thank you!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found