@mparticle/web-sdk 2.79.0 → 2.79.2
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 +21 -10
- package/dist/mparticle.esm.js +21 -10
- package/dist/mparticle.js +198 -65
- package/dist/types/src/ecommerce.interfaces.d.ts +8 -7
- package/dist/types/src/events.d.ts +3 -18
- package/dist/types/src/events.interfaces.d.ts +2 -2
- package/dist/types/src/helpers.d.ts +3 -54
- package/dist/types/src/pageViewTracker.d.ts +14 -1
- package/dist/types/src/polyfill.d.ts +13 -14
- package/dist/types/src/sdkRuntimeModels.d.ts +10 -3
- package/dist/types/src/store.d.ts +1 -0
- package/package.json +1 -1
- package/src/ecommerce.interfaces.ts +12 -8
- package/src/events.interfaces.ts +3 -3
- package/src/{events.js → events.ts} +152 -82
- package/src/{helpers.js → helpers.ts} +117 -63
- package/src/mp-instance.ts +32 -2
- package/src/pageViewTracker.ts +162 -47
- package/src/{polyfill.js → polyfill.ts} +36 -36
- package/src/sdkRuntimeModels.ts +19 -3
- package/src/store.ts +1 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Base64 encoder/decoder - http://www.webtoolkit.info/javascript_base64.html
|
|
2
|
-
|
|
2
|
+
const Base64 = {
|
|
3
3
|
_keyStr:
|
|
4
4
|
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',
|
|
5
5
|
|
|
6
6
|
// Input must be a string
|
|
7
|
-
encode: function encode(input) {
|
|
7
|
+
encode: function encode(input: string): string {
|
|
8
8
|
try {
|
|
9
9
|
if (window.btoa && window.atob) {
|
|
10
10
|
return window.btoa(unescape(encodeURIComponent(input)));
|
|
@@ -15,10 +15,10 @@ var Base64 = {
|
|
|
15
15
|
return this._encode(input);
|
|
16
16
|
},
|
|
17
17
|
|
|
18
|
-
_encode: function _encode(input) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
_encode: function _encode(input: string): string {
|
|
19
|
+
let output = '';
|
|
20
|
+
let chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
|
21
|
+
let i = 0;
|
|
22
22
|
|
|
23
23
|
input = UTF8.encode(input);
|
|
24
24
|
|
|
@@ -48,7 +48,7 @@ var Base64 = {
|
|
|
48
48
|
return output;
|
|
49
49
|
},
|
|
50
50
|
|
|
51
|
-
decode: function decode(input) {
|
|
51
|
+
decode: function decode(input: string): string {
|
|
52
52
|
try {
|
|
53
53
|
if (window.btoa && window.atob) {
|
|
54
54
|
return decodeURIComponent(escape(window.atob(input)));
|
|
@@ -59,11 +59,11 @@ var Base64 = {
|
|
|
59
59
|
return Base64._decode(input);
|
|
60
60
|
},
|
|
61
61
|
|
|
62
|
-
_decode: function _decode(input) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
_decode: function _decode(input: string): string {
|
|
63
|
+
let output = '';
|
|
64
|
+
let chr1, chr2, chr3;
|
|
65
|
+
let enc1, enc2, enc3, enc4;
|
|
66
|
+
let i = 0;
|
|
67
67
|
|
|
68
68
|
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
|
|
69
69
|
|
|
@@ -91,12 +91,12 @@ var Base64 = {
|
|
|
91
91
|
},
|
|
92
92
|
};
|
|
93
93
|
|
|
94
|
-
|
|
95
|
-
encode: function encode(s) {
|
|
96
|
-
|
|
94
|
+
const UTF8 = {
|
|
95
|
+
encode: function encode(s: string): string {
|
|
96
|
+
let utftext = '';
|
|
97
97
|
|
|
98
|
-
for (
|
|
99
|
-
|
|
98
|
+
for (let n = 0; n < s.length; n++) {
|
|
99
|
+
const c = s.charCodeAt(n);
|
|
100
100
|
|
|
101
101
|
if (c < 128) {
|
|
102
102
|
utftext += String.fromCharCode(c);
|
|
@@ -112,10 +112,10 @@ var UTF8 = {
|
|
|
112
112
|
return utftext;
|
|
113
113
|
},
|
|
114
114
|
|
|
115
|
-
decode: function decode(utftext) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
decode: function decode(utftext: string): string {
|
|
116
|
+
let s = '';
|
|
117
|
+
let i = 0;
|
|
118
|
+
let c = 0,
|
|
119
119
|
c1 = 0,
|
|
120
120
|
c2 = 0;
|
|
121
121
|
|
|
@@ -146,14 +146,14 @@ export default {
|
|
|
146
146
|
// Production steps of ECMA-262, Edition 5, 15.4.4.18
|
|
147
147
|
// Reference: http://es5.github.io/#x15.4.4.18
|
|
148
148
|
forEach: function(callback, thisArg) {
|
|
149
|
-
|
|
149
|
+
let T, k;
|
|
150
150
|
|
|
151
151
|
if (this == null) {
|
|
152
152
|
throw new TypeError(' this is null or not defined');
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
const O = Object(this);
|
|
156
|
+
const len = O.length >>> 0;
|
|
157
157
|
|
|
158
158
|
if (typeof callback !== 'function') {
|
|
159
159
|
throw new TypeError(callback + ' is not a function');
|
|
@@ -166,7 +166,7 @@ export default {
|
|
|
166
166
|
k = 0;
|
|
167
167
|
|
|
168
168
|
while (k < len) {
|
|
169
|
-
|
|
169
|
+
let kValue;
|
|
170
170
|
if (k in O) {
|
|
171
171
|
kValue = O[k];
|
|
172
172
|
callback.call(T, kValue, k, O);
|
|
@@ -179,14 +179,14 @@ export default {
|
|
|
179
179
|
// Production steps of ECMA-262, Edition 5, 15.4.4.19
|
|
180
180
|
// Reference: http://es5.github.io/#x15.4.4.19
|
|
181
181
|
map: function(callback, thisArg) {
|
|
182
|
-
|
|
182
|
+
let T, A, k;
|
|
183
183
|
|
|
184
184
|
if (this === null) {
|
|
185
185
|
throw new TypeError(' this is null or not defined');
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
|
|
188
|
+
const O = Object(this);
|
|
189
|
+
const len = O.length >>> 0;
|
|
190
190
|
|
|
191
191
|
if (typeof callback !== 'function') {
|
|
192
192
|
throw new TypeError(callback + ' is not a function');
|
|
@@ -201,7 +201,7 @@ export default {
|
|
|
201
201
|
k = 0;
|
|
202
202
|
|
|
203
203
|
while (k < len) {
|
|
204
|
-
|
|
204
|
+
let kValue, mappedValue;
|
|
205
205
|
if (k in O) {
|
|
206
206
|
kValue = O[k];
|
|
207
207
|
mappedValue = callback.call(T, kValue, k, O);
|
|
@@ -223,17 +223,17 @@ export default {
|
|
|
223
223
|
throw new TypeError();
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
const t = Object(this);
|
|
227
|
+
const len = t.length >>> 0;
|
|
228
228
|
if (typeof fun !== 'function') {
|
|
229
229
|
throw new TypeError();
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
for (
|
|
232
|
+
const res = [];
|
|
233
|
+
const thisArg = arguments.length >= 2 ? arguments[1] : void 0;
|
|
234
|
+
for (let i = 0; i < len; i++) {
|
|
235
235
|
if (i in t) {
|
|
236
|
-
|
|
236
|
+
const val = t[i];
|
|
237
237
|
if (fun.call(thisArg, val, i, t)) {
|
|
238
238
|
res.push(val);
|
|
239
239
|
}
|
|
@@ -244,7 +244,7 @@ export default {
|
|
|
244
244
|
},
|
|
245
245
|
|
|
246
246
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
247
|
-
isArray: function(arg) {
|
|
247
|
+
isArray: function(arg: unknown): boolean {
|
|
248
248
|
return Object.prototype.toString.call(arg) === '[object Array]';
|
|
249
249
|
},
|
|
250
250
|
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -265,7 +265,7 @@ export interface MParticleWebSDK {
|
|
|
265
265
|
startTrackingLocation(callback?: Callback): void;
|
|
266
266
|
|
|
267
267
|
stopTrackingLocation(): void;
|
|
268
|
-
generateHash(value: string):
|
|
268
|
+
generateHash(value: string): number;
|
|
269
269
|
setIntegrationAttribute(
|
|
270
270
|
integrationModuleId: number,
|
|
271
271
|
attrs: IntegrationAttribute
|
|
@@ -375,13 +375,29 @@ export interface SDKHelpersApi {
|
|
|
375
375
|
findKeyInObject?(obj: any, key: string): string;
|
|
376
376
|
parseNumber?(value: string | number): number;
|
|
377
377
|
generateUniqueId();
|
|
378
|
-
generateHash?(value: string):
|
|
378
|
+
generateHash?(value: string): number;
|
|
379
379
|
// https://go.mparticle.com/work/SQDSDKS-6317
|
|
380
380
|
getFeatureFlag?(feature: string): boolean | string; // TODO: Feature Constants should be converted to enum
|
|
381
|
+
decoded?(s: string): string;
|
|
382
|
+
parseStringOrNumber?(value: string | number): string | number | null;
|
|
383
|
+
inArray?(items: any[], value: any): boolean;
|
|
384
|
+
converted?(s: string): string;
|
|
385
|
+
filterUserIdentitiesForForwarders?(
|
|
386
|
+
userIdentities: Dictionary,
|
|
387
|
+
filterList: number[]
|
|
388
|
+
): Dictionary;
|
|
389
|
+
filterUserAttributes?(
|
|
390
|
+
userAttributes: Dictionary,
|
|
391
|
+
filterList: number[]
|
|
392
|
+
): Dictionary;
|
|
393
|
+
filterUserIdentities?(
|
|
394
|
+
userIdentitiesObject: Dictionary<string>,
|
|
395
|
+
filterList: number[]
|
|
396
|
+
): ISDKUserIdentity[];
|
|
381
397
|
invokeAliasCallback(
|
|
382
398
|
aliasCallback: IAliasCallback,
|
|
383
399
|
number: number,
|
|
384
|
-
errorMessage
|
|
400
|
+
errorMessage?: string
|
|
385
401
|
): void;
|
|
386
402
|
isDelayedByIntegration?(
|
|
387
403
|
delayedIntegrations: Dictionary<boolean>,
|