davide-scalzo / react-native-mixpanel

A React Native wrapper for Mixpanel tracking
MIT License
455 stars 195 forks source link

Allow `timeEvent` to be ended with `trackWithProperties` (or even better, deprecate `trackWithProperties` altogether and use `track`) #183

Open dwilt opened 5 years ago

dwilt commented 5 years ago

According to the documentation for web, it looks like you can end the timeEvent along with custom properties:

mixpanel.time_event('Registered');
mixpanel.track('Registered', {'Gender': 'Male', 'Age': 21});

However, in the react native version, if you try and end a timeEvent with trackWithProperties:

Mixpanel.timeEvent('some event);
// some async operation taking time
Mixpanel.trackWithProperties('some event', { name: 'Dan' });

the event gets logged in Mixpanel but the duration field is blank. If you end the timeEvent with track instead of trackWithProperties:

Mixpanel.timeEvent('some event);
// some async operation taking time
Mixpanel.track('some event');

the duration field is in the event in Mixpanel but you don't get the other properties you passed.

The underlying question really is, why the differentiation between track and trackWithProperties? Why not, like the web version, just use track and it can take an optional object of parameters?

yogeshchoudhary147 commented 4 years ago

+1