@mparticle/web-sdk 2.26.4 → 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 +1 -1
- package/dist/mparticle.esm.js +1 -1
- package/dist/mparticle.js +1 -1
- package/package.json +1 -1
- package/src/identity-user-interfaces.ts +55 -6
- package/src/identity-utils.ts +6 -4
- package/src/identity.interfaces.ts +6 -6
- package/src/sdkRuntimeModels.ts +20 -2
- package/src/store.ts +2 -1
- package/src/types.interfaces.ts +5 -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
|
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
|
package/dist/mparticle.js
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AllUserAttributes,
|
|
3
|
-
IdentityCallback,
|
|
4
|
-
Product,
|
|
5
|
-
User,
|
|
6
|
-
} from '@mparticle/web-sdk';
|
|
1
|
+
import { AllUserAttributes, MPID, Product, User } from '@mparticle/web-sdk';
|
|
7
2
|
import { SDKIdentityTypeEnum } from './identity.interfaces';
|
|
8
3
|
import { MessageType } from './types.interfaces';
|
|
9
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
|
+
}
|
|
10
28
|
|
|
11
29
|
// https://go.mparticle.com/work/SQDSDKS-5033
|
|
12
30
|
// https://go.mparticle.com/work/SQDSDKS-6354
|
|
@@ -15,6 +33,10 @@ export interface IMParticleUser extends User {
|
|
|
15
33
|
setUserTag(tagName: string, value?: any): void;
|
|
16
34
|
setUserAttribute(key: string, value: any): void;
|
|
17
35
|
getUserAudiences?(callback?: IdentityCallback): void;
|
|
36
|
+
/*
|
|
37
|
+
* @deprecated
|
|
38
|
+
*/
|
|
39
|
+
getCart(): Cart;
|
|
18
40
|
}
|
|
19
41
|
|
|
20
42
|
export interface ISDKUserIdentity {
|
|
@@ -53,6 +75,33 @@ export interface IUserAttributeChangeEvent extends BaseEvent {
|
|
|
53
75
|
userAttributeChanges: ISDKUserAttributeChangeData;
|
|
54
76
|
}
|
|
55
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
|
+
|
|
56
105
|
export interface mParticleUserCart {
|
|
57
106
|
add(product: Product, logEvent: boolean): void;
|
|
58
107
|
remove(product: Product, logEvent: boolean): void;
|
package/src/identity-utils.ts
CHANGED
|
@@ -7,6 +7,8 @@ import { IdentityAPIMethod } from './identity.interfaces';
|
|
|
7
7
|
|
|
8
8
|
const { Identify, Modify, Login, Logout } = Constants.IdentityMethods;
|
|
9
9
|
|
|
10
|
+
export type IdentityCache = BaseVault<Dictionary<ICachedIdentityCall>>;
|
|
11
|
+
|
|
10
12
|
export type IParseCachedIdentityResponse = (
|
|
11
13
|
cachedIdentity: ICachedIdentityCall,
|
|
12
14
|
mpid: string,
|
|
@@ -69,7 +71,7 @@ export const cacheIdentityRequest = (
|
|
|
69
71
|
method: IdentityAPIMethod,
|
|
70
72
|
identities: IKnownIdentities,
|
|
71
73
|
expireTimestamp: number,
|
|
72
|
-
idCache:
|
|
74
|
+
idCache: IdentityCache,
|
|
73
75
|
xhr: XMLHttpRequest
|
|
74
76
|
): void => {
|
|
75
77
|
const cache: Dictionary<ICachedIdentityCall> = idCache.retrieve() || ({} as Dictionary<ICachedIdentityCall>);
|
|
@@ -126,7 +128,7 @@ export const concatenateIdentities = (
|
|
|
126
128
|
export const hasValidCachedIdentity = (
|
|
127
129
|
method: IdentityAPIMethod,
|
|
128
130
|
proposedUserIdentities: IKnownIdentities,
|
|
129
|
-
idCache?:
|
|
131
|
+
idCache?: IdentityCache,
|
|
130
132
|
): boolean => {
|
|
131
133
|
// There is an edge case where multiple identity calls are taking place
|
|
132
134
|
// before identify fires, so there may not be a cache. See what happens when
|
|
@@ -166,7 +168,7 @@ export const hasValidCachedIdentity = (
|
|
|
166
168
|
export const getCachedIdentity = (
|
|
167
169
|
method: IdentityAPIMethod,
|
|
168
170
|
proposedUserIdentities: IKnownIdentities,
|
|
169
|
-
idCache:
|
|
171
|
+
idCache: IdentityCache,
|
|
170
172
|
): ICachedIdentityCall | null => {
|
|
171
173
|
const cacheKey: string = concatenateIdentities(
|
|
172
174
|
method,
|
|
@@ -215,7 +217,7 @@ export const removeExpiredIdentityCacheDates = (idCache: BaseVault<Dictionary<IC
|
|
|
215
217
|
|
|
216
218
|
export const tryCacheIdentity = (
|
|
217
219
|
knownIdentities: IKnownIdentities,
|
|
218
|
-
idCache:
|
|
220
|
+
idCache: IdentityCache,
|
|
219
221
|
parseIdentityResponse: IParseCachedIdentityResponse,
|
|
220
222
|
mpid: string,
|
|
221
223
|
callback: IdentityCallback,
|
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IdentityApiData,
|
|
3
|
-
IdentityCallback,
|
|
4
|
-
MPID,
|
|
5
|
-
UserIdentities,
|
|
6
|
-
} from '@mparticle/web-sdk';
|
|
1
|
+
import { IdentityApiData, MPID, UserIdentities } from '@mparticle/web-sdk';
|
|
7
2
|
import AudienceManager from './audienceManager';
|
|
8
3
|
import { ICachedIdentityCall, IKnownIdentities } from './identity-utils';
|
|
9
4
|
import { BaseVault } from './vault';
|
|
10
5
|
import { Dictionary, Environment, valueof } from './utils';
|
|
11
6
|
import Constants from './constants';
|
|
12
7
|
import {
|
|
8
|
+
IdentityCallback,
|
|
13
9
|
IUserAttributeChangeEvent,
|
|
14
10
|
IUserIdentityChangeEvent,
|
|
15
11
|
IMParticleUser,
|
|
@@ -78,6 +74,10 @@ export interface IIdentityAPIIdentityChangeData {
|
|
|
78
74
|
}
|
|
79
75
|
|
|
80
76
|
export interface IIdentityRequest {
|
|
77
|
+
combineUserIdentities(
|
|
78
|
+
previousUIByName: UserIdentities,
|
|
79
|
+
newUIByName: UserIdentities
|
|
80
|
+
): UserIdentities;
|
|
81
81
|
createIdentityRequest(
|
|
82
82
|
identityApiData: IdentityApiData,
|
|
83
83
|
platform: string,
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import * as EventsApi from '@mparticle/event-models';
|
|
2
2
|
import { DataPlanVersion } from '@mparticle/data-planning-models';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
MPConfiguration,
|
|
5
|
+
MPID,
|
|
6
|
+
Callback,
|
|
7
|
+
IdentityApiData,
|
|
8
|
+
} from '@mparticle/web-sdk';
|
|
4
9
|
import { IStore } from './store';
|
|
5
10
|
import Validators from './validators';
|
|
6
11
|
import { Dictionary } from './utils';
|
|
@@ -11,13 +16,15 @@ import { IPersistence } from './persistence.interfaces';
|
|
|
11
16
|
import { IMPSideloadedKit } from './sideloadedKit';
|
|
12
17
|
import { ISessionManager } from './sessionManager';
|
|
13
18
|
import { Kit, MPForwarder } from './forwarders.interfaces';
|
|
14
|
-
import { SDKIdentityApi } from './identity.interfaces';
|
|
19
|
+
import { IIdentity, SDKIdentityApi } from './identity.interfaces';
|
|
15
20
|
import {
|
|
16
21
|
ISDKUserAttributeChangeData,
|
|
17
22
|
ISDKUserIdentityChanges,
|
|
18
23
|
IMParticleUser,
|
|
19
24
|
ISDKUserIdentity,
|
|
25
|
+
IdentityCallback,
|
|
20
26
|
} from './identity-user-interfaces';
|
|
27
|
+
import { IIdentityType } from './types.interfaces';
|
|
21
28
|
|
|
22
29
|
// TODO: Resolve this with version in @mparticle/web-sdk
|
|
23
30
|
export type SDKEventCustomFlags = Dictionary<any>;
|
|
@@ -137,6 +144,8 @@ interface IEvents {
|
|
|
137
144
|
|
|
138
145
|
export interface MParticleWebSDK {
|
|
139
146
|
addForwarder(mockForwarder: MPForwarder): void;
|
|
147
|
+
IdentityType: IIdentityType;
|
|
148
|
+
_Identity: IIdentity;
|
|
140
149
|
Identity: SDKIdentityApi;
|
|
141
150
|
Logger: SDKLoggerApi;
|
|
142
151
|
MPSideloadedKit: IMPSideloadedKit;
|
|
@@ -160,14 +169,20 @@ export interface MParticleWebSDK {
|
|
|
160
169
|
keepPersistence?: boolean,
|
|
161
170
|
instance?: MParticleWebSDK
|
|
162
171
|
): void;
|
|
172
|
+
endSession(): void;
|
|
173
|
+
identifyRequest: IdentityApiData;
|
|
163
174
|
init(apiKey: string, config: SDKInitConfig, instanceName?: string): void;
|
|
175
|
+
_getActiveForwarders(): MPForwarder[];
|
|
164
176
|
getAppName(): string;
|
|
165
177
|
getAppVersion(): string;
|
|
166
178
|
getDeviceId(): string;
|
|
179
|
+
setDeviceId(deviceId: string): void;
|
|
167
180
|
getInstance(): MParticleWebSDK; // TODO: Create a new type for MParticleWebSDKInstance
|
|
168
181
|
ServerModel();
|
|
169
182
|
upload();
|
|
183
|
+
setLogLevel(logLevel: LogLevelType): void;
|
|
170
184
|
setPosition(lat: number | string, lng: number | string): void;
|
|
185
|
+
startNewSession(): void;
|
|
171
186
|
logEvent(
|
|
172
187
|
eventName: string,
|
|
173
188
|
eventType?: number,
|
|
@@ -224,6 +239,9 @@ export interface SDKInitConfig
|
|
|
224
239
|
|
|
225
240
|
workspaceToken?: string;
|
|
226
241
|
isDevelopmentMode?: boolean;
|
|
242
|
+
|
|
243
|
+
// https://go.mparticle.com/work/SQDSDKS-6460
|
|
244
|
+
identityCallback?: IdentityCallback;
|
|
227
245
|
}
|
|
228
246
|
|
|
229
247
|
export interface DataPlanConfig {
|
package/src/store.ts
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
DataPlanConfig,
|
|
5
5
|
MPID,
|
|
6
6
|
IdentifyRequest,
|
|
7
|
-
IdentityCallback,
|
|
8
7
|
SDKEventCustomFlags,
|
|
9
8
|
} from '@mparticle/web-sdk';
|
|
10
9
|
import { IKitConfigs } from './configAPIClient';
|
|
@@ -32,6 +31,7 @@ import {
|
|
|
32
31
|
import { SDKConsentState } from './consent';
|
|
33
32
|
import { Kit, MPForwarder } from './forwarders.interfaces';
|
|
34
33
|
import { IPersistenceMinified } from './persistence.interfaces';
|
|
34
|
+
import { IdentityCallback } from './identity-user-interfaces';
|
|
35
35
|
|
|
36
36
|
// This represents the runtime configuration of the SDK AFTER
|
|
37
37
|
// initialization has been complete and all settings and
|
|
@@ -71,6 +71,7 @@ export interface SDKConfig {
|
|
|
71
71
|
identityUrl?: string;
|
|
72
72
|
userAudienceUrl?: string;
|
|
73
73
|
isIOS?: boolean;
|
|
74
|
+
maxAliasWindow: number;
|
|
74
75
|
maxProducts: number;
|
|
75
76
|
requestConfig?: boolean;
|
|
76
77
|
sessionTimeout?: number;
|