Releases: mixpanel/mixpanel-js
Session recording updates
This releases bundles several updates and fixes for the session recording feature:
- New debugging method
mixpanel.get_session_replay_url()
returns a mixpanel.com link to view the current replay if there is an active recording taking place. - The
record_inline_images
configuration option has been removed for now due to buggy behavior in the rrweb library. - Recording payloads now include additional metadata: the current URL, library type, and library version.
- Sourcemaps are now generated for the recorder module.
- Added some additional error handling for when
mixpanel.stop_session_recording()
fails or rrweb silently fails to start recording.
Misc fixes and updates
- Adds a minimum recording length option for session recording. For example,
{record_min_ms: 4000}
won't send any recordings that are less than 4 seconds long. The maximum value allowed is 8000. - Added a fix for session recordings being sent with an empty start time.
- Fixes and improvements for request batcher to support offline queueing and retry.
- Fix for query param parsing/escaping (#443).
- Support for more UTM tags / click IDs (#442).
Module bundling and session recording updates
The SDK is now provided in several new builds with different options around included modules and asynchronous loading:
- Core mixpanel build with bundled
mixpanel-recorder
session-recording module (default):
import mixpanel from 'mixpanel-browser';
- Core mixpanel build that optionally loads
mixpanel-recorder
asynchronously via script tag (previous default):
import mixpanel from 'mixpanel-browser/src/loaders/loader-module-with-async-recorder';
- Core mixpanel build only (no session recording available):
import mixpanel from 'mixpanel-browser/src/loaders/loader-module-core';
This release also includes updates and improvements to the session recording module:
- Improved reliability via integration with the main SDK's network batching/retry system
- Inactivity timeouts are now determined by user interaction events
- New configuration options enable inlining of images and fonts into recording payloads:
mixpanel.init(`my token`, {
record_sessions_percent: 5,
record_collect_fonts: true,
record_inline_images: true,
});
NOTE: with image-inlining turned on, image-intensive pages may increase payload size significantly and possibly surpass the API server's request size limit.
Session recording updates
- Network payload format for session recording batches has changed, including client-side compression on browsers which support it
- Google Tag Manager wrapper now includes session-recording start/stop methods
Revert to persisting UTM params by default
This release reverts the UTM param persistence change introduced in v2.51.0, to minimize disruption for older implementations. UTM parameters will be persisted by default in super property storage when the SDK finds them on pageload. To opt in to the recommended modern behavior, use initialization option {stop_utm_persistence: true}
.
Updates to UTM param persistence, localStorage/cookie migration, session recording
- UTM parameters are no longer persisted as superproperties by default. Mixpanel analyses now have attribution support that does not require client-side persistence of these properties. To opt in to the previous behavior, use initialization option
{stop_utm_persistence: false}
. - localStorage->cookie migration support: when switching an implementation from localStorage persistence to cookie persistence (to support cross-subdomain tracking), the SDK will now automatically copy any existing superproperties from localStorage into the new superprop cookie. This migration behavior already existed in the opposite direction (going from cookie to localStorage).
- The initialization options
record_block_class
,record_block_selector
, andrecord_mask_text_class
offer finer-grained control over elements to block in session recording, and provide stricter defaults. - New method
mixpanel.get_session_recording_properties()
exposes Replay ID property for tagging events controlled by other client-side SDKs such as Segment or mParticle.
Session recording support
v2.50.0 2.50.0
Attribution/web analytics updates
This release updates capabilities related to web/marketing/attribution analytics.
The track_pageview
init option now accepts three string values to support SPA pageview tracking:
"url-with-path"
: fire pageview events only when main url path changes (https://example.com/foo
->https://example.com/bar
but nothttps://example.com/foo?bar=1
->https://example.com/foo?bar=2
)"url-with-path-and-query-string"
: fire pageview events only when main url path or query string changes (https://example.com/foo?bar=1
->https://example.com/foo?bar=2
but nothttps://example.com/foo?bar=1#baz
->https://example.com/foo?bar=1#qux
)"full-url"
: fire pageview events when anything on the URL changes
Example:
mixpanel.init(`my token`, {track_pageview: `url-with-path-and-query-string`});
Profile properties storing referrer info ($initial_referrer
and $initial_referring_domain
) are now saved with set_once
instead of set
, to prevent overwriting.
Persistence of UTM parameters can now be turned off with the init option {stop_utm_persistence: true}
. This is opt-in today but will be the default setting in a future release. The stop_utm_persistence
option will also override the store_google
option, which is responsible persisting UTM parameters today. If store_google
and stop_utm_persistence
are both true
, any persisted UTM parameters will be cleared from storage.
Visits from AhrefsSiteAudit crawler are now ignored.
Minification fix for UTM campaign properties
This update patches a discrepancy between the minified and unminified versions of the packaged SDK. Campaign parameters will now be stored as super properties persistently in all versions.
Configurable API endpoints, miscellaneous updates and fixes
API endpoint routes can now be configured individually, so you can rename /track, /engage, and /groups HTTP endpoints arbitrarily. Configure with the api_routes
option:
mixpanel.init(`my token`, {
api_host: `https://my-proxy.example.com`,
api_routes: {
track: `foo/`,
engage: `bar/`,
groups: `baz/`,
},
));
In the above example, event-tracking requests will go to https://my-proxy.example.com/foo/
, user profile updates to https://my-proxy.example.com/bar/
, etc.
Other fixes:
- Event properties object passed to
mixpanel.track()
will no longer be mutated - Super properties are now reloaded from persistence when making every tracking call (i.e., kept fresh when another tab/window in the same browser has updated them)
- Extra failsafe behavior for trying to clear queued requests when localStorage doesn't work on startup, e.g., when localStorage is full so writes fail
- Block Chrome-Lighthouse user agent
- Fix for error in
add_group()
when adding a new group to an existing list