How to wait for event request of Rudderstack JavaScript SDK?

487 Views Asked by At

I want to redirect the user after the track event or any other event fired by rudderstack has be done.

As I've tested on track event it doesn't not return a promise.

How can I wait for the requests to end to redirect after?

Below there is an example of what i am doing:

// import    
import { track, load, ready, identify } from 'rudder-sdk-js';
[...]

await load(write_key, data_plane_url)

await ready(async () => {
  await identify(hashedId, userInfo);

  await track('ORDER_APPROVED');    
});

history.push('/some-page')

I'm using it with React btw.

0

There are 0 best solutions below