@mparticle/web-sdk 2.61.0 → 2.62.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/mparticle.common.js +1 -1
  2. package/dist/mparticle.esm.js +1 -1
  3. package/dist/mparticle.js +1 -1
  4. package/dist/types/src/apiClient.d.ts +34 -0
  5. package/dist/types/src/audience.d.ts +4 -0
  6. package/dist/types/src/audienceManager.d.ts +19 -0
  7. package/dist/types/src/batchUploader.d.ts +72 -0
  8. package/dist/types/src/configAPIClient.d.ts +68 -0
  9. package/dist/types/src/consent.d.ts +71 -0
  10. package/dist/types/src/constants.d.ts +201 -0
  11. package/dist/types/src/cookieConsentManager.d.ts +50 -0
  12. package/dist/types/src/cookieSyncManager.d.ts +34 -0
  13. package/dist/types/src/ecommerce.d.ts +52 -0
  14. package/dist/types/src/ecommerce.interfaces.d.ts +78 -0
  15. package/dist/types/src/events.d.ts +17 -0
  16. package/dist/types/src/events.interfaces.d.ts +21 -0
  17. package/dist/types/src/filteredMparticleUser.d.ts +8 -0
  18. package/dist/types/src/foregroundTimeTracker.d.ts +21 -0
  19. package/dist/types/src/forwarders.d.ts +26 -0
  20. package/dist/types/src/forwarders.interfaces.d.ts +59 -0
  21. package/dist/types/src/forwardingStatsUploader.d.ts +5 -0
  22. package/dist/types/src/helpers.d.ts +54 -0
  23. package/dist/types/src/identity-user-interfaces.d.ts +106 -0
  24. package/dist/types/src/identity-utils.d.ts +36 -0
  25. package/dist/types/src/identity.interfaces.d.ts +117 -0
  26. package/dist/types/src/identityApiClient.d.ts +14 -0
  27. package/dist/types/src/integrationCapture.d.ts +83 -0
  28. package/dist/types/src/internal-types.d.ts +20 -0
  29. package/dist/types/src/kitBlocking.d.ts +116 -0
  30. package/dist/types/src/kitFilterHelper.d.ts +15 -0
  31. package/dist/types/src/logger.d.ts +18 -0
  32. package/dist/types/src/mockBatchCreator.d.ts +7 -0
  33. package/dist/types/src/mp-instance.d.ts +76 -0
  34. package/dist/types/src/mparticle-instance-manager.d.ts +2 -0
  35. package/dist/types/src/nativeSdkHelpers.d.ts +12 -0
  36. package/dist/types/src/nativeSdkHelpers.interfaces.d.ts +10 -0
  37. package/dist/types/src/persistence.d.ts +44 -0
  38. package/dist/types/src/persistence.interfaces.d.ts +73 -0
  39. package/dist/types/src/polyfill.d.ts +15 -0
  40. package/dist/types/src/pre-init-utils.d.ts +11 -0
  41. package/dist/types/src/public-types.d.ts +23 -0
  42. package/dist/types/src/reporting/errorReportingDispatcher.d.ts +8 -0
  43. package/dist/types/src/reporting/loggingDispatcher.d.ts +8 -0
  44. package/dist/types/src/reporting/types.d.ts +37 -0
  45. package/dist/types/src/roktManager.d.ts +176 -0
  46. package/dist/types/src/sdkRuntimeModels.d.ts +319 -0
  47. package/dist/types/src/sdkToEventsApiConverter.d.ts +43 -0
  48. package/dist/types/src/serverModel.d.ts +105 -0
  49. package/dist/types/src/sessionManager.d.ts +16 -0
  50. package/dist/types/src/sideloadedKit.d.ts +30 -0
  51. package/dist/types/src/store.d.ts +157 -0
  52. package/dist/types/src/stub/mparticle.stub.d.ts +182 -0
  53. package/dist/types/src/types.d.ts +154 -0
  54. package/dist/types/src/uploaders.d.ts +21 -0
  55. package/dist/types/src/user-utils.d.ts +5 -0
  56. package/dist/types/src/utils.d.ts +82 -0
  57. package/dist/types/src/validators.d.ts +18 -0
  58. package/dist/types/src/vault.d.ts +41 -0
  59. package/package.json +15 -2
  60. package/src/forwarders.interfaces.ts +42 -0
  61. package/src/internal-types.ts +66 -0
  62. package/src/public-types.ts +84 -0
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
15
15
  filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
16
16
  isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
17
17
 
18
- var version = "2.61.0";
18
+ var version = "2.62.0";
19
19
 
20
20
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",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
21
21
  },DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
15
15
  filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
16
16
  isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
17
17
 
18
- var version = "2.61.0";
18
+ var version = "2.62.0";
19
19
 
20
20
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",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
21
21
  },DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
package/dist/mparticle.js CHANGED
@@ -203,7 +203,7 @@ var mParticle = (function () {
203
203
  Base64: Base64$1
204
204
  };
205
205
 
206
- var version = "2.61.0";
206
+ var version = "2.62.0";
207
207
 
208
208
  var Constants = {
209
209
  sdkVersion: version,
@@ -0,0 +1,34 @@
1
+ import { BatchUploader } from './batchUploader';
2
+ import { SDKEvent, SDKDataPlan } from './sdkRuntimeModels';
3
+ import KitBlocker from './kitBlocking';
4
+ import { Dictionary } from './utils';
5
+ import { IUploadObject } from './serverModel';
6
+ import { MPForwarder } from './forwarders.interfaces';
7
+ import { IMParticleUser, ISDKUserAttributes } from './identity-user-interfaces';
8
+ import { AsyncUploader } from './uploaders';
9
+ import { IMParticleWebSDKInstance } from './mp-instance';
10
+ export interface IAPIClient {
11
+ uploader: BatchUploader | null;
12
+ queueEventForBatchUpload: (event: SDKEvent) => void;
13
+ processQueuedEvents: () => void;
14
+ appendUserInfoToEvents: (user: IMParticleUser, events: SDKEvent[]) => void;
15
+ sendEventToServer: (event: SDKEvent, _options?: Dictionary<any>) => void;
16
+ sendSingleEventToServer: (event: SDKEvent) => void;
17
+ sendBatchForwardingStatsToServer: (forwardingStatsData: IForwardingStatsData, xhr: XMLHttpRequest) => void;
18
+ initializeForwarderStatsUploader: () => AsyncUploader;
19
+ prepareForwardingStats: (forwarder: MPForwarder, event: IUploadObject) => void;
20
+ }
21
+ export interface IForwardingStatsData {
22
+ mid: number;
23
+ esid: number;
24
+ n: string;
25
+ attrs: ISDKUserAttributes;
26
+ sdk: string;
27
+ dt: number;
28
+ et: number;
29
+ dbg: boolean;
30
+ ct: number;
31
+ eec: number;
32
+ dp: SDKDataPlan;
33
+ }
34
+ export default function APIClient(this: IAPIClient, mpInstance: IMParticleWebSDKInstance, kitBlocker: KitBlocker): void;
@@ -0,0 +1,4 @@
1
+ export default class Audience {
2
+ audience_id: number;
3
+ constructor(audience_id: number);
4
+ }
@@ -0,0 +1,19 @@
1
+ import { SDKLoggerApi } from './sdkRuntimeModels';
2
+ import { AsyncUploader } from './uploaders';
3
+ import Audience from './audience';
4
+ export interface IAudienceMembershipsServerResponse {
5
+ dt: 'cam';
6
+ ct: number;
7
+ id: string;
8
+ audience_memberships: Audience[];
9
+ }
10
+ export interface IAudienceMemberships {
11
+ currentAudienceMemberships: Audience[];
12
+ }
13
+ export default class AudienceManager {
14
+ url: string;
15
+ userAudienceAPI: AsyncUploader;
16
+ logger: SDKLoggerApi;
17
+ constructor(userAudienceUrl: string, apiKey: string, logger: SDKLoggerApi);
18
+ sendGetUserAudienceRequest(mpid: string, callback: (userAudiences: IAudienceMemberships) => void): Promise<void>;
19
+ }
@@ -0,0 +1,72 @@
1
+ import { Batch } from '@mparticle/event-models';
2
+ import { SDKEvent } from './sdkRuntimeModels';
3
+ import { IMParticleWebSDKInstance } from './mp-instance';
4
+ /**
5
+ * BatchUploader contains all the logic to store/retrieve events and batches
6
+ * to/from persistence, and upload batches to mParticle.
7
+ * It queues events as they come in, storing them in persistence, then at set
8
+ * intervals turns them into batches and transfers between event and batch
9
+ * persistence.
10
+ * It then attempts to upload them to mParticle, purging batch persistence if
11
+ * the upload is successful
12
+ *
13
+ * These uploads happen on an interval basis using window.fetch or XHR
14
+ * requests, depending on what is available in the browser.
15
+ *
16
+ * Uploads can also be triggered on browser visibility/focus changes via an
17
+ * event listener, which then uploads to mPartice via the browser's Beacon API.
18
+ */
19
+ export declare class BatchUploader {
20
+ static readonly CONTENT_TYPE: string;
21
+ static readonly MINIMUM_INTERVAL_MILLIS: number;
22
+ uploadIntervalMillis: number;
23
+ eventsQueuedForProcessing: SDKEvent[];
24
+ batchesQueuedForProcessing: Batch[];
25
+ mpInstance: IMParticleWebSDKInstance;
26
+ uploadUrl: string;
27
+ batchingEnabled: boolean;
28
+ private eventVault;
29
+ private batchVault;
30
+ private offlineStorageEnabled;
31
+ private uploader;
32
+ private lastASTEventTime;
33
+ private readonly AST_DEBOUNCE_MS;
34
+ /**
35
+ * Creates an instance of a BatchUploader
36
+ * @param {IMParticleWebSDKInstance} mpInstance - the mParticle SDK instance
37
+ * @param {number} uploadInterval - the desired upload interval in milliseconds
38
+ */
39
+ constructor(mpInstance: IMParticleWebSDKInstance, uploadInterval: number);
40
+ private isOfflineStorageAvailable;
41
+ private shouldDebounceAndUpdateLastASTTime;
42
+ private createBackgroundASTEvent;
43
+ private addEventListeners;
44
+ private isBeaconAvailable;
45
+ private triggerUploadInterval;
46
+ /**
47
+ * This method will queue a single Event which will eventually be processed into a Batch
48
+ * @param event event that should be queued
49
+ */
50
+ queueEvent(event: SDKEvent): void;
51
+ private shouldTriggerImmediateUpload;
52
+ /**
53
+ * This implements crucial logic to:
54
+ * - bucket pending events by MPID, and then by Session, and upload individual batches for each bucket.
55
+ *
56
+ * In the future this should enforce other requirements such as maximum batch size.
57
+ *
58
+ * @param sdkEvents current pending events
59
+ * @param defaultUser the user to reference for events that are missing data
60
+ */
61
+ private static createNewBatches;
62
+ /**
63
+ * This is the main loop function:
64
+ * - take all pending events and turn them into batches
65
+ * - attempt to upload each batch
66
+ *
67
+ * @param triggerFuture whether to trigger the loop again - for manual/forced uploads this should be false
68
+ * @param useBeacon whether to use the beacon API - used when the page is being unloaded
69
+ */
70
+ prepareAndUpload(triggerFuture?: boolean, useBeacon?: boolean): Promise<void>;
71
+ private uploadBatches;
72
+ }
@@ -0,0 +1,68 @@
1
+ import { BooleanStringLowerCase, DataPlanResult, SDKEventCustomFlags, SDKInitConfig } from './sdkRuntimeModels';
2
+ import { Dictionary } from './utils';
3
+ import { IPixelConfiguration } from './cookieSyncManager';
4
+ import { IMParticleWebSDKInstance } from './mp-instance';
5
+ export interface IKitConfigs extends IKitFilterSettings {
6
+ name: string;
7
+ suffix?: string;
8
+ moduleId: number;
9
+ isDebug: boolean;
10
+ isVisible: boolean;
11
+ isDebugString: BooleanStringLowerCase;
12
+ hasDebugString: BooleanStringLowerCase;
13
+ settings: Dictionary;
14
+ eventSubscriptionId: number;
15
+ excludeAnonymousUser: boolean;
16
+ }
17
+ export interface IKitFilterSettings {
18
+ eventTypeFilters: number[];
19
+ eventNameFilters: number[];
20
+ screenNameFilters: number[];
21
+ screenAttributeFilters: number[];
22
+ userIdentityFilters: number[];
23
+ userAttributeFilters: number[];
24
+ attributeFilters: number[];
25
+ filteringEventAttributeValue?: IFilteringEventAttributeValue;
26
+ filteringUserAttributeValue?: IFilteringUserAttributeValue;
27
+ filteringConsentRuleValues?: IFilteringConsentRuleValues;
28
+ consentRegulationFilters: number[];
29
+ consentRegulationPurposeFilters: number[];
30
+ messageTypeFilters: number[];
31
+ messageTypeStateFilters: number[];
32
+ }
33
+ export interface IFilteringEventAttributeValue {
34
+ eventAttributeName: string;
35
+ eventAttributeValue: string;
36
+ includeOnMatch: boolean;
37
+ }
38
+ export interface IFilteringUserAttributeValue {
39
+ userAttributeName: string;
40
+ userAttributeValue: string;
41
+ includeOnMatch: boolean;
42
+ }
43
+ export interface IFilteringConsentRuleValues {
44
+ includeOnMatch: boolean;
45
+ values: IConsentRuleValue[];
46
+ }
47
+ export interface IConsentRuleValue {
48
+ consentPurpose: string;
49
+ hasConsented: boolean;
50
+ }
51
+ export interface IConfigResponse {
52
+ appName: string;
53
+ dataPlanResult: DataPlanResult;
54
+ kitConfigs: IKitConfigs[];
55
+ serviceUrl: string;
56
+ secureServiceUrl: string;
57
+ minWebviewBridgeVersion: number;
58
+ workspaceToken: string;
59
+ pixelConfigs: IPixelConfiguration[];
60
+ flags: SDKEventCustomFlags;
61
+ }
62
+ export interface IConfigAPIClient {
63
+ apiKey: string;
64
+ config: SDKInitConfig;
65
+ mpInstance: IMParticleWebSDKInstance;
66
+ getSDKConfiguration: () => Promise<IConfigResponse>;
67
+ }
68
+ export default function ConfigAPIClient(this: IConfigAPIClient, apiKey: string, config: SDKInitConfig, mpInstance: IMParticleWebSDKInstance): void;
@@ -0,0 +1,71 @@
1
+ import { ConsentState, PrivacyConsentState } from '@mparticle/web-sdk';
2
+ import { Dictionary } from './utils';
3
+ import { IMParticleUser } from './identity-user-interfaces';
4
+ import { IMParticleWebSDKInstance } from './mp-instance';
5
+ declare const CCPAPurpose: "data_sale_opt_out";
6
+ export interface IMinifiedConsentJSONObject {
7
+ gdpr?: Dictionary<IPrivacyV2DTO>;
8
+ ccpa?: {
9
+ [CCPAPurpose]: IPrivacyV2DTO;
10
+ };
11
+ }
12
+ export interface ICreatePrivacyConsentFunction {
13
+ (consented: boolean, timestamp?: number, consentDocument?: string, location?: string, hardwareId?: string): PrivacyConsentState | null;
14
+ }
15
+ export interface SDKConsentApi {
16
+ createGDPRConsent: ICreatePrivacyConsentFunction;
17
+ createCCPAConsent: ICreatePrivacyConsentFunction;
18
+ createConsentState: (consentState?: ConsentState) => ConsentState;
19
+ }
20
+ export interface IConsentSerialization {
21
+ toMinifiedJsonObject: (state: ConsentState) => IMinifiedConsentJSONObject;
22
+ fromMinifiedJsonObject: (json: IMinifiedConsentJSONObject) => ConsentState;
23
+ }
24
+ export interface SDKConsentState extends Omit<ConsentState, 'getGDPRConsentState' | 'getCCPAConsentState'> {
25
+ getGDPRConsentState(): SDKGDPRConsentState;
26
+ getCCPAConsentState(): SDKCCPAConsentState;
27
+ }
28
+ export interface SDKConsentStateData {
29
+ Consented: boolean;
30
+ Timestamp?: number;
31
+ ConsentDocument?: string;
32
+ Location?: string;
33
+ HardwareId?: string;
34
+ }
35
+ export type SDKGDPRConsentState = Dictionary<SDKConsentStateData>;
36
+ export interface SDKCCPAConsentState extends SDKConsentStateData {
37
+ }
38
+ export interface IPrivacyV2DTO {
39
+ c: boolean;
40
+ ts: number;
41
+ d: string;
42
+ l: string;
43
+ h: string;
44
+ }
45
+ export type IGDPRConsentStateV2DTO = Dictionary<IPrivacyV2DTO>;
46
+ export interface ICCPAConsentStateV2DTO {
47
+ [CCPAPurpose]: IPrivacyV2DTO;
48
+ }
49
+ export interface IConsentStateV2DTO {
50
+ gdpr?: IGDPRConsentStateV2DTO;
51
+ ccpa?: ICCPAConsentStateV2DTO;
52
+ }
53
+ export interface IConsentRulesValues {
54
+ consentPurpose: string;
55
+ hasConsented: boolean;
56
+ }
57
+ export interface IConsentRules {
58
+ includeOnMatch: boolean;
59
+ values: IConsentRulesValues[];
60
+ }
61
+ export interface IConsentState extends ConsentState {
62
+ removeCCPAState: () => ConsentState;
63
+ }
64
+ export interface IConsent {
65
+ isEnabledForUserConsent: (consentRules: IConsentRules, user: IMParticleUser) => boolean;
66
+ createPrivacyConsent: ICreatePrivacyConsentFunction;
67
+ createConsentState: (consentState?: ConsentState) => ConsentState;
68
+ ConsentSerialization: IConsentSerialization;
69
+ }
70
+ export default function Consent(this: IConsent, mpInstance: IMParticleWebSDKInstance): void;
71
+ export {};
@@ -0,0 +1,201 @@
1
+ declare const Constants: {
2
+ readonly sdkVersion: string;
3
+ readonly sdkVendor: "mparticle";
4
+ readonly platform: "web";
5
+ readonly Messages: {
6
+ readonly DeprecationMessages: {
7
+ readonly MethodHasBeenDeprecated: "has been deprecated.";
8
+ readonly MethodMarkedForDeprecationPostfix: "is a deprecated method and will be removed in future releases.";
9
+ readonly AlternativeMethodPrefix: "Please use the alternate method:";
10
+ };
11
+ readonly ErrorMessages: {
12
+ readonly NoToken: "A token must be specified.";
13
+ readonly EventNameInvalidType: "Event name must be a valid string value.";
14
+ readonly EventDataInvalidType: "Event data must be a valid object hash.";
15
+ readonly LoggingDisabled: "Event logging is currently disabled.";
16
+ readonly CookieParseError: "Could not parse cookie";
17
+ readonly EventEmpty: "Event object is null or undefined, cancelling send";
18
+ readonly APIRequestEmpty: "APIRequest is null or undefined, cancelling send";
19
+ readonly NoEventType: "Event type must be specified.";
20
+ readonly TransactionIdRequired: "Transaction ID is required";
21
+ readonly TransactionRequired: "A transaction attributes object is required";
22
+ readonly PromotionIdRequired: "Promotion ID is required";
23
+ readonly BadAttribute: "Attribute value cannot be object or array";
24
+ readonly BadKey: "Key value cannot be object or array";
25
+ readonly BadLogPurchase: "Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions";
26
+ readonly AudienceAPINotEnabled: "Your workspace is not enabled to retrieve user audiences.";
27
+ };
28
+ readonly InformationMessages: {
29
+ readonly CookieSearch: "Searching for cookie";
30
+ readonly CookieFound: "Cookie found, parsing values";
31
+ readonly CookieNotFound: "Cookies not found";
32
+ readonly CookieSet: "Setting cookie";
33
+ readonly CookieSync: "Performing cookie sync";
34
+ readonly SendBegin: "Starting to send event";
35
+ readonly SendIdentityBegin: "Starting to send event to identity server";
36
+ readonly SendWindowsPhone: "Sending event to Windows Phone container";
37
+ readonly SendIOS: "Calling iOS path: ";
38
+ readonly SendAndroid: "Calling Android JS interface method: ";
39
+ readonly SendHttp: "Sending event to mParticle HTTP service";
40
+ readonly SendAliasHttp: "Sending alias request to mParticle HTTP service";
41
+ readonly SendIdentityHttp: "Sending event to mParticle HTTP service";
42
+ readonly StartingNewSession: "Starting new Session";
43
+ readonly StartingLogEvent: "Starting to log event";
44
+ readonly StartingLogOptOut: "Starting to log user opt in/out";
45
+ readonly StartingEndSession: "Starting to end session";
46
+ readonly StartingInitialization: "Starting to initialize";
47
+ readonly StartingLogCommerceEvent: "Starting to log commerce event";
48
+ readonly StartingAliasRequest: "Starting to Alias MPIDs";
49
+ readonly LoadingConfig: "Loading configuration options";
50
+ readonly AbandonLogEvent: "Cannot log event, logging disabled or developer token not set";
51
+ readonly AbandonAliasUsers: "Cannot Alias Users, logging disabled or developer token not set";
52
+ readonly AbandonStartSession: "Cannot start session, logging disabled or developer token not set";
53
+ readonly AbandonEndSession: "Cannot end session, logging disabled or developer token not set";
54
+ readonly NoSessionToEnd: "Cannot end session, no active session found";
55
+ };
56
+ readonly ValidationMessages: {
57
+ readonly ModifyIdentityRequestUserIdentitiesPresent: "identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again";
58
+ readonly 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.";
59
+ readonly OnUserAliasType: "The onUserAlias value must be a function.";
60
+ readonly 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.";
61
+ readonly UserIdentitiesInvalidKey: "There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.";
62
+ readonly UserIdentitiesInvalidValues: "All user identity values must be strings or null. Request not sent to server. Please fix and try again.";
63
+ readonly AliasMissingMpid: "Alias Request must contain both a destinationMpid and a sourceMpid";
64
+ readonly AliasNonUniqueMpid: "Alias Request's destinationMpid and sourceMpid must be unique";
65
+ readonly AliasMissingTime: "Alias Request must have both a startTime and an endTime";
66
+ readonly AliasStartBeforeEndTime: "Alias Request's endTime must be later than its startTime";
67
+ };
68
+ };
69
+ readonly NativeSdkPaths: {
70
+ readonly LogEvent: "logEvent";
71
+ readonly SetUserTag: "setUserTag";
72
+ readonly RemoveUserTag: "removeUserTag";
73
+ readonly SetUserAttribute: "setUserAttribute";
74
+ readonly RemoveUserAttribute: "removeUserAttribute";
75
+ readonly SetSessionAttribute: "setSessionAttribute";
76
+ readonly AddToCart: "addToCart";
77
+ readonly RemoveFromCart: "removeFromCart";
78
+ readonly ClearCart: "clearCart";
79
+ readonly LogOut: "logOut";
80
+ readonly SetUserAttributeList: "setUserAttributeList";
81
+ readonly RemoveAllUserAttributes: "removeAllUserAttributes";
82
+ readonly GetUserAttributesLists: "getUserAttributesLists";
83
+ readonly GetAllUserAttributes: "getAllUserAttributes";
84
+ readonly Identify: "identify";
85
+ readonly Logout: "logout";
86
+ readonly Login: "login";
87
+ readonly Modify: "modify";
88
+ readonly Alias: "aliasUsers";
89
+ readonly Upload: "upload";
90
+ };
91
+ readonly StorageNames: {
92
+ readonly localStorageName: "mprtcl-api";
93
+ readonly localStorageNameV3: "mprtcl-v3";
94
+ readonly cookieName: "mprtcl-api";
95
+ readonly cookieNameV2: "mprtcl-v2";
96
+ readonly cookieNameV3: "mprtcl-v3";
97
+ readonly localStorageNameV4: "mprtcl-v4";
98
+ readonly localStorageProductsV4: "mprtcl-prodv4";
99
+ readonly cookieNameV4: "mprtcl-v4";
100
+ readonly currentStorageName: "mprtcl-v4";
101
+ readonly currentStorageProductsName: "mprtcl-prodv4";
102
+ };
103
+ readonly DefaultConfig: {
104
+ readonly cookieDomain: any;
105
+ readonly cookieExpiration: 365;
106
+ readonly logLevel: any;
107
+ readonly timeout: 300;
108
+ readonly sessionTimeout: 30;
109
+ readonly maxProducts: 20;
110
+ readonly forwarderStatsTimeout: 5000;
111
+ readonly integrationDelayTimeout: 5000;
112
+ readonly maxCookieSize: 3000;
113
+ readonly aliasMaxWindow: 90;
114
+ readonly uploadInterval: 0;
115
+ };
116
+ readonly DefaultBaseUrls: {
117
+ readonly v1SecureServiceUrl: "jssdks.mparticle.com/v1/JS/";
118
+ readonly v2SecureServiceUrl: "jssdks.mparticle.com/v2/JS/";
119
+ readonly v3SecureServiceUrl: "jssdks.mparticle.com/v3/JS/";
120
+ readonly configUrl: "jssdkcdns.mparticle.com/JS/v2/";
121
+ readonly identityUrl: "identity.mparticle.com/v1/";
122
+ readonly aliasUrl: "jssdks.mparticle.com/v1/identity/";
123
+ readonly userAudienceUrl: "nativesdks.mparticle.com/v1/";
124
+ };
125
+ readonly CNAMEUrlPaths: {
126
+ readonly v1SecureServiceUrl: "/webevents/v1/JS/";
127
+ readonly v2SecureServiceUrl: "/webevents/v2/JS/";
128
+ readonly v3SecureServiceUrl: "/webevents/v3/JS/";
129
+ readonly configUrl: "/tags/JS/v2/";
130
+ readonly identityUrl: "/identity/v1/";
131
+ readonly aliasUrl: "/webevents/v1/identity/";
132
+ };
133
+ readonly Base64CookieKeys: {
134
+ readonly csm: 1;
135
+ readonly sa: 1;
136
+ readonly ss: 1;
137
+ readonly lsa: 1;
138
+ readonly ua: 1;
139
+ readonly ui: 1;
140
+ readonly csd: 1;
141
+ readonly ia: 1;
142
+ readonly con: 1;
143
+ };
144
+ readonly SDKv2NonMPIDCookieKeys: {
145
+ readonly gs: 1;
146
+ readonly cu: 1;
147
+ readonly l: 1;
148
+ readonly globalSettings: 1;
149
+ readonly currentUserMPID: 1;
150
+ };
151
+ readonly HTTPCodes: {
152
+ readonly noHttpCoverage: -1;
153
+ readonly activeIdentityRequest: -2;
154
+ readonly activeSession: -3;
155
+ readonly validationIssue: -4;
156
+ readonly nativeIdentityRequest: -5;
157
+ readonly loggingDisabledOrMissingAPIKey: -6;
158
+ readonly tooManyRequests: 429;
159
+ };
160
+ readonly FeatureFlags: {
161
+ readonly ReportBatching: "reportBatching";
162
+ readonly EventBatchingIntervalMillis: "eventBatchingIntervalMillis";
163
+ readonly OfflineStorage: "offlineStorage";
164
+ readonly DirectUrlRouting: "directURLRouting";
165
+ readonly CacheIdentity: "cacheIdentity";
166
+ readonly AudienceAPI: "audienceAPI";
167
+ readonly CaptureIntegrationSpecificIds: "captureIntegrationSpecificIds";
168
+ readonly CaptureIntegrationSpecificIdsV2: "captureIntegrationSpecificIdsV2";
169
+ readonly AstBackgroundEvents: "astBackgroundEvents";
170
+ };
171
+ readonly DefaultInstance: "default_instance";
172
+ readonly CCPAPurpose: "data_sale_opt_out";
173
+ readonly IdentityMethods: {
174
+ readonly Modify: "modify";
175
+ readonly Logout: "logout";
176
+ readonly Login: "login";
177
+ readonly Identify: "identify";
178
+ };
179
+ readonly Environment: {
180
+ readonly Development: "development";
181
+ readonly Production: "production";
182
+ };
183
+ readonly CaptureIntegrationSpecificIdsV2Modes: {
184
+ readonly All: "all";
185
+ readonly None: "none";
186
+ readonly RoktOnly: "roktonly";
187
+ };
188
+ readonly Rokt: {
189
+ readonly LauncherInstanceGuidKey: "__rokt_li_guid__";
190
+ };
191
+ };
192
+ export default Constants;
193
+ export declare const ONE_DAY_IN_SECONDS: number;
194
+ export declare const MILLIS_IN_ONE_SEC = 1000;
195
+ export declare const HTTP_OK: 200;
196
+ export declare const HTTP_ACCEPTED: 202;
197
+ export declare const HTTP_BAD_REQUEST: 400;
198
+ export declare const HTTP_UNAUTHORIZED: 401;
199
+ export declare const HTTP_FORBIDDEN: 403;
200
+ export declare const HTTP_NOT_FOUND: 404;
201
+ export declare const HTTP_SERVER_ERROR: 500;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Cookie consent flags control SDK behavior based on user consent preferences for Rokt integration.
3
+ * @see https://docs.rokt.com/developers/integration-guides/web/cookie-consent-flags/
4
+ */
5
+ export interface ICookieConsentFlags {
6
+ /**
7
+ * When true, indicates the user has opted out of functional cookies/tracking.
8
+ * Default: false (functional tracking is allowed)
9
+ */
10
+ noFunctional: boolean;
11
+ /**
12
+ * When true, indicates the user has opted out of targeting cookies/tracking.
13
+ * This flag is used to block cookie syncs and other targeting-related features.
14
+ * Default: false (targeting is allowed)
15
+ */
16
+ noTargeting: boolean;
17
+ }
18
+ export interface ICookieConsentManager {
19
+ /**
20
+ * Targeting is allowed when noTargeting is false (default)
21
+ */
22
+ getNoTargeting: () => boolean;
23
+ /**
24
+ * Functional tracking is allowed when noFunctional is false (default)
25
+ */
26
+ getNoFunctional: () => boolean;
27
+ }
28
+ /**
29
+ * CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
30
+ * that are passed via launcherOptions during SDK initialization.
31
+ *
32
+ * These flags allow Rokt integration to respect user privacy choices.
33
+ *
34
+ * Default behavior: Both flags default to false, meaning all features are allowed
35
+ * unless explicitly opted out by the user.
36
+ */
37
+ export default class CookieConsentManager implements ICookieConsentManager {
38
+ private flags;
39
+ constructor(flags: ICookieConsentFlags);
40
+ /**
41
+ * Returns true if third-party targeting is disabled.
42
+ * Targeting is allowed when noTargeting is false (default).
43
+ */
44
+ getNoTargeting(): boolean;
45
+ /**
46
+ * Returns true if functional tracking is disabled.
47
+ * Functional tracking is allowed when noFunctional is false (default).
48
+ */
49
+ getNoFunctional(): boolean;
50
+ }
@@ -0,0 +1,34 @@
1
+ import { Dictionary } from './utils';
2
+ import { MPID } from '@mparticle/web-sdk';
3
+ import { IConsentRules } from './consent';
4
+ import { IMParticleWebSDKInstance } from './mp-instance';
5
+ export declare const DAYS_IN_MILLISECONDS: number;
6
+ export declare const PARTNER_MODULE_IDS: {
7
+ readonly AdobeEventForwarder: 11;
8
+ readonly DoubleclickDFP: 41;
9
+ readonly AppNexus: 50;
10
+ readonly Lotame: 58;
11
+ readonly TradeDesk: 103;
12
+ readonly VerizonMedia: 155;
13
+ readonly Rokt: 1277;
14
+ };
15
+ export type CookieSyncDates = Dictionary<number>;
16
+ export interface IPixelConfiguration {
17
+ name?: string;
18
+ moduleId: number;
19
+ esId?: number;
20
+ isDebug?: boolean;
21
+ isProduction?: boolean;
22
+ settings: Dictionary<string>;
23
+ frequencyCap: number;
24
+ pixelUrl: string;
25
+ redirectUrl: string;
26
+ filteringConsentRuleValues?: IConsentRules;
27
+ }
28
+ export interface ICookieSyncManager {
29
+ attemptCookieSync: (mpid: MPID, mpidIsNotInCookies?: boolean) => void;
30
+ performCookieSync: (url: string, moduleId: string, mpid: MPID, cookieSyncDates: CookieSyncDates) => void;
31
+ combineUrlWithRedirect: (mpid: MPID, pixelUrl: string, redirectUrl: string) => string;
32
+ }
33
+ export default function CookieSyncManager(this: ICookieSyncManager, mpInstance: IMParticleWebSDKInstance): void;
34
+ export declare const isLastSyncDateExpired: (frequencyCap: number, lastSyncDate?: number) => boolean;