mixpanel-js
mixpanel-js copied to clipboard
allow callback in time_event to modify tracked time
As suggested in #204, here's a first stab at adding a callback to time_event so one can see or manipulate the tracked time. I'm not sure of the standards and best practices that you guys follow so I used my best judgment. I'm not stoked about adding the EVENT_TIMERS_KEY_CALLBACK constant but I wasn't sure where to stash it and figured it'd be best to just ask for forgiveness than permission... I added one test, too. Happy to modify this however you'd like.
@tdumitrescu
@tdumitrescu, I've updated this as suggested in your comment. I also added a test to demonstrate that it correctly removes the callback after it is fired. I'm not totally sure about whether I handled storing it on the instance correctly. It doesn't feel right to introduce a new key right on the instance but I couldn't find a really clear example of something similar happening, so let me know if I should handle it differently.
I'll squash these down to one commit if we can get this approved, I'm just leaving them as independent commits for now so we can see the feature's genesis.
Just checking in here. Any thoughts?