Closed iipanda closed 2 months ago
I'm also noticing you are using XMLHttpRequest
to send requests instead of the fetch
API. Is there any particular reason? If there is no need to keep this I would replace it with fetch since XHR would require me to wrestle with callbacks instead of simply returning a promise.
Hi @iipanda, there's no reason to use XMLHttpRequest
, feel free to rewrite it to Fetch and return a promise in the track method
I'm trying to track link clicks:
Swetrix.track({ ev: 'cta_link_click' });
The issue with this is the navigation happens before the event finishes sending and thus the request fails with NS_BINDING_ABORTED status without being sent. The solution would be returning a promise from the Swetrix.track function or accepting a callback to know when the event has finished sending and proceed with the navigation then.I can implement this functionality I just wanted to make sure this contribution would be welcome.