@mparticle/web-sdk 2.26.3 → 2.26.5
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 +8 -4
- package/dist/mparticle.esm.js +8 -4
- package/dist/mparticle.js +31 -26
- package/package.json +1 -1
- package/src/apiClient.ts +3 -2
- package/src/batchUploader.ts +5 -9
- package/src/consent.ts +4 -3
- package/src/forwarders.interfaces.ts +20 -18
- package/src/identity-user-interfaces.ts +113 -0
- package/src/identity-utils.ts +7 -5
- package/src/identity.interfaces.ts +205 -0
- package/src/identity.js +3 -0
- package/src/persistence.interfaces.ts +1 -4
- package/src/sdkRuntimeModels.ts +28 -81
- package/src/sdkToEventsApiConverter.ts +33 -23
- package/src/serverModel.ts +10 -8
- package/src/sessionManager.ts +3 -2
- package/src/store.ts +2 -1
- package/src/types.interfaces.ts +5 -1
- package/src/utils.ts +2 -0
- package/src/validators.ts +1 -1
package/dist/mparticle.common.js
CHANGED
|
@@ -61,7 +61,7 @@ var _TriggerUploadType,MessageType$2={SessionStart:1,SessionEnd:2,PageView:3,Pag
|
|
|
61
61
|
// Continuation of enum above, but in seperate object since we don't expose these to end user
|
|
62
62
|
IdentityType$1.isValid=function(a){if("number"==typeof a)for(var b in IdentityType$1)if(IdentityType$1.hasOwnProperty(b)&&IdentityType$1[b]===a)return !0;return !1},IdentityType$1.getName=function(a){return a===window.mParticle.IdentityType.CustomerId?"Customer ID":a===window.mParticle.IdentityType.Facebook?"Facebook ID":a===window.mParticle.IdentityType.Twitter?"Twitter ID":a===window.mParticle.IdentityType.Google?"Google ID":a===window.mParticle.IdentityType.Microsoft?"Microsoft ID":a===window.mParticle.IdentityType.Yahoo?"Yahoo ID":a===window.mParticle.IdentityType.Email?"Email":a===window.mParticle.IdentityType.FacebookCustomAudienceId?"Facebook App User ID":"Other ID"},IdentityType$1.getIdentityType=function(a){return "other"===a?IdentityType$1.Other:"customerid"===a?IdentityType$1.CustomerId:"facebook"===a?IdentityType$1.Facebook:"twitter"===a?IdentityType$1.Twitter:"google"===a?IdentityType$1.Google:"microsoft"===a?IdentityType$1.Microsoft:"yahoo"===a?IdentityType$1.Yahoo:"email"===a?IdentityType$1.Email:"facebookcustomaudienceid"===a?IdentityType$1.FacebookCustomAudienceId:"other2"===a?IdentityType$1.Other2:"other3"===a?IdentityType$1.Other3:"other4"===a?IdentityType$1.Other4:"other5"===a?IdentityType$1.Other5:"other6"===a?IdentityType$1.Other6:"other7"===a?IdentityType$1.Other7:"other8"===a?IdentityType$1.Other8:"other9"===a?IdentityType$1.Other9:"other10"===a?IdentityType$1.Other10:"mobile_number"===a?IdentityType$1.MobileNumber:"phone_number_2"===a?IdentityType$1.PhoneNumber2:!("phone_number_3"!=a)&&IdentityType$1.PhoneNumber3},IdentityType$1.getIdentityName=function(a){return a===IdentityType$1.Other?"other":a===IdentityType$1.CustomerId?"customerid":a===IdentityType$1.Facebook?"facebook":a===IdentityType$1.Twitter?"twitter":a===IdentityType$1.Google?"google":a===IdentityType$1.Microsoft?"microsoft":a===IdentityType$1.Yahoo?"yahoo":a===IdentityType$1.Email?"email":a===IdentityType$1.FacebookCustomAudienceId?"facebookcustomaudienceid":a===IdentityType$1.Other2?"other2":a===IdentityType$1.Other3?"other3":a===IdentityType$1.Other4?"other4":a===IdentityType$1.Other5?"other5":a===IdentityType$1.Other6?"other6":a===IdentityType$1.Other7?"other7":a===IdentityType$1.Other8?"other8":a===IdentityType$1.Other9?"other9":a===IdentityType$1.Other10?"other10":a===IdentityType$1.MobileNumber?"mobile_number":a===IdentityType$1.PhoneNumber2?"phone_number_2":a===IdentityType$1.PhoneNumber3?"phone_number_3":void 0};var ProductActionType={Unknown:0,AddToCart:1,RemoveFromCart:2,Checkout:3,CheckoutOption:4,Click:5,ViewDetail:6,Purchase:7,Refund:8,AddToWishlist:9,RemoveFromWishlist:10};ProductActionType.getName=function(a){return a===ProductActionType.AddToCart?"Add to Cart":a===ProductActionType.RemoveFromCart?"Remove from Cart":a===ProductActionType.Checkout?"Checkout":a===ProductActionType.CheckoutOption?"Checkout Option":a===ProductActionType.Click?"Click":a===ProductActionType.ViewDetail?"View Detail":a===ProductActionType.Purchase?"Purchase":a===ProductActionType.Refund?"Refund":a===ProductActionType.AddToWishlist?"Add to Wishlist":a===ProductActionType.RemoveFromWishlist?"Remove from Wishlist":"Unknown"},ProductActionType.getExpansionName=function(a){return a===ProductActionType.AddToCart?"add_to_cart":a===ProductActionType.RemoveFromCart?"remove_from_cart":a===ProductActionType.Checkout?"checkout":a===ProductActionType.CheckoutOption?"checkout_option":a===ProductActionType.Click?"click":a===ProductActionType.ViewDetail?"view_detail":a===ProductActionType.Purchase?"purchase":a===ProductActionType.Refund?"refund":a===ProductActionType.AddToWishlist?"add_to_wishlist":a===ProductActionType.RemoveFromWishlist?"remove_from_wishlist":"unknown"};var PromotionActionType={Unknown:0,PromotionView:1,PromotionClick:2};PromotionActionType.getName=function(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"},PromotionActionType.getExpansionName=function(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"};var ProfileMessageType={Logout:3},ApplicationTransitionType$1={AppInit:1},Environment={Production:"production",Development:"development"};var Types = {MessageType:MessageType$2,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType$1,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,TriggerUploadType:TriggerUploadType,Environment:Environment};
|
|
63
63
|
|
|
64
|
-
var version = "2.26.
|
|
64
|
+
var version = "2.26.5";
|
|
65
65
|
|
|
66
66
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"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",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",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",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,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
|
|
67
67
|
},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/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
|
|
@@ -162,7 +162,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
162
162
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={}));
|
|
165
|
+
var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={}));
|
|
166
166
|
|
|
167
167
|
var dist = {};
|
|
168
168
|
|
|
@@ -408,6 +408,8 @@ return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"
|
|
|
408
408
|
* Returns a value between 1-100 inclusive.
|
|
409
409
|
*/ // FIXME: REFACTOR for V3
|
|
410
410
|
|
|
411
|
+
var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a.facebook="facebook",a.twitter="twitter",a.google="google",a.microsoft="microsoft",a.yahoo="yahoo",a.email="email",a.alias="alias",a.facebookCustomAudienceId="facebookcustomaudienceid",a.otherId2="other2",a.otherId3="other3",a.otherId4="other4",a.otherId5="other5",a.otherId6="other6",a.otherId7="other7",a.otherId8="other8",a.otherId9="other9",a.otherId10="other10",a.mobileNumber="mobile_number",a.phoneNumber2="phone_number_2",a.phoneNumber3="phone_number_3";})(SDKIdentityTypeEnum||(SDKIdentityTypeEnum={}));
|
|
412
|
+
|
|
411
413
|
function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c.Identity.getCurrentUser(),f=[],g=null,h=0,i=b;h<i.length;h++)if(d=i[h],d){g=d;var j=convertEvent(d);j&&f.push(j);}if(!g)return null;var k=null;// Add the consent state from either the Last Event or the user
|
|
412
414
|
isEmpty(g.ConsentState)?!isEmpty(e)&&(k=e.getConsentState()):k=g.ConsentState;var l={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:g.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:f,mp_deviceid:g.DeviceId,sdk_version:g.SDKVersion,// TODO: Refactor this to read from _Store or a global config
|
|
413
415
|
application_info:{application_version:g.AppVersion,application_name:g.AppName,package:g.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:window.screen.width,screen_height:window.screen.height},user_attributes:g.UserAttributes,user_identities:convertUserIdentities(g.UserIdentities),consent_state:convertConsentState(k),integration_attributes:g.IntegrationAttributes};return g.DataPlan&&g.DataPlan.PlanId&&(l.context={data_plan:{plan_id:g.DataPlan.PlanId,plan_version:g.DataPlan.PlanVersion||void 0}}),l}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
|
|
@@ -859,7 +861,8 @@ if(c?(g=!1,d=o[c],delete o[c]):g=!0,o[r]=u,a&&a[e]&&(a[e].ua=o,t._Persistence.sa
|
|
|
859
861
|
* Get user audiences
|
|
860
862
|
* @method getuserAudiences
|
|
861
863
|
* @param {Function} [callback] A callback function that is invoked when the user audience request completes
|
|
862
|
-
*/
|
|
864
|
+
*/ // https://go.mparticle.com/work/SQDSDKS-6436
|
|
865
|
+
getUserAudiences:function getUserAudiences(r){// user audience API is feature flagged
|
|
863
866
|
return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audienceManager&&(s.audienceManager=new AudienceManager(t._Store.SDKConfig.userAudienceUrl,t._Store.devToken,t.Logger,e)),s.audienceManager.sendGetUserAudienceRequest(e,r)):void t.Logger.error(ErrorMessages.AudienceAPINotEnabled)}}},this.mParticleUserCart=function(e){return {/**
|
|
864
867
|
* Adds a cart product to the user cart
|
|
865
868
|
* @method add
|
|
@@ -881,7 +884,8 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
|
|
|
881
884
|
* @method getCartProducts
|
|
882
885
|
* @return {Array} array of cart products
|
|
883
886
|
* @deprecated
|
|
884
|
-
*/getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(s,i,n,a,o,d,g){var l,u,c,p,_=t.Identity.getUser(i),I={},y=_?_.getUserIdentities().userIdentities:{},v=t._Helpers.extend({},y);t._Store.identityCallInFlight=!1;try{if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),s.responseText&&(c=JSON.parse(s.responseText),c.hasOwnProperty("is_logged_in")&&(t._Store.isLoggedIn=c.is_logged_in)),(!_||_.getMPID()&&c.mpid&&c.mpid!==_.getMPID())&&(t._Store.mpid=c.mpid,_&&t._Persistence.setLastSeenTime(i),!t._Persistence.getFirstSeenTime(c.mpid)&&(u=!0),t._Persistence.setFirstSeenTime(c.mpid)),200===s.status){if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)&&cacheOrClearIdCache(o,d,r.idCache,s,g),o===Modify$1)I=t._Identity.IdentityRequest.combineUserIdentities(y,a.userIdentities),t._Persistence.saveUserIdentitiesToPersistence(i,I);else {var m=r.IdentityAPI.getUser(c.mpid),S=m?m.getUserIdentities().userIdentities:{},P=t._Helpers.extend({},S);t.Logger.verbose("Successfully parsed Identity Response"),o===Identify&&_&&c.mpid===_.getMPID()&&t._Persistence.setFirstSeenTime(c.mpid),p=t._Store.currentSessionMPIDs.indexOf(c.mpid),t._Store.sessionId&&c.mpid&&i!==c.mpid&&0>p&&t._Store.currentSessionMPIDs.push(c.mpid),-1<p&&(t._Store.currentSessionMPIDs=t._Store.currentSessionMPIDs.slice(0,p).concat(t._Store.currentSessionMPIDs.slice(p+1,t._Store.currentSessionMPIDs.length)),t._Store.currentSessionMPIDs.push(c.mpid)),t._CookieSyncManager.attemptCookieSync(i,c.mpid,u),r.checkIdentitySwap(i,c.mpid,t._Store.currentSessionMPIDs),a&&a.userIdentities&&Object.keys(a.userIdentities).length&&(I=r.IdentityRequest.combineUserIdentities(S,a.userIdentities)),t._Persistence.saveUserIdentitiesToPersistence(c.mpid,I),t._Persistence.update(),t._Persistence.findPrevCookiesBasedOnUI(a),t._Store.context=c.context||t._Store.context;}if(l=t.Identity.getCurrentUser(),a&&a.onUserAlias&&t._Helpers.Validators.isFunction(a.onUserAlias))try{t.Logger.warning("Deprecated function onUserAlias will be removed in future releases"),a.onUserAlias(_,l);}catch(r){t.Logger.error("There was an error with your onUserAlias function - "+r);}var b=t._Persistence.getPersistence();l&&(t._Persistence.storeDataInMemory(b,l.getMPID()),(!_||l.getMPID()!==_.getMPID()||_.isLoggedIn()!==l.isLoggedIn())&&t._Forwarders.initForwarders(l.getUserIdentities().userIdentities,t._APIClient.prepareForwardingStats),t._Forwarders.setForwarderUserIdentities(l.getUserIdentities().userIdentities),t._Forwarders.setForwarderOnIdentityComplete(l,o),t._Forwarders.setForwarderOnUserIdentified(l));var A={};for(var k in I)A[Types.IdentityType.getIdentityName(t._Helpers.parseNumber(k))]=I[k];r.sendUserIdentityChangeEvent(A,o,c.mpid,o===Modify$1?v:P);}n?0===s.status?t._Helpers.invokeCallback(n,HTTPCodes$2.noHttpCoverage,c||null,l):t._Helpers.invokeCallback(n,s.status,c||null,l):c&&c.errors&&c.errors.length&&t.Logger.error("Received HTTP response code of "+s.status+" - "+c.errors[0].message),t._APIClient.processQueuedEvents();}catch(r){n&&t._Helpers.invokeCallback(n,s.status,c||null),t.Logger.error("Error parsing JSON response from Identity server: "+r);}},this.sendUserIdentityChangeEvent=function(e,s,i,n){var a,o;if(i||s===Modify$1)for(var d in a=this.IdentityAPI.getUser(i),e)if(n[d]!==e[d]){var g=!n[d];o=r.createUserIdentityChange(d,e[d],n[d],g,a),t._APIClient.sendEventToServer(o);}},this.createUserIdentityChange=function(e,r,s,i,n){var a
|
|
887
|
+
*/getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(s,i,n,a,o,d,g){var l,u,c,p,_=t.Identity.getUser(i),I={},y=_?_.getUserIdentities().userIdentities:{},v=t._Helpers.extend({},y);t._Store.identityCallInFlight=!1;try{if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),s.responseText&&(c=JSON.parse(s.responseText),c.hasOwnProperty("is_logged_in")&&(t._Store.isLoggedIn=c.is_logged_in)),(!_||_.getMPID()&&c.mpid&&c.mpid!==_.getMPID())&&(t._Store.mpid=c.mpid,_&&t._Persistence.setLastSeenTime(i),!t._Persistence.getFirstSeenTime(c.mpid)&&(u=!0),t._Persistence.setFirstSeenTime(c.mpid)),200===s.status){if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)&&cacheOrClearIdCache(o,d,r.idCache,s,g),o===Modify$1)I=t._Identity.IdentityRequest.combineUserIdentities(y,a.userIdentities),t._Persistence.saveUserIdentitiesToPersistence(i,I);else {var m=r.IdentityAPI.getUser(c.mpid),S=m?m.getUserIdentities().userIdentities:{},P=t._Helpers.extend({},S);t.Logger.verbose("Successfully parsed Identity Response"),o===Identify&&_&&c.mpid===_.getMPID()&&t._Persistence.setFirstSeenTime(c.mpid),p=t._Store.currentSessionMPIDs.indexOf(c.mpid),t._Store.sessionId&&c.mpid&&i!==c.mpid&&0>p&&t._Store.currentSessionMPIDs.push(c.mpid),-1<p&&(t._Store.currentSessionMPIDs=t._Store.currentSessionMPIDs.slice(0,p).concat(t._Store.currentSessionMPIDs.slice(p+1,t._Store.currentSessionMPIDs.length)),t._Store.currentSessionMPIDs.push(c.mpid)),t._CookieSyncManager.attemptCookieSync(i,c.mpid,u),r.checkIdentitySwap(i,c.mpid,t._Store.currentSessionMPIDs),a&&a.userIdentities&&Object.keys(a.userIdentities).length&&(I=r.IdentityRequest.combineUserIdentities(S,a.userIdentities)),t._Persistence.saveUserIdentitiesToPersistence(c.mpid,I),t._Persistence.update(),t._Persistence.findPrevCookiesBasedOnUI(a),t._Store.context=c.context||t._Store.context;}if(l=t.Identity.getCurrentUser(),a&&a.onUserAlias&&t._Helpers.Validators.isFunction(a.onUserAlias))try{t.Logger.warning("Deprecated function onUserAlias will be removed in future releases"),a.onUserAlias(_,l);}catch(r){t.Logger.error("There was an error with your onUserAlias function - "+r);}var b=t._Persistence.getPersistence();l&&(t._Persistence.storeDataInMemory(b,l.getMPID()),(!_||l.getMPID()!==_.getMPID()||_.isLoggedIn()!==l.isLoggedIn())&&t._Forwarders.initForwarders(l.getUserIdentities().userIdentities,t._APIClient.prepareForwardingStats),t._Forwarders.setForwarderUserIdentities(l.getUserIdentities().userIdentities),t._Forwarders.setForwarderOnIdentityComplete(l,o),t._Forwarders.setForwarderOnUserIdentified(l));var A={};for(var k in I)A[Types.IdentityType.getIdentityName(t._Helpers.parseNumber(k))]=I[k];r.sendUserIdentityChangeEvent(A,o,c.mpid,o===Modify$1?v:P);}n?0===s.status?t._Helpers.invokeCallback(n,HTTPCodes$2.noHttpCoverage,c||null,l):t._Helpers.invokeCallback(n,s.status,c||null,l):c&&c.errors&&c.errors.length&&t.Logger.error("Received HTTP response code of "+s.status+" - "+c.errors[0].message),t._APIClient.processQueuedEvents();}catch(r){n&&t._Helpers.invokeCallback(n,s.status,c||null),t.Logger.error("Error parsing JSON response from Identity server: "+r);}},this.sendUserIdentityChangeEvent=function(e,s,i,n){var a,o;if(i||s===Modify$1)for(var d in a=this.IdentityAPI.getUser(i),e)if(n[d]!==e[d]){var g=!n[d];o=r.createUserIdentityChange(d,e[d],n[d],g,a),t._APIClient.sendEventToServer(o);}},this.createUserIdentityChange=function(e,r,s,i,n){var a;// https://go.mparticle.com/work/SQDSDKS-6439
|
|
888
|
+
return a=t._ServerModel.createEventObject({messageType:Types.MessageType.UserIdentityChange,userIdentityChanges:{New:{IdentityType:e,Identity:r,CreatedThisBatch:i},Old:{IdentityType:e,Identity:s,CreatedThisBatch:!1}},userInMemory:n}),a},this.sendUserAttributeChangeEvent=function(e,s,i,n,a,o){var d=r.createUserAttributeChange(e,s,i,n,a,o);d&&t._APIClient.sendEventToServer(d);},this.createUserAttributeChange=function(e,r,s,i,n,a){"undefined"==typeof s&&(s=null);var o;return r!==s&&(o=t._ServerModel.createEventObject({messageType:Types.MessageType.UserAttributeChange,userAttributeChanges:{UserAttributeName:e,New:r,Old:s,Deleted:n,IsNewAttribute:i}},a)),o};}
|
|
885
889
|
|
|
886
890
|
var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){var b=this;// this function is called when consent is required to
|
|
887
891
|
// determine if a cookie sync should happen, or a
|
package/dist/mparticle.esm.js
CHANGED
|
@@ -61,7 +61,7 @@ var _TriggerUploadType,MessageType$2={SessionStart:1,SessionEnd:2,PageView:3,Pag
|
|
|
61
61
|
// Continuation of enum above, but in seperate object since we don't expose these to end user
|
|
62
62
|
IdentityType$1.isValid=function(a){if("number"==typeof a)for(var b in IdentityType$1)if(IdentityType$1.hasOwnProperty(b)&&IdentityType$1[b]===a)return !0;return !1},IdentityType$1.getName=function(a){return a===window.mParticle.IdentityType.CustomerId?"Customer ID":a===window.mParticle.IdentityType.Facebook?"Facebook ID":a===window.mParticle.IdentityType.Twitter?"Twitter ID":a===window.mParticle.IdentityType.Google?"Google ID":a===window.mParticle.IdentityType.Microsoft?"Microsoft ID":a===window.mParticle.IdentityType.Yahoo?"Yahoo ID":a===window.mParticle.IdentityType.Email?"Email":a===window.mParticle.IdentityType.FacebookCustomAudienceId?"Facebook App User ID":"Other ID"},IdentityType$1.getIdentityType=function(a){return "other"===a?IdentityType$1.Other:"customerid"===a?IdentityType$1.CustomerId:"facebook"===a?IdentityType$1.Facebook:"twitter"===a?IdentityType$1.Twitter:"google"===a?IdentityType$1.Google:"microsoft"===a?IdentityType$1.Microsoft:"yahoo"===a?IdentityType$1.Yahoo:"email"===a?IdentityType$1.Email:"facebookcustomaudienceid"===a?IdentityType$1.FacebookCustomAudienceId:"other2"===a?IdentityType$1.Other2:"other3"===a?IdentityType$1.Other3:"other4"===a?IdentityType$1.Other4:"other5"===a?IdentityType$1.Other5:"other6"===a?IdentityType$1.Other6:"other7"===a?IdentityType$1.Other7:"other8"===a?IdentityType$1.Other8:"other9"===a?IdentityType$1.Other9:"other10"===a?IdentityType$1.Other10:"mobile_number"===a?IdentityType$1.MobileNumber:"phone_number_2"===a?IdentityType$1.PhoneNumber2:!("phone_number_3"!=a)&&IdentityType$1.PhoneNumber3},IdentityType$1.getIdentityName=function(a){return a===IdentityType$1.Other?"other":a===IdentityType$1.CustomerId?"customerid":a===IdentityType$1.Facebook?"facebook":a===IdentityType$1.Twitter?"twitter":a===IdentityType$1.Google?"google":a===IdentityType$1.Microsoft?"microsoft":a===IdentityType$1.Yahoo?"yahoo":a===IdentityType$1.Email?"email":a===IdentityType$1.FacebookCustomAudienceId?"facebookcustomaudienceid":a===IdentityType$1.Other2?"other2":a===IdentityType$1.Other3?"other3":a===IdentityType$1.Other4?"other4":a===IdentityType$1.Other5?"other5":a===IdentityType$1.Other6?"other6":a===IdentityType$1.Other7?"other7":a===IdentityType$1.Other8?"other8":a===IdentityType$1.Other9?"other9":a===IdentityType$1.Other10?"other10":a===IdentityType$1.MobileNumber?"mobile_number":a===IdentityType$1.PhoneNumber2?"phone_number_2":a===IdentityType$1.PhoneNumber3?"phone_number_3":void 0};var ProductActionType={Unknown:0,AddToCart:1,RemoveFromCart:2,Checkout:3,CheckoutOption:4,Click:5,ViewDetail:6,Purchase:7,Refund:8,AddToWishlist:9,RemoveFromWishlist:10};ProductActionType.getName=function(a){return a===ProductActionType.AddToCart?"Add to Cart":a===ProductActionType.RemoveFromCart?"Remove from Cart":a===ProductActionType.Checkout?"Checkout":a===ProductActionType.CheckoutOption?"Checkout Option":a===ProductActionType.Click?"Click":a===ProductActionType.ViewDetail?"View Detail":a===ProductActionType.Purchase?"Purchase":a===ProductActionType.Refund?"Refund":a===ProductActionType.AddToWishlist?"Add to Wishlist":a===ProductActionType.RemoveFromWishlist?"Remove from Wishlist":"Unknown"},ProductActionType.getExpansionName=function(a){return a===ProductActionType.AddToCart?"add_to_cart":a===ProductActionType.RemoveFromCart?"remove_from_cart":a===ProductActionType.Checkout?"checkout":a===ProductActionType.CheckoutOption?"checkout_option":a===ProductActionType.Click?"click":a===ProductActionType.ViewDetail?"view_detail":a===ProductActionType.Purchase?"purchase":a===ProductActionType.Refund?"refund":a===ProductActionType.AddToWishlist?"add_to_wishlist":a===ProductActionType.RemoveFromWishlist?"remove_from_wishlist":"unknown"};var PromotionActionType={Unknown:0,PromotionView:1,PromotionClick:2};PromotionActionType.getName=function(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"},PromotionActionType.getExpansionName=function(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"};var ProfileMessageType={Logout:3},ApplicationTransitionType$1={AppInit:1},Environment={Production:"production",Development:"development"};var Types = {MessageType:MessageType$2,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType$1,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,TriggerUploadType:TriggerUploadType,Environment:Environment};
|
|
63
63
|
|
|
64
|
-
var version = "2.26.
|
|
64
|
+
var version = "2.26.5";
|
|
65
65
|
|
|
66
66
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"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",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",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",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,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
|
|
67
67
|
},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/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
|
|
@@ -162,7 +162,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
162
162
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
-
var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={}));
|
|
165
|
+
var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={}));
|
|
166
166
|
|
|
167
167
|
var dist = {};
|
|
168
168
|
|
|
@@ -408,6 +408,8 @@ return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"
|
|
|
408
408
|
* Returns a value between 1-100 inclusive.
|
|
409
409
|
*/ // FIXME: REFACTOR for V3
|
|
410
410
|
|
|
411
|
+
var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a.facebook="facebook",a.twitter="twitter",a.google="google",a.microsoft="microsoft",a.yahoo="yahoo",a.email="email",a.alias="alias",a.facebookCustomAudienceId="facebookcustomaudienceid",a.otherId2="other2",a.otherId3="other3",a.otherId4="other4",a.otherId5="other5",a.otherId6="other6",a.otherId7="other7",a.otherId8="other8",a.otherId9="other9",a.otherId10="other10",a.mobileNumber="mobile_number",a.phoneNumber2="phone_number_2",a.phoneNumber3="phone_number_3";})(SDKIdentityTypeEnum||(SDKIdentityTypeEnum={}));
|
|
412
|
+
|
|
411
413
|
function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c.Identity.getCurrentUser(),f=[],g=null,h=0,i=b;h<i.length;h++)if(d=i[h],d){g=d;var j=convertEvent(d);j&&f.push(j);}if(!g)return null;var k=null;// Add the consent state from either the Last Event or the user
|
|
412
414
|
isEmpty(g.ConsentState)?!isEmpty(e)&&(k=e.getConsentState()):k=g.ConsentState;var l={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:g.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:f,mp_deviceid:g.DeviceId,sdk_version:g.SDKVersion,// TODO: Refactor this to read from _Store or a global config
|
|
413
415
|
application_info:{application_version:g.AppVersion,application_name:g.AppName,package:g.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:window.screen.width,screen_height:window.screen.height},user_attributes:g.UserAttributes,user_identities:convertUserIdentities(g.UserIdentities),consent_state:convertConsentState(k),integration_attributes:g.IntegrationAttributes};return g.DataPlan&&g.DataPlan.PlanId&&(l.context={data_plan:{plan_id:g.DataPlan.PlanId,plan_version:g.DataPlan.PlanVersion||void 0}}),l}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents
|
|
@@ -859,7 +861,8 @@ if(c?(g=!1,d=o[c],delete o[c]):g=!0,o[r]=u,a&&a[e]&&(a[e].ua=o,t._Persistence.sa
|
|
|
859
861
|
* Get user audiences
|
|
860
862
|
* @method getuserAudiences
|
|
861
863
|
* @param {Function} [callback] A callback function that is invoked when the user audience request completes
|
|
862
|
-
*/
|
|
864
|
+
*/ // https://go.mparticle.com/work/SQDSDKS-6436
|
|
865
|
+
getUserAudiences:function getUserAudiences(r){// user audience API is feature flagged
|
|
863
866
|
return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audienceManager&&(s.audienceManager=new AudienceManager(t._Store.SDKConfig.userAudienceUrl,t._Store.devToken,t.Logger,e)),s.audienceManager.sendGetUserAudienceRequest(e,r)):void t.Logger.error(ErrorMessages.AudienceAPINotEnabled)}}},this.mParticleUserCart=function(e){return {/**
|
|
864
867
|
* Adds a cart product to the user cart
|
|
865
868
|
* @method add
|
|
@@ -881,7 +884,8 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
|
|
|
881
884
|
* @method getCartProducts
|
|
882
885
|
* @return {Array} array of cart products
|
|
883
886
|
* @deprecated
|
|
884
|
-
*/getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(s,i,n,a,o,d,g){var l,u,c,p,_=t.Identity.getUser(i),I={},y=_?_.getUserIdentities().userIdentities:{},v=t._Helpers.extend({},y);t._Store.identityCallInFlight=!1;try{if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),s.responseText&&(c=JSON.parse(s.responseText),c.hasOwnProperty("is_logged_in")&&(t._Store.isLoggedIn=c.is_logged_in)),(!_||_.getMPID()&&c.mpid&&c.mpid!==_.getMPID())&&(t._Store.mpid=c.mpid,_&&t._Persistence.setLastSeenTime(i),!t._Persistence.getFirstSeenTime(c.mpid)&&(u=!0),t._Persistence.setFirstSeenTime(c.mpid)),200===s.status){if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)&&cacheOrClearIdCache(o,d,r.idCache,s,g),o===Modify$1)I=t._Identity.IdentityRequest.combineUserIdentities(y,a.userIdentities),t._Persistence.saveUserIdentitiesToPersistence(i,I);else {var m=r.IdentityAPI.getUser(c.mpid),S=m?m.getUserIdentities().userIdentities:{},P=t._Helpers.extend({},S);t.Logger.verbose("Successfully parsed Identity Response"),o===Identify&&_&&c.mpid===_.getMPID()&&t._Persistence.setFirstSeenTime(c.mpid),p=t._Store.currentSessionMPIDs.indexOf(c.mpid),t._Store.sessionId&&c.mpid&&i!==c.mpid&&0>p&&t._Store.currentSessionMPIDs.push(c.mpid),-1<p&&(t._Store.currentSessionMPIDs=t._Store.currentSessionMPIDs.slice(0,p).concat(t._Store.currentSessionMPIDs.slice(p+1,t._Store.currentSessionMPIDs.length)),t._Store.currentSessionMPIDs.push(c.mpid)),t._CookieSyncManager.attemptCookieSync(i,c.mpid,u),r.checkIdentitySwap(i,c.mpid,t._Store.currentSessionMPIDs),a&&a.userIdentities&&Object.keys(a.userIdentities).length&&(I=r.IdentityRequest.combineUserIdentities(S,a.userIdentities)),t._Persistence.saveUserIdentitiesToPersistence(c.mpid,I),t._Persistence.update(),t._Persistence.findPrevCookiesBasedOnUI(a),t._Store.context=c.context||t._Store.context;}if(l=t.Identity.getCurrentUser(),a&&a.onUserAlias&&t._Helpers.Validators.isFunction(a.onUserAlias))try{t.Logger.warning("Deprecated function onUserAlias will be removed in future releases"),a.onUserAlias(_,l);}catch(r){t.Logger.error("There was an error with your onUserAlias function - "+r);}var b=t._Persistence.getPersistence();l&&(t._Persistence.storeDataInMemory(b,l.getMPID()),(!_||l.getMPID()!==_.getMPID()||_.isLoggedIn()!==l.isLoggedIn())&&t._Forwarders.initForwarders(l.getUserIdentities().userIdentities,t._APIClient.prepareForwardingStats),t._Forwarders.setForwarderUserIdentities(l.getUserIdentities().userIdentities),t._Forwarders.setForwarderOnIdentityComplete(l,o),t._Forwarders.setForwarderOnUserIdentified(l));var A={};for(var k in I)A[Types.IdentityType.getIdentityName(t._Helpers.parseNumber(k))]=I[k];r.sendUserIdentityChangeEvent(A,o,c.mpid,o===Modify$1?v:P);}n?0===s.status?t._Helpers.invokeCallback(n,HTTPCodes$2.noHttpCoverage,c||null,l):t._Helpers.invokeCallback(n,s.status,c||null,l):c&&c.errors&&c.errors.length&&t.Logger.error("Received HTTP response code of "+s.status+" - "+c.errors[0].message),t._APIClient.processQueuedEvents();}catch(r){n&&t._Helpers.invokeCallback(n,s.status,c||null),t.Logger.error("Error parsing JSON response from Identity server: "+r);}},this.sendUserIdentityChangeEvent=function(e,s,i,n){var a,o;if(i||s===Modify$1)for(var d in a=this.IdentityAPI.getUser(i),e)if(n[d]!==e[d]){var g=!n[d];o=r.createUserIdentityChange(d,e[d],n[d],g,a),t._APIClient.sendEventToServer(o);}},this.createUserIdentityChange=function(e,r,s,i,n){var a
|
|
887
|
+
*/getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(s,i,n,a,o,d,g){var l,u,c,p,_=t.Identity.getUser(i),I={},y=_?_.getUserIdentities().userIdentities:{},v=t._Helpers.extend({},y);t._Store.identityCallInFlight=!1;try{if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),s.responseText&&(c=JSON.parse(s.responseText),c.hasOwnProperty("is_logged_in")&&(t._Store.isLoggedIn=c.is_logged_in)),(!_||_.getMPID()&&c.mpid&&c.mpid!==_.getMPID())&&(t._Store.mpid=c.mpid,_&&t._Persistence.setLastSeenTime(i),!t._Persistence.getFirstSeenTime(c.mpid)&&(u=!0),t._Persistence.setFirstSeenTime(c.mpid)),200===s.status){if(t._Helpers.getFeatureFlag(Constants.FeatureFlags.CacheIdentity)&&cacheOrClearIdCache(o,d,r.idCache,s,g),o===Modify$1)I=t._Identity.IdentityRequest.combineUserIdentities(y,a.userIdentities),t._Persistence.saveUserIdentitiesToPersistence(i,I);else {var m=r.IdentityAPI.getUser(c.mpid),S=m?m.getUserIdentities().userIdentities:{},P=t._Helpers.extend({},S);t.Logger.verbose("Successfully parsed Identity Response"),o===Identify&&_&&c.mpid===_.getMPID()&&t._Persistence.setFirstSeenTime(c.mpid),p=t._Store.currentSessionMPIDs.indexOf(c.mpid),t._Store.sessionId&&c.mpid&&i!==c.mpid&&0>p&&t._Store.currentSessionMPIDs.push(c.mpid),-1<p&&(t._Store.currentSessionMPIDs=t._Store.currentSessionMPIDs.slice(0,p).concat(t._Store.currentSessionMPIDs.slice(p+1,t._Store.currentSessionMPIDs.length)),t._Store.currentSessionMPIDs.push(c.mpid)),t._CookieSyncManager.attemptCookieSync(i,c.mpid,u),r.checkIdentitySwap(i,c.mpid,t._Store.currentSessionMPIDs),a&&a.userIdentities&&Object.keys(a.userIdentities).length&&(I=r.IdentityRequest.combineUserIdentities(S,a.userIdentities)),t._Persistence.saveUserIdentitiesToPersistence(c.mpid,I),t._Persistence.update(),t._Persistence.findPrevCookiesBasedOnUI(a),t._Store.context=c.context||t._Store.context;}if(l=t.Identity.getCurrentUser(),a&&a.onUserAlias&&t._Helpers.Validators.isFunction(a.onUserAlias))try{t.Logger.warning("Deprecated function onUserAlias will be removed in future releases"),a.onUserAlias(_,l);}catch(r){t.Logger.error("There was an error with your onUserAlias function - "+r);}var b=t._Persistence.getPersistence();l&&(t._Persistence.storeDataInMemory(b,l.getMPID()),(!_||l.getMPID()!==_.getMPID()||_.isLoggedIn()!==l.isLoggedIn())&&t._Forwarders.initForwarders(l.getUserIdentities().userIdentities,t._APIClient.prepareForwardingStats),t._Forwarders.setForwarderUserIdentities(l.getUserIdentities().userIdentities),t._Forwarders.setForwarderOnIdentityComplete(l,o),t._Forwarders.setForwarderOnUserIdentified(l));var A={};for(var k in I)A[Types.IdentityType.getIdentityName(t._Helpers.parseNumber(k))]=I[k];r.sendUserIdentityChangeEvent(A,o,c.mpid,o===Modify$1?v:P);}n?0===s.status?t._Helpers.invokeCallback(n,HTTPCodes$2.noHttpCoverage,c||null,l):t._Helpers.invokeCallback(n,s.status,c||null,l):c&&c.errors&&c.errors.length&&t.Logger.error("Received HTTP response code of "+s.status+" - "+c.errors[0].message),t._APIClient.processQueuedEvents();}catch(r){n&&t._Helpers.invokeCallback(n,s.status,c||null),t.Logger.error("Error parsing JSON response from Identity server: "+r);}},this.sendUserIdentityChangeEvent=function(e,s,i,n){var a,o;if(i||s===Modify$1)for(var d in a=this.IdentityAPI.getUser(i),e)if(n[d]!==e[d]){var g=!n[d];o=r.createUserIdentityChange(d,e[d],n[d],g,a),t._APIClient.sendEventToServer(o);}},this.createUserIdentityChange=function(e,r,s,i,n){var a;// https://go.mparticle.com/work/SQDSDKS-6439
|
|
888
|
+
return a=t._ServerModel.createEventObject({messageType:Types.MessageType.UserIdentityChange,userIdentityChanges:{New:{IdentityType:e,Identity:r,CreatedThisBatch:i},Old:{IdentityType:e,Identity:s,CreatedThisBatch:!1}},userInMemory:n}),a},this.sendUserAttributeChangeEvent=function(e,s,i,n,a,o){var d=r.createUserAttributeChange(e,s,i,n,a,o);d&&t._APIClient.sendEventToServer(d);},this.createUserAttributeChange=function(e,r,s,i,n,a){"undefined"==typeof s&&(s=null);var o;return r!==s&&(o=t._ServerModel.createEventObject({messageType:Types.MessageType.UserAttributeChange,userAttributeChanges:{UserAttributeName:e,New:r,Old:s,Deleted:n,IsNewAttribute:i}},a)),o};}
|
|
885
889
|
|
|
886
890
|
var CCPAPurpose=Constants.CCPAPurpose;function Consent(a){var b=this;// this function is called when consent is required to
|
|
887
891
|
// determine if a cookie sync should happen, or a
|
package/dist/mparticle.js
CHANGED
|
@@ -608,7 +608,7 @@ var mParticle = (function () {
|
|
|
608
608
|
Environment: Environment
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
-
var version = "2.26.
|
|
611
|
+
var version = "2.26.5";
|
|
612
612
|
|
|
613
613
|
var Constants = {
|
|
614
614
|
sdkVersion: version,
|
|
@@ -891,31 +891,6 @@ var mParticle = (function () {
|
|
|
891
891
|
SDKProductActionType[SDKProductActionType["AddToWishlist"] = 9] = "AddToWishlist";
|
|
892
892
|
SDKProductActionType[SDKProductActionType["RemoveFromWishlist"] = 10] = "RemoveFromWishlist";
|
|
893
893
|
})(SDKProductActionType || (SDKProductActionType = {}));
|
|
894
|
-
var SDKIdentityTypeEnum;
|
|
895
|
-
(function (SDKIdentityTypeEnum) {
|
|
896
|
-
SDKIdentityTypeEnum["other"] = "other";
|
|
897
|
-
SDKIdentityTypeEnum["customerId"] = "customerid";
|
|
898
|
-
SDKIdentityTypeEnum["facebook"] = "facebook";
|
|
899
|
-
SDKIdentityTypeEnum["twitter"] = "twitter";
|
|
900
|
-
SDKIdentityTypeEnum["google"] = "google";
|
|
901
|
-
SDKIdentityTypeEnum["microsoft"] = "microsoft";
|
|
902
|
-
SDKIdentityTypeEnum["yahoo"] = "yahoo";
|
|
903
|
-
SDKIdentityTypeEnum["email"] = "email";
|
|
904
|
-
SDKIdentityTypeEnum["alias"] = "alias";
|
|
905
|
-
SDKIdentityTypeEnum["facebookCustomAudienceId"] = "facebookcustomaudienceid";
|
|
906
|
-
SDKIdentityTypeEnum["otherId2"] = "other2";
|
|
907
|
-
SDKIdentityTypeEnum["otherId3"] = "other3";
|
|
908
|
-
SDKIdentityTypeEnum["otherId4"] = "other4";
|
|
909
|
-
SDKIdentityTypeEnum["otherId5"] = "other5";
|
|
910
|
-
SDKIdentityTypeEnum["otherId6"] = "other6";
|
|
911
|
-
SDKIdentityTypeEnum["otherId7"] = "other7";
|
|
912
|
-
SDKIdentityTypeEnum["otherId8"] = "other8";
|
|
913
|
-
SDKIdentityTypeEnum["otherId9"] = "other9";
|
|
914
|
-
SDKIdentityTypeEnum["otherId10"] = "other10";
|
|
915
|
-
SDKIdentityTypeEnum["mobileNumber"] = "mobile_number";
|
|
916
|
-
SDKIdentityTypeEnum["phoneNumber2"] = "phone_number_2";
|
|
917
|
-
SDKIdentityTypeEnum["phoneNumber3"] = "phone_number_3";
|
|
918
|
-
})(SDKIdentityTypeEnum || (SDKIdentityTypeEnum = {}));
|
|
919
894
|
|
|
920
895
|
var dist = {};
|
|
921
896
|
|
|
@@ -1330,6 +1305,32 @@ var mParticle = (function () {
|
|
|
1330
1305
|
return value == null || !(Object.keys(value) || value).length;
|
|
1331
1306
|
};
|
|
1332
1307
|
|
|
1308
|
+
var SDKIdentityTypeEnum;
|
|
1309
|
+
(function (SDKIdentityTypeEnum) {
|
|
1310
|
+
SDKIdentityTypeEnum["other"] = "other";
|
|
1311
|
+
SDKIdentityTypeEnum["customerId"] = "customerid";
|
|
1312
|
+
SDKIdentityTypeEnum["facebook"] = "facebook";
|
|
1313
|
+
SDKIdentityTypeEnum["twitter"] = "twitter";
|
|
1314
|
+
SDKIdentityTypeEnum["google"] = "google";
|
|
1315
|
+
SDKIdentityTypeEnum["microsoft"] = "microsoft";
|
|
1316
|
+
SDKIdentityTypeEnum["yahoo"] = "yahoo";
|
|
1317
|
+
SDKIdentityTypeEnum["email"] = "email";
|
|
1318
|
+
SDKIdentityTypeEnum["alias"] = "alias";
|
|
1319
|
+
SDKIdentityTypeEnum["facebookCustomAudienceId"] = "facebookcustomaudienceid";
|
|
1320
|
+
SDKIdentityTypeEnum["otherId2"] = "other2";
|
|
1321
|
+
SDKIdentityTypeEnum["otherId3"] = "other3";
|
|
1322
|
+
SDKIdentityTypeEnum["otherId4"] = "other4";
|
|
1323
|
+
SDKIdentityTypeEnum["otherId5"] = "other5";
|
|
1324
|
+
SDKIdentityTypeEnum["otherId6"] = "other6";
|
|
1325
|
+
SDKIdentityTypeEnum["otherId7"] = "other7";
|
|
1326
|
+
SDKIdentityTypeEnum["otherId8"] = "other8";
|
|
1327
|
+
SDKIdentityTypeEnum["otherId9"] = "other9";
|
|
1328
|
+
SDKIdentityTypeEnum["otherId10"] = "other10";
|
|
1329
|
+
SDKIdentityTypeEnum["mobileNumber"] = "mobile_number";
|
|
1330
|
+
SDKIdentityTypeEnum["phoneNumber2"] = "phone_number_2";
|
|
1331
|
+
SDKIdentityTypeEnum["phoneNumber3"] = "phone_number_3";
|
|
1332
|
+
})(SDKIdentityTypeEnum || (SDKIdentityTypeEnum = {}));
|
|
1333
|
+
|
|
1333
1334
|
function convertEvents(mpid, sdkEvents, mpInstance) {
|
|
1334
1335
|
if (!mpid) {
|
|
1335
1336
|
return null;
|
|
@@ -7223,6 +7224,7 @@ var mParticle = (function () {
|
|
|
7223
7224
|
* @method getuserAudiences
|
|
7224
7225
|
* @param {Function} [callback] A callback function that is invoked when the user audience request completes
|
|
7225
7226
|
*/
|
|
7227
|
+
// https://go.mparticle.com/work/SQDSDKS-6436
|
|
7226
7228
|
getUserAudiences: function getUserAudiences(callback) {
|
|
7227
7229
|
// user audience API is feature flagged
|
|
7228
7230
|
if (!mpInstance._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)) {
|
|
@@ -7490,6 +7492,8 @@ var mParticle = (function () {
|
|
|
7490
7492
|
};
|
|
7491
7493
|
this.createUserIdentityChange = function (identityType, newIdentity, oldIdentity, newCreatedThisBatch, userInMemory) {
|
|
7492
7494
|
var userIdentityChangeEvent;
|
|
7495
|
+
|
|
7496
|
+
// https://go.mparticle.com/work/SQDSDKS-6439
|
|
7493
7497
|
userIdentityChangeEvent = mpInstance._ServerModel.createEventObject({
|
|
7494
7498
|
messageType: Types.MessageType.UserIdentityChange,
|
|
7495
7499
|
userIdentityChanges: {
|
|
@@ -7520,6 +7524,7 @@ var mParticle = (function () {
|
|
|
7520
7524
|
}
|
|
7521
7525
|
var userAttributeChangeEvent;
|
|
7522
7526
|
if (newValue !== previousUserAttributeValue) {
|
|
7527
|
+
// https://go.mparticle.com/work/SQDSDKS-6439
|
|
7523
7528
|
userAttributeChangeEvent = mpInstance._ServerModel.createEventObject({
|
|
7524
7529
|
messageType: Types.MessageType.UserAttributeChange,
|
|
7525
7530
|
userAttributeChanges: {
|
package/package.json
CHANGED
package/src/apiClient.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import Constants from './constants';
|
|
2
2
|
import Types from './types';
|
|
3
3
|
import { BatchUploader } from './batchUploader';
|
|
4
|
-
import {
|
|
4
|
+
import { MParticleWebSDK, SDKEvent } from './sdkRuntimeModels';
|
|
5
5
|
import KitBlocker from './kitBlocking';
|
|
6
6
|
import { Dictionary, getRampNumber, isEmpty, parseNumber } from './utils';
|
|
7
7
|
import { IUploadObject } from './serverModel';
|
|
8
8
|
import { MPForwarder } from './forwarders.interfaces';
|
|
9
|
+
import { IMParticleUser } from './identity-user-interfaces';
|
|
9
10
|
|
|
10
11
|
export type ForwardingStatsData = Dictionary<any>;
|
|
11
12
|
|
|
@@ -13,7 +14,7 @@ export interface IAPIClient {
|
|
|
13
14
|
uploader: BatchUploader | null;
|
|
14
15
|
queueEventForBatchUpload: (event: SDKEvent) => void;
|
|
15
16
|
processQueuedEvents: () => void;
|
|
16
|
-
appendUserInfoToEvents: (user:
|
|
17
|
+
appendUserInfoToEvents: (user: IMParticleUser, events: SDKEvent[]) => void;
|
|
17
18
|
sendEventToServer: (event: SDKEvent, _options?: Dictionary<any>) => void;
|
|
18
19
|
sendSingleEventToServer: (event: SDKEvent) => void;
|
|
19
20
|
sendBatchForwardingStatsToServer: (
|
package/src/batchUploader.ts
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
import { Batch } from '@mparticle/event-models';
|
|
2
2
|
import Constants from './constants';
|
|
3
|
-
import {
|
|
4
|
-
SDKEvent,
|
|
5
|
-
MParticleUser,
|
|
6
|
-
MParticleWebSDK,
|
|
7
|
-
SDKLoggerApi,
|
|
8
|
-
} from './sdkRuntimeModels';
|
|
3
|
+
import { SDKEvent, MParticleWebSDK, SDKLoggerApi } from './sdkRuntimeModels';
|
|
9
4
|
import { convertEvents } from './sdkToEventsApiConverter';
|
|
10
5
|
import Types from './types';
|
|
11
6
|
import { getRampNumber, isEmpty } from './utils';
|
|
12
7
|
import { SessionStorageVault, LocalStorageVault } from './vault';
|
|
13
|
-
import {
|
|
8
|
+
import {
|
|
14
9
|
AsyncUploader,
|
|
15
10
|
FetchUploader,
|
|
16
11
|
XHRUploader,
|
|
17
|
-
fetchPayload
|
|
12
|
+
fetchPayload,
|
|
18
13
|
} from './uploaders';
|
|
14
|
+
import { IMParticleUser } from './identity-user-interfaces';
|
|
19
15
|
|
|
20
16
|
/**
|
|
21
17
|
* BatchUploader contains all the logic to store/retrieve events and batches
|
|
@@ -205,7 +201,7 @@ export class BatchUploader {
|
|
|
205
201
|
*/
|
|
206
202
|
private static createNewBatches(
|
|
207
203
|
sdkEvents: SDKEvent[],
|
|
208
|
-
defaultUser:
|
|
204
|
+
defaultUser: IMParticleUser,
|
|
209
205
|
mpInstance: MParticleWebSDK
|
|
210
206
|
): Batch[] | null {
|
|
211
207
|
if (!defaultUser || !sdkEvents || !sdkEvents.length) {
|
package/src/consent.ts
CHANGED
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
GDPRConsentState,
|
|
5
5
|
PrivacyConsentState,
|
|
6
6
|
} from '@mparticle/web-sdk';
|
|
7
|
-
import {
|
|
7
|
+
import { MParticleWebSDK } from './sdkRuntimeModels';
|
|
8
8
|
import { Dictionary, isObject } from './utils';
|
|
9
9
|
import KitFilterHelper from './kitFilterHelper';
|
|
10
10
|
import Constants from './constants';
|
|
11
|
+
import { IMParticleUser } from './identity-user-interfaces';
|
|
11
12
|
|
|
12
13
|
const { CCPAPurpose } = Constants;
|
|
13
14
|
|
|
@@ -108,7 +109,7 @@ export interface IConsentState extends ConsentState {
|
|
|
108
109
|
export interface IConsent {
|
|
109
110
|
isEnabledForUserConsent: (
|
|
110
111
|
consentRules: IConsentRules,
|
|
111
|
-
user:
|
|
112
|
+
user: IMParticleUser
|
|
112
113
|
) => boolean;
|
|
113
114
|
createPrivacyConsent: ICreatePrivacyConsentFunction;
|
|
114
115
|
createConsentState: (consentState?: ConsentState) => ConsentState;
|
|
@@ -123,7 +124,7 @@ export default function Consent(this: IConsent, mpInstance: MParticleWebSDK) {
|
|
|
123
124
|
// forwarder should be initialized
|
|
124
125
|
this.isEnabledForUserConsent = function(
|
|
125
126
|
consentRules: IConsentRules,
|
|
126
|
-
user:
|
|
127
|
+
user: IMParticleUser
|
|
127
128
|
): boolean {
|
|
128
129
|
if (
|
|
129
130
|
!consentRules ||
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
MParticleUser,
|
|
3
|
-
SDKEvent,
|
|
4
|
-
SDKEventCustomFlags,
|
|
5
|
-
SDKUserIdentity,
|
|
6
|
-
} from './sdkRuntimeModels';
|
|
1
|
+
import { SDKEvent, SDKEventCustomFlags } from './sdkRuntimeModels';
|
|
7
2
|
import { Dictionary } from './utils';
|
|
8
3
|
import { IKitConfigs } from './configAPIClient';
|
|
9
|
-
import { UserAttributes } from './persistence.interfaces';
|
|
10
4
|
import { IdentityApiData } from '@mparticle/web-sdk';
|
|
5
|
+
import {
|
|
6
|
+
IMParticleUser,
|
|
7
|
+
ISDKUserIdentity,
|
|
8
|
+
UserAttributes,
|
|
9
|
+
} from './identity-user-interfaces';
|
|
11
10
|
|
|
12
11
|
// TODO: https://go.mparticle.com/work/SQDSDKS-6035
|
|
13
12
|
export type Kit = Dictionary;
|
|
@@ -19,7 +18,7 @@ export interface UnregisteredKit {
|
|
|
19
18
|
register(config): void;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
// The state of the kit after being added to forwarderConstructors in the CDN
|
|
21
|
+
// The state of the kit after being added to forwarderConstructors in the CDN
|
|
23
22
|
// or after registered to SDKConfig.kits via NPM
|
|
24
23
|
export interface RegisteredKit {
|
|
25
24
|
constructor(): void;
|
|
@@ -37,47 +36,50 @@ export interface ConfiguredKit
|
|
|
37
36
|
testMode: boolean,
|
|
38
37
|
trackerId: string | null,
|
|
39
38
|
userAttributes: UserAttributes,
|
|
40
|
-
userIdentities:
|
|
39
|
+
userIdentities: ISDKUserIdentity,
|
|
41
40
|
appVersion: string,
|
|
42
41
|
appName: string,
|
|
43
42
|
customFlags: SDKEventCustomFlags,
|
|
44
43
|
clientId: string
|
|
45
44
|
): string;
|
|
46
45
|
onIdentifyComplete(
|
|
47
|
-
user:
|
|
46
|
+
user: IMParticleUser,
|
|
48
47
|
filteredIdentityRequest: IdentityApiData
|
|
49
48
|
): string | KitMappedMethodFailure;
|
|
50
49
|
onLoginComplete(
|
|
51
|
-
user:
|
|
50
|
+
user: IMParticleUser,
|
|
52
51
|
filteredIdentityRequest: IdentityApiData
|
|
53
52
|
): string | KitMappedMethodFailure;
|
|
54
53
|
onLogoutComplete(
|
|
55
|
-
user:
|
|
54
|
+
user: IMParticleUser,
|
|
56
55
|
filteredIdentityRequest: IdentityApiData
|
|
57
56
|
): string | KitMappedMethodFailure;
|
|
58
57
|
onModifyComplete(
|
|
59
|
-
user:
|
|
58
|
+
user: IMParticleUser,
|
|
60
59
|
filteredIdentityRequest: IdentityApiData
|
|
61
60
|
): string | KitMappedMethodFailure;
|
|
62
|
-
onUserIdentified(user:
|
|
61
|
+
onUserIdentified(user: IMParticleUser): string | KitMappedMethodFailure;
|
|
63
62
|
process(event: SDKEvent): string;
|
|
64
63
|
setOptOut(isOptingOut: boolean): string | KitMappedMethodFailure;
|
|
65
64
|
removeUserAttribute(key: string): string;
|
|
66
|
-
setUserAttribute(key: string, value:string): string;
|
|
65
|
+
setUserAttribute(key: string, value: string): string;
|
|
67
66
|
|
|
68
67
|
// TODO: Convert type to enum during Identity migration
|
|
69
68
|
// https://go.mparticle.com/work/SQDSDKS-5218
|
|
70
69
|
setUserIdentity(id: UserIdentityId, type: UserIdentityType): void;
|
|
71
70
|
|
|
72
71
|
// TODO: https://go.mparticle.com/work/SQDSDKS-5156
|
|
73
|
-
isSandbox: boolean;
|
|
72
|
+
isSandbox: boolean;
|
|
74
73
|
hasSandbox: boolean;
|
|
75
74
|
}
|
|
76
75
|
export interface KitMappedMethodFailure {
|
|
77
|
-
error: string
|
|
76
|
+
error: string;
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
export type UserIdentityId = string;
|
|
81
80
|
export type UserIdentityType = number;
|
|
82
81
|
|
|
83
|
-
export type forwardingStatsCallback = (
|
|
82
|
+
export type forwardingStatsCallback = (
|
|
83
|
+
forwarder: ConfiguredKit,
|
|
84
|
+
event: SDKEvent
|
|
85
|
+
) => void;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { AllUserAttributes, MPID, Product, User } from '@mparticle/web-sdk';
|
|
2
|
+
import { SDKIdentityTypeEnum } from './identity.interfaces';
|
|
3
|
+
import { MessageType } from './types.interfaces';
|
|
4
|
+
import { BaseEvent } from './sdkRuntimeModels';
|
|
5
|
+
import Constants from './constants';
|
|
6
|
+
const { HTTPCodes } = Constants;
|
|
7
|
+
|
|
8
|
+
// Cart is Deprecated and private to mParticle user in @mparticle/web-sdk
|
|
9
|
+
// but we need to expose it here for type safety in some of our tests
|
|
10
|
+
interface Cart {
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.AddToCart, [products])
|
|
13
|
+
*/
|
|
14
|
+
add: (product: Product, logEventBoolean?: boolean) => void;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.RemoveFromCart, [products])
|
|
17
|
+
*/
|
|
18
|
+
remove: (product: Product, logEventBoolean?: boolean) => void;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Cart persistence in mParticle has been deprecated.
|
|
21
|
+
*/
|
|
22
|
+
clear: () => void;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Cart Products have been deprecated
|
|
25
|
+
*/
|
|
26
|
+
getCartProducts: () => Product[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// https://go.mparticle.com/work/SQDSDKS-5033
|
|
30
|
+
// https://go.mparticle.com/work/SQDSDKS-6354
|
|
31
|
+
export interface IMParticleUser extends User {
|
|
32
|
+
getAllUserAttributes(): any;
|
|
33
|
+
setUserTag(tagName: string, value?: any): void;
|
|
34
|
+
setUserAttribute(key: string, value: any): void;
|
|
35
|
+
getUserAudiences?(callback?: IdentityCallback): void;
|
|
36
|
+
/*
|
|
37
|
+
* @deprecated
|
|
38
|
+
*/
|
|
39
|
+
getCart(): Cart;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ISDKUserIdentity {
|
|
43
|
+
Identity: string;
|
|
44
|
+
Type: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ISDKUserIdentityChanges {
|
|
48
|
+
New: ISDKUserIdentityChangeData;
|
|
49
|
+
Old: ISDKUserIdentityChangeData;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ISDKUserIdentityChangeData {
|
|
53
|
+
IdentityType: SDKIdentityTypeEnum;
|
|
54
|
+
Identity: string;
|
|
55
|
+
CreatedThisBatch: boolean;
|
|
56
|
+
// https://go.mparticle.com/work/SQDSDKS-6438
|
|
57
|
+
Timestamp?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface IUserIdentityChangeEvent extends BaseEvent {
|
|
61
|
+
messageType: MessageType.UserIdentityChange;
|
|
62
|
+
userIdentityChanges: ISDKUserIdentityChanges;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ISDKUserAttributeChangeData {
|
|
66
|
+
UserAttributeName: string;
|
|
67
|
+
New: string;
|
|
68
|
+
Old: string;
|
|
69
|
+
Deleted: boolean;
|
|
70
|
+
IsNewAttribute: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface IUserAttributeChangeEvent extends BaseEvent {
|
|
74
|
+
messageType: MessageType.UserAttributeChange;
|
|
75
|
+
userAttributeChanges: ISDKUserAttributeChangeData;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// https://go.mparticle.com/work/SQDSDKS-6460
|
|
79
|
+
export interface IdentityCallback {
|
|
80
|
+
(result: IdentityResult): void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface IdentityResult {
|
|
84
|
+
httpCode: typeof HTTPCodes;
|
|
85
|
+
getPreviousUser(): User;
|
|
86
|
+
getUser(): User;
|
|
87
|
+
body: IdentityResultBody | IdentityModifyResultBody;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface IdentityResultBody {
|
|
91
|
+
context: string | null;
|
|
92
|
+
is_ephemeral: boolean;
|
|
93
|
+
is_logged_in: boolean;
|
|
94
|
+
matched_identities: Record<string, unknown>;
|
|
95
|
+
mpid?: MPID;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface IdentityModifyResultBody {
|
|
99
|
+
change_results?: {
|
|
100
|
+
identity_type: SDKIdentityTypeEnum;
|
|
101
|
+
modified_mpid: MPID;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface mParticleUserCart {
|
|
106
|
+
add(product: Product, logEvent: boolean): void;
|
|
107
|
+
remove(product: Product, logEvent: boolean): void;
|
|
108
|
+
clear(): void;
|
|
109
|
+
getCartProducts(): Product[];
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// https://go.mparticle.com/work/SQDSDKS-5196
|
|
113
|
+
export type UserAttributes = AllUserAttributes;
|