@dotcms/experiments 0.0.1-alpha.14 → 0.0.1-alpha.16
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.esm.js
CHANGED
|
@@ -317,10 +317,10 @@ var SHARED = '__core-js_shared__';
|
|
|
317
317
|
var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty$2(SHARED, {});
|
|
318
318
|
|
|
319
319
|
(store$3.versions || (store$3.versions = [])).push({
|
|
320
|
-
version: '3.37.
|
|
320
|
+
version: '3.37.1',
|
|
321
321
|
mode: 'global',
|
|
322
322
|
copyright: '© 2014-2024 Denis Pushkarev (zloirock.ru)',
|
|
323
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.37.
|
|
323
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE',
|
|
324
324
|
source: 'https://github.com/zloirock/core-js'
|
|
325
325
|
});
|
|
326
326
|
|
|
@@ -3803,6 +3803,28 @@ var DEBUG_LEVELS;
|
|
|
3803
3803
|
})(DEBUG_LEVELS || (DEBUG_LEVELS = {}));
|
|
3804
3804
|
const PAGE_VIEW_EVENT_NAME = 'pageview';
|
|
3805
3805
|
|
|
3806
|
+
var $$3 = _export;
|
|
3807
|
+
var $includes = arrayIncludes.includes;
|
|
3808
|
+
var fails$2 = fails$l;
|
|
3809
|
+
var addToUnscopables = addToUnscopables$2;
|
|
3810
|
+
|
|
3811
|
+
// FF99+ bug
|
|
3812
|
+
var BROKEN_ON_SPARSE = fails$2(function () {
|
|
3813
|
+
// eslint-disable-next-line es/no-array-prototype-includes -- detection
|
|
3814
|
+
return !Array(1).includes();
|
|
3815
|
+
});
|
|
3816
|
+
|
|
3817
|
+
// `Array.prototype.includes` method
|
|
3818
|
+
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
3819
|
+
$$3({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
|
|
3820
|
+
includes: function includes(el /* , fromIndex = 0 */) {
|
|
3821
|
+
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
|
3822
|
+
}
|
|
3823
|
+
});
|
|
3824
|
+
|
|
3825
|
+
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
3826
|
+
addToUnscopables('includes');
|
|
3827
|
+
|
|
3806
3828
|
var isCallable = isCallable$m;
|
|
3807
3829
|
var isObject$1 = isObject$d;
|
|
3808
3830
|
var setPrototypeOf = objectSetPrototypeOf;
|
|
@@ -3873,7 +3895,7 @@ var getRegExpFlags$1 = regexpGetFlags;
|
|
|
3873
3895
|
var stickyHelpers = regexpStickyHelpers;
|
|
3874
3896
|
var proxyAccessor = proxyAccessor$1;
|
|
3875
3897
|
var defineBuiltIn$2 = defineBuiltIn$b;
|
|
3876
|
-
var fails$
|
|
3898
|
+
var fails$1 = fails$l;
|
|
3877
3899
|
var hasOwn$1 = hasOwnProperty_1;
|
|
3878
3900
|
var enforceInternalState = internalState.enforce;
|
|
3879
3901
|
var setSpecies = setSpecies$2;
|
|
@@ -3902,7 +3924,7 @@ var MISSED_STICKY = stickyHelpers.MISSED_STICKY;
|
|
|
3902
3924
|
var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
|
|
3903
3925
|
|
|
3904
3926
|
var BASE_FORCED = DESCRIPTORS$2 &&
|
|
3905
|
-
(!CORRECT_NEW || MISSED_STICKY || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG || fails$
|
|
3927
|
+
(!CORRECT_NEW || MISSED_STICKY || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG || fails$1(function () {
|
|
3906
3928
|
re2[MATCH$1] = false;
|
|
3907
3929
|
// RegExp constructor can alter flags and IsRegExp works correct with @@match
|
|
3908
3930
|
return NativeRegExp(re1) !== re1 || NativeRegExp(re2) === re2 || String(NativeRegExp(re1, 'i')) !== '/a/i';
|
|
@@ -4054,14 +4076,14 @@ var PROPER_FUNCTION_NAME = functionName.PROPER;
|
|
|
4054
4076
|
var defineBuiltIn$1 = defineBuiltIn$b;
|
|
4055
4077
|
var anObject$1 = anObject$f;
|
|
4056
4078
|
var $toString$1 = toString$6;
|
|
4057
|
-
var fails
|
|
4079
|
+
var fails = fails$l;
|
|
4058
4080
|
var getRegExpFlags = regexpGetFlags;
|
|
4059
4081
|
|
|
4060
4082
|
var TO_STRING = 'toString';
|
|
4061
4083
|
var RegExpPrototype = RegExp.prototype;
|
|
4062
4084
|
var nativeToString = RegExpPrototype[TO_STRING];
|
|
4063
4085
|
|
|
4064
|
-
var NOT_GENERIC = fails
|
|
4086
|
+
var NOT_GENERIC = fails(function () { return nativeToString.call({ source: 'a', flags: 'b' }) !== '/a/b'; });
|
|
4065
4087
|
// FF44- RegExp#toString has a wrong name
|
|
4066
4088
|
var INCORRECT_NAME = PROPER_FUNCTION_NAME && nativeToString.name !== TO_STRING;
|
|
4067
4089
|
|
|
@@ -4076,18 +4098,65 @@ if (NOT_GENERIC || INCORRECT_NAME) {
|
|
|
4076
4098
|
}, { unsafe: true });
|
|
4077
4099
|
}
|
|
4078
4100
|
|
|
4101
|
+
var isRegExp = isRegexp;
|
|
4102
|
+
|
|
4103
|
+
var $TypeError = TypeError;
|
|
4104
|
+
|
|
4105
|
+
var notARegexp = function (it) {
|
|
4106
|
+
if (isRegExp(it)) {
|
|
4107
|
+
throw new $TypeError("The method doesn't accept regular expressions");
|
|
4108
|
+
} return it;
|
|
4109
|
+
};
|
|
4110
|
+
|
|
4111
|
+
var wellKnownSymbol = wellKnownSymbol$k;
|
|
4112
|
+
|
|
4113
|
+
var MATCH = wellKnownSymbol('match');
|
|
4114
|
+
|
|
4115
|
+
var correctIsRegexpLogic = function (METHOD_NAME) {
|
|
4116
|
+
var regexp = /./;
|
|
4117
|
+
try {
|
|
4118
|
+
'/./'[METHOD_NAME](regexp);
|
|
4119
|
+
} catch (error1) {
|
|
4120
|
+
try {
|
|
4121
|
+
regexp[MATCH] = false;
|
|
4122
|
+
return '/./'[METHOD_NAME](regexp);
|
|
4123
|
+
} catch (error2) { /* empty */ }
|
|
4124
|
+
} return false;
|
|
4125
|
+
};
|
|
4126
|
+
|
|
4127
|
+
var $$2 = _export;
|
|
4079
4128
|
var uncurryThis$3 = functionUncurryThis;
|
|
4080
|
-
var
|
|
4081
|
-
var toString$2 = toString$6;
|
|
4129
|
+
var notARegExp = notARegexp;
|
|
4082
4130
|
var requireObjectCoercible$1 = requireObjectCoercible$6;
|
|
4131
|
+
var toString$2 = toString$6;
|
|
4132
|
+
var correctIsRegExpLogic = correctIsRegexpLogic;
|
|
4133
|
+
|
|
4134
|
+
var stringIndexOf = uncurryThis$3(''.indexOf);
|
|
4083
4135
|
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
|
|
4136
|
+
// `String.prototype.includes` method
|
|
4137
|
+
// https://tc39.es/ecma262/#sec-string.prototype.includes
|
|
4138
|
+
$$2({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
|
|
4139
|
+
includes: function includes(searchString /* , position = 0 */) {
|
|
4140
|
+
return !!~stringIndexOf(
|
|
4141
|
+
toString$2(requireObjectCoercible$1(this)),
|
|
4142
|
+
toString$2(notARegExp(searchString)),
|
|
4143
|
+
arguments.length > 1 ? arguments[1] : undefined
|
|
4144
|
+
);
|
|
4145
|
+
}
|
|
4146
|
+
});
|
|
4147
|
+
|
|
4148
|
+
var uncurryThis$2 = functionUncurryThis;
|
|
4149
|
+
var toIntegerOrInfinity = toIntegerOrInfinity$3;
|
|
4150
|
+
var toString$1 = toString$6;
|
|
4151
|
+
var requireObjectCoercible = requireObjectCoercible$6;
|
|
4152
|
+
|
|
4153
|
+
var charAt$2 = uncurryThis$2(''.charAt);
|
|
4154
|
+
var charCodeAt$1 = uncurryThis$2(''.charCodeAt);
|
|
4155
|
+
var stringSlice$1 = uncurryThis$2(''.slice);
|
|
4087
4156
|
|
|
4088
4157
|
var createMethod = function (CONVERT_TO_STRING) {
|
|
4089
4158
|
return function ($this, pos) {
|
|
4090
|
-
var S = toString$
|
|
4159
|
+
var S = toString$1(requireObjectCoercible($this));
|
|
4091
4160
|
var position = toIntegerOrInfinity(pos);
|
|
4092
4161
|
var size = S.length;
|
|
4093
4162
|
var first, second;
|
|
@@ -4114,7 +4183,7 @@ var stringMultibyte = {
|
|
|
4114
4183
|
};
|
|
4115
4184
|
|
|
4116
4185
|
var charAt$1 = stringMultibyte.charAt;
|
|
4117
|
-
var toString
|
|
4186
|
+
var toString = toString$6;
|
|
4118
4187
|
var InternalStateModule$1 = internalState;
|
|
4119
4188
|
var defineIterator = iteratorDefine;
|
|
4120
4189
|
var createIterResultObject = createIterResultObject$3;
|
|
@@ -4128,7 +4197,7 @@ var getInternalState = InternalStateModule$1.getterFor(STRING_ITERATOR);
|
|
|
4128
4197
|
defineIterator(String, 'String', function (iterated) {
|
|
4129
4198
|
setInternalState$1(this, {
|
|
4130
4199
|
type: STRING_ITERATOR,
|
|
4131
|
-
string: toString
|
|
4200
|
+
string: toString(iterated),
|
|
4132
4201
|
index: 0
|
|
4133
4202
|
});
|
|
4134
4203
|
// `%StringIteratorPrototype%.next` method
|
|
@@ -4212,7 +4281,7 @@ var arrayFrom$1 = function from(arrayLike /* , mapfn = undefined, thisArg = unde
|
|
|
4212
4281
|
};
|
|
4213
4282
|
|
|
4214
4283
|
// based on https://github.com/bestiejs/punycode.js/blob/master/punycode.js
|
|
4215
|
-
var uncurryThis$
|
|
4284
|
+
var uncurryThis$1 = functionUncurryThis;
|
|
4216
4285
|
|
|
4217
4286
|
var maxInt = 2147483647; // aka. 0x7FFFFFFF or 2^31-1
|
|
4218
4287
|
var base = 36;
|
|
@@ -4229,15 +4298,15 @@ var OVERFLOW_ERROR = 'Overflow: input needs wider integers to process';
|
|
|
4229
4298
|
var baseMinusTMin = base - tMin;
|
|
4230
4299
|
|
|
4231
4300
|
var $RangeError = RangeError;
|
|
4232
|
-
var exec$1 = uncurryThis$
|
|
4301
|
+
var exec$1 = uncurryThis$1(regexSeparators.exec);
|
|
4233
4302
|
var floor$1 = Math.floor;
|
|
4234
4303
|
var fromCharCode = String.fromCharCode;
|
|
4235
|
-
var charCodeAt = uncurryThis$
|
|
4236
|
-
var join$1 = uncurryThis$
|
|
4237
|
-
var push$1 = uncurryThis$
|
|
4238
|
-
var replace$1 = uncurryThis$
|
|
4239
|
-
var split$1 = uncurryThis$
|
|
4240
|
-
var toLowerCase$1 = uncurryThis$
|
|
4304
|
+
var charCodeAt = uncurryThis$1(''.charCodeAt);
|
|
4305
|
+
var join$1 = uncurryThis$1([].join);
|
|
4306
|
+
var push$1 = uncurryThis$1([].push);
|
|
4307
|
+
var replace$1 = uncurryThis$1(''.replace);
|
|
4308
|
+
var split$1 = uncurryThis$1(''.split);
|
|
4309
|
+
var toLowerCase$1 = uncurryThis$1(''.toLowerCase);
|
|
4241
4310
|
|
|
4242
4311
|
/**
|
|
4243
4312
|
* Creates an array containing the numeric code points of each Unicode
|
|
@@ -4394,12 +4463,12 @@ var stringPunycodeToAscii = function (input) {
|
|
|
4394
4463
|
|
|
4395
4464
|
// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
|
|
4396
4465
|
|
|
4397
|
-
var $$
|
|
4466
|
+
var $$1 = _export;
|
|
4398
4467
|
var DESCRIPTORS = descriptors;
|
|
4399
4468
|
var USE_NATIVE_URL = urlConstructorDetection;
|
|
4400
4469
|
var global$1 = global$o;
|
|
4401
4470
|
var bind = functionBindContext;
|
|
4402
|
-
var uncurryThis
|
|
4471
|
+
var uncurryThis = functionUncurryThis;
|
|
4403
4472
|
var defineBuiltIn = defineBuiltIn$b;
|
|
4404
4473
|
var defineBuiltInAccessor = defineBuiltInAccessor$3;
|
|
4405
4474
|
var anInstance = anInstance$3;
|
|
@@ -4425,18 +4494,18 @@ var TypeError$1 = global$1.TypeError;
|
|
|
4425
4494
|
var parseInt = global$1.parseInt;
|
|
4426
4495
|
var floor = Math.floor;
|
|
4427
4496
|
var pow = Math.pow;
|
|
4428
|
-
var charAt = uncurryThis
|
|
4429
|
-
var exec = uncurryThis
|
|
4430
|
-
var join = uncurryThis
|
|
4431
|
-
var numberToString = uncurryThis
|
|
4432
|
-
var pop = uncurryThis
|
|
4433
|
-
var push = uncurryThis
|
|
4434
|
-
var replace = uncurryThis
|
|
4435
|
-
var shift = uncurryThis
|
|
4436
|
-
var split = uncurryThis
|
|
4437
|
-
var stringSlice = uncurryThis
|
|
4438
|
-
var toLowerCase = uncurryThis
|
|
4439
|
-
var unshift = uncurryThis
|
|
4497
|
+
var charAt = uncurryThis(''.charAt);
|
|
4498
|
+
var exec = uncurryThis(/./.exec);
|
|
4499
|
+
var join = uncurryThis([].join);
|
|
4500
|
+
var numberToString = uncurryThis(1.0.toString);
|
|
4501
|
+
var pop = uncurryThis([].pop);
|
|
4502
|
+
var push = uncurryThis([].push);
|
|
4503
|
+
var replace = uncurryThis(''.replace);
|
|
4504
|
+
var shift = uncurryThis([].shift);
|
|
4505
|
+
var split = uncurryThis(''.split);
|
|
4506
|
+
var stringSlice = uncurryThis(''.slice);
|
|
4507
|
+
var toLowerCase = uncurryThis(''.toLowerCase);
|
|
4508
|
+
var unshift = uncurryThis([].unshift);
|
|
4440
4509
|
|
|
4441
4510
|
var INVALID_AUTHORITY = 'Invalid authority';
|
|
4442
4511
|
var INVALID_SCHEME = 'Invalid scheme';
|
|
@@ -5436,16 +5505,16 @@ if (NativeURL) {
|
|
|
5436
5505
|
|
|
5437
5506
|
setToStringTag(URLConstructor, 'URL');
|
|
5438
5507
|
|
|
5439
|
-
$$
|
|
5508
|
+
$$1({ global: true, constructor: true, forced: !USE_NATIVE_URL, sham: !DESCRIPTORS }, {
|
|
5440
5509
|
URL: URLConstructor
|
|
5441
5510
|
});
|
|
5442
5511
|
|
|
5443
|
-
var
|
|
5512
|
+
var $ = _export;
|
|
5444
5513
|
var call = functionCall;
|
|
5445
5514
|
|
|
5446
5515
|
// `URL.prototype.toJSON` method
|
|
5447
5516
|
// https://url.spec.whatwg.org/#dom-url-tojson
|
|
5448
|
-
|
|
5517
|
+
$({ target: 'URL', proto: true, enumerable: true }, {
|
|
5449
5518
|
toJSON: function toJSON() {
|
|
5450
5519
|
return call(URL.prototype.toString, this);
|
|
5451
5520
|
}
|
|
@@ -5524,20 +5593,23 @@ const verifyRegex = (regexToCheck, href) => {
|
|
|
5524
5593
|
*/
|
|
5525
5594
|
const parseData = (fetchExperiments, storedExperiments) => {
|
|
5526
5595
|
let dataToStorage = {};
|
|
5596
|
+
const {
|
|
5597
|
+
excludedExperimentIdsEnded
|
|
5598
|
+
} = fetchExperiments;
|
|
5527
5599
|
if (fetchExperiments && !storedExperiments) {
|
|
5528
5600
|
// TODO: Use fetchExperiment instead fetchExperimentsNoNoneExperimentID when the endpoint dont retrieve NONE experiment
|
|
5529
5601
|
// https://github.com/dotCMS/core/issues/27905
|
|
5530
|
-
const fetchExperimentsNoNoneExperimentID = fetchExperiments ? fetchExperiments.filter(experiment => experiment.id !== 'NONE') : [];
|
|
5602
|
+
const fetchExperimentsNoNoneExperimentID = fetchExperiments.experiments ? fetchExperiments.experiments.filter(experiment => experiment.id !== 'NONE') : [];
|
|
5531
5603
|
dataToStorage = addExpireTimeToExperiments(fetchExperimentsNoNoneExperimentID);
|
|
5532
5604
|
}
|
|
5533
5605
|
if (!fetchExperiments && storedExperiments) {
|
|
5534
|
-
dataToStorage = getUnexpiredExperiments(storedExperiments);
|
|
5606
|
+
dataToStorage = getUnexpiredExperiments(storedExperiments, excludedExperimentIdsEnded);
|
|
5535
5607
|
}
|
|
5536
5608
|
if (fetchExperiments && storedExperiments) {
|
|
5537
5609
|
// TODO: Use fetchExperiment instead fetchExperimentsNoNoneExperimentID when the endpoint dont retrieve NONE experiment
|
|
5538
5610
|
// https://github.com/dotCMS/core/issues/27905
|
|
5539
|
-
const fetchExperimentsNoNoneExperimentID = fetchExperiments ? fetchExperiments.filter(experiment => experiment.id !== 'NONE') : [];
|
|
5540
|
-
dataToStorage = [...addExpireTimeToExperiments(fetchExperimentsNoNoneExperimentID), ...getUnexpiredExperiments(storedExperiments)];
|
|
5611
|
+
const fetchExperimentsNoNoneExperimentID = fetchExperiments.experiments ? fetchExperiments.experiments.filter(experiment => experiment.id !== 'NONE') : [];
|
|
5612
|
+
dataToStorage = [...addExpireTimeToExperiments(fetchExperimentsNoNoneExperimentID), ...getUnexpiredExperiments(storedExperiments, excludedExperimentIdsEnded)];
|
|
5541
5613
|
}
|
|
5542
5614
|
return dataToStorage;
|
|
5543
5615
|
};
|
|
@@ -5567,14 +5639,15 @@ const addExpireTimeToExperiments = experiments => {
|
|
|
5567
5639
|
* Returns an array of experiments that have not expired yet.
|
|
5568
5640
|
*
|
|
5569
5641
|
* @param {Experiment[]} experiments - An array of experiments to filter.
|
|
5642
|
+
* @param excludedExperimentIdsEnded - Array of Experiments ids that have been manually ended.
|
|
5570
5643
|
* @returns {Experiment[]} An array of unexpired experiments.
|
|
5571
5644
|
*/
|
|
5572
|
-
const getUnexpiredExperiments = experiments => {
|
|
5645
|
+
const getUnexpiredExperiments = (experiments, excludedExperimentIdsEnded) => {
|
|
5573
5646
|
const now = Date.now();
|
|
5574
5647
|
return experiments.filter(experiment => {
|
|
5575
5648
|
var _experiment$lookBackW;
|
|
5576
5649
|
const expireTime = (_experiment$lookBackW = experiment.lookBackWindow) == null ? void 0 : _experiment$lookBackW.expireTime;
|
|
5577
|
-
return expireTime ? expireTime > now : false;
|
|
5650
|
+
return expireTime ? expireTime > now && !excludedExperimentIdsEnded.includes(experiment.id) : false;
|
|
5578
5651
|
});
|
|
5579
5652
|
};
|
|
5580
5653
|
|
|
@@ -5793,75 +5866,6 @@ class DotLogger {
|
|
|
5793
5866
|
}
|
|
5794
5867
|
}
|
|
5795
5868
|
|
|
5796
|
-
var $$1 = _export;
|
|
5797
|
-
var $includes = arrayIncludes.includes;
|
|
5798
|
-
var fails = fails$l;
|
|
5799
|
-
var addToUnscopables = addToUnscopables$2;
|
|
5800
|
-
|
|
5801
|
-
// FF99+ bug
|
|
5802
|
-
var BROKEN_ON_SPARSE = fails(function () {
|
|
5803
|
-
// eslint-disable-next-line es/no-array-prototype-includes -- detection
|
|
5804
|
-
return !Array(1).includes();
|
|
5805
|
-
});
|
|
5806
|
-
|
|
5807
|
-
// `Array.prototype.includes` method
|
|
5808
|
-
// https://tc39.es/ecma262/#sec-array.prototype.includes
|
|
5809
|
-
$$1({ target: 'Array', proto: true, forced: BROKEN_ON_SPARSE }, {
|
|
5810
|
-
includes: function includes(el /* , fromIndex = 0 */) {
|
|
5811
|
-
return $includes(this, el, arguments.length > 1 ? arguments[1] : undefined);
|
|
5812
|
-
}
|
|
5813
|
-
});
|
|
5814
|
-
|
|
5815
|
-
// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
|
|
5816
|
-
addToUnscopables('includes');
|
|
5817
|
-
|
|
5818
|
-
var isRegExp = isRegexp;
|
|
5819
|
-
|
|
5820
|
-
var $TypeError = TypeError;
|
|
5821
|
-
|
|
5822
|
-
var notARegexp = function (it) {
|
|
5823
|
-
if (isRegExp(it)) {
|
|
5824
|
-
throw new $TypeError("The method doesn't accept regular expressions");
|
|
5825
|
-
} return it;
|
|
5826
|
-
};
|
|
5827
|
-
|
|
5828
|
-
var wellKnownSymbol = wellKnownSymbol$k;
|
|
5829
|
-
|
|
5830
|
-
var MATCH = wellKnownSymbol('match');
|
|
5831
|
-
|
|
5832
|
-
var correctIsRegexpLogic = function (METHOD_NAME) {
|
|
5833
|
-
var regexp = /./;
|
|
5834
|
-
try {
|
|
5835
|
-
'/./'[METHOD_NAME](regexp);
|
|
5836
|
-
} catch (error1) {
|
|
5837
|
-
try {
|
|
5838
|
-
regexp[MATCH] = false;
|
|
5839
|
-
return '/./'[METHOD_NAME](regexp);
|
|
5840
|
-
} catch (error2) { /* empty */ }
|
|
5841
|
-
} return false;
|
|
5842
|
-
};
|
|
5843
|
-
|
|
5844
|
-
var $ = _export;
|
|
5845
|
-
var uncurryThis = functionUncurryThis;
|
|
5846
|
-
var notARegExp = notARegexp;
|
|
5847
|
-
var requireObjectCoercible = requireObjectCoercible$6;
|
|
5848
|
-
var toString = toString$6;
|
|
5849
|
-
var correctIsRegExpLogic = correctIsRegexpLogic;
|
|
5850
|
-
|
|
5851
|
-
var stringIndexOf = uncurryThis(''.indexOf);
|
|
5852
|
-
|
|
5853
|
-
// `String.prototype.includes` method
|
|
5854
|
-
// https://tc39.es/ecma262/#sec-string.prototype.includes
|
|
5855
|
-
$({ target: 'String', proto: true, forced: !correctIsRegExpLogic('includes') }, {
|
|
5856
|
-
includes: function includes(searchString /* , position = 0 */) {
|
|
5857
|
-
return !!~stringIndexOf(
|
|
5858
|
-
toString(requireObjectCoercible(this)),
|
|
5859
|
-
toString(notARegExp(searchString)),
|
|
5860
|
-
arguments.length > 1 ? arguments[1] : undefined
|
|
5861
|
-
);
|
|
5862
|
-
}
|
|
5863
|
-
});
|
|
5864
|
-
|
|
5865
5869
|
/**
|
|
5866
5870
|
* Checks the flag indicating whether the experiment has already been checked.
|
|
5867
5871
|
*
|
|
@@ -6204,11 +6208,16 @@ class DotExperiments {
|
|
|
6204
6208
|
*/
|
|
6205
6209
|
shouldTrackPageView() {
|
|
6206
6210
|
if (!this.config.trackPageView) {
|
|
6211
|
+
this.logger.log(`No send pageView. Tracking disabled. Config: ${this.config.trackPageView}.`);
|
|
6212
|
+
return false;
|
|
6213
|
+
}
|
|
6214
|
+
if (this.experimentsAssigned.length === 0) {
|
|
6215
|
+
this.logger.log(`No send pageView. No experiments to track.`);
|
|
6207
6216
|
return false;
|
|
6208
6217
|
}
|
|
6209
6218
|
// If the previous location is the same as the current location, we don't need to track the page view
|
|
6210
6219
|
if (this.prevLocation === this.currentLocation.href) {
|
|
6211
|
-
this.logger.log(`No
|
|
6220
|
+
this.logger.log(`No send pageView. Same location.`);
|
|
6212
6221
|
return false;
|
|
6213
6222
|
}
|
|
6214
6223
|
return true;
|
|
@@ -6268,7 +6277,7 @@ class DotExperiments {
|
|
|
6268
6277
|
this.logger.group('Fetch Experiments');
|
|
6269
6278
|
this.logger.time('Fetch Time');
|
|
6270
6279
|
try {
|
|
6271
|
-
var _responseJson$entity;
|
|
6280
|
+
var _responseJson$entity$, _responseJson$entity, _responseJson$entity$2, _responseJson$entity2;
|
|
6272
6281
|
const body = {
|
|
6273
6282
|
exclude: this.experimentsAssigned ? getExperimentsIds(this.experimentsAssigned) : []
|
|
6274
6283
|
};
|
|
@@ -6285,10 +6294,15 @@ class DotExperiments {
|
|
|
6285
6294
|
throw new Error(`HTTP error! status: ${response.status}, body: ${responseText}`);
|
|
6286
6295
|
}
|
|
6287
6296
|
const responseJson = await response.json();
|
|
6288
|
-
const experiments = responseJson == null || (_responseJson$entity = responseJson.entity) == null ? void 0 : _responseJson$entity.experiments;
|
|
6297
|
+
const experiments = (_responseJson$entity$ = responseJson == null || (_responseJson$entity = responseJson.entity) == null ? void 0 : _responseJson$entity.experiments) != null ? _responseJson$entity$ : [];
|
|
6298
|
+
const excludedExperimentIdsEnded = (_responseJson$entity$2 = responseJson == null || (_responseJson$entity2 = responseJson.entity) == null ? void 0 : _responseJson$entity2.excludedExperimentIdsEnded) != null ? _responseJson$entity$2 : [];
|
|
6289
6299
|
this.logger.log(`Experiment data get successfully `);
|
|
6290
6300
|
this.persistenceHandler.setFlagExperimentAlreadyChecked();
|
|
6291
|
-
|
|
6301
|
+
this.persistenceHandler.setFetchExpiredTime();
|
|
6302
|
+
return {
|
|
6303
|
+
experiments,
|
|
6304
|
+
excludedExperimentIdsEnded
|
|
6305
|
+
};
|
|
6292
6306
|
} catch (error) {
|
|
6293
6307
|
this.logger.error(`An error occurred while trying to fetch the experiments: ${error.message}`);
|
|
6294
6308
|
throw error;
|
|
@@ -6314,13 +6328,14 @@ class DotExperiments {
|
|
|
6314
6328
|
*/
|
|
6315
6329
|
async verifyExperimentData() {
|
|
6316
6330
|
try {
|
|
6317
|
-
let fetchedExperiments =
|
|
6331
|
+
let fetchedExperiments = {
|
|
6332
|
+
excludedExperimentIdsEnded: [],
|
|
6333
|
+
experiments: []
|
|
6334
|
+
};
|
|
6318
6335
|
const storedExperiments = this.experimentsAssigned ? this.experimentsAssigned : [];
|
|
6319
6336
|
// Checks whether fetching experiment data from the server is necessary.
|
|
6320
6337
|
if (this.shouldFetchNewData()) {
|
|
6321
6338
|
fetchedExperiments = await this.getExperimentsFromServer();
|
|
6322
|
-
this.persistenceHandler.setFlagExperimentAlreadyChecked();
|
|
6323
|
-
this.persistenceHandler.setFetchExpiredTime();
|
|
6324
6339
|
}
|
|
6325
6340
|
const dataToPersist = parseData(fetchedExperiments, storedExperiments);
|
|
6326
6341
|
// If my stored data is equal to my parsed data, I don't need to persist again
|
|
@@ -6454,11 +6469,12 @@ class DotExperiments {
|
|
|
6454
6469
|
this.logger.log(`${EXPERIMENT_ALREADY_CHECKED_KEY} not found, fetch data from Analytics`);
|
|
6455
6470
|
return true;
|
|
6456
6471
|
}
|
|
6457
|
-
if (!this.experimentsAssigned) {
|
|
6472
|
+
if (!this.experimentsAssigned || this.experimentsAssigned.length === 0) {
|
|
6473
|
+
this.logger.log(`No experiments assigned to the client, fetch data from Analytics`);
|
|
6458
6474
|
return true;
|
|
6459
6475
|
}
|
|
6460
6476
|
if (!isDataCreateValid()) {
|
|
6461
|
-
this.logger.log(`
|
|
6477
|
+
this.logger.log(`The validity period of the persistence has passed, fetch data from Analytics`);
|
|
6462
6478
|
return true;
|
|
6463
6479
|
}
|
|
6464
6480
|
this.logger.log(`Not should Check Analytics by now...`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/experiments",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.16",
|
|
4
4
|
"description": "Official JavaScript library to use Experiments with DotCMS.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"react": ">=18",
|
|
27
27
|
"react-dom": ">=18",
|
|
28
|
-
"@dotcms/client": "0.0.1-alpha.
|
|
28
|
+
"@dotcms/client": "0.0.1-alpha.16"
|
|
29
29
|
},
|
|
30
30
|
"module": "./index.esm.js",
|
|
31
31
|
"type": "module",
|
|
@@ -9,6 +9,8 @@ import { Experiment, ExperimentEvent, IsUserIncludedApiResponse } from '../model
|
|
|
9
9
|
*/
|
|
10
10
|
export declare const IsUserIncludedResponse: IsUserIncludedApiResponse;
|
|
11
11
|
export declare const NewIsUserIncludedResponse: IsUserIncludedApiResponse;
|
|
12
|
+
export declare const After15DaysIsUserIncludedResponse: IsUserIncludedApiResponse;
|
|
13
|
+
export declare const NoExperimentsIsUserIncludedResponse: IsUserIncludedApiResponse;
|
|
12
14
|
export declare const MOCK_CURRENT_TIMESTAMP = 1704096000000;
|
|
13
15
|
export declare const TIME_15_DAYS_MILLISECONDS: number;
|
|
14
16
|
export declare const TIME_5_DAYS_MILLISECONDS: number;
|
|
@@ -128,7 +128,15 @@ export interface AssignedExperiments {
|
|
|
128
128
|
* The ids of the experiments included in the assignment.
|
|
129
129
|
*/
|
|
130
130
|
includedExperimentIds: string[];
|
|
131
|
+
/**
|
|
132
|
+
* The ids of the experiments that are excluded in the request and have ended.
|
|
133
|
+
*/
|
|
134
|
+
excludedExperimentIdsEnded: string[];
|
|
131
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Represents the response from the backend when fetching an experiment and the excludedExperimentIdsEnded.
|
|
138
|
+
*/
|
|
139
|
+
export type FetchExperiments = Pick<AssignedExperiments, 'excludedExperimentIdsEnded' | 'experiments'>;
|
|
132
140
|
/**
|
|
133
141
|
* Represents the response from backend holding information about running experiments and variant assignment.
|
|
134
142
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Experiment, ExperimentParsed } from '../models';
|
|
1
|
+
import { Experiment, ExperimentParsed, FetchExperiments } from '../models';
|
|
2
2
|
/**
|
|
3
3
|
* This arrow function parses a given set of assigned experiments for analytics.
|
|
4
4
|
*
|
|
@@ -44,7 +44,7 @@ export declare const verifyRegex: (regexToCheck: string | null, href: string) =>
|
|
|
44
44
|
*
|
|
45
45
|
* There could be scenarios where none of these conditions are met, in that case, dataToStorage will be the default empty object.
|
|
46
46
|
*/
|
|
47
|
-
export declare const parseData: (fetchExperiments:
|
|
47
|
+
export declare const parseData: (fetchExperiments: FetchExperiments, storedExperiments: Experiment[] | undefined) => Experiment[];
|
|
48
48
|
/**
|
|
49
49
|
* Retrieves the array of experiment IDs from the given AssignedExperiments..
|
|
50
50
|
*
|