@mparticle/web-sdk 3.11.0 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +3 -10
- package/dist/mparticle.esm.js +3 -10
- package/dist/mparticle.js +26 -18
- package/package.json +2 -1
- package/src/kitBlocking.ts +22 -16
package/dist/mparticle.common.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "3.11.
|
|
18
|
+
var version = "3.11.1";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
|
|
@@ -1270,21 +1270,14 @@ if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null=
|
|
|
1270
1270
|
return a transformed event based on event/event attributes,
|
|
1271
1271
|
then product attributes if applicable, then user attributes,
|
|
1272
1272
|
then the user identities
|
|
1273
|
-
*/try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b=__assign({},a),
|
|
1273
|
+
*/try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b,c=__assign({},a),d=convertEvent(c),e=this.getMatchKey(d),f=this.dataPlanMatchLookups[e];if(this.blockEvents&&!f)/*
|
|
1274
1274
|
If the event is not planned, it doesn't exist in dataPlanMatchLookups
|
|
1275
1275
|
and should be blocked (return null to not send anything to forwarders)
|
|
1276
1276
|
*/return null;if(this.blockEventAttributes){/*
|
|
1277
1277
|
matchedEvent is set to `true` if additionalProperties is `true`
|
|
1278
1278
|
otherwise, delete attributes that exist on event.EventAttributes
|
|
1279
1279
|
that aren't on
|
|
1280
|
-
*/if(!0===
|
|
1281
|
-
If the event is not planned, it doesn't exist in dataPlanMatchLookups
|
|
1282
|
-
and should be blocked (return null to not send anything to forwarders)
|
|
1283
|
-
*/return null;if(this.blockEventAttributes){/*
|
|
1284
|
-
matchedEvent is set to `true` if additionalProperties is `true`
|
|
1285
|
-
otherwise, delete attributes that exist on event.EventAttributes
|
|
1286
|
-
that aren't on
|
|
1287
|
-
*/if(!0===g)return d;if(g){switch(a.EventCategory){case Types.CommerceEventType.ProductImpression:d.ProductImpressions.forEach(function(a){b(g,null===a||void 0===a?void 0:a.ProductList);});break;case Types.CommerceEventType.ProductPurchase:b(g,null===(c=d.ProductAction)||void 0===c?void 0:c.ProductList);break;default:this.mpInstance.Logger.warning("Product Not Supported ");}return d}return d}return d},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
|
|
1280
|
+
*/if(!0===f)return c;if(f){for(var g,h=0,i=Object.keys(null!==(b=c.EventAttributes)&&void 0!==b?b:{});h<i.length;h++)g=i[h],f[g]||delete c.EventAttributes[g];return c}return c}return c},a.prototype.transformProductAttributes=function(a){function b(a,b){return null===b||void 0===b?void 0:b.map(function(b){if(!b.Attributes)return b;for(var c,d={},e=0,f=Object.keys(b.Attributes);e<f.length;e++)c=f[e],!0===a[c]&&(d[c]=b.Attributes[c]);return __assign(__assign({},b),{Attributes:d})})}var c=__assign({},a),d=convertEvent(c),e=this.getProductAttributeMatchKey(d),f=this.dataPlanMatchLookups[e];return this.blockEvents&&!f?null:this.blockEventAttributes?!0===f?c:f?(c.ProductAction?c.ProductAction=__assign(__assign({},c.ProductAction),{ProductList:b(f,c.ProductAction.ProductList)}):c.ProductImpressions?c.ProductImpressions=c.ProductImpressions.map(function(a){return __assign(__assign({},a),{ProductList:b(f,a.ProductList)})}):this.mpInstance.Logger.warning("Product Not Supported "),c):c:c},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
|
|
1288
1281
|
If the user attribute is not found in the matchedAttributes
|
|
1289
1282
|
then remove it from event.UserAttributes as it is blocked
|
|
1290
1283
|
*/var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c))for(var d,e=0,f=Object.keys(b.UserAttributes);e<f.length;e++)d=f[e],c[d]||delete b.UserAttributes[d];}return b},a.prototype.isAttributeKeyBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserAttributes)return !1;var b=this.dataPlanMatchLookups.user_attributes;// When additionalProperties is set to true, matchedAttributes
|
package/dist/mparticle.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "3.11.
|
|
18
|
+
var version = "3.11.1";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
|
|
@@ -1270,21 +1270,14 @@ if(v=null===(u=null===(t=null===(s=null===(r=null===(q=null===(p=null===(o=null=
|
|
|
1270
1270
|
return a transformed event based on event/event attributes,
|
|
1271
1271
|
then product attributes if applicable, then user attributes,
|
|
1272
1272
|
then the user identities
|
|
1273
|
-
*/try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b=__assign({},a),
|
|
1273
|
+
*/try{return a&&(a=this.transformEventAndEventAttributes(a)),a&&a.EventDataType===Types.MessageType.Commerce&&(a=this.transformProductAttributes(a)),a&&(a=this.transformUserAttributes(a),a=this.transformUserIdentities(a)),a}catch(b){return a}},a.prototype.transformEventAndEventAttributes=function(a){var b,c=__assign({},a),d=convertEvent(c),e=this.getMatchKey(d),f=this.dataPlanMatchLookups[e];if(this.blockEvents&&!f)/*
|
|
1274
1274
|
If the event is not planned, it doesn't exist in dataPlanMatchLookups
|
|
1275
1275
|
and should be blocked (return null to not send anything to forwarders)
|
|
1276
1276
|
*/return null;if(this.blockEventAttributes){/*
|
|
1277
1277
|
matchedEvent is set to `true` if additionalProperties is `true`
|
|
1278
1278
|
otherwise, delete attributes that exist on event.EventAttributes
|
|
1279
1279
|
that aren't on
|
|
1280
|
-
*/if(!0===
|
|
1281
|
-
If the event is not planned, it doesn't exist in dataPlanMatchLookups
|
|
1282
|
-
and should be blocked (return null to not send anything to forwarders)
|
|
1283
|
-
*/return null;if(this.blockEventAttributes){/*
|
|
1284
|
-
matchedEvent is set to `true` if additionalProperties is `true`
|
|
1285
|
-
otherwise, delete attributes that exist on event.EventAttributes
|
|
1286
|
-
that aren't on
|
|
1287
|
-
*/if(!0===g)return d;if(g){switch(a.EventCategory){case Types.CommerceEventType.ProductImpression:d.ProductImpressions.forEach(function(a){b(g,null===a||void 0===a?void 0:a.ProductList);});break;case Types.CommerceEventType.ProductPurchase:b(g,null===(c=d.ProductAction)||void 0===c?void 0:c.ProductList);break;default:this.mpInstance.Logger.warning("Product Not Supported ");}return d}return d}return d},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
|
|
1280
|
+
*/if(!0===f)return c;if(f){for(var g,h=0,i=Object.keys(null!==(b=c.EventAttributes)&&void 0!==b?b:{});h<i.length;h++)g=i[h],f[g]||delete c.EventAttributes[g];return c}return c}return c},a.prototype.transformProductAttributes=function(a){function b(a,b){return null===b||void 0===b?void 0:b.map(function(b){if(!b.Attributes)return b;for(var c,d={},e=0,f=Object.keys(b.Attributes);e<f.length;e++)c=f[e],!0===a[c]&&(d[c]=b.Attributes[c]);return __assign(__assign({},b),{Attributes:d})})}var c=__assign({},a),d=convertEvent(c),e=this.getProductAttributeMatchKey(d),f=this.dataPlanMatchLookups[e];return this.blockEvents&&!f?null:this.blockEventAttributes?!0===f?c:f?(c.ProductAction?c.ProductAction=__assign(__assign({},c.ProductAction),{ProductList:b(f,c.ProductAction.ProductList)}):c.ProductImpressions?c.ProductImpressions=c.ProductImpressions.map(function(a){return __assign(__assign({},a),{ProductList:b(f,a.ProductList)})}):this.mpInstance.Logger.warning("Product Not Supported "),c):c:c},a.prototype.transformUserAttributes=function(a){var b=__assign({},a);if(this.blockUserAttributes){/*
|
|
1288
1281
|
If the user attribute is not found in the matchedAttributes
|
|
1289
1282
|
then remove it from event.UserAttributes as it is blocked
|
|
1290
1283
|
*/var c=this.dataPlanMatchLookups.user_attributes;if(this.mpInstance._Helpers.isObject(c))for(var d,e=0,f=Object.keys(b.UserAttributes);e<f.length;e++)d=f[e],c[d]||delete b.UserAttributes[d];}return b},a.prototype.isAttributeKeyBlocked=function(a){/* used when an attribute is added to the user */if(!this.blockUserAttributes)return !1;var b=this.dataPlanMatchLookups.user_attributes;// When additionalProperties is set to true, matchedAttributes
|
package/dist/mparticle.js
CHANGED
|
@@ -204,7 +204,7 @@ var mParticle = (function () {
|
|
|
204
204
|
Base64: Base64$1
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
var version = "3.11.
|
|
207
|
+
var version = "3.11.1";
|
|
208
208
|
|
|
209
209
|
var Constants = {
|
|
210
210
|
sdkVersion: version,
|
|
@@ -9812,6 +9812,7 @@ var mParticle = (function () {
|
|
|
9812
9812
|
}
|
|
9813
9813
|
};
|
|
9814
9814
|
KitBlocker.prototype.transformEventAndEventAttributes = function (event) {
|
|
9815
|
+
var _a;
|
|
9815
9816
|
var clonedEvent = __assign({}, event);
|
|
9816
9817
|
var baseEvent = convertEvent(clonedEvent);
|
|
9817
9818
|
var matchKey = this.getMatchKey(baseEvent);
|
|
@@ -9835,8 +9836,8 @@ var mParticle = (function () {
|
|
|
9835
9836
|
return clonedEvent;
|
|
9836
9837
|
}
|
|
9837
9838
|
if (matchedEvent) {
|
|
9838
|
-
for (var _i = 0,
|
|
9839
|
-
var key =
|
|
9839
|
+
for (var _i = 0, _b = Object.keys((_a = clonedEvent.EventAttributes) !== null && _a !== void 0 ? _a : {}); _i < _b.length; _i++) {
|
|
9840
|
+
var key = _b[_i];
|
|
9840
9841
|
if (!matchedEvent[key]) {
|
|
9841
9842
|
delete clonedEvent.EventAttributes[key];
|
|
9842
9843
|
}
|
|
@@ -9849,19 +9850,25 @@ var mParticle = (function () {
|
|
|
9849
9850
|
return clonedEvent;
|
|
9850
9851
|
};
|
|
9851
9852
|
KitBlocker.prototype.transformProductAttributes = function (event) {
|
|
9852
|
-
var _a;
|
|
9853
9853
|
var clonedEvent = __assign({}, event);
|
|
9854
9854
|
var baseEvent = convertEvent(clonedEvent);
|
|
9855
9855
|
var matchKey = this.getProductAttributeMatchKey(baseEvent);
|
|
9856
9856
|
var matchedEvent = this.dataPlanMatchLookups[matchKey];
|
|
9857
|
-
function
|
|
9858
|
-
productList.
|
|
9857
|
+
function withPlannedAttributesOnly(plannedAttributes, productList) {
|
|
9858
|
+
return productList === null || productList === void 0 ? void 0 : productList.map(function (product) {
|
|
9859
|
+
if (!product.Attributes) {
|
|
9860
|
+
return product;
|
|
9861
|
+
}
|
|
9862
|
+
var attributes = {};
|
|
9859
9863
|
for (var _i = 0, _a = Object.keys(product.Attributes); _i < _a.length; _i++) {
|
|
9860
9864
|
var productKey = _a[_i];
|
|
9861
|
-
if (
|
|
9862
|
-
|
|
9865
|
+
if (plannedAttributes[productKey] === true) {
|
|
9866
|
+
attributes[productKey] = product.Attributes[productKey];
|
|
9863
9867
|
}
|
|
9864
9868
|
}
|
|
9869
|
+
return __assign(__assign({}, product), {
|
|
9870
|
+
Attributes: attributes
|
|
9871
|
+
});
|
|
9865
9872
|
});
|
|
9866
9873
|
}
|
|
9867
9874
|
if (this.blockEvents) {
|
|
@@ -9883,17 +9890,18 @@ var mParticle = (function () {
|
|
|
9883
9890
|
return clonedEvent;
|
|
9884
9891
|
}
|
|
9885
9892
|
if (matchedEvent) {
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
clonedEvent.
|
|
9889
|
-
|
|
9893
|
+
if (clonedEvent.ProductAction) {
|
|
9894
|
+
clonedEvent.ProductAction = __assign(__assign({}, clonedEvent.ProductAction), {
|
|
9895
|
+
ProductList: withPlannedAttributesOnly(matchedEvent, clonedEvent.ProductAction.ProductList)
|
|
9896
|
+
});
|
|
9897
|
+
} else if (clonedEvent.ProductImpressions) {
|
|
9898
|
+
clonedEvent.ProductImpressions = clonedEvent.ProductImpressions.map(function (impression) {
|
|
9899
|
+
return __assign(__assign({}, impression), {
|
|
9900
|
+
ProductList: withPlannedAttributesOnly(matchedEvent, impression.ProductList)
|
|
9890
9901
|
});
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
break;
|
|
9895
|
-
default:
|
|
9896
|
-
this.mpInstance.Logger.warning('Product Not Supported ');
|
|
9902
|
+
});
|
|
9903
|
+
} else {
|
|
9904
|
+
this.mpInstance.Logger.warning('Product Not Supported ');
|
|
9897
9905
|
}
|
|
9898
9906
|
return clonedEvent;
|
|
9899
9907
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-sdk",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "mParticle core SDK for web applications",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"gts:check": "gts check",
|
|
86
86
|
"gts:fix": "gts fix",
|
|
87
87
|
"prettier": "node_modules/.bin/prettier --check \"**/*.js\"",
|
|
88
|
+
"typecheck:v3-candidate": "tsc -p tsconfig.candidate.json",
|
|
88
89
|
"uglify": "npx uglify-js dist/mparticle.js --output dist/mparticle.min.js",
|
|
89
90
|
"gzip": "gzip -c dist/mparticle.min.js > dist/mparticle.min.js.gz",
|
|
90
91
|
"bundle": "npm run uglify && npm run gzip",
|
package/src/kitBlocking.ts
CHANGED
|
@@ -364,7 +364,7 @@ export default class KitBlocker {
|
|
|
364
364
|
return clonedEvent;
|
|
365
365
|
}
|
|
366
366
|
if (matchedEvent) {
|
|
367
|
-
for (const key of Object.keys(clonedEvent.EventAttributes)) {
|
|
367
|
+
for (const key of Object.keys(clonedEvent.EventAttributes ?? {})) {
|
|
368
368
|
if (!matchedEvent[key]) {
|
|
369
369
|
delete clonedEvent.EventAttributes[key];
|
|
370
370
|
}
|
|
@@ -384,13 +384,18 @@ export default class KitBlocker {
|
|
|
384
384
|
const matchKey: string = this.getProductAttributeMatchKey(baseEvent);
|
|
385
385
|
const matchedEvent = this.dataPlanMatchLookups[matchKey];
|
|
386
386
|
|
|
387
|
-
function
|
|
388
|
-
productList
|
|
387
|
+
function withPlannedAttributesOnly(plannedAttributes: { [key: string]: boolean }, productList: SDKProduct[]): SDKProduct[] {
|
|
388
|
+
return productList?.map(product => {
|
|
389
|
+
if (!product.Attributes) {
|
|
390
|
+
return product;
|
|
391
|
+
}
|
|
392
|
+
const attributes = {};
|
|
389
393
|
for (const productKey of Object.keys(product.Attributes)) {
|
|
390
|
-
if (
|
|
391
|
-
|
|
394
|
+
if (plannedAttributes[productKey] === true) {
|
|
395
|
+
attributes[productKey] = product.Attributes[productKey];
|
|
392
396
|
}
|
|
393
397
|
}
|
|
398
|
+
return { ...product, Attributes: attributes };
|
|
394
399
|
});
|
|
395
400
|
}
|
|
396
401
|
|
|
@@ -414,17 +419,18 @@ export default class KitBlocker {
|
|
|
414
419
|
return clonedEvent;
|
|
415
420
|
}
|
|
416
421
|
if (matchedEvent) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
clonedEvent.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
422
|
+
if (clonedEvent.ProductAction) {
|
|
423
|
+
clonedEvent.ProductAction = {
|
|
424
|
+
...clonedEvent.ProductAction,
|
|
425
|
+
ProductList: withPlannedAttributesOnly(matchedEvent, clonedEvent.ProductAction.ProductList),
|
|
426
|
+
};
|
|
427
|
+
} else if (clonedEvent.ProductImpressions) {
|
|
428
|
+
clonedEvent.ProductImpressions = clonedEvent.ProductImpressions.map(impression => ({
|
|
429
|
+
...impression,
|
|
430
|
+
ProductList: withPlannedAttributesOnly(matchedEvent, impression.ProductList),
|
|
431
|
+
}));
|
|
432
|
+
} else {
|
|
433
|
+
this.mpInstance.Logger.warning('Product Not Supported ')
|
|
428
434
|
}
|
|
429
435
|
|
|
430
436
|
return clonedEvent;
|