npm mixpanel-browser 2.33.0
sendBeacon support and User Agent updates

latest releases: 2.51.0, 2.50.0, 2.49.0...
4 years ago

This release adds new options to use the (sendBeacon API)[https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon] ("for analytics and diagnostics that send data to a server before the document is unloaded"). This network transport mechanism is useful for "fire-and-forget" tracking without blocking page unload, but comes at the cost of not providing any callbacks or mechanisms for knowing whether the request succeeded. There are several ways to use it for Mixpanel tracking:

// for an individual track() call
mixpanel.track('my event', {my: 'props'}, {transport: 'sendBeacon'});

// turn on for every Mixpanel call when page is unloading
// (you would use this to use sendBeacon for everything, including
// mixpanel.people calls)
window.addEventListener(`unload`, function() {
  mixpanel.set_config({api_transport: 'sendBeacon'});
  mixpanel.track('my event');
  mixpanel.people.set({foo: 'bar'});
});

// initialize for all tracking; not recommended as it will prevent any
// request-retry facilities
mixpanel.init('my token', {api_transport: 'sendBeacon'});
mixpanel.track('my event');

Browser and browser-version detection has also been updated for the new line of Microsoft Edge (based on Chromium) as well as Samsung Internet browser.

Don't miss a new mixpanel-browser release

NewReleases is sending notifications on new releases.