Closed sinchang closed 3 years ago
I'm not 100% sure what you mean by "a callback function on the track method". Do you mean that you would want the callback to be called as soon as the event has actually been delivered to LaunchDarkly, and then you would know it was safe to leave the page?
If so, there's already a way to do that: the flush() method, which isn't specific to custom events but causes any and all pending analytics events to be delivered.
client.track("my-custom-event");
client.flush(function() {
// the event has been delivered
});
And, as with all of the SDK methods that can take a callback, flush() can also return a Promise instead:
client.track("my-custom-event");
client.flush().then(function() {
// the event has been delivered
});
Or, in async syntax:
client.track("my-custom-event");
await client.flush();
// the event has been delivered
thanks @eli-darkly
Your solution is my needed.
Is your feature request related to a problem? Please describe. I want to track the click event on a link button, but the tracking API call would be canceled because of redirection.
Describe the solution you'd like Add a callback function on the track method with a timeout
Thanks