@mparticle/web-sdk 2.80.0 → 2.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +75 -488
- package/dist/mparticle.esm.js +75 -488
- package/dist/mparticle.js +244 -673
- package/dist/types/src/configAPIClient.d.ts +1 -0
- package/dist/types/src/ecommerce.d.ts +3 -53
- package/dist/types/src/ecommerce.interfaces.d.ts +11 -12
- package/dist/types/src/events.interfaces.d.ts +1 -1
- package/dist/types/src/forwarders.d.ts +4 -26
- package/dist/types/src/forwarders.interfaces.d.ts +41 -10
- package/dist/types/src/identity-utils.d.ts +3 -3
- package/dist/types/src/identity.d.ts +3 -0
- package/dist/types/src/identity.interfaces.d.ts +45 -11
- package/dist/types/src/identityApiClient.d.ts +5 -4
- package/dist/types/src/mp-instance.d.ts +2 -2
- package/dist/types/src/persistence.interfaces.d.ts +2 -3
- package/dist/types/src/roktManager.d.ts +18 -0
- package/dist/types/src/sdkRuntimeModels.d.ts +2 -2
- package/dist/types/src/store.d.ts +4 -3
- package/package.json +1 -1
- package/src/configAPIClient.ts +1 -0
- package/src/ecommerce.interfaces.ts +12 -21
- package/src/{ecommerce.js → ecommerce.ts} +144 -73
- package/src/events.interfaces.ts +1 -1
- package/src/events.ts +1 -1
- package/src/forwarders.interfaces.ts +73 -10
- package/src/{forwarders.js → forwarders.ts} +214 -176
- package/src/helpers.ts +7 -3
- package/src/identity-utils.ts +2 -2
- package/src/identity.interfaces.ts +58 -14
- package/src/{identity.js → identity.ts} +237 -192
- package/src/identityApiClient.ts +9 -9
- package/src/mp-instance.ts +2 -2
- package/src/persistence.interfaces.ts +2 -3
- package/src/roktManager.ts +37 -0
- package/src/sdkRuntimeModels.ts +2 -1
- package/src/store.ts +4 -3
package/src/identityApiClient.ts
CHANGED
|
@@ -5,19 +5,19 @@ import {
|
|
|
5
5
|
XHRUploader,
|
|
6
6
|
IFetchPayload,
|
|
7
7
|
} from './uploaders';
|
|
8
|
-
import { CACHE_HEADER } from './identity-utils';
|
|
8
|
+
import { CACHE_HEADER, IKnownIdentities } from './identity-utils';
|
|
9
9
|
import { obfuscateData, parseNumber, valueof, getErrorMessage } from './utils';
|
|
10
10
|
import {
|
|
11
11
|
IAliasCallback,
|
|
12
|
-
|
|
12
|
+
IAliasNetworkRequest,
|
|
13
13
|
IdentityAPIMethod,
|
|
14
14
|
IIdentity,
|
|
15
15
|
IIdentityAPIRequestData,
|
|
16
|
+
IIdentityAPIModifyRequestData,
|
|
16
17
|
} from './identity.interfaces';
|
|
17
18
|
import {
|
|
18
19
|
IdentityApiData,
|
|
19
20
|
MPID,
|
|
20
|
-
UserIdentities,
|
|
21
21
|
} from '@mparticle/web-sdk';
|
|
22
22
|
import {
|
|
23
23
|
IdentityCallback,
|
|
@@ -33,17 +33,17 @@ const { Modify } = IdentityMethods;
|
|
|
33
33
|
|
|
34
34
|
export interface IIdentityApiClient {
|
|
35
35
|
sendAliasRequest: (
|
|
36
|
-
aliasRequest:
|
|
36
|
+
aliasRequest: IAliasNetworkRequest,
|
|
37
37
|
aliasCallback: IAliasCallback
|
|
38
38
|
) => Promise<void>;
|
|
39
39
|
sendIdentityRequest: (
|
|
40
|
-
identityApiRequest: IIdentityAPIRequestData,
|
|
40
|
+
identityApiRequest: IIdentityAPIRequestData | IIdentityAPIModifyRequestData,
|
|
41
41
|
method: IdentityAPIMethod,
|
|
42
42
|
callback: IdentityCallback,
|
|
43
43
|
originalIdentityApiData: IdentityApiData,
|
|
44
44
|
parseIdentityResponse: IIdentity['parseIdentityResponse'],
|
|
45
45
|
mpid: MPID,
|
|
46
|
-
knownIdentities
|
|
46
|
+
knownIdentities?: IKnownIdentities
|
|
47
47
|
) => Promise<void>;
|
|
48
48
|
getUploadUrl: (method: IdentityAPIMethod, mpid: MPID) => string;
|
|
49
49
|
getIdentityResponseFromFetch: (
|
|
@@ -86,7 +86,7 @@ export default function IdentityAPIClient(
|
|
|
86
86
|
mpInstance: IMParticleWebSDKInstance
|
|
87
87
|
) {
|
|
88
88
|
this.sendAliasRequest = async function(
|
|
89
|
-
aliasRequest:
|
|
89
|
+
aliasRequest: IAliasNetworkRequest,
|
|
90
90
|
aliasCallback: IAliasCallback
|
|
91
91
|
) {
|
|
92
92
|
const { Logger } = mpInstance;
|
|
@@ -186,13 +186,13 @@ export default function IdentityAPIClient(
|
|
|
186
186
|
};
|
|
187
187
|
|
|
188
188
|
this.sendIdentityRequest = async function(
|
|
189
|
-
identityApiRequest: IIdentityAPIRequestData,
|
|
189
|
+
identityApiRequest: IIdentityAPIRequestData | IIdentityAPIModifyRequestData,
|
|
190
190
|
method: IdentityAPIMethod,
|
|
191
191
|
callback: IdentityCallback,
|
|
192
192
|
originalIdentityApiData: IdentityApiData,
|
|
193
193
|
parseIdentityResponse: IIdentity['parseIdentityResponse'],
|
|
194
194
|
mpid: MPID,
|
|
195
|
-
knownIdentities
|
|
195
|
+
knownIdentities?: IKnownIdentities
|
|
196
196
|
) {
|
|
197
197
|
if (mpInstance._RoktManager?.isInitialized) {
|
|
198
198
|
mpInstance._Store.identifyRequestCount = (mpInstance._Store.identifyRequestCount || 0) + 1;
|
package/src/mp-instance.ts
CHANGED
|
@@ -37,7 +37,7 @@ import Identity from './identity';
|
|
|
37
37
|
import Consent, { IConsent } from './consent';
|
|
38
38
|
import KitBlocker from './kitBlocking';
|
|
39
39
|
import ConfigAPIClient, { IKitConfigs } from './configAPIClient';
|
|
40
|
-
import IdentityAPIClient from './identityApiClient';
|
|
40
|
+
import IdentityAPIClient, { IIdentityApiClient } from './identityApiClient';
|
|
41
41
|
import { isFunction, parseConfig, valueof, generateDeprecationMessage, extend } from './utils';
|
|
42
42
|
import { DisabledVault, LocalStorageVault } from './vault';
|
|
43
43
|
import { removeExpiredIdentityCacheDates, hasExplicitIdentifier } from './identity-utils';
|
|
@@ -92,7 +92,7 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
|
|
|
92
92
|
_ForwardingStatsUploader: IForwardingStatsUploader;
|
|
93
93
|
_Helpers: SDKHelpersApi;
|
|
94
94
|
_Identity: IIdentity;
|
|
95
|
-
_IdentityAPIClient:
|
|
95
|
+
_IdentityAPIClient: IIdentityApiClient;
|
|
96
96
|
_IntegrationCapture: IntegrationCapture;
|
|
97
97
|
_NativeSdkHelpers: INativeSdkHelpers;
|
|
98
98
|
_PageViewTracker?: PageViewTracker;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Context } from '@mparticle/event-models';
|
|
2
1
|
import {
|
|
3
2
|
IdentityApiData,
|
|
4
3
|
MPID,
|
|
@@ -34,7 +33,7 @@ export interface IGlobalStoreV2MinifiedKeys {
|
|
|
34
33
|
cgid: string; // Client Generated ID
|
|
35
34
|
das: string; // Device ID/ Device Application String
|
|
36
35
|
ia: IntegrationAttributes;
|
|
37
|
-
c:
|
|
36
|
+
c: string | null;
|
|
38
37
|
csm: MPID[]; // Current Session MPIDs
|
|
39
38
|
les: number; // Last Event Sent Timestamp
|
|
40
39
|
ssd: number; // Session Start Date
|
|
@@ -118,7 +117,7 @@ export interface IPersistence {
|
|
|
118
117
|
getCookieDomain(): string;
|
|
119
118
|
getDomain(doc: Document, locationHostname: string): string;
|
|
120
119
|
saveUserCookieSyncDatesToPersistence(mpid: MPID, csd: CookieSyncDates): void;
|
|
121
|
-
savePersistence(
|
|
120
|
+
savePersistence(persistence: IPersistenceMinified): void;
|
|
122
121
|
getPersistence(): IPersistenceMinified | null;
|
|
123
122
|
getFirstSeenTime(mpid: MPID): number | null;
|
|
124
123
|
setFirstSeenTime(mpid: MPID, time?: number): void;
|
package/src/roktManager.ts
CHANGED
|
@@ -83,6 +83,9 @@ export interface IRoktKit {
|
|
|
83
83
|
setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
|
|
84
84
|
use: <T>(name: string) => Promise<T>;
|
|
85
85
|
onShoppableAdsReady(callback: () => void): void;
|
|
86
|
+
// Optional because the Rokt Kit ships on its own release cadence; a kit
|
|
87
|
+
// published before terminate() existed will not implement it.
|
|
88
|
+
terminate?: () => Promise<void>;
|
|
86
89
|
launcherOptions?: Dictionary<any>;
|
|
87
90
|
settings?: IRoktKitSettings;
|
|
88
91
|
integrationName?: string;
|
|
@@ -479,6 +482,40 @@ export default class RoktManager {
|
|
|
479
482
|
}
|
|
480
483
|
}
|
|
481
484
|
|
|
485
|
+
/**
|
|
486
|
+
* Tears down the current Rokt launcher and removes the placements it rendered.
|
|
487
|
+
*
|
|
488
|
+
* Intended for hosts that cannot simply destroy the container element —
|
|
489
|
+
* SPA route changes and confirmation pages, for example.
|
|
490
|
+
*
|
|
491
|
+
* Unlike the other proxied methods, a call made before the kit is ready is
|
|
492
|
+
* *not* queued. Replaying a teardown against a launcher created later would
|
|
493
|
+
* silently tear down placements the caller never asked to remove; with no
|
|
494
|
+
* launcher there is nothing to terminate, so this resolves as a no-op.
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* await window.mParticle.Rokt.terminate();
|
|
498
|
+
*
|
|
499
|
+
* @returns {Promise<void>} Resolves once the launcher has torn down. Never rejects.
|
|
500
|
+
*/
|
|
501
|
+
public async terminate(): Promise<void> {
|
|
502
|
+
if (!this.isReady()) {
|
|
503
|
+
this.logger?.verbose('mParticle.Rokt.terminate called before the Rokt kit was ready. Nothing to terminate.');
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if (!isFunction(this.kit.terminate)) {
|
|
508
|
+
this.logger?.error('mParticle.Rokt.terminate is not supported by the attached Rokt Kit version.');
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
try {
|
|
513
|
+
await this.kit.terminate();
|
|
514
|
+
} catch (error) {
|
|
515
|
+
this.logger?.error(`Failed to terminate the Rokt launcher: ${getErrorMessage(error)}`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
482
519
|
public onShoppableAdsReady(callback: () => void): void {
|
|
483
520
|
if (!this.kit || !this.isShoppableAdsLoaded) {
|
|
484
521
|
this.deferredCall<void>('onShoppableAdsReady', callback);
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
SDKEventOptions,
|
|
7
7
|
SDKEventAttrs,
|
|
8
8
|
Callback,
|
|
9
|
+
UserIdentities,
|
|
9
10
|
} from '@mparticle/web-sdk';
|
|
10
11
|
import {
|
|
11
12
|
IntegrationAttribute,
|
|
@@ -393,7 +394,7 @@ export interface SDKHelpersApi {
|
|
|
393
394
|
filterList: number[]
|
|
394
395
|
): Dictionary;
|
|
395
396
|
filterUserIdentities?(
|
|
396
|
-
userIdentitiesObject: Dictionary<string>,
|
|
397
|
+
userIdentitiesObject: UserIdentities | Dictionary<string>,
|
|
397
398
|
filterList: number[]
|
|
398
399
|
): ISDKUserIdentity[];
|
|
399
400
|
invokeAliasCallback(
|
package/src/store.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Batch
|
|
1
|
+
import { Batch } from '@mparticle/event-models';
|
|
2
2
|
import {
|
|
3
3
|
DataPlanConfig,
|
|
4
4
|
MPID,
|
|
@@ -160,6 +160,7 @@ export interface IFeatureFlags {
|
|
|
160
160
|
export interface IStore {
|
|
161
161
|
isEnabled: boolean;
|
|
162
162
|
isInitialized: boolean;
|
|
163
|
+
mpid: MPID;
|
|
163
164
|
|
|
164
165
|
// Session Attributes are persistent attributes that are tied to the current session and
|
|
165
166
|
// are uploaded then cleared when the session ends.
|
|
@@ -186,7 +187,7 @@ export interface IStore {
|
|
|
186
187
|
eventQueue: SDKEvent[];
|
|
187
188
|
currencyCode: string | null;
|
|
188
189
|
globalTimer: number | null;
|
|
189
|
-
context:
|
|
190
|
+
context: string | null;
|
|
190
191
|
configurationLoaded: boolean;
|
|
191
192
|
identityCallInFlight: boolean;
|
|
192
193
|
identityCallFailed: boolean;
|
|
@@ -204,7 +205,7 @@ export interface IStore {
|
|
|
204
205
|
activeForwarders: ConfiguredKit[];
|
|
205
206
|
kits: Dictionary<MPForwarder>;
|
|
206
207
|
sideloadedKits: MPForwarder[];
|
|
207
|
-
configuredForwarders:
|
|
208
|
+
configuredForwarders: ConfiguredKit[];
|
|
208
209
|
pixelConfigurations: IPixelConfiguration[];
|
|
209
210
|
integrationDelayTimeoutStart: number; // UNIX Timestamp
|
|
210
211
|
webviewBridgeEnabled?: boolean;
|