@convertcom/js-sdk-rules 2.0.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +2 -2
  2. package/lib/enums/index.d.ts +26 -0
  3. package/lib/enums/src/bucketing-error.d.ts +9 -0
  4. package/lib/enums/src/conversion-setting-key.d.ts +9 -0
  5. package/lib/enums/src/data-enitites.d.ts +16 -0
  6. package/lib/enums/src/dictionary.d.ts +68 -0
  7. package/lib/enums/src/do-not-track.d.ts +12 -0
  8. package/lib/enums/src/entity-type.d.ts +15 -0
  9. package/lib/enums/src/feature-status.d.ts +10 -0
  10. package/lib/enums/src/goal-data-key.d.ts +11 -0
  11. package/lib/enums/src/log-level.d.ts +14 -0
  12. package/lib/enums/src/log-method.d.ts +14 -0
  13. package/lib/enums/src/project-type.d.ts +10 -0
  14. package/lib/enums/src/rule-error.d.ts +10 -0
  15. package/lib/enums/src/segments/browser-type.d.ts +17 -0
  16. package/lib/enums/src/segments/device-type.d.ts +16 -0
  17. package/lib/enums/src/segments/segments-keys.d.ts +15 -0
  18. package/lib/enums/src/segments/source-type.d.ts +12 -0
  19. package/lib/enums/src/segments/visitor-type.d.ts +10 -0
  20. package/lib/enums/src/system-events.d.ts +22 -0
  21. package/lib/enums/src/variable-types.d.ts +7 -0
  22. package/lib/enums/src/variation-change-type.d.ts +14 -0
  23. package/lib/index.d.ts +5 -4
  24. package/lib/index.js +767 -30
  25. package/lib/index.js.map +1 -1
  26. package/lib/index.min.js +1 -1
  27. package/lib/index.min.js.map +1 -1
  28. package/lib/index.min.mjs +1 -1
  29. package/lib/index.min.mjs.map +1 -1
  30. package/lib/index.mjs +743 -6
  31. package/lib/index.mjs.map +1 -1
  32. package/lib/legacy/index.js +798 -140
  33. package/lib/legacy/index.js.map +1 -1
  34. package/lib/legacy/index.min.js +1 -1
  35. package/lib/legacy/index.min.js.map +1 -1
  36. package/lib/logger/index.d.ts +8 -0
  37. package/lib/logger/src/interfaces/log-client.d.ts +13 -0
  38. package/lib/logger/src/interfaces/log-manager.d.ts +18 -0
  39. package/lib/logger/src/interfaces/log-method-map.d.ts +15 -0
  40. package/lib/logger/src/log-manager.d.ts +64 -0
  41. package/lib/package.json +6 -6
  42. package/lib/rules/index.d.ts +8 -0
  43. package/lib/rules/src/interfaces/rule-manager.d.ts +15 -0
  44. package/lib/rules/src/rule-manager.d.ts +82 -0
  45. package/lib/types/index.d.ts +28 -0
  46. package/lib/types/src/BucketedFeature.d.ts +29 -0
  47. package/lib/types/src/BucketedVariation.d.ts +13 -0
  48. package/lib/types/src/BucketingAllocation.d.ts +10 -0
  49. package/lib/types/src/BucketingAttributes.d.ts +17 -0
  50. package/lib/types/src/BucketingHash.d.ts +11 -0
  51. package/lib/types/src/Config.d.ts +60 -0
  52. package/lib/types/src/ConversionAttributes.d.ts +13 -0
  53. package/lib/types/src/Entity.d.ts +8 -0
  54. package/lib/types/src/GoalData.d.ts +11 -0
  55. package/lib/types/src/IndentityField.d.ts +7 -0
  56. package/lib/types/src/Integration.d.ts +8 -0
  57. package/lib/types/src/LocationAttributes.d.ts +12 -0
  58. package/lib/types/src/Path.d.ts +10 -0
  59. package/lib/types/src/RequireAtLeastOne.d.ts +3 -0
  60. package/lib/types/src/Rule.d.ts +13 -0
  61. package/lib/types/src/SegmentsAttributes.d.ts +9 -0
  62. package/lib/types/src/StoreData.d.ts +13 -0
  63. package/lib/types/src/TrackingEvent.d.ts +14 -0
  64. package/lib/types/src/VariableType.d.ts +8 -0
  65. package/lib/types/src/Visitor.d.ts +12 -0
  66. package/lib/types/src/VisitorsQueue.d.ts +14 -0
  67. package/lib/types/src/config/index.d.ts +1 -0
  68. package/lib/types/src/config/types.gen.d.ts +2387 -0
  69. package/lib/utils/index.d.ts +14 -0
  70. package/lib/utils/src/array-utils.d.ts +11 -0
  71. package/lib/utils/src/comparisons.d.ts +22 -0
  72. package/lib/utils/src/data-store.d.ts +39 -0
  73. package/lib/utils/src/file-logger.d.ts +40 -0
  74. package/lib/utils/src/http-client.d.ts +115 -0
  75. package/lib/utils/src/object-utils.d.ts +35 -0
  76. package/lib/utils/src/string-utils.d.ts +32 -0
  77. package/lib/utils/src/types-utils.d.ts +12 -0
  78. package/package.json +35 -31
package/lib/index.mjs CHANGED
@@ -1,5 +1,736 @@
1
- import { Comparisons, arrayNotEmpty, camelCase, objectNotEmpty } from '@convertcom/js-sdk-utils';
2
- import { MESSAGES, RuleError, ERROR_MESSAGES } from '@convertcom/js-sdk-enums';
1
+ /*!
2
+ * Convert JS SDK
3
+ * Version 1.0.0
4
+ * Copyright(c) 2020 Convert Insights, Inc
5
+ * License Apache-2.0
6
+ */
7
+ /**
8
+ * Validates variable is array and not empty
9
+ * @param array
10
+ */
11
+ function arrayNotEmpty(array) {
12
+ return Array.isArray(array) && array.length > 0;
13
+ }
14
+
15
+ /*!
16
+ * Convert JS SDK
17
+ * Version 1.0.0
18
+ * Copyright(c) 2020 Convert Insights, Inc
19
+ * License Apache-2.0
20
+ */
21
+ /**
22
+ * Returns the value at path of object
23
+ * TODO: get this utility to work with the optional mapper() helper from config
24
+ * @param {Record<string, any>} object
25
+ * @param {string} path
26
+ * @param {any=} defaultValue
27
+ * @param {boolean=} truthy Should Number 0 number and Boolean false be considered as normal value
28
+ * @return {any}
29
+ */
30
+ /**
31
+ * Validates variable is object and not empty
32
+ * @param object
33
+ */
34
+ function objectNotEmpty(object) {
35
+ return (typeof object === 'object' &&
36
+ object !== null &&
37
+ Object.keys(object).length > 0);
38
+ }
39
+
40
+ var murmurhash = {exports: {}};
41
+
42
+ (function (module) {
43
+ (function(){
44
+
45
+ const createBuffer = (val) => new TextEncoder().encode(val);
46
+
47
+ /**
48
+ * JS Implementation of MurmurHash2
49
+ *
50
+ * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
51
+ * @see http://github.com/garycourt/murmurhash-js
52
+ * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
53
+ * @see http://sites.google.com/site/murmurhash/
54
+ *
55
+ * @param {Uint8Array | string} str ASCII only
56
+ * @param {number} seed Positive integer only
57
+ * @return {number} 32-bit positive integer hash
58
+ */
59
+ function MurmurHashV2(str, seed) {
60
+ if (typeof str === 'string') str = createBuffer(str);
61
+ let
62
+ l = str.length,
63
+ h = seed ^ l,
64
+ i = 0,
65
+ k;
66
+
67
+ while (l >= 4) {
68
+ k =
69
+ ((str[i] & 0xff)) |
70
+ ((str[++i] & 0xff) << 8) |
71
+ ((str[++i] & 0xff) << 16) |
72
+ ((str[++i] & 0xff) << 24);
73
+
74
+ k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
75
+ k ^= k >>> 24;
76
+ k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
77
+
78
+ h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;
79
+
80
+ l -= 4;
81
+ ++i;
82
+ }
83
+
84
+ switch (l) {
85
+ case 3: h ^= (str[i + 2] & 0xff) << 16;
86
+ case 2: h ^= (str[i + 1] & 0xff) << 8;
87
+ case 1: h ^= (str[i] & 0xff);
88
+ h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
89
+ }
90
+
91
+ h ^= h >>> 13;
92
+ h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
93
+ h ^= h >>> 15;
94
+
95
+ return h >>> 0;
96
+ }
97
+ /*
98
+ * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
99
+ *
100
+ * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
101
+ * @see http://github.com/garycourt/murmurhash-js
102
+ * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
103
+ * @see http://sites.google.com/site/murmurhash/
104
+ *
105
+ * @param {Uint8Array | string} key ASCII only
106
+ * @param {number} seed Positive integer only
107
+ * @return {number} 32-bit positive integer hash
108
+ */
109
+ function MurmurHashV3(key, seed) {
110
+ if (typeof key === 'string') key = createBuffer(key);
111
+
112
+ let remainder, bytes, h1, h1b, c1, c2, k1, i;
113
+
114
+ remainder = key.length & 3; // key.length % 4
115
+ bytes = key.length - remainder;
116
+ h1 = seed;
117
+ c1 = 0xcc9e2d51;
118
+ c2 = 0x1b873593;
119
+ i = 0;
120
+
121
+ while (i < bytes) {
122
+ k1 =
123
+ ((key[i] & 0xff)) |
124
+ ((key[++i] & 0xff) << 8) |
125
+ ((key[++i] & 0xff) << 16) |
126
+ ((key[++i] & 0xff) << 24);
127
+ ++i;
128
+
129
+ k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
130
+ k1 = (k1 << 15) | (k1 >>> 17);
131
+ k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
132
+
133
+ h1 ^= k1;
134
+ h1 = (h1 << 13) | (h1 >>> 19);
135
+ h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
136
+ h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
137
+ }
138
+
139
+ k1 = 0;
140
+
141
+ switch (remainder) {
142
+ case 3: k1 ^= (key[i + 2] & 0xff) << 16;
143
+ case 2: k1 ^= (key[i + 1] & 0xff) << 8;
144
+ case 1: k1 ^= (key[i] & 0xff);
145
+
146
+ k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
147
+ k1 = (k1 << 15) | (k1 >>> 17);
148
+ k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
149
+ h1 ^= k1;
150
+ }
151
+
152
+ h1 ^= key.length;
153
+
154
+ h1 ^= h1 >>> 16;
155
+ h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
156
+ h1 ^= h1 >>> 13;
157
+ h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
158
+ h1 ^= h1 >>> 16;
159
+
160
+ return h1 >>> 0;
161
+ }
162
+
163
+ const murmur = MurmurHashV3;
164
+ murmur.v2 = MurmurHashV2;
165
+ murmur.v3 = MurmurHashV3;
166
+
167
+ {
168
+ module.exports = murmur;
169
+ }
170
+ }());
171
+ } (murmurhash));
172
+
173
+ /*!
174
+ * Convert JS SDK
175
+ * Version 1.0.0
176
+ * Copyright(c) 2020 Convert Insights, Inc
177
+ * License Apache-2.0
178
+ */
179
+ /**
180
+ * String formatter tool. Transforms a space-separated string into camelCase
181
+ * @param {string} input
182
+ * @return {string}
183
+ */
184
+ function camelCase(input) {
185
+ return input
186
+ .replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
187
+ return index === 0 ? word.toLowerCase() : word.toUpperCase();
188
+ })
189
+ .replace(/\s+/g, '');
190
+ }
191
+ /**
192
+ * Check if a value is numeric
193
+ * @param {string | number} value
194
+ * @returns {boolean}
195
+ */
196
+ function isNumeric(value) {
197
+ if (typeof value === 'number') {
198
+ return true;
199
+ }
200
+ const number = parseFloat(String(value));
201
+ return Number.isFinite(number) && !isNaN(number);
202
+ }
203
+ /**
204
+ * Convert a string to a number
205
+ * @param {string | number} value
206
+ * @returns {number}
207
+ */
208
+ function toNumber(value) {
209
+ if (typeof value === 'number') {
210
+ return value;
211
+ }
212
+ const parts = String(value).split(',');
213
+ return parseFloat(parts[0] == '0'
214
+ ? String(value).replace(/,/g, '.')
215
+ : String(value).replace(/,/g, ''));
216
+ }
217
+
218
+ /*!
219
+ * Convert JS SDK
220
+ * Version 1.0.0
221
+ * Copyright(c) 2020 Convert Insights, Inc
222
+ * License Apache-2.0
223
+ */
224
+ var _a;
225
+ /**
226
+ * Comparison Processor. Provides comparison methods for rules validation
227
+ */
228
+ class Comparisons {
229
+ static equals(value, testAgainst, negation) {
230
+ if (Array.isArray(value))
231
+ return this._returnNegationCheck(value.indexOf(testAgainst) !== -1, negation);
232
+ if (objectNotEmpty(value))
233
+ return this._returnNegationCheck(Object.keys(value).indexOf(String(testAgainst)) !== -1, negation);
234
+ value = String(value);
235
+ testAgainst = String(testAgainst);
236
+ value = value.valueOf().toLowerCase();
237
+ testAgainst = testAgainst.valueOf().toLowerCase();
238
+ return this._returnNegationCheck(value === testAgainst, negation);
239
+ }
240
+ static less(value, testAgainst, negation) {
241
+ value = isNumeric(value) ? toNumber(value) : value;
242
+ testAgainst = isNumeric(testAgainst) ? toNumber(testAgainst) : testAgainst;
243
+ if (typeof value !== typeof testAgainst) {
244
+ return false;
245
+ }
246
+ return this._returnNegationCheck(value < testAgainst, negation);
247
+ }
248
+ static lessEqual(value, testAgainst, negation) {
249
+ value = isNumeric(value) ? toNumber(value) : value;
250
+ testAgainst = isNumeric(testAgainst) ? toNumber(testAgainst) : testAgainst;
251
+ if (typeof value !== typeof testAgainst) {
252
+ return false;
253
+ }
254
+ return this._returnNegationCheck(value <= testAgainst, negation);
255
+ }
256
+ static contains(value, testAgainst, negation) {
257
+ value = String(value);
258
+ testAgainst = String(testAgainst);
259
+ value = value.valueOf().toLowerCase();
260
+ testAgainst = testAgainst.valueOf().toLowerCase();
261
+ if (testAgainst.replace(/^([\s]*)|([\s]*)$/g, '').length === 0) {
262
+ return this._returnNegationCheck(true, negation);
263
+ }
264
+ return this._returnNegationCheck(value.indexOf(testAgainst) !== -1, negation);
265
+ }
266
+ static isIn(values, testAgainst, negation = false, splitter = '|') {
267
+ const matchedValuesArray = String(values)
268
+ .split(splitter)
269
+ .map((item) => {
270
+ return String(item);
271
+ });
272
+ if (typeof testAgainst === 'string') {
273
+ testAgainst = testAgainst.split(splitter);
274
+ }
275
+ if (!Array.isArray(testAgainst)) {
276
+ testAgainst = [];
277
+ }
278
+ testAgainst = testAgainst.map((item) => {
279
+ return String(item).valueOf().toLowerCase();
280
+ });
281
+ for (let i = 0; i < matchedValuesArray.length; i++) {
282
+ if (testAgainst.indexOf(matchedValuesArray[i]) !== -1) {
283
+ return this._returnNegationCheck(true, negation);
284
+ }
285
+ }
286
+ return this._returnNegationCheck(false, negation);
287
+ }
288
+ static startsWith(value, testAgainst, negation) {
289
+ value = String(value).valueOf().toLowerCase();
290
+ testAgainst = String(testAgainst).valueOf().toLowerCase();
291
+ return this._returnNegationCheck(value.indexOf(testAgainst) === 0, negation);
292
+ }
293
+ static endsWith(value, testAgainst, negation) {
294
+ value = String(value).valueOf().toLowerCase();
295
+ testAgainst = String(testAgainst).valueOf().toLowerCase();
296
+ return this._returnNegationCheck(value.indexOf(testAgainst, value.length - testAgainst.length) !== -1, negation);
297
+ }
298
+ static regexMatches(value, testAgainst, negation) {
299
+ value = String(value).valueOf().toLowerCase();
300
+ testAgainst = String(testAgainst).valueOf();
301
+ const regExp = new RegExp(testAgainst, 'i');
302
+ return this._returnNegationCheck(regExp.test(value), negation);
303
+ }
304
+ static _returnNegationCheck(value, negation = false) {
305
+ if (negation) {
306
+ return !value;
307
+ }
308
+ else {
309
+ return value;
310
+ }
311
+ }
312
+ }
313
+ _a = Comparisons;
314
+ Comparisons.equalsNumber = _a.equals;
315
+ Comparisons.matches = _a.equals;
316
+
317
+ /******************************************************************************
318
+ Copyright (c) Microsoft Corporation.
319
+
320
+ Permission to use, copy, modify, and/or distribute this software for any
321
+ purpose with or without fee is hereby granted.
322
+
323
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
324
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
325
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
326
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
327
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
328
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
329
+ PERFORMANCE OF THIS SOFTWARE.
330
+ ***************************************************************************** */
331
+ /* global Reflect, Promise, SuppressedError, Symbol */
332
+
333
+
334
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
335
+ var e = new Error(message);
336
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
337
+ };
338
+
339
+ /*!
340
+ * Convert JS SDK
341
+ * Version 1.0.0
342
+ * Copyright(c) 2020 Convert Insights, Inc
343
+ * License Apache-2.0
344
+ */
345
+ var BucketingError;
346
+ (function (BucketingError) {
347
+ BucketingError["VARIAION_NOT_DECIDED"] = "convert.com_variation_not_decided";
348
+ })(BucketingError || (BucketingError = {}));
349
+
350
+ /*!
351
+ * Convert JS SDK
352
+ * Version 1.0.0
353
+ * Copyright(c) 2020 Convert Insights, Inc
354
+ * License Apache-2.0
355
+ */
356
+ var ConversionSettingKey;
357
+ (function (ConversionSettingKey) {
358
+ ConversionSettingKey["FORCE_MULTIPLE_TRANSACTIONS"] = "forceMultipleTransactions";
359
+ })(ConversionSettingKey || (ConversionSettingKey = {}));
360
+
361
+ /*!
362
+ * Convert JS SDK
363
+ * Version 1.0.0
364
+ * Copyright(c) 2020 Convert Insights, Inc
365
+ * License Apache-2.0
366
+ */
367
+ const ERROR_MESSAGES = {
368
+ SDK_KEY_MISSING: 'SDK key is missing',
369
+ DATA_OBJECT_MISSING: 'Data object is missing',
370
+ CONFIG_DATA_NOT_VALID: 'Config Data is not valid',
371
+ SDK_OR_DATA_OBJECT_REQUIRED: 'SDK key or Data object should be provided',
372
+ RULE_NOT_VALID: 'Provided rule is not valid',
373
+ RULE_DATA_NOT_VALID: 'Provided rule data is not valid',
374
+ RULE_MATCH_TYPE_NOT_SUPPORTED: 'Provided rule matching type "#" is not supported',
375
+ RULE_ERROR: 'Rule error',
376
+ DATA_STORE_NOT_VALID: 'DataStore object is not valid. It should contain get and set methods',
377
+ VISITOR_ID_REQUIRED: 'Visitor string string is not present',
378
+ GOAL_DATA_NOT_VALID: 'GoalData object is not valid',
379
+ UNABLE_TO_SELECT_BUCKET_FOR_VISITOR: 'Unable to bucket visitor',
380
+ UNABLE_TO_PERFORM_NETWORK_REQUEST: 'Unable to perform network request',
381
+ UNSUPPORTED_RESPONSE_TYPE: 'Unsupported response type'
382
+ };
383
+ const MESSAGES = {
384
+ CONFIG_DATA_UPDATED: 'Config Data updated',
385
+ CORE_CONSTRUCTOR: 'Core Manager constructor has been called',
386
+ CORE_INITIALIZED: 'Core Manager has been initialized',
387
+ EXPERIENCE_CONSTRUCTOR: 'Experience Manager constructor has been called',
388
+ EXPERIENCE_NOT_FOUND: 'Experience not found',
389
+ EXPERIENCE_ARCHIVED: 'Experience archived',
390
+ EXPERIENCE_ENVIRONMENT_NOT_MATCH: 'Experience environment does not match',
391
+ EXPERIENCE_RULES_MATCHED: 'Experience rules matched',
392
+ VARIATIONS_NOT_FOUND: 'Variations not found',
393
+ VARIATION_CHANGE_NOT_SUPPORTED: 'Variation change not supported',
394
+ FEATURE_CONSTRUCTOR: 'Feature Manager constructor has been called',
395
+ FEATURE_NOT_FOUND: 'Fullstack Feature not found',
396
+ FEATURE_VARIABLES_NOT_FOUND: 'Fullstack Feature Variables not found',
397
+ FEATURE_VARIABLES_TYPE_NOT_FOUND: 'Fullstack Feature Variables Type not found',
398
+ BUCKETING_CONSTRUCTOR: 'Bucketing Manager constructor has been called',
399
+ DATA_CONSTRUCTOR: 'Data Manager constructor has been called',
400
+ RULE_CONSTRUCTOR: 'Rule Manager constructor has been called',
401
+ PROCESSING_ENTITY: 'Processing #',
402
+ LOCATION_MATCH: 'Location # rule matched',
403
+ LOCATION_NOT_MATCH: 'Location does not match',
404
+ LOCATION_NOT_RESTRICTED: 'Location not restricted',
405
+ AUDIENCE_MATCH: 'Audience # rule matched',
406
+ AUDIENCE_NOT_MATCH: 'Audience does not match',
407
+ NON_PERMANENT_AUDIENCE_NOT_RESTRICTED: 'Non-Permanent Audience not restricted',
408
+ AUDIENCE_NOT_RESTRICTED: 'Audience not restricted',
409
+ SEGMENTATION_MATCH: 'Segmentation # rule matched',
410
+ SEGMENTATION_NOT_RESTRICTED: 'Segmentation not restricted',
411
+ RULE_NOT_MATCH: 'Rule does not match',
412
+ RULE_MATCH: 'Found matched rule at OR block #',
413
+ RULE_MATCH_AND: 'AND block rule macthed',
414
+ RULE_MATCH_START: 'About to evaluate rule #',
415
+ LOCATION_ACTIVATED: 'Location # activated',
416
+ LOCATION_DEACTIVATED: 'Location # deactivated',
417
+ BUCKETED_VISITOR_FOUND: 'Visitor is already bucketed for variation #',
418
+ BUCKETED_VISITOR_FORCED: 'Forcing variation #',
419
+ BUCKETED_VISITOR: 'Visitor is bucketed for variation #',
420
+ GOAL_NOT_FOUND: 'Goal not found',
421
+ GOAL_RULE_NOT_MATCH: 'Goal rule do not match',
422
+ GOAL_FOUND: 'Goal # already triggered',
423
+ SEGMENTS_NOT_FOUND: 'Segments not found',
424
+ SEGMENTS_RULE_NOT_MATCH: 'Segments rule do not match',
425
+ CUSTOM_SEGMENTS_KEY_FOUND: 'Custom segments key already set',
426
+ SEND_BEACON_SUCCESS: 'The user agent successfully queued the data for transfer',
427
+ RELEASING_QUEUE: 'Releasing event queue...'
428
+ };
429
+
430
+ /*!
431
+ * Convert JS SDK
432
+ * Version 1.0.0
433
+ * Copyright(c) 2020 Convert Insights, Inc
434
+ * License Apache-2.0
435
+ */
436
+ var DoNotTrack;
437
+ (function (DoNotTrack) {
438
+ DoNotTrack["OFF"] = "OFF";
439
+ DoNotTrack["EU_ONLY"] = "EU ONLY";
440
+ DoNotTrack["EEA_ONLY"] = "EEA ONLY";
441
+ DoNotTrack["WORLDWIDE"] = "Worldwide";
442
+ })(DoNotTrack || (DoNotTrack = {}));
443
+
444
+ /*!
445
+ * Convert JS SDK
446
+ * Version 1.0.0
447
+ * Copyright(c) 2020 Convert Insights, Inc
448
+ * License Apache-2.0
449
+ */
450
+ var EntityType;
451
+ (function (EntityType) {
452
+ EntityType["AUDIENCE"] = "audience";
453
+ EntityType["LOCATION"] = "location";
454
+ EntityType["SEGMENT"] = "segment";
455
+ EntityType["FEATURE"] = "feature";
456
+ EntityType["GOAL"] = "goal";
457
+ EntityType["EXPERIENCE"] = "experience";
458
+ EntityType["VARIATION"] = "variation";
459
+ })(EntityType || (EntityType = {}));
460
+
461
+ /*!
462
+ * Convert JS SDK
463
+ * Version 1.0.0
464
+ * Copyright(c) 2020 Convert Insights, Inc
465
+ * License Apache-2.0
466
+ */
467
+ var FeatureStatus;
468
+ (function (FeatureStatus) {
469
+ FeatureStatus["ENABLED"] = "enabled";
470
+ FeatureStatus["DISABLED"] = "disabled";
471
+ })(FeatureStatus || (FeatureStatus = {}));
472
+
473
+ /*!
474
+ * Convert JS SDK
475
+ * Version 1.0.0
476
+ * Copyright(c) 2020 Convert Insights, Inc
477
+ * License Apache-2.0
478
+ */
479
+ var GoalDataKey;
480
+ (function (GoalDataKey) {
481
+ GoalDataKey["AMOUNT"] = "amount";
482
+ GoalDataKey["PRODUCTS_COUNT"] = "productsCount";
483
+ GoalDataKey["TRANSACTION_ID"] = "transactionId";
484
+ })(GoalDataKey || (GoalDataKey = {}));
485
+
486
+ /*!
487
+ * Convert JS SDK
488
+ * Version 1.0.0
489
+ * Copyright(c) 2020 Convert Insights, Inc
490
+ * License Apache-2.0
491
+ */
492
+ var LogLevel;
493
+ (function (LogLevel) {
494
+ LogLevel[LogLevel["TRACE"] = 0] = "TRACE";
495
+ LogLevel[LogLevel["DEBUG"] = 1] = "DEBUG";
496
+ LogLevel[LogLevel["INFO"] = 2] = "INFO";
497
+ LogLevel[LogLevel["WARN"] = 3] = "WARN";
498
+ LogLevel[LogLevel["ERROR"] = 4] = "ERROR";
499
+ LogLevel[LogLevel["SILENT"] = 5] = "SILENT";
500
+ })(LogLevel || (LogLevel = {}));
501
+
502
+ /*!
503
+ * Convert JS SDK
504
+ * Version 1.0.0
505
+ * Copyright(c) 2020 Convert Insights, Inc
506
+ * License Apache-2.0
507
+ */
508
+ var LogMethod;
509
+ (function (LogMethod) {
510
+ LogMethod["LOG"] = "log";
511
+ LogMethod["TRACE"] = "trace";
512
+ LogMethod["DEBUG"] = "debug";
513
+ LogMethod["INFO"] = "info";
514
+ LogMethod["WARN"] = "warn";
515
+ LogMethod["ERROR"] = "error";
516
+ })(LogMethod || (LogMethod = {}));
517
+
518
+ /*!
519
+ * Convert JS SDK
520
+ * Version 1.0.0
521
+ * Copyright(c) 2020 Convert Insights, Inc
522
+ * License Apache-2.0
523
+ */
524
+ var ProjectType;
525
+ (function (ProjectType) {
526
+ ProjectType["WEB"] = "web";
527
+ ProjectType["FULLSTACK"] = "fullstack";
528
+ })(ProjectType || (ProjectType = {}));
529
+
530
+ /*!
531
+ * Convert JS SDK
532
+ * Version 1.0.0
533
+ * Copyright(c) 2020 Convert Insights, Inc
534
+ * License Apache-2.0
535
+ */
536
+ var RuleError;
537
+ (function (RuleError) {
538
+ RuleError["NO_DATA_FOUND"] = "convert.com_no_data_found";
539
+ RuleError["NEED_MORE_DATA"] = "convert.com_need_more_data";
540
+ })(RuleError || (RuleError = {}));
541
+
542
+ /*!
543
+ * Convert JS SDK
544
+ * Version 1.0.0
545
+ * Copyright(c) 2020 Convert Insights, Inc
546
+ * License Apache-2.0
547
+ */
548
+ /**
549
+ * SDK system events. Possible values: 'ready' | 'queue-released'
550
+ * or custom visitor's event
551
+ */
552
+ var SystemEvents;
553
+ (function (SystemEvents) {
554
+ SystemEvents["READY"] = "ready";
555
+ SystemEvents["CONFIG_UPDATED"] = "config.updated";
556
+ SystemEvents["API_QUEUE_RELEASED"] = "api.queue.released";
557
+ SystemEvents["BUCKETING"] = "bucketing";
558
+ SystemEvents["CONVERSION"] = "conversion";
559
+ SystemEvents["SEGMENTS"] = "segments";
560
+ SystemEvents["LOCATION_ACTIVATED"] = "location.activated";
561
+ SystemEvents["LOCATION_DEACTIVATED"] = "location.deactivated";
562
+ SystemEvents["AUDIENCES"] = "audiences";
563
+ SystemEvents["DATA_STORE_QUEUE_RELEASED"] = "datastore.queue.released";
564
+ })(SystemEvents || (SystemEvents = {}));
565
+
566
+ /*!
567
+ * Convert JS SDK
568
+ * Version 1.0.0
569
+ * Copyright(c) 2020 Convert Insights, Inc
570
+ * License Apache-2.0
571
+ */
572
+ var VariationChangeType;
573
+ (function (VariationChangeType) {
574
+ VariationChangeType["RICH_STRUCTURE"] = "richStructure";
575
+ VariationChangeType["CUSTOM_CODE"] = "customCode";
576
+ VariationChangeType["DEFAULT_CODE"] = "defaultCode";
577
+ VariationChangeType["DEFAULT_CODE_MULTIPAGE"] = "defaultCodeMultipage";
578
+ VariationChangeType["DEFAULT_REDIRECT"] = "defaultRedirect";
579
+ VariationChangeType["FULLSTACK_FEATURE"] = "fullStackFeature";
580
+ })(VariationChangeType || (VariationChangeType = {}));
581
+
582
+ /*!
583
+ * Convert JS SDK
584
+ * Version 1.0.0
585
+ * Copyright(c) 2020 Convert Insights, Inc
586
+ * License Apache-2.0
587
+ */
588
+ var BrowserType;
589
+ (function (BrowserType) {
590
+ BrowserType["IE"] = "IE";
591
+ BrowserType["CH"] = "CH";
592
+ BrowserType["FF"] = "FF";
593
+ BrowserType["OP"] = "OP";
594
+ BrowserType["SF"] = "SF";
595
+ BrowserType["EDG"] = "EDG";
596
+ BrowserType["MO"] = "MO";
597
+ BrowserType["NS"] = "NS";
598
+ BrowserType["OTH"] = "OTH";
599
+ })(BrowserType || (BrowserType = {}));
600
+
601
+ /*!
602
+ * Convert JS SDK
603
+ * Version 1.0.0
604
+ * Copyright(c) 2020 Convert Insights, Inc
605
+ * License Apache-2.0
606
+ */
607
+ var DeviceType;
608
+ (function (DeviceType) {
609
+ DeviceType["ALLPH"] = "ALLPH";
610
+ DeviceType["IPH"] = "IPH";
611
+ DeviceType["OTHPH"] = "OTHPH";
612
+ DeviceType["ALLTAB"] = "ALLTAB";
613
+ DeviceType["IPAD"] = "IPAD";
614
+ DeviceType["OTHTAB"] = "OTHTAB";
615
+ DeviceType["DESK"] = "DESK";
616
+ DeviceType["OTHDEV"] = "OTHDEV";
617
+ })(DeviceType || (DeviceType = {}));
618
+
619
+ /*!
620
+ * Convert JS SDK
621
+ * Version 1.0.0
622
+ * Copyright(c) 2020 Convert Insights, Inc
623
+ * License Apache-2.0
624
+ */
625
+ var SegmentsKeys;
626
+ (function (SegmentsKeys) {
627
+ SegmentsKeys["COUNTRY"] = "country";
628
+ SegmentsKeys["BROWSER"] = "browser";
629
+ SegmentsKeys["DEVICES"] = "devices";
630
+ SegmentsKeys["SOURCE"] = "source";
631
+ SegmentsKeys["CAMPAIGN"] = "campaign";
632
+ SegmentsKeys["VISITOR_TYPE"] = "visitorType";
633
+ SegmentsKeys["CUSTOM_SEGMENTS"] = "customSegments";
634
+ })(SegmentsKeys || (SegmentsKeys = {}));
635
+
636
+ /*!
637
+ * Convert JS SDK
638
+ * Version 1.0.0
639
+ * Copyright(c) 2020 Convert Insights, Inc
640
+ * License Apache-2.0
641
+ */
642
+ var SourceType;
643
+ (function (SourceType) {
644
+ SourceType["CAMPAIGN"] = "campaign";
645
+ SourceType["SEARCH"] = "search";
646
+ SourceType["REFERRAL"] = "referral";
647
+ SourceType["DIRECT"] = "direct";
648
+ })(SourceType || (SourceType = {}));
649
+
650
+ /*!
651
+ * Convert JS SDK
652
+ * Version 1.0.0
653
+ * Copyright(c) 2020 Convert Insights, Inc
654
+ * License Apache-2.0
655
+ */
656
+ var VisitorType;
657
+ (function (VisitorType) {
658
+ VisitorType["NEW"] = "new";
659
+ VisitorType["RETURNING"] = "returning";
660
+ })(VisitorType || (VisitorType = {}));
661
+
662
+ /*!
663
+ * Convert JS SDK
664
+ * Version 1.0.0
665
+ * Copyright(c) 2020 Convert Insights, Inc
666
+ * License Apache-2.0
667
+ */
668
+ var HttpStatusCode;
669
+ (function (HttpStatusCode) {
670
+ HttpStatusCode[HttpStatusCode["Continue"] = 100] = "Continue";
671
+ HttpStatusCode[HttpStatusCode["SwitchingProtocols"] = 101] = "SwitchingProtocols";
672
+ HttpStatusCode[HttpStatusCode["Processing"] = 102] = "Processing";
673
+ HttpStatusCode[HttpStatusCode["EarlyHints"] = 103] = "EarlyHints";
674
+ HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
675
+ HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
676
+ HttpStatusCode[HttpStatusCode["Accepted"] = 202] = "Accepted";
677
+ HttpStatusCode[HttpStatusCode["NonAuthoritativeInformation"] = 203] = "NonAuthoritativeInformation";
678
+ HttpStatusCode[HttpStatusCode["NoContent"] = 204] = "NoContent";
679
+ HttpStatusCode[HttpStatusCode["ResetContent"] = 205] = "ResetContent";
680
+ HttpStatusCode[HttpStatusCode["PartialContent"] = 206] = "PartialContent";
681
+ HttpStatusCode[HttpStatusCode["MultiStatus"] = 207] = "MultiStatus";
682
+ HttpStatusCode[HttpStatusCode["AlreadyReported"] = 208] = "AlreadyReported";
683
+ HttpStatusCode[HttpStatusCode["ImUsed"] = 226] = "ImUsed";
684
+ HttpStatusCode[HttpStatusCode["MultipleChoices"] = 300] = "MultipleChoices";
685
+ HttpStatusCode[HttpStatusCode["MovedPermanently"] = 301] = "MovedPermanently";
686
+ HttpStatusCode[HttpStatusCode["Found"] = 302] = "Found";
687
+ HttpStatusCode[HttpStatusCode["SeeOther"] = 303] = "SeeOther";
688
+ HttpStatusCode[HttpStatusCode["NotModified"] = 304] = "NotModified";
689
+ HttpStatusCode[HttpStatusCode["UseProxy"] = 305] = "UseProxy";
690
+ HttpStatusCode[HttpStatusCode["Unused"] = 306] = "Unused";
691
+ HttpStatusCode[HttpStatusCode["TemporaryRedirect"] = 307] = "TemporaryRedirect";
692
+ HttpStatusCode[HttpStatusCode["PermanentRedirect"] = 308] = "PermanentRedirect";
693
+ HttpStatusCode[HttpStatusCode["BadRequest"] = 400] = "BadRequest";
694
+ HttpStatusCode[HttpStatusCode["Unauthorized"] = 401] = "Unauthorized";
695
+ HttpStatusCode[HttpStatusCode["PaymentRequired"] = 402] = "PaymentRequired";
696
+ HttpStatusCode[HttpStatusCode["Forbidden"] = 403] = "Forbidden";
697
+ HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
698
+ HttpStatusCode[HttpStatusCode["MethodNotAllowed"] = 405] = "MethodNotAllowed";
699
+ HttpStatusCode[HttpStatusCode["NotAcceptable"] = 406] = "NotAcceptable";
700
+ HttpStatusCode[HttpStatusCode["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired";
701
+ HttpStatusCode[HttpStatusCode["RequestTimeout"] = 408] = "RequestTimeout";
702
+ HttpStatusCode[HttpStatusCode["Conflict"] = 409] = "Conflict";
703
+ HttpStatusCode[HttpStatusCode["Gone"] = 410] = "Gone";
704
+ HttpStatusCode[HttpStatusCode["LengthRequired"] = 411] = "LengthRequired";
705
+ HttpStatusCode[HttpStatusCode["PreconditionFailed"] = 412] = "PreconditionFailed";
706
+ HttpStatusCode[HttpStatusCode["PayloadTooLarge"] = 413] = "PayloadTooLarge";
707
+ HttpStatusCode[HttpStatusCode["UriTooLong"] = 414] = "UriTooLong";
708
+ HttpStatusCode[HttpStatusCode["UnsupportedMediaType"] = 415] = "UnsupportedMediaType";
709
+ HttpStatusCode[HttpStatusCode["RangeNotSatisfiable"] = 416] = "RangeNotSatisfiable";
710
+ HttpStatusCode[HttpStatusCode["ExpectationFailed"] = 417] = "ExpectationFailed";
711
+ HttpStatusCode[HttpStatusCode["ImATeapot"] = 418] = "ImATeapot";
712
+ HttpStatusCode[HttpStatusCode["MisdirectedRequest"] = 421] = "MisdirectedRequest";
713
+ HttpStatusCode[HttpStatusCode["UnprocessableEntity"] = 422] = "UnprocessableEntity";
714
+ HttpStatusCode[HttpStatusCode["Locked"] = 423] = "Locked";
715
+ HttpStatusCode[HttpStatusCode["FailedDependency"] = 424] = "FailedDependency";
716
+ HttpStatusCode[HttpStatusCode["TooEarly"] = 425] = "TooEarly";
717
+ HttpStatusCode[HttpStatusCode["UpgradeRequired"] = 426] = "UpgradeRequired";
718
+ HttpStatusCode[HttpStatusCode["PreconditionRequired"] = 428] = "PreconditionRequired";
719
+ HttpStatusCode[HttpStatusCode["TooManyRequests"] = 429] = "TooManyRequests";
720
+ HttpStatusCode[HttpStatusCode["RequestHeaderFieldsTooLarge"] = 431] = "RequestHeaderFieldsTooLarge";
721
+ HttpStatusCode[HttpStatusCode["UnavailableForLegalReasons"] = 451] = "UnavailableForLegalReasons";
722
+ HttpStatusCode[HttpStatusCode["InternalServerError"] = 500] = "InternalServerError";
723
+ HttpStatusCode[HttpStatusCode["NotImplemented"] = 501] = "NotImplemented";
724
+ HttpStatusCode[HttpStatusCode["BadGateway"] = 502] = "BadGateway";
725
+ HttpStatusCode[HttpStatusCode["ServiceUnavailable"] = 503] = "ServiceUnavailable";
726
+ HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
727
+ HttpStatusCode[HttpStatusCode["HttpVersionNotSupported"] = 505] = "HttpVersionNotSupported";
728
+ HttpStatusCode[HttpStatusCode["VariantAlsoNegotiates"] = 506] = "VariantAlsoNegotiates";
729
+ HttpStatusCode[HttpStatusCode["InsufficientStorage"] = 507] = "InsufficientStorage";
730
+ HttpStatusCode[HttpStatusCode["LoopDetected"] = 508] = "LoopDetected";
731
+ HttpStatusCode[HttpStatusCode["NotExtended"] = 510] = "NotExtended";
732
+ HttpStatusCode[HttpStatusCode["NetworkAuthenticationRequired"] = 511] = "NetworkAuthenticationRequired";
733
+ })(HttpStatusCode || (HttpStatusCode = {}));
3
734
 
4
735
  /*!
5
736
  * Convert JS SDK
@@ -76,6 +807,9 @@ class RuleManager {
76
807
  arrayNotEmpty(ruleSet === null || ruleSet === void 0 ? void 0 : ruleSet.OR)) {
77
808
  for (let i = 0, l = ruleSet.OR.length; i < l; i++) {
78
809
  match = this._processAND(data, ruleSet.OR[i]);
810
+ if (match === true) {
811
+ return match;
812
+ }
79
813
  if (Object.values(RuleError).includes(match)) {
80
814
  (_f = (_e = this._loggerManager) === null || _e === void 0 ? void 0 : _e.info) === null || _f === void 0 ? void 0 : _f.call(_e, 'RuleManager.isRuleMatched()', logEntry || '', ERROR_MESSAGES.RULE_ERROR);
81
815
  }
@@ -84,9 +818,9 @@ class RuleManager {
84
818
  ? MESSAGES.RULE_NOT_MATCH
85
819
  : MESSAGES.RULE_MATCH.replace('#', String(i)));
86
820
  }
87
- if (match !== false) {
88
- return match;
89
- }
821
+ }
822
+ if (match !== false) {
823
+ return match;
90
824
  }
91
825
  }
92
826
  else {
@@ -156,10 +890,13 @@ class RuleManager {
156
890
  arrayNotEmpty(rulesSubset === null || rulesSubset === void 0 ? void 0 : rulesSubset.OR_WHEN)) {
157
891
  for (let i = 0, l = rulesSubset.OR_WHEN.length; i < l; i++) {
158
892
  match = this._processRuleItem(data, rulesSubset.OR_WHEN[i]);
159
- if (match !== false) {
893
+ if (match === true) {
160
894
  return match;
161
895
  }
162
896
  }
897
+ if (match !== false) {
898
+ return match;
899
+ }
163
900
  }
164
901
  else {
165
902
  (_b = (_a = this._loggerManager) === null || _a === void 0 ? void 0 : _a.warn) === null || _b === void 0 ? void 0 : _b.call(_a, 'RuleManager._processORWHEN()', ERROR_MESSAGES.RULE_NOT_VALID);