mixpanel-node icon indicating copy to clipboard operation
mixpanel-node copied to clipboard

Using promises

Open shareefhadid opened this issue 11 months ago • 1 comments

This package should really be using promises as most calls are asynchronous.

This wasn't made clear in the documentation, but I realized it when I performed an expensive operation and the connection closed before it could be completed.

For now I need to wrap the calls in promises myself and resolve/reject in the callback like so:

await new Promise((resolve, reject) => {
  mixpanel.people.set_once(identifier, data, (e) => {
    if (e) {
      reject(e);
    }

    resolve(null);
  });
}

shareefhadid avatar Mar 13 '24 14:03 shareefhadid