Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [2.30.4](https://github.com/mParticle/mparticle-web-sdk/compare/v2.30.3...v2.30.4) (2024-11-05)


### Bug Fixes

* Move ready queue processing after identity request ([#933](https://github.com/mParticle/mparticle-web-sdk/issues/933)) ([678ccb7](https://github.com/mParticle/mparticle-web-sdk/commit/678ccb7fd97e25e15bac572c3cb899a3af23b976))

## [2.30.3](https://github.com/mParticle/mparticle-web-sdk/compare/v2.30.2...v2.30.3) (2024-11-05)

## [2.30.2](https://github.com/mParticle/mparticle-web-sdk/compare/v2.30.1...v2.30.2) (2024-10-28)


### Bug Fixes

* Support capturing click ids as custom flags in commerce events ([#939](https://github.com/mParticle/mparticle-web-sdk/issues/939)) ([6fb2476](https://github.com/mParticle/mparticle-web-sdk/commit/6fb2476aa617e9a861280c02d09c0d21555d510c))

# [2.30.1](https://github.com/mParticle/mparticle-web-sdk/compare/v2.30.0...v2.30.1) (2024-10-15)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Hello! This is the public repo of the mParticle Web SDK. We've built the mPartic

## Documentation

Fully detailed documentation and other information about mParticle web SDK can be found at our doc site [here](https://docs.mparticle.com/developers/sdk/web/getting-started)
Fully detailed documentation and other information about mParticle web SDK can be found at our doc site [here](https://docs.mparticle.com/developers/sdk/web/initialization/)

## Include and Initialize the SDK

Expand Down
20 changes: 11 additions & 9 deletions dist/mparticle.common.js

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions dist/mparticle.esm.js

Large diffs are not rendered by default.

86 changes: 45 additions & 41 deletions dist/mparticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ var mParticle = (function () {
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};

var version = "2.30.1";
var version = "2.30.4";

var Constants = {
sdkVersion: version,
Expand Down Expand Up @@ -3913,6 +3913,8 @@ var mParticle = (function () {
};
this.createCommerceEventObject = function (customFlags, options) {
var baseEvent;
// https://go.mparticle.com/work/SQDSDKS-4801
var extend = mpInstance._Helpers.extend;
mpInstance.Logger.verbose(Messages$6.InformationMessages.StartingLogCommerceEvent);
if (mpInstance._Helpers.canLog()) {
baseEvent = mpInstance._ServerModel.createEventObject({
Expand All @@ -3922,7 +3924,7 @@ var mParticle = (function () {
baseEvent.EventName = 'eCommerce - ';
baseEvent.CurrencyCode = mpInstance._Store.currencyCode;
baseEvent.ShoppingCart = [];
baseEvent.CustomFlags = customFlags;
baseEvent.CustomFlags = extend(baseEvent.CustomFlags, customFlags);
return baseEvent;
} else {
mpInstance.Logger.verbose(Messages$6.InformationMessages.AbandonLogEvent);
Expand Down Expand Up @@ -7045,6 +7047,41 @@ var mParticle = (function () {
return !prevUser || prevUser.getMPID() && identityApiResult.mpid && identityApiResult.mpid !== prevUser.getMPID();
}

var _this = undefined;
var processReadyQueue = function processReadyQueue(readyQueue) {
if (!isEmpty(readyQueue)) {
readyQueue.forEach(function (readyQueueItem) {
if (isFunction(readyQueueItem)) {
readyQueueItem();
} else if (Array.isArray(readyQueueItem)) {
processPreloadedItem(readyQueueItem);
}
});
}
return [];
};
var processPreloadedItem = function processPreloadedItem(readyQueueItem) {
var args = readyQueueItem;
var method = args.splice(0, 1)[0];
// if the first argument is a method on the base mParticle object, run it
if (typeof window !== 'undefined' && window.mParticle && window.mParticle[args[0]]) {
window.mParticle[method].apply(_this, args);
// otherwise, the method is on either eCommerce or Identity objects, ie. "eCommerce.setCurrencyCode", "Identity.login"
} else {
var methodArray = method.split('.');
try {
var computedMPFunction = window.mParticle;
for (var _i = 0, methodArray_1 = methodArray; _i < methodArray_1.length; _i++) {
var currentMethod = methodArray_1[_i];
computedMPFunction = computedMPFunction[currentMethod];
}
computedMPFunction.apply(_this, args);
} catch (e) {
throw new Error('Unable to compute proper mParticle function ' + e);
}
}
};

var Messages$3 = Constants.Messages,
HTTPCodes$3 = Constants.HTTPCodes,
FeatureFlags$1 = Constants.FeatureFlags,
Expand Down Expand Up @@ -8049,6 +8086,8 @@ var mParticle = (function () {
}
mpInstance.Logger.error('Error parsing JSON response from Identity server: ' + e);
}
mpInstance._Store.isInitialized = true;
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
};

// send a user identity change request on identify, login, logout, modify when any values change.
Expand Down Expand Up @@ -10285,13 +10324,12 @@ var mParticle = (function () {
mpInstance._Events.logAST();
processIdentityCallback(mpInstance, currentUser, currentUserMPID, currentUserIdentities);
}
mpInstance._Store.isInitialized = true;

// Call any functions that are waiting for the library to be initialized
try {
// We will continue to clear out the ready queue as part of the initial init flow
// if an identify request is unnecessary, such as if there is an existing session
if (mpInstance._Store.mpid && !mpInstance._Store.identifyCalled || mpInstance._Store.webviewBridgeEnabled) {
mpInstance._Store.isInitialized = true;
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
} catch (error) {
mpInstance.Logger.error(error);
}

// https://go.mparticle.com/work/SQDSDKS-6040
Expand Down Expand Up @@ -10408,40 +10446,6 @@ var mParticle = (function () {
});
}
}
function processPreloadedItem(readyQueueItem) {
var args = readyQueueItem;
var method = args.splice(0, 1)[0];
// if the first argument is a method on the base mParticle object, run it
if (mParticle[args[0]]) {
mParticle[method].apply(this, args);
// otherwise, the method is on either eCommerce or Identity objects, ie. "eCommerce.setCurrencyCode", "Identity.login"
} else {
var methodArray = method.split('.');
try {
var computedMPFunction = mParticle;
for (var i = 0; i < methodArray.length; i++) {
var currentMethod = methodArray[i];
computedMPFunction = computedMPFunction[currentMethod];
}
computedMPFunction.apply(this, args);
} catch (e) {
throw new Error('Unable to compute proper mParticle function ' + e);
}
}
}
function processReadyQueue(readyQueue) {
if (!isEmpty(readyQueue)) {
readyQueue.forEach(function (readyQueueItem) {
if (isFunction(readyQueueItem)) {
readyQueueItem();
} else if (Array.isArray(readyQueueItem)) {
processPreloadedItem(readyQueueItem);
}
});
}
// https://go.mparticle.com/work/SQDSDKS-6835
return [];
}
function queueIfNotInitialized(func, self) {
if (!self.isInitialized()) {
self.ready(function () {
Expand Down
106 changes: 38 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mparticle/web-sdk",
"version": "2.30.1",
"version": "2.30.4",
"description": "mParticle core SDK for web applications",
"license": "Apache-2.0",
"keywords": [
Expand Down
Loading