Skip to content

trackEvent does not handle null values in JSONObject #505

Closed
@markcerqueira

Description

@markcerqueira

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions