Hi, I am facing an issue where I want to be able to send a button click event instantly, but I have enabled sending batch events for my whole application.
I use the JS SDK to initiate like this
amplitudeClient.init('API_KEY', null, {
batchEvents: true,
...
});
With “batchEvents” enabled, events are batched together and uploaded only when the number of unsent events reaches a threshold or after a some seconds have passed since the first unsent event was logged.
In my landing page, there is a login button that redirects the user to another domain. I want to track the click event for that button before redirecting, so I log the event and then redirect the user in the callback, like this
amplitudeClient.logEvent('LOGIN_LINK_CLICK', {}, () => {
// Redirect the user to the login page
})
However, since we use “batchEvents”, this event is not sent immediately, so the user has to wait several seconds to be redirected. I want to know if I can send this event immediately, either by disabling “batchEvents” temporarily, or by using the HTTPv2 API, or any other method.
Thank you for your support