@mparticle/web-sdk 3.12.1 → 3.13.0
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 -3
- package/dist/mparticle.esm.js +3 -3
- package/dist/mparticle.js +6 -6
- package/package.json +1 -1
- package/src/consent.ts +9 -7
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.
|
|
18
|
+
var version = "3.13.0";
|
|
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
|
|
@@ -1207,14 +1207,14 @@ return g=a._ServerModel.createEventObject({messageType:Types.MessageType.UserIde
|
|
|
1207
1207
|
null===(d=a._Forwarders)||void 0===d?void 0:d.setForwarderUserIdentities(b.getUserIdentities().userIdentities),null===(e=a._Forwarders)||void 0===e?void 0:e.setForwarderOnIdentityComplete(b,c),null===(f=a._Forwarders)||void 0===f?void 0:f.setForwarderOnUserIdentified(b);};}// https://go.mparticle.com/work/SQDSDKS-6359
|
|
1208
1208
|
function tryOnUserAlias(a,b,c,d,e){if(c&&c.onUserAlias&&isFunction(c.onUserAlias))try{logDeprecatedMethodUsage({methodName:"onUserAlias",warningMessage:generateDeprecationMessage("onUserAlias")},d,e),c.onUserAlias(a,b);}catch(a){d.error("There was an error with your onUserAlias function - "+a);}}
|
|
1209
1209
|
|
|
1210
|
-
var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){function b(a){
|
|
1210
|
+
var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){function b(a){return isObject(a)?c.createPrivacyConsent(a.c,a.ts,a.d,a.l,a.h):null}// TODO: Refactor this method into a constructor
|
|
1211
1211
|
var c=this;// this function is called when consent is required to
|
|
1212
1212
|
// determine if a cookie sync should happen, or a
|
|
1213
1213
|
// forwarder should be initialized
|
|
1214
1214
|
this.isEnabledForUserConsent=function(a,b){if(!a||!a.values||!a.values.length)return !0;if(!b)return !1;var c,d={},e=b.getConsentState();if(e){// the server hashes consent purposes in the following way:
|
|
1215
1215
|
// GDPR - '1' + purpose name
|
|
1216
1216
|
// CCPA - '2data_sale_opt_out' (there is only 1 purpose of data_sale_opt_out for CCPA)
|
|
1217
|
-
var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("1",g),d[c]=f[g].Consented);var h=e.getCCPAConsentState();h&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("2",CCPAPurpose),d[c]=h.Consented);}var i=a.values.some(function(a){var b=a.consentPurpose,c=a.hasConsented;return !!d.hasOwnProperty(b)&&d[b]===c});return a.includeOnMatch===i},this.createPrivacyConsent=function(b,c,d,e,f){return "boolean"
|
|
1217
|
+
var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("1",g),d[c]=f[g].Consented);var h=e.getCCPAConsentState();h&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("2",CCPAPurpose),d[c]=h.Consented);}var i=a.values.some(function(a){var b=a.consentPurpose,c=a.hasConsented;return !!d.hasOwnProperty(b)&&d[b]===c});return a.includeOnMatch===i},this.createPrivacyConsent=function(b,c,d,e,f){if("boolean"!=typeof b)return a.Logger.error("Consented boolean is required when constructing a Consent object."),null;var g=c instanceof Date;return g&&(c=c.getTime()),(c||g)&&("number"!=typeof c&&"string"!=typeof c||isNaN(c))?(a.Logger.error("Timestamp must be a valid number when constructing a Consent object."),null):d&&"string"!=typeof d?(a.Logger.error("Document must be a valid string when constructing a Consent object."),null):e&&"string"!=typeof e?(a.Logger.error("Location must be a valid string when constructing a Consent object."),null):f&&"string"!=typeof f?(a.Logger.error("Hardware ID must be a valid string when constructing a Consent object."),null):{Consented:b,Timestamp:c||Date.now(),ConsentDocument:d,Location:e,HardwareId:f}},this.ConsentSerialization={toMinifiedJsonObject:function toMinifiedJsonObject(a){var b,c={};if(a){var d=a.getGDPRConsentState();if(d)for(var e in c.gdpr={},d)if(d.hasOwnProperty(e)){var f=d[e];c.gdpr[e]={},"boolean"==typeof f.Consented&&(c.gdpr[e].c=f.Consented),"number"==typeof f.Timestamp&&(c.gdpr[e].ts=f.Timestamp),"string"==typeof f.ConsentDocument&&(c.gdpr[e].d=f.ConsentDocument),"string"==typeof f.Location&&(c.gdpr[e].l=f.Location),"string"==typeof f.HardwareId&&(c.gdpr[e].h=f.HardwareId);}var g=a.getCCPAConsentState();g&&(c.ccpa=(b={},b[CCPAPurpose]={},b),"boolean"==typeof g.Consented&&(c.ccpa[CCPAPurpose].c=g.Consented),"number"==typeof g.Timestamp&&(c.ccpa[CCPAPurpose].ts=g.Timestamp),"string"==typeof g.ConsentDocument&&(c.ccpa[CCPAPurpose].d=g.ConsentDocument),"string"==typeof g.Location&&(c.ccpa[CCPAPurpose].l=g.Location),"string"==typeof g.HardwareId&&(c.ccpa[CCPAPurpose].h=g.HardwareId));}return c},fromMinifiedJsonObject:function fromMinifiedJsonObject(a){var d=c.createConsentState();if(!isObject(a))return d;if(isObject(a.gdpr))for(var e in a.gdpr)hasOwnProp(a.gdpr,e)&&d.addGDPRConsentState(e,b(a.gdpr[e]));return isObject(a.ccpa)&&hasOwnProp(a.ccpa,CCPAPurpose)&&d.setCCPAConsentState(b(a.ccpa[CCPAPurpose])),d}},this.createConsentState=function(b){function d(a){if("string"!=typeof a)return null;var b=a.trim();return b.length?b.toLowerCase():null}/**
|
|
1218
1218
|
* Invoke these methods on a consent state object.
|
|
1219
1219
|
* <p>
|
|
1220
1220
|
* Usage: const consent = mParticle.Consent.createConsentState()
|
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.
|
|
18
|
+
var version = "3.13.0";
|
|
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
|
|
@@ -1207,14 +1207,14 @@ return g=a._ServerModel.createEventObject({messageType:Types.MessageType.UserIde
|
|
|
1207
1207
|
null===(d=a._Forwarders)||void 0===d?void 0:d.setForwarderUserIdentities(b.getUserIdentities().userIdentities),null===(e=a._Forwarders)||void 0===e?void 0:e.setForwarderOnIdentityComplete(b,c),null===(f=a._Forwarders)||void 0===f?void 0:f.setForwarderOnUserIdentified(b);};}// https://go.mparticle.com/work/SQDSDKS-6359
|
|
1208
1208
|
function tryOnUserAlias(a,b,c,d,e){if(c&&c.onUserAlias&&isFunction(c.onUserAlias))try{logDeprecatedMethodUsage({methodName:"onUserAlias",warningMessage:generateDeprecationMessage("onUserAlias")},d,e),c.onUserAlias(a,b);}catch(a){d.error("There was an error with your onUserAlias function - "+a);}}
|
|
1209
1209
|
|
|
1210
|
-
var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){function b(a){
|
|
1210
|
+
var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){function b(a){return isObject(a)?c.createPrivacyConsent(a.c,a.ts,a.d,a.l,a.h):null}// TODO: Refactor this method into a constructor
|
|
1211
1211
|
var c=this;// this function is called when consent is required to
|
|
1212
1212
|
// determine if a cookie sync should happen, or a
|
|
1213
1213
|
// forwarder should be initialized
|
|
1214
1214
|
this.isEnabledForUserConsent=function(a,b){if(!a||!a.values||!a.values.length)return !0;if(!b)return !1;var c,d={},e=b.getConsentState();if(e){// the server hashes consent purposes in the following way:
|
|
1215
1215
|
// GDPR - '1' + purpose name
|
|
1216
1216
|
// CCPA - '2data_sale_opt_out' (there is only 1 purpose of data_sale_opt_out for CCPA)
|
|
1217
|
-
var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("1",g),d[c]=f[g].Consented);var h=e.getCCPAConsentState();h&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("2",CCPAPurpose),d[c]=h.Consented);}var i=a.values.some(function(a){var b=a.consentPurpose,c=a.hasConsented;return !!d.hasOwnProperty(b)&&d[b]===c});return a.includeOnMatch===i},this.createPrivacyConsent=function(b,c,d,e,f){return "boolean"
|
|
1217
|
+
var f=e.getGDPRConsentState();if(f)for(var g in f)f.hasOwnProperty(g)&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("1",g),d[c]=f[g].Consented);var h=e.getCCPAConsentState();h&&(c=KitFilterHelper.hashConsentPurposeConditionalForwarding("2",CCPAPurpose),d[c]=h.Consented);}var i=a.values.some(function(a){var b=a.consentPurpose,c=a.hasConsented;return !!d.hasOwnProperty(b)&&d[b]===c});return a.includeOnMatch===i},this.createPrivacyConsent=function(b,c,d,e,f){if("boolean"!=typeof b)return a.Logger.error("Consented boolean is required when constructing a Consent object."),null;var g=c instanceof Date;return g&&(c=c.getTime()),(c||g)&&("number"!=typeof c&&"string"!=typeof c||isNaN(c))?(a.Logger.error("Timestamp must be a valid number when constructing a Consent object."),null):d&&"string"!=typeof d?(a.Logger.error("Document must be a valid string when constructing a Consent object."),null):e&&"string"!=typeof e?(a.Logger.error("Location must be a valid string when constructing a Consent object."),null):f&&"string"!=typeof f?(a.Logger.error("Hardware ID must be a valid string when constructing a Consent object."),null):{Consented:b,Timestamp:c||Date.now(),ConsentDocument:d,Location:e,HardwareId:f}},this.ConsentSerialization={toMinifiedJsonObject:function toMinifiedJsonObject(a){var b,c={};if(a){var d=a.getGDPRConsentState();if(d)for(var e in c.gdpr={},d)if(d.hasOwnProperty(e)){var f=d[e];c.gdpr[e]={},"boolean"==typeof f.Consented&&(c.gdpr[e].c=f.Consented),"number"==typeof f.Timestamp&&(c.gdpr[e].ts=f.Timestamp),"string"==typeof f.ConsentDocument&&(c.gdpr[e].d=f.ConsentDocument),"string"==typeof f.Location&&(c.gdpr[e].l=f.Location),"string"==typeof f.HardwareId&&(c.gdpr[e].h=f.HardwareId);}var g=a.getCCPAConsentState();g&&(c.ccpa=(b={},b[CCPAPurpose]={},b),"boolean"==typeof g.Consented&&(c.ccpa[CCPAPurpose].c=g.Consented),"number"==typeof g.Timestamp&&(c.ccpa[CCPAPurpose].ts=g.Timestamp),"string"==typeof g.ConsentDocument&&(c.ccpa[CCPAPurpose].d=g.ConsentDocument),"string"==typeof g.Location&&(c.ccpa[CCPAPurpose].l=g.Location),"string"==typeof g.HardwareId&&(c.ccpa[CCPAPurpose].h=g.HardwareId));}return c},fromMinifiedJsonObject:function fromMinifiedJsonObject(a){var d=c.createConsentState();if(!isObject(a))return d;if(isObject(a.gdpr))for(var e in a.gdpr)hasOwnProp(a.gdpr,e)&&d.addGDPRConsentState(e,b(a.gdpr[e]));return isObject(a.ccpa)&&hasOwnProp(a.ccpa,CCPAPurpose)&&d.setCCPAConsentState(b(a.ccpa[CCPAPurpose])),d}},this.createConsentState=function(b){function d(a){if("string"!=typeof a)return null;var b=a.trim();return b.length?b.toLowerCase():null}/**
|
|
1218
1218
|
* Invoke these methods on a consent state object.
|
|
1219
1219
|
* <p>
|
|
1220
1220
|
* Usage: const consent = mParticle.Consent.createConsentState()
|
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.
|
|
207
|
+
var version = "3.13.0";
|
|
208
208
|
|
|
209
209
|
var Constants = {
|
|
210
210
|
sdkVersion: version,
|
|
@@ -9249,7 +9249,11 @@ var mParticle = (function () {
|
|
|
9249
9249
|
mpInstance.Logger.error('Consented boolean is required when constructing a Consent object.');
|
|
9250
9250
|
return null;
|
|
9251
9251
|
}
|
|
9252
|
-
|
|
9252
|
+
var isDate = timestamp instanceof Date;
|
|
9253
|
+
if (isDate) {
|
|
9254
|
+
timestamp = timestamp.getTime();
|
|
9255
|
+
}
|
|
9256
|
+
if ((timestamp || isDate) && (typeof timestamp !== 'number' && typeof timestamp !== 'string' || isNaN(timestamp))) {
|
|
9253
9257
|
mpInstance.Logger.error('Timestamp must be a valid number when constructing a Consent object.');
|
|
9254
9258
|
return null;
|
|
9255
9259
|
}
|
|
@@ -9349,10 +9353,6 @@ var mParticle = (function () {
|
|
|
9349
9353
|
if (!isObject(minifiedConsent)) {
|
|
9350
9354
|
return null;
|
|
9351
9355
|
}
|
|
9352
|
-
var timestampIsObject = _typeof(minifiedConsent.ts) === 'object' && minifiedConsent.ts !== null;
|
|
9353
|
-
if (timestampIsObject) {
|
|
9354
|
-
return null;
|
|
9355
|
-
}
|
|
9356
9356
|
return self.createPrivacyConsent(minifiedConsent.c, minifiedConsent.ts, minifiedConsent.d, minifiedConsent.l, minifiedConsent.h);
|
|
9357
9357
|
}
|
|
9358
9358
|
// TODO: Refactor this method into a constructor
|
package/package.json
CHANGED
package/src/consent.ts
CHANGED
|
@@ -182,7 +182,15 @@ export default function Consent(this: IConsent, mpInstance: IMParticleWebSDKInst
|
|
|
182
182
|
);
|
|
183
183
|
return null;
|
|
184
184
|
}
|
|
185
|
-
|
|
185
|
+
const isDate = (timestamp as unknown) instanceof Date;
|
|
186
|
+
if (isDate) {
|
|
187
|
+
timestamp = ((timestamp as unknown) as Date).getTime();
|
|
188
|
+
}
|
|
189
|
+
if (
|
|
190
|
+
(timestamp || isDate) &&
|
|
191
|
+
((typeof timestamp !== 'number' && typeof timestamp !== 'string') ||
|
|
192
|
+
isNaN(timestamp))
|
|
193
|
+
) {
|
|
186
194
|
mpInstance.Logger.error(
|
|
187
195
|
'Timestamp must be a valid number when constructing a Consent object.'
|
|
188
196
|
);
|
|
@@ -316,12 +324,6 @@ export default function Consent(this: IConsent, mpInstance: IMParticleWebSDKInst
|
|
|
316
324
|
if (!isObject(minifiedConsent)) {
|
|
317
325
|
return null;
|
|
318
326
|
}
|
|
319
|
-
const timestampIsObject =
|
|
320
|
-
typeof minifiedConsent.ts === 'object' &&
|
|
321
|
-
minifiedConsent.ts !== null;
|
|
322
|
-
if (timestampIsObject) {
|
|
323
|
-
return null;
|
|
324
|
-
}
|
|
325
327
|
return self.createPrivacyConsent(
|
|
326
328
|
minifiedConsent.c,
|
|
327
329
|
minifiedConsent.ts,
|