You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have cases where I want to be able to pass some custom objects (which are not JSON serializable by default) as properties of a mixpanel event, from various places in my code. The simplest and most flexible way to deal with this (such that it can automatically handle my object within a list, or standalone) is to create a JSONEncoder subclass that knows how to serialize my class, and then use that encoder class for the json.dumps call.
It's not currently too bad to do this - just requires subclassing EventTracker and overriding the _encode_params method. But this still requires duplicating some things I don't care about customizing - the base64-encoding, and the MIXPANEL_DATA_VARIABLE.
It would be nice if either there were a json_encoder_class class attribute on EventTracker, or a more fine-grained _params_to_json method. (Names up for debate).
The text was updated successfully, but these errors were encountered:
I have cases where I want to be able to pass some custom objects (which are not JSON serializable by default) as properties of a mixpanel event, from various places in my code. The simplest and most flexible way to deal with this (such that it can automatically handle my object within a list, or standalone) is to create a
JSONEncoder
subclass that knows how to serialize my class, and then use that encoder class for thejson.dumps
call.It's not currently too bad to do this - just requires subclassing
EventTracker
and overriding the_encode_params
method. But this still requires duplicating some things I don't care about customizing - the base64-encoding, and theMIXPANEL_DATA_VARIABLE
.It would be nice if either there were a
json_encoder_class
class attribute onEventTracker
, or a more fine-grained_params_to_json
method. (Names up for debate).The text was updated successfully, but these errors were encountered: