Version 2 of the web SDK contains breaking changes from version 1.x, including new methods to support mParticle’s IDSync features and the deprecation of older methods for managing users. Ignore this section if you are using the mParticle SDK for the first time and don’t need to upgrade from an older version.
Please use the snippet here on this page. Version 2 allows methods to be called on the SDK before the SDK has loaded. These methods get enqueued and replayed once the SDK loads. To enable this, the new snippet must be used.
It is now possible to provide an Identity Request and Identity Callback in your
mParticle.config. These options handle the intial Identity Request made by the SDK on initialization. See Configure the SDK. Also,
isSandbox has been deprecated in favor of ‘isDevelopmentMode’. Finally,
isDebug has been deprecated on the config object as well. In order to view detailed logs in version 2, you can pass add
mParticle.config.logLevel = 'verbose' to the snippet.
Previously, current user identities and attributes were set at the level of the browser and included with any outgoing batches. This approach has been deprecated in favor of more explicit user management via the Identity API. It is recommended that you include an Identity request when you initialize the SDK - if you do not, a request will automatically be sent containing only the Device Application Stamp. You should also update the current User Identity at appropriate points in your app lifecycle, such as Login and Logout.
When transitioning from one user to another, usually as a previously anonymous user creates an account and becomes a known user, some Identity Strategies will alias the old anonymous profile to the new known one. Setting
onUserAlias gives you the option to copy over attributes currently held in local storage to the new user profile.
setUserAttribute methods are deprecated as at version 2. Instead, the current user, as determined by the Identity API is exposed via
mParticle.Identity.getCurrentUser(). The returned user object provides methods to check the MPID of the current user, modify the user’s Identity Record and get/set attributes.
The shopping cart has been deprecated.
setUserIdentitywith the appropriate Identity method.
Any methods affecting a user must now be called on your your current user object. Check the following methods across your implementation:
Was this page helpful?