@ninetailed/experience.js 2.2.9-beta.0 → 3.0.1-beta.4
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/index.d.ts +0 -2
- package/index.esm.js +481 -725
- package/index.umd.js +282 -698
- package/lib/Ninetailed.d.ts +5 -6
- package/lib/analytics/constants.d.ts +4 -0
- package/lib/analytics/get-analytics-plugin.d.ts +0 -6
- package/lib/analytics/index.d.ts +0 -1
- package/lib/experience/selectVariant.d.ts +1 -1
- package/lib/utils/asyncThrottle.d.ts +6 -0
- package/package.json +6 -6
- package/lib/analytics/Cache/cache.d.ts +0 -11
- package/lib/analytics/Cache/index.d.ts +0 -1
- package/lib/analytics/utility/apiClient.d.ts +0 -23
- package/lib/analytics/utility/index.d.ts +0 -1
- package/lib/logger/ConsoleLogSink.d.ts +0 -10
- package/lib/logger/LogSink.d.ts +0 -10
- package/lib/logger/Logger.d.ts +0 -17
- package/lib/logger/OnErrorLogSink.d.ts +0 -10
- package/lib/logger/OnLogLogSink.d.ts +0 -12
- package/lib/logger/index.d.ts +0 -7
package/index.umd.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'lodash/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Javascript = {}, global.
|
|
5
|
-
})(this, (function (exports,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash/unionBy'), require('@ninetailed/experience.js-shared'), require('analytics'), require('lodash/flatten'), require('lodash/find'), require('lodash/includes'), require('lodash/pickBy'), require('murmurhash-js')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'lodash/unionBy', '@ninetailed/experience.js-shared', 'analytics', 'lodash/flatten', 'lodash/find', 'lodash/includes', 'lodash/pickBy', 'murmurhash-js'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Javascript = {}, global.unionBy, global.experience_jsShared, global.Analytics, global.flatten, global.find, global.includes, global.pickBy, global.murmurhashJs));
|
|
5
|
+
})(this, (function (exports, unionBy, experience_jsShared, Analytics, flatten, find, includes, pickBy, murmurhashJs) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
9
|
-
var get__default = /*#__PURE__*/_interopDefaultLegacy(get$2);
|
|
10
9
|
var unionBy__default = /*#__PURE__*/_interopDefaultLegacy(unionBy);
|
|
11
10
|
var Analytics__default = /*#__PURE__*/_interopDefaultLegacy(Analytics);
|
|
12
11
|
var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
|
|
@@ -95,32 +94,32 @@
|
|
|
95
94
|
var FunctionPrototype$2 = Function.prototype;
|
|
96
95
|
var bind$5 = FunctionPrototype$2.bind;
|
|
97
96
|
var call$d = FunctionPrototype$2.call;
|
|
98
|
-
var uncurryThis$
|
|
97
|
+
var uncurryThis$o = NATIVE_BIND$2 && bind$5.bind(call$d, call$d);
|
|
99
98
|
|
|
100
99
|
var functionUncurryThis = NATIVE_BIND$2 ? function (fn) {
|
|
101
|
-
return fn && uncurryThis$
|
|
100
|
+
return fn && uncurryThis$o(fn);
|
|
102
101
|
} : function (fn) {
|
|
103
102
|
return fn && function () {
|
|
104
103
|
return call$d.apply(fn, arguments);
|
|
105
104
|
};
|
|
106
105
|
};
|
|
107
106
|
|
|
108
|
-
var uncurryThis$
|
|
107
|
+
var uncurryThis$n = functionUncurryThis;
|
|
109
108
|
|
|
110
|
-
var toString$
|
|
111
|
-
var stringSlice$6 = uncurryThis$
|
|
109
|
+
var toString$a = uncurryThis$n({}.toString);
|
|
110
|
+
var stringSlice$6 = uncurryThis$n(''.slice);
|
|
112
111
|
|
|
113
112
|
var classofRaw$1 = function (it) {
|
|
114
|
-
return stringSlice$6(toString$
|
|
113
|
+
return stringSlice$6(toString$a(it), 8, -1);
|
|
115
114
|
};
|
|
116
115
|
|
|
117
116
|
var global$H = global$I;
|
|
118
|
-
var uncurryThis$
|
|
117
|
+
var uncurryThis$m = functionUncurryThis;
|
|
119
118
|
var fails$f = fails$i;
|
|
120
119
|
var classof$7 = classofRaw$1;
|
|
121
120
|
|
|
122
121
|
var Object$4 = global$H.Object;
|
|
123
|
-
var split = uncurryThis$
|
|
122
|
+
var split = uncurryThis$m(''.split);
|
|
124
123
|
|
|
125
124
|
// fallback for non-array-like ES3 and non-enumerable old V8 strings
|
|
126
125
|
var indexedObject = fails$f(function () {
|
|
@@ -137,17 +136,17 @@
|
|
|
137
136
|
|
|
138
137
|
// `RequireObjectCoercible` abstract operation
|
|
139
138
|
// https://tc39.es/ecma262/#sec-requireobjectcoercible
|
|
140
|
-
var requireObjectCoercible$
|
|
139
|
+
var requireObjectCoercible$8 = function (it) {
|
|
141
140
|
if (it == undefined) throw TypeError$h("Can't call method on " + it);
|
|
142
141
|
return it;
|
|
143
142
|
};
|
|
144
143
|
|
|
145
144
|
// toObject with fallback for non-array-like ES3 strings
|
|
146
145
|
var IndexedObject$2 = indexedObject;
|
|
147
|
-
var requireObjectCoercible$
|
|
146
|
+
var requireObjectCoercible$7 = requireObjectCoercible$8;
|
|
148
147
|
|
|
149
148
|
var toIndexedObject$4 = function (it) {
|
|
150
|
-
return IndexedObject$2(requireObjectCoercible$
|
|
149
|
+
return IndexedObject$2(requireObjectCoercible$7(it));
|
|
151
150
|
};
|
|
152
151
|
|
|
153
152
|
// `IsCallable` abstract operation
|
|
@@ -173,9 +172,9 @@
|
|
|
173
172
|
return arguments.length < 2 ? aFunction(global$F[namespace]) : global$F[namespace] && global$F[namespace][method];
|
|
174
173
|
};
|
|
175
174
|
|
|
176
|
-
var uncurryThis$
|
|
175
|
+
var uncurryThis$l = functionUncurryThis;
|
|
177
176
|
|
|
178
|
-
var objectIsPrototypeOf = uncurryThis$
|
|
177
|
+
var objectIsPrototypeOf = uncurryThis$l({}.isPrototypeOf);
|
|
179
178
|
|
|
180
179
|
var getBuiltIn$6 = getBuiltIn$7;
|
|
181
180
|
|
|
@@ -333,20 +332,20 @@
|
|
|
333
332
|
});
|
|
334
333
|
|
|
335
334
|
var global$x = global$I;
|
|
336
|
-
var requireObjectCoercible$
|
|
335
|
+
var requireObjectCoercible$6 = requireObjectCoercible$8;
|
|
337
336
|
|
|
338
337
|
var Object$2 = global$x.Object;
|
|
339
338
|
|
|
340
339
|
// `ToObject` abstract operation
|
|
341
340
|
// https://tc39.es/ecma262/#sec-toobject
|
|
342
341
|
var toObject$4 = function (argument) {
|
|
343
|
-
return Object$2(requireObjectCoercible$
|
|
342
|
+
return Object$2(requireObjectCoercible$6(argument));
|
|
344
343
|
};
|
|
345
344
|
|
|
346
|
-
var uncurryThis$
|
|
345
|
+
var uncurryThis$k = functionUncurryThis;
|
|
347
346
|
var toObject$3 = toObject$4;
|
|
348
347
|
|
|
349
|
-
var hasOwnProperty = uncurryThis$
|
|
348
|
+
var hasOwnProperty = uncurryThis$k({}.hasOwnProperty);
|
|
350
349
|
|
|
351
350
|
// `HasOwnProperty` abstract operation
|
|
352
351
|
// https://tc39.es/ecma262/#sec-hasownproperty
|
|
@@ -354,14 +353,14 @@
|
|
|
354
353
|
return hasOwnProperty(toObject$3(it), key);
|
|
355
354
|
};
|
|
356
355
|
|
|
357
|
-
var uncurryThis$
|
|
356
|
+
var uncurryThis$j = functionUncurryThis;
|
|
358
357
|
|
|
359
358
|
var id = 0;
|
|
360
359
|
var postfix = Math.random();
|
|
361
|
-
var toString$
|
|
360
|
+
var toString$9 = uncurryThis$j(1.0.toString);
|
|
362
361
|
|
|
363
362
|
var uid$2 = function (key) {
|
|
364
|
-
return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$
|
|
363
|
+
return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$9(++id + postfix, 36);
|
|
365
364
|
};
|
|
366
365
|
|
|
367
366
|
var global$w = global$I;
|
|
@@ -557,11 +556,11 @@
|
|
|
557
556
|
|
|
558
557
|
var redefine$4 = {exports: {}};
|
|
559
558
|
|
|
560
|
-
var uncurryThis$
|
|
559
|
+
var uncurryThis$i = functionUncurryThis;
|
|
561
560
|
var isCallable$a = isCallable$g;
|
|
562
561
|
var store$1 = sharedStore;
|
|
563
562
|
|
|
564
|
-
var functionToString = uncurryThis$
|
|
563
|
+
var functionToString = uncurryThis$i(Function.toString);
|
|
565
564
|
|
|
566
565
|
// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
|
|
567
566
|
if (!isCallable$a(store$1.inspectSource)) {
|
|
@@ -593,7 +592,7 @@
|
|
|
593
592
|
|
|
594
593
|
var NATIVE_WEAK_MAP = nativeWeakMap;
|
|
595
594
|
var global$q = global$I;
|
|
596
|
-
var uncurryThis$
|
|
595
|
+
var uncurryThis$h = functionUncurryThis;
|
|
597
596
|
var isObject$3 = isObject$8;
|
|
598
597
|
var createNonEnumerableProperty$3 = createNonEnumerableProperty$4;
|
|
599
598
|
var hasOwn$6 = hasOwnProperty_1;
|
|
@@ -604,16 +603,16 @@
|
|
|
604
603
|
var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
|
|
605
604
|
var TypeError$b = global$q.TypeError;
|
|
606
605
|
var WeakMap = global$q.WeakMap;
|
|
607
|
-
var set$
|
|
606
|
+
var set$1, get, has;
|
|
608
607
|
|
|
609
608
|
var enforce = function (it) {
|
|
610
|
-
return has(it) ? get
|
|
609
|
+
return has(it) ? get(it) : set$1(it, {});
|
|
611
610
|
};
|
|
612
611
|
|
|
613
612
|
var getterFor = function (TYPE) {
|
|
614
613
|
return function (it) {
|
|
615
614
|
var state;
|
|
616
|
-
if (!isObject$3(it) || (state = get
|
|
615
|
+
if (!isObject$3(it) || (state = get(it)).type !== TYPE) {
|
|
617
616
|
throw TypeError$b('Incompatible receiver, ' + TYPE + ' required');
|
|
618
617
|
} return state;
|
|
619
618
|
};
|
|
@@ -621,16 +620,16 @@
|
|
|
621
620
|
|
|
622
621
|
if (NATIVE_WEAK_MAP || shared$1.state) {
|
|
623
622
|
var store = shared$1.state || (shared$1.state = new WeakMap());
|
|
624
|
-
var wmget = uncurryThis$
|
|
625
|
-
var wmhas = uncurryThis$
|
|
626
|
-
var wmset = uncurryThis$
|
|
627
|
-
set$
|
|
623
|
+
var wmget = uncurryThis$h(store.get);
|
|
624
|
+
var wmhas = uncurryThis$h(store.has);
|
|
625
|
+
var wmset = uncurryThis$h(store.set);
|
|
626
|
+
set$1 = function (it, metadata) {
|
|
628
627
|
if (wmhas(store, it)) throw new TypeError$b(OBJECT_ALREADY_INITIALIZED);
|
|
629
628
|
metadata.facade = it;
|
|
630
629
|
wmset(store, it, metadata);
|
|
631
630
|
return metadata;
|
|
632
631
|
};
|
|
633
|
-
get
|
|
632
|
+
get = function (it) {
|
|
634
633
|
return wmget(store, it) || {};
|
|
635
634
|
};
|
|
636
635
|
has = function (it) {
|
|
@@ -639,13 +638,13 @@
|
|
|
639
638
|
} else {
|
|
640
639
|
var STATE = sharedKey$1('state');
|
|
641
640
|
hiddenKeys$3[STATE] = true;
|
|
642
|
-
set$
|
|
641
|
+
set$1 = function (it, metadata) {
|
|
643
642
|
if (hasOwn$6(it, STATE)) throw new TypeError$b(OBJECT_ALREADY_INITIALIZED);
|
|
644
643
|
metadata.facade = it;
|
|
645
644
|
createNonEnumerableProperty$3(it, STATE, metadata);
|
|
646
645
|
return metadata;
|
|
647
646
|
};
|
|
648
|
-
get
|
|
647
|
+
get = function (it) {
|
|
649
648
|
return hasOwn$6(it, STATE) ? it[STATE] : {};
|
|
650
649
|
};
|
|
651
650
|
has = function (it) {
|
|
@@ -654,8 +653,8 @@
|
|
|
654
653
|
}
|
|
655
654
|
|
|
656
655
|
var internalState = {
|
|
657
|
-
set: set$
|
|
658
|
-
get: get
|
|
656
|
+
set: set$1,
|
|
657
|
+
get: get,
|
|
659
658
|
has: has,
|
|
660
659
|
enforce: enforce,
|
|
661
660
|
getterFor: getterFor
|
|
@@ -803,13 +802,13 @@
|
|
|
803
802
|
indexOf: createMethod$3(false)
|
|
804
803
|
};
|
|
805
804
|
|
|
806
|
-
var uncurryThis$
|
|
805
|
+
var uncurryThis$g = functionUncurryThis;
|
|
807
806
|
var hasOwn$3 = hasOwnProperty_1;
|
|
808
807
|
var toIndexedObject$1 = toIndexedObject$4;
|
|
809
808
|
var indexOf$1 = arrayIncludes.indexOf;
|
|
810
809
|
var hiddenKeys$2 = hiddenKeys$4;
|
|
811
810
|
|
|
812
|
-
var push$2 = uncurryThis$
|
|
811
|
+
var push$2 = uncurryThis$g([].push);
|
|
813
812
|
|
|
814
813
|
var objectKeysInternal = function (object, names) {
|
|
815
814
|
var O = toIndexedObject$1(object);
|
|
@@ -853,12 +852,12 @@
|
|
|
853
852
|
objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols;
|
|
854
853
|
|
|
855
854
|
var getBuiltIn$4 = getBuiltIn$7;
|
|
856
|
-
var uncurryThis$
|
|
855
|
+
var uncurryThis$f = functionUncurryThis;
|
|
857
856
|
var getOwnPropertyNamesModule = objectGetOwnPropertyNames;
|
|
858
857
|
var getOwnPropertySymbolsModule$1 = objectGetOwnPropertySymbols;
|
|
859
858
|
var anObject$c = anObject$e;
|
|
860
859
|
|
|
861
|
-
var concat$2 = uncurryThis$
|
|
860
|
+
var concat$2 = uncurryThis$f([].concat);
|
|
862
861
|
|
|
863
862
|
// all object keys, includes non-enumerable and symbols
|
|
864
863
|
var ownKeys$1 = getBuiltIn$4('Reflect', 'ownKeys') || function ownKeys(it) {
|
|
@@ -987,7 +986,7 @@
|
|
|
987
986
|
|
|
988
987
|
/* eslint-disable no-proto -- safe */
|
|
989
988
|
|
|
990
|
-
var uncurryThis$
|
|
989
|
+
var uncurryThis$e = functionUncurryThis;
|
|
991
990
|
var anObject$b = anObject$e;
|
|
992
991
|
var aPossiblePrototype = aPossiblePrototype$1;
|
|
993
992
|
|
|
@@ -1001,7 +1000,7 @@
|
|
|
1001
1000
|
var setter;
|
|
1002
1001
|
try {
|
|
1003
1002
|
// eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
|
|
1004
|
-
setter = uncurryThis$
|
|
1003
|
+
setter = uncurryThis$e(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set);
|
|
1005
1004
|
setter(test, []);
|
|
1006
1005
|
CORRECT_SETTER = test instanceof Array;
|
|
1007
1006
|
} catch (error) { /* empty */ }
|
|
@@ -1056,11 +1055,11 @@
|
|
|
1056
1055
|
throw TypeError$9('Incorrect invocation');
|
|
1057
1056
|
};
|
|
1058
1057
|
|
|
1059
|
-
var uncurryThis$
|
|
1058
|
+
var uncurryThis$d = functionUncurryThis;
|
|
1060
1059
|
var aCallable$4 = aCallable$6;
|
|
1061
1060
|
var NATIVE_BIND$1 = functionBindNative;
|
|
1062
1061
|
|
|
1063
|
-
var bind$4 = uncurryThis$
|
|
1062
|
+
var bind$4 = uncurryThis$d(uncurryThis$d.bind);
|
|
1064
1063
|
|
|
1065
1064
|
// optional / simple context binding
|
|
1066
1065
|
var functionBindContext = function (fn, that) {
|
|
@@ -1281,7 +1280,7 @@
|
|
|
1281
1280
|
return ITERATION_SUPPORT;
|
|
1282
1281
|
};
|
|
1283
1282
|
|
|
1284
|
-
var uncurryThis$
|
|
1283
|
+
var uncurryThis$c = functionUncurryThis;
|
|
1285
1284
|
var fails$a = fails$i;
|
|
1286
1285
|
var isCallable$4 = isCallable$g;
|
|
1287
1286
|
var classof$4 = classof$6;
|
|
@@ -1292,7 +1291,7 @@
|
|
|
1292
1291
|
var empty = [];
|
|
1293
1292
|
var construct = getBuiltIn$2('Reflect', 'construct');
|
|
1294
1293
|
var constructorRegExp = /^\s*(?:class|function)\b/;
|
|
1295
|
-
var exec$3 = uncurryThis$
|
|
1294
|
+
var exec$3 = uncurryThis$c(constructorRegExp.exec);
|
|
1296
1295
|
var INCORRECT_TO_STRING = !constructorRegExp.exec(noop);
|
|
1297
1296
|
|
|
1298
1297
|
var isConstructorModern = function isConstructor(argument) {
|
|
@@ -1375,9 +1374,9 @@
|
|
|
1375
1374
|
|
|
1376
1375
|
var html$2 = getBuiltIn$1('document', 'documentElement');
|
|
1377
1376
|
|
|
1378
|
-
var uncurryThis$
|
|
1377
|
+
var uncurryThis$b = functionUncurryThis;
|
|
1379
1378
|
|
|
1380
|
-
var arraySlice$2 = uncurryThis$
|
|
1379
|
+
var arraySlice$2 = uncurryThis$b([].slice);
|
|
1381
1380
|
|
|
1382
1381
|
var global$g = global$I;
|
|
1383
1382
|
|
|
@@ -1410,7 +1409,7 @@
|
|
|
1410
1409
|
var IS_IOS$1 = engineIsIos;
|
|
1411
1410
|
var IS_NODE$3 = engineIsNode;
|
|
1412
1411
|
|
|
1413
|
-
var set
|
|
1412
|
+
var set = global$e.setImmediate;
|
|
1414
1413
|
var clear = global$e.clearImmediate;
|
|
1415
1414
|
var process$2 = global$e.process;
|
|
1416
1415
|
var Dispatch = global$e.Dispatch;
|
|
@@ -1451,8 +1450,8 @@
|
|
|
1451
1450
|
};
|
|
1452
1451
|
|
|
1453
1452
|
// Node.js 0.9+ & IE10+ has setImmediate, otherwise:
|
|
1454
|
-
if (!set
|
|
1455
|
-
set
|
|
1453
|
+
if (!set || !clear) {
|
|
1454
|
+
set = function setImmediate(handler) {
|
|
1456
1455
|
validateArgumentsLength(arguments.length, 1);
|
|
1457
1456
|
var fn = isCallable$3(handler) ? handler : Function$1(handler);
|
|
1458
1457
|
var args = arraySlice$1(arguments, 1);
|
|
@@ -1510,7 +1509,7 @@
|
|
|
1510
1509
|
}
|
|
1511
1510
|
|
|
1512
1511
|
var task$1 = {
|
|
1513
|
-
set: set
|
|
1512
|
+
set: set,
|
|
1514
1513
|
clear: clear
|
|
1515
1514
|
};
|
|
1516
1515
|
|
|
@@ -1686,7 +1685,7 @@
|
|
|
1686
1685
|
|
|
1687
1686
|
var engineIsBrowser = typeof window == 'object';
|
|
1688
1687
|
|
|
1689
|
-
var $$
|
|
1688
|
+
var $$6 = _export;
|
|
1690
1689
|
var global$a = global$I;
|
|
1691
1690
|
var getBuiltIn = getBuiltIn$7;
|
|
1692
1691
|
var call$5 = functionCall;
|
|
@@ -2011,7 +2010,7 @@
|
|
|
2011
2010
|
}
|
|
2012
2011
|
}
|
|
2013
2012
|
|
|
2014
|
-
$$
|
|
2013
|
+
$$6({ global: true, wrap: true, forced: FORCED$1 }, {
|
|
2015
2014
|
Promise: PromiseConstructor
|
|
2016
2015
|
});
|
|
2017
2016
|
|
|
@@ -2021,7 +2020,7 @@
|
|
|
2021
2020
|
PromiseWrapper = getBuiltIn(PROMISE);
|
|
2022
2021
|
|
|
2023
2022
|
// statics
|
|
2024
|
-
$$
|
|
2023
|
+
$$6({ target: PROMISE, stat: true, forced: FORCED$1 }, {
|
|
2025
2024
|
// `Promise.reject` method
|
|
2026
2025
|
// https://tc39.es/ecma262/#sec-promise.reject
|
|
2027
2026
|
reject: function reject(r) {
|
|
@@ -2031,7 +2030,7 @@
|
|
|
2031
2030
|
}
|
|
2032
2031
|
});
|
|
2033
2032
|
|
|
2034
|
-
$$
|
|
2033
|
+
$$6({ target: PROMISE, stat: true, forced: FORCED$1 }, {
|
|
2035
2034
|
// `Promise.resolve` method
|
|
2036
2035
|
// https://tc39.es/ecma262/#sec-promise.resolve
|
|
2037
2036
|
resolve: function resolve(x) {
|
|
@@ -2039,7 +2038,7 @@
|
|
|
2039
2038
|
}
|
|
2040
2039
|
});
|
|
2041
2040
|
|
|
2042
|
-
$$
|
|
2041
|
+
$$6({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
|
|
2043
2042
|
// `Promise.all` method
|
|
2044
2043
|
// https://tc39.es/ecma262/#sec-promise.all
|
|
2045
2044
|
all: function all(iterable) {
|
|
@@ -2096,7 +2095,7 @@
|
|
|
2096
2095
|
};
|
|
2097
2096
|
|
|
2098
2097
|
var DESCRIPTORS$1 = descriptors;
|
|
2099
|
-
var uncurryThis$
|
|
2098
|
+
var uncurryThis$a = functionUncurryThis;
|
|
2100
2099
|
var call$4 = functionCall;
|
|
2101
2100
|
var fails$8 = fails$i;
|
|
2102
2101
|
var objectKeys$1 = objectKeys$2;
|
|
@@ -2109,7 +2108,7 @@
|
|
|
2109
2108
|
var $assign = Object.assign;
|
|
2110
2109
|
// eslint-disable-next-line es/no-object-defineproperty -- required for testing
|
|
2111
2110
|
var defineProperty = Object.defineProperty;
|
|
2112
|
-
var concat$1 = uncurryThis$
|
|
2111
|
+
var concat$1 = uncurryThis$a([].concat);
|
|
2113
2112
|
|
|
2114
2113
|
// `Object.assign` method
|
|
2115
2114
|
// https://tc39.es/ecma262/#sec-object.assign
|
|
@@ -2152,16 +2151,87 @@
|
|
|
2152
2151
|
} return T;
|
|
2153
2152
|
} : $assign;
|
|
2154
2153
|
|
|
2155
|
-
var $$
|
|
2154
|
+
var $$5 = _export;
|
|
2156
2155
|
var assign = objectAssign;
|
|
2157
2156
|
|
|
2158
2157
|
// `Object.assign` method
|
|
2159
2158
|
// https://tc39.es/ecma262/#sec-object.assign
|
|
2160
2159
|
// eslint-disable-next-line es/no-object-assign -- required for testing
|
|
2161
|
-
$$
|
|
2160
|
+
$$5({ target: 'Object', stat: true, forced: Object.assign !== assign }, {
|
|
2162
2161
|
assign: assign
|
|
2163
2162
|
});
|
|
2164
2163
|
|
|
2164
|
+
var isObject = isObject$8;
|
|
2165
|
+
var classof$2 = classofRaw$1;
|
|
2166
|
+
var wellKnownSymbol$3 = wellKnownSymbol$e;
|
|
2167
|
+
|
|
2168
|
+
var MATCH$1 = wellKnownSymbol$3('match');
|
|
2169
|
+
|
|
2170
|
+
// `IsRegExp` abstract operation
|
|
2171
|
+
// https://tc39.es/ecma262/#sec-isregexp
|
|
2172
|
+
var isRegexp = function (it) {
|
|
2173
|
+
var isRegExp;
|
|
2174
|
+
return isObject(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$2(it) == 'RegExp');
|
|
2175
|
+
};
|
|
2176
|
+
|
|
2177
|
+
var global$9 = global$I;
|
|
2178
|
+
var isRegExp$1 = isRegexp;
|
|
2179
|
+
|
|
2180
|
+
var TypeError$3 = global$9.TypeError;
|
|
2181
|
+
|
|
2182
|
+
var notARegexp = function (it) {
|
|
2183
|
+
if (isRegExp$1(it)) {
|
|
2184
|
+
throw TypeError$3("The method doesn't accept regular expressions");
|
|
2185
|
+
} return it;
|
|
2186
|
+
};
|
|
2187
|
+
|
|
2188
|
+
var global$8 = global$I;
|
|
2189
|
+
var classof$1 = classof$6;
|
|
2190
|
+
|
|
2191
|
+
var String$1 = global$8.String;
|
|
2192
|
+
|
|
2193
|
+
var toString$8 = function (argument) {
|
|
2194
|
+
if (classof$1(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
|
|
2195
|
+
return String$1(argument);
|
|
2196
|
+
};
|
|
2197
|
+
|
|
2198
|
+
var wellKnownSymbol$2 = wellKnownSymbol$e;
|
|
2199
|
+
|
|
2200
|
+
var MATCH = wellKnownSymbol$2('match');
|
|
2201
|
+
|
|
2202
|
+
var correctIsRegexpLogic = function (METHOD_NAME) {
|
|
2203
|
+
var regexp = /./;
|
|
2204
|
+
try {
|
|
2205
|
+
'/./'[METHOD_NAME](regexp);
|
|
2206
|
+
} catch (error1) {
|
|
2207
|
+
try {
|
|
2208
|
+
regexp[MATCH] = false;
|
|
2209
|
+
return '/./'[METHOD_NAME](regexp);
|
|
2210
|
+
} catch (error2) { /* empty */ }
|
|
2211
|
+
} return false;
|
|
2212
|
+
};
|
|
2213
|
+
|
|
2214
|
+
var $$4 = _export;
|
|
2215
|
+
var uncurryThis$9 = functionUncurryThis;
|
|
2216
|
+
var notARegExp$1 = notARegexp;
|
|
2217
|
+
var requireObjectCoercible$5 = requireObjectCoercible$8;
|
|
2218
|
+
var toString$7 = toString$8;
|
|
2219
|
+
var correctIsRegExpLogic$1 = correctIsRegexpLogic;
|
|
2220
|
+
|
|
2221
|
+
var stringIndexOf$1 = uncurryThis$9(''.indexOf);
|
|
2222
|
+
|
|
2223
|
+
// `String.prototype.includes` method
|
|
2224
|
+
// https://tc39.es/ecma262/#sec-string.prototype.includes
|
|
2225
|
+
$$4({ target: 'String', proto: true, forced: !correctIsRegExpLogic$1('includes') }, {
|
|
2226
|
+
includes: function includes(searchString /* , position = 0 */) {
|
|
2227
|
+
return !!~stringIndexOf$1(
|
|
2228
|
+
toString$7(requireObjectCoercible$5(this)),
|
|
2229
|
+
toString$7(notARegExp$1(searchString)),
|
|
2230
|
+
arguments.length > 1 ? arguments[1] : undefined
|
|
2231
|
+
);
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
|
|
2165
2235
|
/*! *****************************************************************************
|
|
2166
2236
|
Copyright (c) Microsoft Corporation.
|
|
2167
2237
|
|
|
@@ -2236,48 +2306,6 @@
|
|
|
2236
2306
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
2237
2307
|
}
|
|
2238
2308
|
|
|
2239
|
-
var NINETAILED_CACHE_KEY = '__nt-cache__';
|
|
2240
|
-
var initialize = function initialize(_a, data) {
|
|
2241
|
-
var instance = _a.instance;
|
|
2242
|
-
|
|
2243
|
-
if (data === void 0) {
|
|
2244
|
-
data = {};
|
|
2245
|
-
}
|
|
2246
|
-
|
|
2247
|
-
var cache = experience_jsShared.buildEmptyCache();
|
|
2248
|
-
instance.storage.setItem(NINETAILED_CACHE_KEY, __assign(__assign({}, cache), data));
|
|
2249
|
-
return cache;
|
|
2250
|
-
};
|
|
2251
|
-
var get = function get(_a) {
|
|
2252
|
-
var instance = _a.instance;
|
|
2253
|
-
var cache = instance.storage.getItem(NINETAILED_CACHE_KEY);
|
|
2254
|
-
return cache;
|
|
2255
|
-
};
|
|
2256
|
-
var set = function set(cache, _a) {
|
|
2257
|
-
var instance = _a.instance;
|
|
2258
|
-
instance.storage.setItem(NINETAILED_CACHE_KEY, cache);
|
|
2259
|
-
return cache;
|
|
2260
|
-
};
|
|
2261
|
-
var remove = function remove(_a) {
|
|
2262
|
-
var instance = _a.instance;
|
|
2263
|
-
instance.storage.removeItem(NINETAILED_CACHE_KEY);
|
|
2264
|
-
};
|
|
2265
|
-
var reset = function reset(_a) {
|
|
2266
|
-
var instance = _a.instance;
|
|
2267
|
-
return initialize({
|
|
2268
|
-
instance: instance
|
|
2269
|
-
});
|
|
2270
|
-
};
|
|
2271
|
-
|
|
2272
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
2273
|
-
__proto__: null,
|
|
2274
|
-
initialize: initialize,
|
|
2275
|
-
get: get,
|
|
2276
|
-
set: set,
|
|
2277
|
-
remove: remove,
|
|
2278
|
-
reset: reset
|
|
2279
|
-
});
|
|
2280
|
-
|
|
2281
2309
|
var buildClientLocale = function buildClientLocale() {
|
|
2282
2310
|
return navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language;
|
|
2283
2311
|
};
|
|
@@ -2294,387 +2322,12 @@
|
|
|
2294
2322
|
};
|
|
2295
2323
|
};
|
|
2296
2324
|
|
|
2297
|
-
var BASE_URL = 'https://api.ninetailed.co';
|
|
2298
|
-
|
|
2299
|
-
var fetchWithTimeout = function fetchWithTimeout(input, init) {
|
|
2300
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
2301
|
-
var timeout, controller, id, response;
|
|
2302
|
-
return __generator(this, function (_a) {
|
|
2303
|
-
switch (_a.label) {
|
|
2304
|
-
case 0:
|
|
2305
|
-
timeout = init.timeout;
|
|
2306
|
-
controller = new AbortController();
|
|
2307
|
-
id = setTimeout(function () {
|
|
2308
|
-
logger.warn('Ninetailed Request timed out.');
|
|
2309
|
-
controller.abort();
|
|
2310
|
-
}, timeout);
|
|
2311
|
-
return [4
|
|
2312
|
-
/*yield*/
|
|
2313
|
-
, fetch(input, __assign(__assign({}, init), {
|
|
2314
|
-
signal: controller.signal
|
|
2315
|
-
}))];
|
|
2316
|
-
|
|
2317
|
-
case 1:
|
|
2318
|
-
response = _a.sent();
|
|
2319
|
-
clearTimeout(id);
|
|
2320
|
-
return [2
|
|
2321
|
-
/*return*/
|
|
2322
|
-
, response];
|
|
2323
|
-
}
|
|
2324
|
-
});
|
|
2325
|
-
});
|
|
2326
|
-
};
|
|
2327
|
-
|
|
2328
|
-
var NinetailedApiClient =
|
|
2329
|
-
/** @class */
|
|
2330
|
-
function () {
|
|
2331
|
-
function NinetailedApiClient(_a) {
|
|
2332
|
-
var clientId = _a.clientId,
|
|
2333
|
-
_b = _a.environment,
|
|
2334
|
-
environment = _b === void 0 ? 'main' : _b,
|
|
2335
|
-
_c = _a.url,
|
|
2336
|
-
url = _c === void 0 ? BASE_URL : _c;
|
|
2337
|
-
this.clientId = clientId;
|
|
2338
|
-
this.environment = environment;
|
|
2339
|
-
this.url = url;
|
|
2340
|
-
}
|
|
2341
|
-
|
|
2342
|
-
NinetailedApiClient.prototype.profile = function (options) {
|
|
2343
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2344
|
-
var events, anonymousId, body, request, data, error_1;
|
|
2345
|
-
return __generator(this, function (_a) {
|
|
2346
|
-
switch (_a.label) {
|
|
2347
|
-
case 0:
|
|
2348
|
-
logger.info('Sending Profile Request.');
|
|
2349
|
-
events = options.events;
|
|
2350
|
-
anonymousId = events[0].anonymousId;
|
|
2351
|
-
body = options;
|
|
2352
|
-
logger.debug('Profile Request Body: ', body);
|
|
2353
|
-
_a.label = 1;
|
|
2354
|
-
|
|
2355
|
-
case 1:
|
|
2356
|
-
_a.trys.push([1, 4,, 5]);
|
|
2357
|
-
|
|
2358
|
-
return [4
|
|
2359
|
-
/*yield*/
|
|
2360
|
-
, fetchWithTimeout("".concat(this.url, "/v1/organizations/").concat(this.clientId, "/environments/").concat(this.environment, "/profiles/").concat(anonymousId, "/events"), {
|
|
2361
|
-
method: 'POST',
|
|
2362
|
-
headers: {
|
|
2363
|
-
'Content-Type': 'application/json'
|
|
2364
|
-
},
|
|
2365
|
-
body: JSON.stringify(body),
|
|
2366
|
-
timeout: options.timeout || 3000
|
|
2367
|
-
})];
|
|
2368
|
-
|
|
2369
|
-
case 2:
|
|
2370
|
-
request = _a.sent();
|
|
2371
|
-
logger.debug('Profile Request: ', request);
|
|
2372
|
-
return [4
|
|
2373
|
-
/*yield*/
|
|
2374
|
-
, request.json()];
|
|
2375
|
-
|
|
2376
|
-
case 3:
|
|
2377
|
-
data = _a.sent().data;
|
|
2378
|
-
logger.debug('Profile Request completed.');
|
|
2379
|
-
return [2
|
|
2380
|
-
/*return*/
|
|
2381
|
-
, data];
|
|
2382
|
-
|
|
2383
|
-
case 4:
|
|
2384
|
-
error_1 = _a.sent();
|
|
2385
|
-
throw error_1;
|
|
2386
|
-
|
|
2387
|
-
case 5:
|
|
2388
|
-
return [2
|
|
2389
|
-
/*return*/
|
|
2390
|
-
];
|
|
2391
|
-
}
|
|
2392
|
-
});
|
|
2393
|
-
});
|
|
2394
|
-
};
|
|
2395
|
-
|
|
2396
|
-
return NinetailedApiClient;
|
|
2397
|
-
}();
|
|
2398
|
-
|
|
2399
|
-
var Logger =
|
|
2400
|
-
/** @class */
|
|
2401
|
-
function () {
|
|
2402
|
-
function Logger() {
|
|
2403
|
-
this.name = '@ninetailed/experience.js';
|
|
2404
|
-
this.sinks = [];
|
|
2405
|
-
this.diary = diary.diary(this.name, this.onLogEvent.bind(this));
|
|
2406
|
-
diary.enable(this.name);
|
|
2407
|
-
}
|
|
2408
|
-
|
|
2409
|
-
Logger.prototype.addSink = function (sink) {
|
|
2410
|
-
this.sinks = __spreadArray(__spreadArray([], this.sinks.filter(function (existingSink) {
|
|
2411
|
-
return existingSink.name !== sink.name;
|
|
2412
|
-
}), true), [sink], false);
|
|
2413
|
-
};
|
|
2414
|
-
|
|
2415
|
-
Logger.prototype.removeSink = function (name) {
|
|
2416
|
-
this.sinks = this.sinks.filter(function (sink) {
|
|
2417
|
-
return sink.name !== name;
|
|
2418
|
-
});
|
|
2419
|
-
};
|
|
2420
|
-
|
|
2421
|
-
Logger.prototype.debug = function (message) {
|
|
2422
|
-
var _a;
|
|
2423
|
-
|
|
2424
|
-
var args = [];
|
|
2425
|
-
|
|
2426
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2427
|
-
args[_i - 1] = arguments[_i];
|
|
2428
|
-
}
|
|
2429
|
-
|
|
2430
|
-
(_a = this.diary).debug.apply(_a, __spreadArray([message], args, false));
|
|
2431
|
-
};
|
|
2432
|
-
|
|
2433
|
-
Logger.prototype.info = function (message) {
|
|
2434
|
-
var _a;
|
|
2435
|
-
|
|
2436
|
-
var args = [];
|
|
2437
|
-
|
|
2438
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2439
|
-
args[_i - 1] = arguments[_i];
|
|
2440
|
-
}
|
|
2441
|
-
|
|
2442
|
-
(_a = this.diary).info.apply(_a, __spreadArray([message], args, false));
|
|
2443
|
-
};
|
|
2444
|
-
|
|
2445
|
-
Logger.prototype.log = function (message) {
|
|
2446
|
-
var _a;
|
|
2447
|
-
|
|
2448
|
-
var args = [];
|
|
2449
|
-
|
|
2450
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2451
|
-
args[_i - 1] = arguments[_i];
|
|
2452
|
-
}
|
|
2453
|
-
|
|
2454
|
-
(_a = this.diary).log.apply(_a, __spreadArray([message], args, false));
|
|
2455
|
-
};
|
|
2456
|
-
|
|
2457
|
-
Logger.prototype.warn = function (message) {
|
|
2458
|
-
var _a;
|
|
2459
|
-
|
|
2460
|
-
var args = [];
|
|
2461
|
-
|
|
2462
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2463
|
-
args[_i - 1] = arguments[_i];
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
(_a = this.diary).warn.apply(_a, __spreadArray([message], args, false));
|
|
2467
|
-
};
|
|
2468
|
-
|
|
2469
|
-
Logger.prototype.error = function (message) {
|
|
2470
|
-
var _a;
|
|
2471
|
-
|
|
2472
|
-
var args = [];
|
|
2473
|
-
|
|
2474
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2475
|
-
args[_i - 1] = arguments[_i];
|
|
2476
|
-
}
|
|
2477
|
-
|
|
2478
|
-
(_a = this.diary).error.apply(_a, __spreadArray([message], args, false));
|
|
2479
|
-
};
|
|
2480
|
-
|
|
2481
|
-
Logger.prototype.fatal = function (message) {
|
|
2482
|
-
var _a;
|
|
2483
|
-
|
|
2484
|
-
var args = [];
|
|
2485
|
-
|
|
2486
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2487
|
-
args[_i - 1] = arguments[_i];
|
|
2488
|
-
}
|
|
2489
|
-
|
|
2490
|
-
(_a = this.diary).fatal.apply(_a, __spreadArray([message], args, false));
|
|
2491
|
-
};
|
|
2492
|
-
|
|
2493
|
-
Logger.prototype.onLogEvent = function (event) {
|
|
2494
|
-
this.sinks.forEach(function (sink) {
|
|
2495
|
-
if (sink[event.level]) {
|
|
2496
|
-
sink[event.level].apply(sink, __spreadArray([event.message], event.extra, false));
|
|
2497
|
-
}
|
|
2498
|
-
});
|
|
2499
|
-
};
|
|
2500
|
-
|
|
2501
|
-
return Logger;
|
|
2502
|
-
}();
|
|
2503
|
-
var logger = new Logger();
|
|
2504
|
-
|
|
2505
|
-
var ConsoleLogSink =
|
|
2506
|
-
/** @class */
|
|
2507
|
-
function () {
|
|
2508
|
-
function ConsoleLogSink() {
|
|
2509
|
-
this.name = "ConsoleLogSink";
|
|
2510
|
-
}
|
|
2511
|
-
|
|
2512
|
-
ConsoleLogSink.prototype.debug = function (message) {
|
|
2513
|
-
var args = [];
|
|
2514
|
-
|
|
2515
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2516
|
-
args[_i - 1] = arguments[_i];
|
|
2517
|
-
}
|
|
2518
|
-
|
|
2519
|
-
console.debug.apply(console, __spreadArray([message], args, false));
|
|
2520
|
-
};
|
|
2521
|
-
|
|
2522
|
-
ConsoleLogSink.prototype.info = function (message) {
|
|
2523
|
-
var args = [];
|
|
2524
|
-
|
|
2525
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2526
|
-
args[_i - 1] = arguments[_i];
|
|
2527
|
-
}
|
|
2528
|
-
|
|
2529
|
-
console.info.apply(console, __spreadArray([message], args, false));
|
|
2530
|
-
};
|
|
2531
|
-
|
|
2532
|
-
ConsoleLogSink.prototype.log = function (message) {
|
|
2533
|
-
var args = [];
|
|
2534
|
-
|
|
2535
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2536
|
-
args[_i - 1] = arguments[_i];
|
|
2537
|
-
}
|
|
2538
|
-
|
|
2539
|
-
console.log.apply(console, __spreadArray([message], args, false));
|
|
2540
|
-
};
|
|
2541
|
-
|
|
2542
|
-
ConsoleLogSink.prototype.warn = function (message) {
|
|
2543
|
-
var args = [];
|
|
2544
|
-
|
|
2545
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2546
|
-
args[_i - 1] = arguments[_i];
|
|
2547
|
-
}
|
|
2548
|
-
|
|
2549
|
-
console.warn.apply(console, __spreadArray([message], args, false));
|
|
2550
|
-
};
|
|
2551
|
-
|
|
2552
|
-
ConsoleLogSink.prototype.error = function (message) {
|
|
2553
|
-
var args = [];
|
|
2554
|
-
|
|
2555
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2556
|
-
args[_i - 1] = arguments[_i];
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
|
-
console.error.apply(console, __spreadArray([message], args, false));
|
|
2560
|
-
};
|
|
2561
|
-
|
|
2562
|
-
ConsoleLogSink.prototype.fatal = function (message) {
|
|
2563
|
-
var args = [];
|
|
2564
|
-
|
|
2565
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2566
|
-
args[_i - 1] = arguments[_i];
|
|
2567
|
-
}
|
|
2568
|
-
|
|
2569
|
-
console.error.apply(console, __spreadArray([message], args, false));
|
|
2570
|
-
};
|
|
2571
|
-
|
|
2572
|
-
return ConsoleLogSink;
|
|
2573
|
-
}();
|
|
2574
|
-
|
|
2575
|
-
var OnLogLogSink =
|
|
2576
|
-
/** @class */
|
|
2577
|
-
function () {
|
|
2578
|
-
function OnLogLogSink(onLog) {
|
|
2579
|
-
this.onLog = onLog;
|
|
2580
|
-
this.name = 'OnLogLogSink';
|
|
2581
|
-
}
|
|
2582
|
-
|
|
2583
|
-
OnLogLogSink.prototype.debug = function (message) {
|
|
2584
|
-
var args = [];
|
|
2585
|
-
|
|
2586
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2587
|
-
args[_i - 1] = arguments[_i];
|
|
2588
|
-
}
|
|
2589
|
-
|
|
2590
|
-
this.onLog.apply(this, __spreadArray([message], args, false));
|
|
2591
|
-
};
|
|
2592
|
-
|
|
2593
|
-
OnLogLogSink.prototype.info = function (message) {
|
|
2594
|
-
var args = [];
|
|
2595
|
-
|
|
2596
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2597
|
-
args[_i - 1] = arguments[_i];
|
|
2598
|
-
}
|
|
2599
|
-
|
|
2600
|
-
this.onLog.apply(this, __spreadArray([message], args, false));
|
|
2601
|
-
};
|
|
2602
|
-
|
|
2603
|
-
OnLogLogSink.prototype.log = function (message) {
|
|
2604
|
-
var args = [];
|
|
2605
|
-
|
|
2606
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2607
|
-
args[_i - 1] = arguments[_i];
|
|
2608
|
-
}
|
|
2609
|
-
|
|
2610
|
-
this.onLog.apply(this, __spreadArray([message], args, false));
|
|
2611
|
-
};
|
|
2612
|
-
|
|
2613
|
-
OnLogLogSink.prototype.warn = function (message) {
|
|
2614
|
-
var args = [];
|
|
2615
|
-
|
|
2616
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2617
|
-
args[_i - 1] = arguments[_i];
|
|
2618
|
-
}
|
|
2619
|
-
|
|
2620
|
-
this.onLog.apply(this, __spreadArray([message], args, false));
|
|
2621
|
-
};
|
|
2622
|
-
|
|
2623
|
-
return OnLogLogSink;
|
|
2624
|
-
}();
|
|
2625
|
-
|
|
2626
|
-
var OnErrorLogSink =
|
|
2627
|
-
/** @class */
|
|
2628
|
-
function () {
|
|
2629
|
-
function OnErrorLogSink(onError) {
|
|
2630
|
-
this.onError = onError;
|
|
2631
|
-
this.name = 'OnErrorLogSink';
|
|
2632
|
-
}
|
|
2633
|
-
|
|
2634
|
-
OnErrorLogSink.prototype.error = function (message) {
|
|
2635
|
-
var args = [];
|
|
2636
|
-
|
|
2637
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2638
|
-
args[_i - 1] = arguments[_i];
|
|
2639
|
-
}
|
|
2640
|
-
|
|
2641
|
-
this.onError.apply(this, __spreadArray([message], args, false));
|
|
2642
|
-
};
|
|
2643
|
-
|
|
2644
|
-
OnErrorLogSink.prototype.fatal = function (message) {
|
|
2645
|
-
var args = [];
|
|
2646
|
-
|
|
2647
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
2648
|
-
args[_i - 1] = arguments[_i];
|
|
2649
|
-
}
|
|
2650
|
-
|
|
2651
|
-
this.onError.apply(this, __spreadArray([message], args, false));
|
|
2652
|
-
};
|
|
2653
|
-
|
|
2654
|
-
return OnErrorLogSink;
|
|
2655
|
-
}();
|
|
2656
|
-
|
|
2657
|
-
var NINETAILED_TRACKER_EVENTS = {
|
|
2658
|
-
/**
|
|
2659
|
-
* `profile` - Fires when the profile is returned by the cdp API.
|
|
2660
|
-
*/
|
|
2661
|
-
profile: 'profile'
|
|
2662
|
-
};
|
|
2663
|
-
var PLUGIN_NAME = 'ninetailed';
|
|
2664
|
-
var DEBUG_FLAG_KEY = 'nt-debug';
|
|
2665
|
-
|
|
2666
|
-
var delay = function delay(ms) {
|
|
2667
|
-
return new Promise(function (resolve) {
|
|
2668
|
-
return setTimeout(resolve, ms);
|
|
2669
|
-
});
|
|
2670
|
-
};
|
|
2671
2325
|
/**
|
|
2672
2326
|
* Similar to _.throttle but waits for the promise to resolve. There is no
|
|
2673
2327
|
* wait time because you can simply await `Promise.timeout` inside `fn`
|
|
2674
2328
|
* to wait some time before the next call.
|
|
2675
2329
|
*/
|
|
2676
2330
|
|
|
2677
|
-
|
|
2678
2331
|
function asyncThrottle(fn) {
|
|
2679
2332
|
var _this = this;
|
|
2680
2333
|
|
|
@@ -2711,32 +2364,55 @@
|
|
|
2711
2364
|
});
|
|
2712
2365
|
};
|
|
2713
2366
|
}
|
|
2367
|
+
|
|
2368
|
+
var LEGACY_ANONYMOUS_ID = '__anon_id';
|
|
2369
|
+
var ANONYMOUS_ID = '__nt_anonymous_id__';
|
|
2370
|
+
var DEBUG_FLAG = '__nt_debug__';
|
|
2371
|
+
var PROFILE_FALLBACK_CACHE = '__nt_profile__';
|
|
2372
|
+
|
|
2373
|
+
var NINETAILED_TRACKER_EVENTS = {
|
|
2374
|
+
/**
|
|
2375
|
+
* `profile` - Fires when the profile is returned by the cdp API.
|
|
2376
|
+
*/
|
|
2377
|
+
profile: 'profile'
|
|
2378
|
+
};
|
|
2379
|
+
var PLUGIN_NAME = 'ninetailed';
|
|
2380
|
+
|
|
2381
|
+
var delay = function delay(ms) {
|
|
2382
|
+
return new Promise(function (resolve) {
|
|
2383
|
+
return setTimeout(resolve, ms);
|
|
2384
|
+
});
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2387
|
+
var emptyProfile = {
|
|
2388
|
+
id: '',
|
|
2389
|
+
random: 0,
|
|
2390
|
+
audiences: [],
|
|
2391
|
+
traits: {},
|
|
2392
|
+
location: {}
|
|
2393
|
+
};
|
|
2714
2394
|
var ninetailedPlugin = function ninetailedPlugin(_a) {
|
|
2715
2395
|
var clientId = _a.clientId,
|
|
2716
|
-
environment = _a.environment
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
var isInitialized = false;
|
|
2723
|
-
var apiClient = new NinetailedApiClient({
|
|
2396
|
+
environment = _a.environment;
|
|
2397
|
+
_a.preview;
|
|
2398
|
+
var url = _a.url,
|
|
2399
|
+
profile = _a.profile;
|
|
2400
|
+
_a.locale;
|
|
2401
|
+
var apiClient = new experience_jsShared.NinetailedApiClient({
|
|
2724
2402
|
clientId: clientId,
|
|
2725
2403
|
environment: environment,
|
|
2726
2404
|
url: url
|
|
2727
2405
|
});
|
|
2728
2406
|
var queue = [];
|
|
2729
|
-
var localOnly = false;
|
|
2730
2407
|
|
|
2731
2408
|
var flush = function flush(instance) {
|
|
2732
2409
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
2733
|
-
var events,
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
switch (_b.label) {
|
|
2410
|
+
var events, anonymousId, profile_1, error_1, fallbackProfile;
|
|
2411
|
+
return __generator(this, function (_a) {
|
|
2412
|
+
switch (_a.label) {
|
|
2737
2413
|
case 0:
|
|
2738
2414
|
events = Object.assign([], queue);
|
|
2739
|
-
logger.info('Start flushing events.');
|
|
2415
|
+
experience_jsShared.logger.info('Start flushing events.');
|
|
2740
2416
|
queue = [];
|
|
2741
2417
|
|
|
2742
2418
|
if (!events.length) {
|
|
@@ -2745,69 +2421,36 @@
|
|
|
2745
2421
|
];
|
|
2746
2422
|
}
|
|
2747
2423
|
|
|
2748
|
-
|
|
2749
|
-
instance: instance
|
|
2750
|
-
});
|
|
2751
|
-
_b.label = 1;
|
|
2424
|
+
_a.label = 1;
|
|
2752
2425
|
|
|
2753
2426
|
case 1:
|
|
2754
|
-
|
|
2427
|
+
_a.trys.push([1, 3,, 4]);
|
|
2755
2428
|
|
|
2756
|
-
|
|
2429
|
+
anonymousId = instance.storage.getItem(ANONYMOUS_ID);
|
|
2757
2430
|
return [4
|
|
2758
2431
|
/*yield*/
|
|
2759
|
-
, apiClient.
|
|
2760
|
-
events: events,
|
|
2761
|
-
signals: get__default["default"](cache, 'signals', {}),
|
|
2762
|
-
traits: get__default["default"](cache, 'traits', {}),
|
|
2763
|
-
traitsUpdatedAt: get__default["default"](cache, 'traitsUpdatedAt', new Date().toISOString()),
|
|
2764
|
-
localOnly: localOnly,
|
|
2765
|
-
preview: preview,
|
|
2766
|
-
options: {
|
|
2767
|
-
locale: locale || 'en'
|
|
2768
|
-
},
|
|
2769
|
-
sessions: get__default["default"](cache, 'sessions', [])
|
|
2770
|
-
})];
|
|
2432
|
+
, apiClient.upsertProfile(events, anonymousId)];
|
|
2771
2433
|
|
|
2772
2434
|
case 2:
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
random: profile_1.random,
|
|
2778
|
-
audiences: profile_1.audiences,
|
|
2779
|
-
traits: profile_1.traits,
|
|
2780
|
-
location: profile_1.location,
|
|
2781
|
-
signals: signals,
|
|
2782
|
-
traitsUpdatedAt: traitsUpdatedAt,
|
|
2783
|
-
sessions: sessions,
|
|
2784
|
-
session: profile_1.session
|
|
2785
|
-
}, {
|
|
2786
|
-
instance: instance
|
|
2787
|
-
});
|
|
2435
|
+
profile_1 = _a.sent();
|
|
2436
|
+
instance.storage.setItem(ANONYMOUS_ID, profile_1.id);
|
|
2437
|
+
instance.storage.setItem(PROFILE_FALLBACK_CACHE, profile_1);
|
|
2438
|
+
experience_jsShared.logger.debug('Profile from api: ', profile_1);
|
|
2788
2439
|
instance.dispatch({
|
|
2789
2440
|
type: NINETAILED_TRACKER_EVENTS.profile,
|
|
2790
|
-
profile: profile_1
|
|
2791
|
-
cache: updatedCache
|
|
2441
|
+
profile: profile_1
|
|
2792
2442
|
});
|
|
2793
2443
|
return [3
|
|
2794
2444
|
/*break*/
|
|
2795
2445
|
, 4];
|
|
2796
2446
|
|
|
2797
2447
|
case 3:
|
|
2798
|
-
error_1 =
|
|
2799
|
-
logger.debug('An error occurred during flushing the events: ', error_1);
|
|
2448
|
+
error_1 = _a.sent();
|
|
2449
|
+
experience_jsShared.logger.debug('An error occurred during flushing the events: ', error_1);
|
|
2450
|
+
fallbackProfile = instance.storage.getItem(PROFILE_FALLBACK_CACHE) || emptyProfile;
|
|
2800
2451
|
instance.dispatch({
|
|
2801
2452
|
type: NINETAILED_TRACKER_EVENTS.profile,
|
|
2802
|
-
profile:
|
|
2803
|
-
id: cache.id,
|
|
2804
|
-
random: cache.random,
|
|
2805
|
-
audiences: cache.audiences,
|
|
2806
|
-
traits: cache.traits,
|
|
2807
|
-
location: cache.location,
|
|
2808
|
-
session: cache.session
|
|
2809
|
-
},
|
|
2810
|
-
cache: cache
|
|
2453
|
+
profile: fallbackProfile
|
|
2811
2454
|
});
|
|
2812
2455
|
return [3
|
|
2813
2456
|
/*break*/
|
|
@@ -2821,7 +2464,7 @@
|
|
|
2821
2464
|
|
|
2822
2465
|
case 5:
|
|
2823
2466
|
// This is necessary to make sure that the cache is updated before the next flush is performed
|
|
2824
|
-
|
|
2467
|
+
_a.sent();
|
|
2825
2468
|
|
|
2826
2469
|
return [2
|
|
2827
2470
|
/*return*/
|
|
@@ -2829,15 +2472,11 @@
|
|
|
2829
2472
|
}
|
|
2830
2473
|
});
|
|
2831
2474
|
});
|
|
2832
|
-
};
|
|
2833
|
-
// leading: false,
|
|
2834
|
-
// trailing: true,
|
|
2835
|
-
// });
|
|
2836
|
-
|
|
2475
|
+
};
|
|
2837
2476
|
|
|
2838
2477
|
var throttledFlush = asyncThrottle(flush);
|
|
2839
2478
|
|
|
2840
|
-
var
|
|
2479
|
+
var enqueueEvent = function enqueueEvent(event, instance) {
|
|
2841
2480
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
2842
2481
|
return __generator(this, function (_a) {
|
|
2843
2482
|
queue = unionBy__default["default"]([event], queue, 'messageId');
|
|
@@ -2855,33 +2494,25 @@
|
|
|
2855
2494
|
initialize: function (_a) {
|
|
2856
2495
|
var instance = _a.instance;
|
|
2857
2496
|
|
|
2858
|
-
if (instance.storage.getItem(
|
|
2859
|
-
logger.addSink(new ConsoleLogSink());
|
|
2860
|
-
logger.info('Ninetailed Debug Mode is enabled.');
|
|
2861
|
-
}
|
|
2497
|
+
if (instance.storage.getItem(DEBUG_FLAG)) {
|
|
2498
|
+
experience_jsShared.logger.addSink(new experience_jsShared.ConsoleLogSink());
|
|
2499
|
+
experience_jsShared.logger.info('Ninetailed Debug Mode is enabled.');
|
|
2500
|
+
} // legacy support for the old anonymousId
|
|
2862
2501
|
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2502
|
+
|
|
2503
|
+
var legacyAnonymousId = instance.storage.getItem(LEGACY_ANONYMOUS_ID);
|
|
2504
|
+
|
|
2505
|
+
if (legacyAnonymousId) {
|
|
2506
|
+
experience_jsShared.logger.debug('Found legacy anonymousId, migrating to new one.', legacyAnonymousId);
|
|
2507
|
+
instance.storage.setItem(ANONYMOUS_ID, legacyAnonymousId);
|
|
2508
|
+
instance.storage.removeItem(LEGACY_ANONYMOUS_ID);
|
|
2509
|
+
}
|
|
2866
2510
|
|
|
2867
2511
|
if (profile) {
|
|
2868
|
-
instance.storage.setItem(
|
|
2869
|
-
initialize({
|
|
2870
|
-
instance: instance
|
|
2871
|
-
}, __assign(__assign({}, cache), {
|
|
2872
|
-
id: profile.id
|
|
2873
|
-
}));
|
|
2874
|
-
} else {
|
|
2875
|
-
var anonymousId = instance.storage.getItem('__anon_id');
|
|
2876
|
-
initialize({
|
|
2877
|
-
instance: instance
|
|
2878
|
-
}, __assign(__assign({}, cache), {
|
|
2879
|
-
id: anonymousId
|
|
2880
|
-
}));
|
|
2512
|
+
instance.storage.setItem(ANONYMOUS_ID, profile.id);
|
|
2881
2513
|
}
|
|
2882
2514
|
|
|
2883
|
-
|
|
2884
|
-
logger.debug('Ninetailed Core plugin initialized.');
|
|
2515
|
+
experience_jsShared.logger.debug('Ninetailed Core plugin initialized.');
|
|
2885
2516
|
},
|
|
2886
2517
|
page: function (_a) {
|
|
2887
2518
|
var payload = _a.payload,
|
|
@@ -2891,14 +2522,11 @@
|
|
|
2891
2522
|
return __generator(this, function (_b) {
|
|
2892
2523
|
switch (_b.label) {
|
|
2893
2524
|
case 0:
|
|
2894
|
-
logger.info('Sending Page event.');
|
|
2525
|
+
experience_jsShared.logger.info('Sending Page event.');
|
|
2895
2526
|
ctx = buildClientNinetailedRequestContext();
|
|
2896
|
-
localOnly = payload.localOnly;
|
|
2897
2527
|
return [4
|
|
2898
2528
|
/*yield*/
|
|
2899
|
-
,
|
|
2900
|
-
// doing this here as the anonymous id is set to late from init
|
|
2901
|
-
anonymousId: (profile === null || profile === void 0 ? void 0 : profile.id) || payload.anonymousId,
|
|
2529
|
+
, enqueueEvent(experience_jsShared.buildPageEvent({
|
|
2902
2530
|
messageId: payload.meta.rid,
|
|
2903
2531
|
timestamp: payload.meta.ts,
|
|
2904
2532
|
properties: payload.properties,
|
|
@@ -2923,14 +2551,11 @@
|
|
|
2923
2551
|
return __generator(this, function (_b) {
|
|
2924
2552
|
switch (_b.label) {
|
|
2925
2553
|
case 0:
|
|
2926
|
-
logger.info('Sending Track event.');
|
|
2554
|
+
experience_jsShared.logger.info('Sending Track event.');
|
|
2927
2555
|
ctx = buildClientNinetailedRequestContext();
|
|
2928
|
-
localOnly = payload.localOnly;
|
|
2929
2556
|
return [4
|
|
2930
2557
|
/*yield*/
|
|
2931
|
-
,
|
|
2932
|
-
// doing this here as the anonymous id is set to late from init
|
|
2933
|
-
anonymousId: (profile === null || profile === void 0 ? void 0 : profile.id) || payload.anonymousId,
|
|
2558
|
+
, enqueueEvent(experience_jsShared.buildTrackEvent({
|
|
2934
2559
|
messageId: payload.meta.rid,
|
|
2935
2560
|
timestamp: payload.meta.ts,
|
|
2936
2561
|
event: payload.event,
|
|
@@ -2956,14 +2581,12 @@
|
|
|
2956
2581
|
return __generator(this, function (_b) {
|
|
2957
2582
|
switch (_b.label) {
|
|
2958
2583
|
case 0:
|
|
2959
|
-
logger.info('Sending Identify event.');
|
|
2960
|
-
localOnly = payload.localOnly;
|
|
2584
|
+
experience_jsShared.logger.info('Sending Identify event.');
|
|
2961
2585
|
ctx = buildClientNinetailedRequestContext();
|
|
2962
2586
|
return [4
|
|
2963
2587
|
/*yield*/
|
|
2964
|
-
,
|
|
2588
|
+
, enqueueEvent(experience_jsShared.buildIdentifyEvent({
|
|
2965
2589
|
// doing this here as the anonymous id is set to late from init
|
|
2966
|
-
anonymousId: (profile === null || profile === void 0 ? void 0 : profile.id) || payload.anonymousId,
|
|
2967
2590
|
messageId: payload.meta.rid,
|
|
2968
2591
|
timestamp: payload.meta.ts,
|
|
2969
2592
|
traits: payload.traits,
|
|
@@ -2981,8 +2604,15 @@
|
|
|
2981
2604
|
});
|
|
2982
2605
|
});
|
|
2983
2606
|
},
|
|
2984
|
-
|
|
2985
|
-
|
|
2607
|
+
setItemStart: function (_a) {
|
|
2608
|
+
var abort = _a.abort,
|
|
2609
|
+
payload = _a.payload;
|
|
2610
|
+
|
|
2611
|
+
if (![ANONYMOUS_ID, DEBUG_FLAG, PROFILE_FALLBACK_CACHE].includes(payload.key)) {
|
|
2612
|
+
return abort();
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
return payload;
|
|
2986
2616
|
},
|
|
2987
2617
|
methods: {
|
|
2988
2618
|
reset: function () {
|
|
@@ -2993,31 +2623,21 @@
|
|
|
2993
2623
|
}
|
|
2994
2624
|
|
|
2995
2625
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
2996
|
-
var instance
|
|
2626
|
+
var instance;
|
|
2997
2627
|
return __generator(this, function (_a) {
|
|
2998
2628
|
switch (_a.label) {
|
|
2999
2629
|
case 0:
|
|
3000
2630
|
instance = args[args.length - 1];
|
|
3001
|
-
cache = reset({
|
|
3002
|
-
instance: instance
|
|
3003
|
-
});
|
|
3004
2631
|
return [4
|
|
3005
2632
|
/*yield*/
|
|
3006
|
-
, instance.storage.
|
|
2633
|
+
, instance.storage.removeItem(ANONYMOUS_ID)];
|
|
3007
2634
|
|
|
3008
2635
|
case 1:
|
|
3009
2636
|
_a.sent();
|
|
3010
2637
|
|
|
3011
2638
|
instance.dispatch({
|
|
3012
2639
|
type: NINETAILED_TRACKER_EVENTS.profile,
|
|
3013
|
-
profile:
|
|
3014
|
-
id: cache.id,
|
|
3015
|
-
random: 0,
|
|
3016
|
-
audiences: [],
|
|
3017
|
-
traits: {},
|
|
3018
|
-
location: {}
|
|
3019
|
-
},
|
|
3020
|
-
cache: cache
|
|
2640
|
+
profile: emptyProfile
|
|
3021
2641
|
});
|
|
3022
2642
|
return [4
|
|
3023
2643
|
/*yield*/
|
|
@@ -3047,21 +2667,19 @@
|
|
|
3047
2667
|
case 0:
|
|
3048
2668
|
enabled = args[0];
|
|
3049
2669
|
instance = args[args.length - 1];
|
|
3050
|
-
consoleLogSink = new ConsoleLogSink();
|
|
2670
|
+
consoleLogSink = new experience_jsShared.ConsoleLogSink();
|
|
3051
2671
|
if (!enabled) return [3
|
|
3052
2672
|
/*break*/
|
|
3053
2673
|
, 2];
|
|
3054
2674
|
return [4
|
|
3055
2675
|
/*yield*/
|
|
3056
|
-
, instance.storage.setItem(
|
|
2676
|
+
, instance.storage.setItem(DEBUG_FLAG, true)];
|
|
3057
2677
|
|
|
3058
2678
|
case 1:
|
|
3059
|
-
_a.sent();
|
|
3060
|
-
|
|
2679
|
+
_a.sent();
|
|
3061
2680
|
|
|
3062
|
-
logger.
|
|
3063
|
-
logger.
|
|
3064
|
-
logger.info('Debug mode enabled.');
|
|
2681
|
+
experience_jsShared.logger.addSink(consoleLogSink);
|
|
2682
|
+
experience_jsShared.logger.info('Debug mode enabled.');
|
|
3065
2683
|
return [3
|
|
3066
2684
|
/*break*/
|
|
3067
2685
|
, 4];
|
|
@@ -3069,13 +2687,13 @@
|
|
|
3069
2687
|
case 2:
|
|
3070
2688
|
return [4
|
|
3071
2689
|
/*yield*/
|
|
3072
|
-
, instance.storage.removeItem(
|
|
2690
|
+
, instance.storage.removeItem(DEBUG_FLAG)];
|
|
3073
2691
|
|
|
3074
2692
|
case 3:
|
|
3075
2693
|
_a.sent();
|
|
3076
2694
|
|
|
3077
|
-
logger.info('Debug mode disabled.');
|
|
3078
|
-
logger.removeSink(consoleLogSink.name);
|
|
2695
|
+
experience_jsShared.logger.info('Debug mode disabled.');
|
|
2696
|
+
experience_jsShared.logger.removeSink(consoleLogSink.name);
|
|
3079
2697
|
_a.label = 4;
|
|
3080
2698
|
|
|
3081
2699
|
case 4:
|
|
@@ -3186,6 +2804,8 @@
|
|
|
3186
2804
|
|
|
3187
2805
|
case 1:
|
|
3188
2806
|
_a.sent();
|
|
2807
|
+
/*console.log("Identify triggered");*/
|
|
2808
|
+
|
|
3189
2809
|
|
|
3190
2810
|
return [2
|
|
3191
2811
|
/*return*/
|
|
@@ -3197,12 +2817,16 @@
|
|
|
3197
2817
|
|
|
3198
2818
|
this.reset = function () {
|
|
3199
2819
|
_this.onIsInitialized(function () {
|
|
2820
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2821
|
+
// @ts-ignore
|
|
3200
2822
|
_this.instance.plugins[PLUGIN_NAME].reset();
|
|
3201
2823
|
});
|
|
3202
2824
|
};
|
|
3203
2825
|
|
|
3204
2826
|
this.debug = function (enabled) {
|
|
3205
2827
|
_this.onIsInitialized(function () {
|
|
2828
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
2829
|
+
// @ts-ignore
|
|
3206
2830
|
_this.instance.plugins[PLUGIN_NAME].debug(enabled);
|
|
3207
2831
|
});
|
|
3208
2832
|
};
|
|
@@ -3214,7 +2838,7 @@
|
|
|
3214
2838
|
cb(__assign(__assign({}, _this._profileState), {
|
|
3215
2839
|
status: 'success',
|
|
3216
2840
|
profile: payload.profile,
|
|
3217
|
-
error:
|
|
2841
|
+
error: null
|
|
3218
2842
|
}));
|
|
3219
2843
|
});
|
|
3220
2844
|
};
|
|
@@ -3244,27 +2868,27 @@
|
|
|
3244
2868
|
this._profileState = {
|
|
3245
2869
|
status: 'success',
|
|
3246
2870
|
profile: profile,
|
|
3247
|
-
error:
|
|
2871
|
+
error: null,
|
|
3248
2872
|
from: 'hydrated'
|
|
3249
2873
|
};
|
|
3250
2874
|
} else {
|
|
3251
2875
|
this._profileState = {
|
|
3252
2876
|
status: 'loading',
|
|
3253
2877
|
profile: null,
|
|
3254
|
-
error:
|
|
2878
|
+
error: null,
|
|
3255
2879
|
from: 'api'
|
|
3256
2880
|
};
|
|
3257
2881
|
}
|
|
3258
2882
|
|
|
3259
2883
|
if (typeof onLog === 'function') {
|
|
3260
|
-
logger.addSink(new OnLogLogSink(onLog));
|
|
2884
|
+
experience_jsShared.logger.addSink(new experience_jsShared.OnLogLogSink(onLog));
|
|
3261
2885
|
}
|
|
3262
2886
|
|
|
3263
2887
|
if (typeof onError === 'function') {
|
|
3264
|
-
logger.addSink(new OnErrorLogSink(onError));
|
|
2888
|
+
experience_jsShared.logger.addSink(new experience_jsShared.OnErrorLogSink(onError));
|
|
3265
2889
|
}
|
|
3266
2890
|
|
|
3267
|
-
this.logger = logger;
|
|
2891
|
+
this.logger = experience_jsShared.logger;
|
|
3268
2892
|
this.instance = Analytics__default["default"]({
|
|
3269
2893
|
app: 'ninetailed',
|
|
3270
2894
|
plugins: __spreadArray(__spreadArray([], this.plugins, true), [ninetailedPlugin({
|
|
@@ -3279,7 +2903,7 @@
|
|
|
3279
2903
|
});
|
|
3280
2904
|
var detachOnReadyListener = this.instance.on('ready', function () {
|
|
3281
2905
|
_this.isInitialized = true;
|
|
3282
|
-
logger.info('Ninetailed Experience.js SDK is completely initialized.');
|
|
2906
|
+
experience_jsShared.logger.info('Ninetailed Experience.js SDK is completely initialized.');
|
|
3283
2907
|
detachOnReadyListener();
|
|
3284
2908
|
}); // put in private method
|
|
3285
2909
|
|
|
@@ -3335,12 +2959,12 @@
|
|
|
3335
2959
|
if (status === 'loading') {
|
|
3336
2960
|
return {
|
|
3337
2961
|
loading: true,
|
|
3338
|
-
variant: __assign({
|
|
2962
|
+
variant: __assign(__assign({}, baseline), {
|
|
3339
2963
|
id: 'baseline',
|
|
3340
2964
|
audience: {
|
|
3341
2965
|
id: 'baseline'
|
|
3342
2966
|
}
|
|
3343
|
-
}
|
|
2967
|
+
}),
|
|
3344
2968
|
audience: {
|
|
3345
2969
|
id: 'baseline'
|
|
3346
2970
|
},
|
|
@@ -3352,12 +2976,12 @@
|
|
|
3352
2976
|
if (status === 'error') {
|
|
3353
2977
|
return {
|
|
3354
2978
|
loading: false,
|
|
3355
|
-
variant: __assign({
|
|
2979
|
+
variant: __assign(__assign({}, baseline), {
|
|
3356
2980
|
id: 'baseline',
|
|
3357
2981
|
audience: {
|
|
3358
2982
|
id: 'baseline'
|
|
3359
2983
|
}
|
|
3360
|
-
}
|
|
2984
|
+
}),
|
|
3361
2985
|
audience: {
|
|
3362
2986
|
id: 'baseline'
|
|
3363
2987
|
},
|
|
@@ -3373,15 +2997,15 @@
|
|
|
3373
2997
|
});
|
|
3374
2998
|
|
|
3375
2999
|
if (variant) {
|
|
3376
|
-
|
|
3000
|
+
// @ts-ignore
|
|
3001
|
+
if ((options === null || options === void 0 ? void 0 : options.holdout) || -1 > (profile === null || profile === void 0 ? void 0 : profile.random)) {
|
|
3377
3002
|
return {
|
|
3378
3003
|
loading: false,
|
|
3379
|
-
variant: __assign({
|
|
3380
|
-
id: baseline.id,
|
|
3004
|
+
variant: __assign(__assign({}, baseline), {
|
|
3381
3005
|
audience: {
|
|
3382
3006
|
id: 'baseline'
|
|
3383
3007
|
}
|
|
3384
|
-
}
|
|
3008
|
+
}),
|
|
3385
3009
|
audience: __assign(__assign({}, variant.audience), {
|
|
3386
3010
|
id: variant.audience.id
|
|
3387
3011
|
}),
|
|
@@ -3407,12 +3031,12 @@
|
|
|
3407
3031
|
|
|
3408
3032
|
return {
|
|
3409
3033
|
loading: false,
|
|
3410
|
-
variant: __assign({
|
|
3034
|
+
variant: __assign(__assign({}, baseline), {
|
|
3411
3035
|
id: 'baseline',
|
|
3412
3036
|
audience: {
|
|
3413
3037
|
id: 'baseline'
|
|
3414
3038
|
}
|
|
3415
|
-
}
|
|
3039
|
+
}),
|
|
3416
3040
|
audience: {
|
|
3417
3041
|
id: 'baseline'
|
|
3418
3042
|
},
|
|
@@ -3424,9 +3048,11 @@
|
|
|
3424
3048
|
var EXPERIENCE_TRAIT_PREFIX = 'nt_experiment_';
|
|
3425
3049
|
|
|
3426
3050
|
var selectBaselineWithVariants = function selectBaselineWithVariants(experience, baseline) {
|
|
3427
|
-
|
|
3051
|
+
var _a;
|
|
3052
|
+
|
|
3053
|
+
return (_a = experience.components.find(function (baselineWithVariants) {
|
|
3428
3054
|
return baselineWithVariants.baseline.id === baseline.id;
|
|
3429
|
-
});
|
|
3055
|
+
})) !== null && _a !== void 0 ? _a : null;
|
|
3430
3056
|
};
|
|
3431
3057
|
|
|
3432
3058
|
var selectVariants = function selectVariants(experience, baseline) {
|
|
@@ -3444,63 +3070,13 @@
|
|
|
3444
3070
|
return variants.length > 0;
|
|
3445
3071
|
};
|
|
3446
3072
|
|
|
3447
|
-
var global$9 = global$I;
|
|
3448
|
-
var classof$2 = classof$6;
|
|
3449
|
-
|
|
3450
|
-
var String$1 = global$9.String;
|
|
3451
|
-
|
|
3452
|
-
var toString$7 = function (argument) {
|
|
3453
|
-
if (classof$2(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string');
|
|
3454
|
-
return String$1(argument);
|
|
3455
|
-
};
|
|
3456
|
-
|
|
3457
|
-
var isObject = isObject$8;
|
|
3458
|
-
var classof$1 = classofRaw$1;
|
|
3459
|
-
var wellKnownSymbol$3 = wellKnownSymbol$e;
|
|
3460
|
-
|
|
3461
|
-
var MATCH$1 = wellKnownSymbol$3('match');
|
|
3462
|
-
|
|
3463
|
-
// `IsRegExp` abstract operation
|
|
3464
|
-
// https://tc39.es/ecma262/#sec-isregexp
|
|
3465
|
-
var isRegexp = function (it) {
|
|
3466
|
-
var isRegExp;
|
|
3467
|
-
return isObject(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$1(it) == 'RegExp');
|
|
3468
|
-
};
|
|
3469
|
-
|
|
3470
|
-
var global$8 = global$I;
|
|
3471
|
-
var isRegExp$1 = isRegexp;
|
|
3472
|
-
|
|
3473
|
-
var TypeError$3 = global$8.TypeError;
|
|
3474
|
-
|
|
3475
|
-
var notARegexp = function (it) {
|
|
3476
|
-
if (isRegExp$1(it)) {
|
|
3477
|
-
throw TypeError$3("The method doesn't accept regular expressions");
|
|
3478
|
-
} return it;
|
|
3479
|
-
};
|
|
3480
|
-
|
|
3481
|
-
var wellKnownSymbol$2 = wellKnownSymbol$e;
|
|
3482
|
-
|
|
3483
|
-
var MATCH = wellKnownSymbol$2('match');
|
|
3484
|
-
|
|
3485
|
-
var correctIsRegexpLogic = function (METHOD_NAME) {
|
|
3486
|
-
var regexp = /./;
|
|
3487
|
-
try {
|
|
3488
|
-
'/./'[METHOD_NAME](regexp);
|
|
3489
|
-
} catch (error1) {
|
|
3490
|
-
try {
|
|
3491
|
-
regexp[MATCH] = false;
|
|
3492
|
-
return '/./'[METHOD_NAME](regexp);
|
|
3493
|
-
} catch (error2) { /* empty */ }
|
|
3494
|
-
} return false;
|
|
3495
|
-
};
|
|
3496
|
-
|
|
3497
3073
|
var $$3 = _export;
|
|
3498
3074
|
var uncurryThis$8 = functionUncurryThis;
|
|
3499
3075
|
var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
|
|
3500
3076
|
var toLength$2 = toLength$4;
|
|
3501
|
-
var toString$6 = toString$
|
|
3077
|
+
var toString$6 = toString$8;
|
|
3502
3078
|
var notARegExp = notARegexp;
|
|
3503
|
-
var requireObjectCoercible$4 = requireObjectCoercible$
|
|
3079
|
+
var requireObjectCoercible$4 = requireObjectCoercible$8;
|
|
3504
3080
|
var correctIsRegExpLogic = correctIsRegexpLogic;
|
|
3505
3081
|
|
|
3506
3082
|
// eslint-disable-next-line es/no-string-prototype-startswith -- safe
|
|
@@ -3710,7 +3286,7 @@
|
|
|
3710
3286
|
/* eslint-disable regexp/no-useless-quantifier -- testing */
|
|
3711
3287
|
var call$3 = functionCall;
|
|
3712
3288
|
var uncurryThis$7 = functionUncurryThis;
|
|
3713
|
-
var toString$5 = toString$
|
|
3289
|
+
var toString$5 = toString$8;
|
|
3714
3290
|
var regexpFlags = regexpFlags$1;
|
|
3715
3291
|
var stickyHelpers$1 = regexpStickyHelpers;
|
|
3716
3292
|
var shared = shared$4.exports;
|
|
@@ -3908,8 +3484,8 @@
|
|
|
3908
3484
|
|
|
3909
3485
|
var uncurryThis$5 = functionUncurryThis;
|
|
3910
3486
|
var toIntegerOrInfinity$1 = toIntegerOrInfinity$4;
|
|
3911
|
-
var toString$4 = toString$
|
|
3912
|
-
var requireObjectCoercible$3 = requireObjectCoercible$
|
|
3487
|
+
var toString$4 = toString$8;
|
|
3488
|
+
var requireObjectCoercible$3 = requireObjectCoercible$8;
|
|
3913
3489
|
|
|
3914
3490
|
var charAt$2 = uncurryThis$5(''.charAt);
|
|
3915
3491
|
var charCodeAt = uncurryThis$5(''.charCodeAt);
|
|
@@ -4027,8 +3603,8 @@
|
|
|
4027
3603
|
var isCallable = isCallable$g;
|
|
4028
3604
|
var toIntegerOrInfinity = toIntegerOrInfinity$4;
|
|
4029
3605
|
var toLength$1 = toLength$4;
|
|
4030
|
-
var toString$3 = toString$
|
|
4031
|
-
var requireObjectCoercible$2 = requireObjectCoercible$
|
|
3606
|
+
var toString$3 = toString$8;
|
|
3607
|
+
var requireObjectCoercible$2 = requireObjectCoercible$8;
|
|
4032
3608
|
var advanceStringIndex$1 = advanceStringIndex$2;
|
|
4033
3609
|
var getMethod$1 = getMethod$5;
|
|
4034
3610
|
var getSubstitution = getSubstitution$1;
|
|
@@ -4209,13 +3785,13 @@
|
|
|
4209
3785
|
activeExperiments = _a.activeExperiments,
|
|
4210
3786
|
profile = _a.profile;
|
|
4211
3787
|
var trafficRandom = getTrafficRandom(profile, experience);
|
|
4212
|
-
logger.info("The traffic random factor for experience ".concat(experience.id, " is ").concat(trafficRandom, ". It's traffic allocation is set to ").concat(experience.trafficAllocation, "."));
|
|
3788
|
+
experience_jsShared.logger.info("The traffic random factor for experience ".concat(experience.id, " is ").concat(trafficRandom, ". It's traffic allocation is set to ").concat(experience.trafficAllocation, "."));
|
|
4213
3789
|
var isInTrafficRange = experience.trafficAllocation > trafficRandom;
|
|
4214
3790
|
var matchesAudience = !experience.audience || includes__default["default"](profile.audiences, experience.audience.id);
|
|
4215
3791
|
var hasActiveExperiment = !!find__default["default"](activeExperiments, {
|
|
4216
3792
|
id: experience.id
|
|
4217
3793
|
});
|
|
4218
|
-
logger.info("Is the profile in traffic allocation range? ".concat(isInTrafficRange ? 'yes' : 'no', ".\n\n Does the profile match the audience of the experience? ").concat(matchesAudience ? 'yes' : 'no', ".\n\n Is there an active experiment for this profile? ").concat(hasActiveExperiment ? 'yes' : 'no', "."));
|
|
3794
|
+
experience_jsShared.logger.info("Is the profile in traffic allocation range? ".concat(isInTrafficRange ? 'yes' : 'no', ".\n\n Does the profile match the audience of the experience? ").concat(matchesAudience ? 'yes' : 'no', ".\n\n Is there an active experiment for this profile? ").concat(hasActiveExperiment ? 'yes' : 'no', "."));
|
|
4219
3795
|
return isInTrafficRange && (matchesAudience || // if the expriment is active already then it's selectible without further contraints to be fullfilled
|
|
4220
3796
|
hasActiveExperiment);
|
|
4221
3797
|
};
|
|
@@ -4235,20 +3811,30 @@
|
|
|
4235
3811
|
profile: profile
|
|
4236
3812
|
});
|
|
4237
3813
|
});
|
|
4238
|
-
return selectedExperience;
|
|
3814
|
+
return selectedExperience !== null && selectedExperience !== void 0 ? selectedExperience : null;
|
|
4239
3815
|
};
|
|
4240
3816
|
|
|
4241
3817
|
var selectDistribution = function selectDistribution(_a) {
|
|
4242
3818
|
var experience = _a.experience,
|
|
4243
3819
|
profile = _a.profile;
|
|
4244
3820
|
var distributionRandom = getDistributionRandom(profile, experience);
|
|
4245
|
-
logger.log("The distribution random factor for experience ".concat(experience.id, " is ").concat(distributionRandom, ". It's distribution is set to ").concat(JSON.stringify(experience.distribution, null, 2), "."));
|
|
3821
|
+
experience_jsShared.logger.log("The distribution random factor for experience ".concat(experience.id, " is ").concat(distributionRandom, ". It's distribution is set to ").concat(JSON.stringify(experience.distribution, null, 2), "."));
|
|
4246
3822
|
var distribution = find__default["default"](experience.distribution, function (_a) {
|
|
4247
3823
|
var start = _a.start,
|
|
4248
3824
|
end = _a.end;
|
|
4249
3825
|
return distributionRandom >= start && distributionRandom <= end;
|
|
4250
3826
|
} // this overlaps on one value for each boundary but we just find the first match
|
|
4251
3827
|
);
|
|
3828
|
+
|
|
3829
|
+
if (!distribution) {
|
|
3830
|
+
// This should never happen. If it happens then the distribution is not configured correctly. So we just return the baseline.
|
|
3831
|
+
return {
|
|
3832
|
+
index: 0,
|
|
3833
|
+
start: 0,
|
|
3834
|
+
end: 1
|
|
3835
|
+
};
|
|
3836
|
+
}
|
|
3837
|
+
|
|
4252
3838
|
return distribution;
|
|
4253
3839
|
};
|
|
4254
3840
|
|
|
@@ -4402,11 +3988,11 @@
|
|
|
4402
3988
|
var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
|
|
4403
3989
|
var isRegExp = isRegexp;
|
|
4404
3990
|
var anObject = anObject$e;
|
|
4405
|
-
var requireObjectCoercible$1 = requireObjectCoercible$
|
|
3991
|
+
var requireObjectCoercible$1 = requireObjectCoercible$8;
|
|
4406
3992
|
var speciesConstructor = speciesConstructor$2;
|
|
4407
3993
|
var advanceStringIndex = advanceStringIndex$2;
|
|
4408
3994
|
var toLength = toLength$4;
|
|
4409
|
-
var toString$2 = toString$
|
|
3995
|
+
var toString$2 = toString$8;
|
|
4410
3996
|
var getMethod = getMethod$5;
|
|
4411
3997
|
var arraySlice = arraySliceSimple;
|
|
4412
3998
|
var callRegExpExec = regexpExecAbstract;
|
|
@@ -4557,8 +4143,8 @@
|
|
|
4557
4143
|
'\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
|
|
4558
4144
|
|
|
4559
4145
|
var uncurryThis$1 = functionUncurryThis;
|
|
4560
|
-
var requireObjectCoercible = requireObjectCoercible$
|
|
4561
|
-
var toString$1 = toString$
|
|
4146
|
+
var requireObjectCoercible = requireObjectCoercible$8;
|
|
4147
|
+
var toString$1 = toString$8;
|
|
4562
4148
|
var whitespaces$1 = whitespaces$2;
|
|
4563
4149
|
|
|
4564
4150
|
var replace = uncurryThis$1(''.replace);
|
|
@@ -4591,7 +4177,7 @@
|
|
|
4591
4177
|
var global$1 = global$I;
|
|
4592
4178
|
var fails = fails$i;
|
|
4593
4179
|
var uncurryThis = functionUncurryThis;
|
|
4594
|
-
var toString = toString$
|
|
4180
|
+
var toString = toString$8;
|
|
4595
4181
|
var trim = stringTrim.trim;
|
|
4596
4182
|
var whitespaces = whitespaces$2;
|
|
4597
4183
|
|
|
@@ -4637,7 +4223,7 @@
|
|
|
4637
4223
|
variantIndex: variantIndex
|
|
4638
4224
|
};
|
|
4639
4225
|
}).filter(function (x) {
|
|
4640
|
-
return x;
|
|
4226
|
+
return !!x;
|
|
4641
4227
|
}).reduce(function (acc, curr) {
|
|
4642
4228
|
var _a;
|
|
4643
4229
|
|
|
@@ -4645,14 +4231,12 @@
|
|
|
4645
4231
|
}, {});
|
|
4646
4232
|
};
|
|
4647
4233
|
|
|
4648
|
-
exports.Cache = index;
|
|
4649
4234
|
exports.EXPERIENCE_TRAIT_PREFIX = EXPERIENCE_TRAIT_PREFIX;
|
|
4650
4235
|
exports.NINETAILED_TRACKER_EVENTS = NINETAILED_TRACKER_EVENTS;
|
|
4651
4236
|
exports.Ninetailed = Ninetailed;
|
|
4652
4237
|
exports.PLUGIN_NAME = PLUGIN_NAME;
|
|
4653
4238
|
exports.decodeExperienceVariantsMap = decodeExperienceVariantsMap;
|
|
4654
4239
|
exports.isExperienceMatch = isExperienceMatch;
|
|
4655
|
-
exports.logger = logger;
|
|
4656
4240
|
exports.ninetailedPlugin = ninetailedPlugin;
|
|
4657
4241
|
exports.selectActiveExperiments = selectActiveExperiments;
|
|
4658
4242
|
exports.selectDistribution = selectDistribution;
|