Solved

Force flush?


Badge

Is there a way to force amplitude-js to flush events? I’m trying to track an event that triggers a browser refresh, but the logEvent calls just prior to the reload are lost... This is true even if I move the browser refresh into the callback provided to logEvent.

icon

Best answer by Denis Holmes 23 July 2021, 07:37

Hi @ejain-bloom ,

 

I believe with the JS SDK you can use the method amplitude.getInstance().sendEvents() to send any events early. There is some documentation available here for that. Is this what you were looking for? Let me know if it is not and I can ask our Engineers internally.

Kind Regards.,
Denis

View original

4 replies

Userlevel 3
Badge +2

Hi @ejain-bloom ,

 

I believe with the JS SDK you can use the method amplitude.getInstance().sendEvents() to send any events early. There is some documentation available here for that. Is this what you were looking for? Let me know if it is not and I can ask our Engineers internally.

Kind Regards.,
Denis

Badge

I’ve tried both sendEvents() as well as doing the call to window.location.reload() from the optional logEvent callback, but in both cases the last event is lost :cry:

Userlevel 3
Badge +2

Hi @ejain-bloom ,

 

So it works but not for the last event? Can you private message me your amplitude email so I that I can create a ticket and investigate this internally for you? Thank you!

Badge

I don’t think there is any guarantee that events will have been sent when sendEvents() returns; for that to work, this function would have to return a promise (or accept a callback)...

Reply