mixpanel / mixpanel-react-native

Official React Native Tracking Library for Mixpanel Analytics
https://mixpanel.com
Apache License 2.0
108 stars 48 forks source link

Feature Request: functionality to get promise on mixpanel.track() #105

Closed Spark-Cybel closed 2 years ago

Spark-Cybel commented 3 years ago

Can we have a functionality to get a promise for track events?

mixpanel.track(event_name, params)
  .then( success => {
      // Can Do if anything required.
  })
  .catch( error => {
      // Need to do some actions if things are not getting tracked.
  });
zihejia commented 2 years ago

hi @Spark-Cybel , when you call track, the event only gets saved in the local storage, not really means it is tracked in Mixpanel. Please see the reason below. If the status of the event being tracked or not is important to you. We'd recommend calling the ingestion API directly. Please check this doc https://developer.mixpanel.com/reference/track-event

To preserve battery life and customer bandwidth, the Mixpanel SDK doesn't send the events you record immediately. Instead, it sends batches to the Mixpanel servers every 60 seconds while your application is running, as well as when the application transitions to the background. You can call flush() manually if you want to force a flush at a particular moment.