mixpanel-js
mixpanel-js copied to clipboard
Offset $duration value
I'm tracking a timed event that relies on data coming in from a piece of hardware. We start the timer and a timeout when the first sample comes in, reset the timeout when each new sample is received, and then the timeout fires when no data has been received for a short amount of time. As a result, all of our recorded durations are off this amount of time. I'd like to find a way to modify the $duration value before it is set, essentially offsetting it by our timeout value. Is there a safe way to do this without mucking about in private interfaces or would I be better off tracking duration on my own?
Thank you!
This sounds like an unusual enough use case that it's probably best to manage in your own app code. The event-timing code is pretty simple. But if you can come up with an API that's suitable for general use (maybe a callback that time_event() can pass duration to for transformation?), then a PR is welcome.
Thanks for getting back to me. I was thinking about a callback function. The code looks straightforward enough. Any advice on where you'd like to the callback to be stored while timing? It would need to go somewhere on the instance and I don't think I should be inventing a new namespace for it.