@ninetailed/experience.js 4.3.0-beta.2 → 4.4.0-beta.1

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.js CHANGED
@@ -5,8 +5,6 @@ import { z } from 'zod';
5
5
 
6
6
  const HAS_SEEN_EXPERIENCE = 'has_seen_experience';
7
7
  const HAS_SEEN_COMPONENT = 'has_seen_component';
8
- const HAS_SEEN_ELEMENT = 'has_seen_element';
9
- const PAGE_HIDDEN = 'page_hidden';
10
8
 
11
9
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
12
10
 
@@ -604,9 +602,9 @@ var inspectSource$3 = store$1.inspectSource;
604
602
  var global$d = global$k;
605
603
  var isCallable$d = isCallable$k;
606
604
 
607
- var WeakMap$2 = global$d.WeakMap;
605
+ var WeakMap$1 = global$d.WeakMap;
608
606
 
609
- var weakMapBasicDetection = isCallable$d(WeakMap$2) && /native code/.test(String(WeakMap$2));
607
+ var weakMapBasicDetection = isCallable$d(WeakMap$1) && /native code/.test(String(WeakMap$1));
610
608
 
611
609
  var shared$1 = shared$3.exports;
612
610
  var uid = uid$2;
@@ -630,7 +628,7 @@ var hiddenKeys$3 = hiddenKeys$4;
630
628
 
631
629
  var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
632
630
  var TypeError$2 = global$c.TypeError;
633
- var WeakMap$1 = global$c.WeakMap;
631
+ var WeakMap = global$c.WeakMap;
634
632
  var set$1, get, has;
635
633
 
636
634
  var enforce = function (it) {
@@ -647,7 +645,7 @@ var getterFor = function (TYPE) {
647
645
  };
648
646
 
649
647
  if (NATIVE_WEAK_MAP || shared.state) {
650
- var store = shared.state || (shared.state = new WeakMap$1());
648
+ var store = shared.state || (shared.state = new WeakMap());
651
649
  /* eslint-disable no-self-assign -- prototype methods protection */
652
650
  store.get = store.get;
653
651
  store.has = store.has;
@@ -2519,18 +2517,6 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2519
2517
  PERFORMANCE OF THIS SOFTWARE.
2520
2518
  ***************************************************************************** */
2521
2519
 
2522
- function __rest(s, e) {
2523
- var t = {};
2524
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2525
- t[p] = s[p];
2526
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
2527
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2528
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2529
- t[p[i]] = s[p[i]];
2530
- }
2531
- return t;
2532
- }
2533
-
2534
2520
  function __awaiter(thisArg, _arguments, P, generator) {
2535
2521
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2536
2522
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -2849,115 +2835,6 @@ if (NOT_GENERIC || INCORRECT_NAME) {
2849
2835
  }, { unsafe: true });
2850
2836
  }
2851
2837
 
2852
- var classof = classofRaw$2;
2853
-
2854
- // `IsArray` abstract operation
2855
- // https://tc39.es/ecma262/#sec-isarray
2856
- // eslint-disable-next-line es/no-array-isarray -- safe
2857
- var isArray$2 = Array.isArray || function isArray(argument) {
2858
- return classof(argument) == 'Array';
2859
- };
2860
-
2861
- var $TypeError$1 = TypeError;
2862
- var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
2863
-
2864
- var doesNotExceedSafeInteger$1 = function (it) {
2865
- if (it > MAX_SAFE_INTEGER) throw $TypeError$1('Maximum allowed index exceeded');
2866
- return it;
2867
- };
2868
-
2869
- var isArray$1 = isArray$2;
2870
- var lengthOfArrayLike$2 = lengthOfArrayLike$5;
2871
- var doesNotExceedSafeInteger = doesNotExceedSafeInteger$1;
2872
- var bind = functionBindContext;
2873
-
2874
- // `FlattenIntoArray` abstract operation
2875
- // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
2876
- var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
2877
- var targetIndex = start;
2878
- var sourceIndex = 0;
2879
- var mapFn = mapper ? bind(mapper, thisArg) : false;
2880
- var element, elementLen;
2881
-
2882
- while (sourceIndex < sourceLen) {
2883
- if (sourceIndex in source) {
2884
- element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
2885
-
2886
- if (depth > 0 && isArray$1(element)) {
2887
- elementLen = lengthOfArrayLike$2(element);
2888
- targetIndex = flattenIntoArray$1(target, original, element, elementLen, targetIndex, depth - 1) - 1;
2889
- } else {
2890
- doesNotExceedSafeInteger(targetIndex + 1);
2891
- target[targetIndex] = element;
2892
- }
2893
-
2894
- targetIndex++;
2895
- }
2896
- sourceIndex++;
2897
- }
2898
- return targetIndex;
2899
- };
2900
-
2901
- var flattenIntoArray_1 = flattenIntoArray$1;
2902
-
2903
- var isArray = isArray$2;
2904
- var isConstructor = isConstructor$2;
2905
- var isObject$1 = isObject$a;
2906
- var wellKnownSymbol$3 = wellKnownSymbol$h;
2907
-
2908
- var SPECIES = wellKnownSymbol$3('species');
2909
- var $Array = Array;
2910
-
2911
- // a part of `ArraySpeciesCreate` abstract operation
2912
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
2913
- var arraySpeciesConstructor$1 = function (originalArray) {
2914
- var C;
2915
- if (isArray(originalArray)) {
2916
- C = originalArray.constructor;
2917
- // cross-realm fallback
2918
- if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
2919
- else if (isObject$1(C)) {
2920
- C = C[SPECIES];
2921
- if (C === null) C = undefined;
2922
- }
2923
- } return C === undefined ? $Array : C;
2924
- };
2925
-
2926
- var arraySpeciesConstructor = arraySpeciesConstructor$1;
2927
-
2928
- // `ArraySpeciesCreate` abstract operation
2929
- // https://tc39.es/ecma262/#sec-arrayspeciescreate
2930
- var arraySpeciesCreate$1 = function (originalArray, length) {
2931
- return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
2932
- };
2933
-
2934
- var $$3 = _export;
2935
- var flattenIntoArray = flattenIntoArray_1;
2936
- var toObject$2 = toObject$5;
2937
- var lengthOfArrayLike$1 = lengthOfArrayLike$5;
2938
- var toIntegerOrInfinity = toIntegerOrInfinity$3;
2939
- var arraySpeciesCreate = arraySpeciesCreate$1;
2940
-
2941
- // `Array.prototype.flat` method
2942
- // https://tc39.es/ecma262/#sec-array.prototype.flat
2943
- $$3({ target: 'Array', proto: true }, {
2944
- flat: function flat(/* depthArg = 1 */) {
2945
- var depthArg = arguments.length ? arguments[0] : undefined;
2946
- var O = toObject$2(this);
2947
- var sourceLen = lengthOfArrayLike$1(O);
2948
- var A = arraySpeciesCreate(O, 0);
2949
- A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
2950
- return A;
2951
- }
2952
- });
2953
-
2954
- // this method was added to unscopables after implementation
2955
- // in popular engines, so it's moved to a separate module
2956
- var addToUnscopables$1 = addToUnscopables$3;
2957
-
2958
- // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
2959
- addToUnscopables$1('flat');
2960
-
2961
2838
  var fails$3 = fails$h;
2962
2839
 
2963
2840
  var correctPrototypeGetter = !fails$3(function () {
@@ -2969,7 +2846,7 @@ var correctPrototypeGetter = !fails$3(function () {
2969
2846
 
2970
2847
  var hasOwn = hasOwnProperty_1;
2971
2848
  var isCallable$2 = isCallable$k;
2972
- var toObject$1 = toObject$5;
2849
+ var toObject$2 = toObject$5;
2973
2850
  var sharedKey = sharedKey$3;
2974
2851
  var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter;
2975
2852
 
@@ -2981,7 +2858,7 @@ var ObjectPrototype = $Object.prototype;
2981
2858
  // https://tc39.es/ecma262/#sec-object.getprototypeof
2982
2859
  // eslint-disable-next-line es/no-object-getprototypeof -- safe
2983
2860
  var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) {
2984
- var object = toObject$1(O);
2861
+ var object = toObject$2(O);
2985
2862
  if (hasOwn(object, IE_PROTO)) return object[IE_PROTO];
2986
2863
  var constructor = object.constructor;
2987
2864
  if (isCallable$2(constructor) && object instanceof constructor) {
@@ -2991,12 +2868,12 @@ var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : f
2991
2868
 
2992
2869
  var fails$2 = fails$h;
2993
2870
  var isCallable$1 = isCallable$k;
2994
- var isObject = isObject$a;
2871
+ var isObject$1 = isObject$a;
2995
2872
  var getPrototypeOf$1 = objectGetPrototypeOf;
2996
2873
  var defineBuiltIn$1 = defineBuiltIn$6;
2997
- var wellKnownSymbol$2 = wellKnownSymbol$h;
2874
+ var wellKnownSymbol$3 = wellKnownSymbol$h;
2998
2875
 
2999
- var ITERATOR$3 = wellKnownSymbol$2('iterator');
2876
+ var ITERATOR$3 = wellKnownSymbol$3('iterator');
3000
2877
  var BUGGY_SAFARI_ITERATORS$1 = false;
3001
2878
 
3002
2879
  // `%IteratorPrototype%` object
@@ -3014,7 +2891,7 @@ if ([].keys) {
3014
2891
  }
3015
2892
  }
3016
2893
 
3017
- var NEW_ITERATOR_PROTOTYPE = !isObject(IteratorPrototype$2) || fails$2(function () {
2894
+ var NEW_ITERATOR_PROTOTYPE = !isObject$1(IteratorPrototype$2) || fails$2(function () {
3018
2895
  var test = {};
3019
2896
  // FF44- legacy iterators case
3020
2897
  return IteratorPrototype$2[ITERATOR$3].call(test) !== test;
@@ -3051,7 +2928,7 @@ var iteratorCreateConstructor = function (IteratorConstructor, NAME, next, ENUME
3051
2928
  return IteratorConstructor;
3052
2929
  };
3053
2930
 
3054
- var $$2 = _export;
2931
+ var $$3 = _export;
3055
2932
  var call = functionCall;
3056
2933
  var FunctionName = functionName;
3057
2934
  var isCallable = isCallable$k;
@@ -3061,7 +2938,7 @@ var setPrototypeOf = objectSetPrototypeOf;
3061
2938
  var setToStringTag = setToStringTag$3;
3062
2939
  var createNonEnumerableProperty$1 = createNonEnumerableProperty$4;
3063
2940
  var defineBuiltIn = defineBuiltIn$6;
3064
- var wellKnownSymbol$1 = wellKnownSymbol$h;
2941
+ var wellKnownSymbol$2 = wellKnownSymbol$h;
3065
2942
  var Iterators$1 = iterators;
3066
2943
  var IteratorsCore = iteratorsCore;
3067
2944
 
@@ -3069,7 +2946,7 @@ var PROPER_FUNCTION_NAME = FunctionName.PROPER;
3069
2946
  var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE;
3070
2947
  var IteratorPrototype = IteratorsCore.IteratorPrototype;
3071
2948
  var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS;
3072
- var ITERATOR$2 = wellKnownSymbol$1('iterator');
2949
+ var ITERATOR$2 = wellKnownSymbol$2('iterator');
3073
2950
  var KEYS = 'keys';
3074
2951
  var VALUES = 'values';
3075
2952
  var ENTRIES = 'entries';
@@ -3136,7 +3013,7 @@ var iteratorDefine = function (Iterable, NAME, IteratorConstructor, next, DEFAUL
3136
3013
  if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) {
3137
3014
  defineBuiltIn(IterablePrototype, KEY, methods[KEY]);
3138
3015
  }
3139
- } else $$2({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
3016
+ } else $$3({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods);
3140
3017
  }
3141
3018
 
3142
3019
  // define iterator
@@ -3155,7 +3032,7 @@ var createIterResultObject$1 = function (value, done) {
3155
3032
  };
3156
3033
 
3157
3034
  var toIndexedObject = toIndexedObject$5;
3158
- var addToUnscopables = addToUnscopables$3;
3035
+ var addToUnscopables$1 = addToUnscopables$3;
3159
3036
  var Iterators = iterators;
3160
3037
  var InternalStateModule = internalState;
3161
3038
  var defineProperty = objectDefineProperty.f;
@@ -3206,9 +3083,9 @@ var es_array_iterator = defineIterator(Array, 'Array', function (iterated, kind)
3206
3083
  var values = Iterators.Arguments = Iterators.Array;
3207
3084
 
3208
3085
  // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3209
- addToUnscopables('keys');
3210
- addToUnscopables('values');
3211
- addToUnscopables('entries');
3086
+ addToUnscopables$1('keys');
3087
+ addToUnscopables$1('values');
3088
+ addToUnscopables$1('entries');
3212
3089
 
3213
3090
  // V8 ~ Chrome 45- bug
3214
3091
  if (DESCRIPTORS && values.name !== 'values') try {
@@ -3264,10 +3141,10 @@ var DOMIterables = domIterables;
3264
3141
  var DOMTokenListPrototype = domTokenListPrototype;
3265
3142
  var ArrayIteratorMethods = es_array_iterator;
3266
3143
  var createNonEnumerableProperty = createNonEnumerableProperty$4;
3267
- var wellKnownSymbol = wellKnownSymbol$h;
3144
+ var wellKnownSymbol$1 = wellKnownSymbol$h;
3268
3145
 
3269
- var ITERATOR$1 = wellKnownSymbol('iterator');
3270
- var TO_STRING_TAG = wellKnownSymbol('toStringTag');
3146
+ var ITERATOR$1 = wellKnownSymbol$1('iterator');
3147
+ var TO_STRING_TAG = wellKnownSymbol$1('toStringTag');
3271
3148
  var ArrayValues = ArrayIteratorMethods.values;
3272
3149
 
3273
3150
  var handlePrototype = function (CollectionPrototype, COLLECTION_NAME) {
@@ -3298,54 +3175,115 @@ for (var COLLECTION_NAME in DOMIterables) {
3298
3175
 
3299
3176
  handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
3300
3177
 
3301
- class ElementSeenObserver {
3302
- constructor(_options) {
3303
- this._options = _options;
3304
- this._elementDelays = new WeakMap();
3305
- this._intersectionTimers = new WeakMap();
3306
- if (typeof IntersectionObserver !== 'undefined') {
3307
- this._intersectionObserver = new IntersectionObserver(this.onIntersection.bind(this));
3308
- }
3309
- }
3310
- onIntersection(entries) {
3311
- entries.forEach(entry => {
3312
- const {
3313
- isIntersecting,
3314
- target
3315
- } = entry;
3316
- if (isIntersecting) {
3317
- const delay = this._elementDelays.get(target);
3318
- const timeOut = window.setTimeout(() => {
3319
- this._options.onElementSeen(target);
3320
- }, delay);
3321
- this._intersectionTimers.set(target, timeOut);
3178
+ var classof = classofRaw$2;
3179
+
3180
+ // `IsArray` abstract operation
3181
+ // https://tc39.es/ecma262/#sec-isarray
3182
+ // eslint-disable-next-line es/no-array-isarray -- safe
3183
+ var isArray$2 = Array.isArray || function isArray(argument) {
3184
+ return classof(argument) == 'Array';
3185
+ };
3186
+
3187
+ var $TypeError$1 = TypeError;
3188
+ var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991
3189
+
3190
+ var doesNotExceedSafeInteger$1 = function (it) {
3191
+ if (it > MAX_SAFE_INTEGER) throw $TypeError$1('Maximum allowed index exceeded');
3192
+ return it;
3193
+ };
3194
+
3195
+ var isArray$1 = isArray$2;
3196
+ var lengthOfArrayLike$2 = lengthOfArrayLike$5;
3197
+ var doesNotExceedSafeInteger = doesNotExceedSafeInteger$1;
3198
+ var bind = functionBindContext;
3199
+
3200
+ // `FlattenIntoArray` abstract operation
3201
+ // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
3202
+ var flattenIntoArray$1 = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
3203
+ var targetIndex = start;
3204
+ var sourceIndex = 0;
3205
+ var mapFn = mapper ? bind(mapper, thisArg) : false;
3206
+ var element, elementLen;
3207
+
3208
+ while (sourceIndex < sourceLen) {
3209
+ if (sourceIndex in source) {
3210
+ element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
3211
+
3212
+ if (depth > 0 && isArray$1(element)) {
3213
+ elementLen = lengthOfArrayLike$2(element);
3214
+ targetIndex = flattenIntoArray$1(target, original, element, elementLen, targetIndex, depth - 1) - 1;
3322
3215
  } else {
3323
- const timeOut = this._intersectionTimers.get(target);
3324
- if (typeof timeOut !== 'undefined') {
3325
- window.clearTimeout(timeOut);
3326
- }
3216
+ doesNotExceedSafeInteger(targetIndex + 1);
3217
+ target[targetIndex] = element;
3327
3218
  }
3328
- });
3329
- }
3330
- observe(element, options) {
3331
- var _a, _b;
3332
- this._elementDelays.set(element, (_a = options === null || options === void 0 ? void 0 : options.delay) !== null && _a !== void 0 ? _a : 2000);
3333
- (_b = this._intersectionObserver) === null || _b === void 0 ? void 0 : _b.observe(element);
3334
- }
3335
- unobserve(element) {
3336
- var _a;
3337
- (_a = this._intersectionObserver) === null || _a === void 0 ? void 0 : _a.unobserve(element);
3219
+
3220
+ targetIndex++;
3221
+ }
3222
+ sourceIndex++;
3338
3223
  }
3339
- }
3224
+ return targetIndex;
3225
+ };
3226
+
3227
+ var flattenIntoArray_1 = flattenIntoArray$1;
3340
3228
 
3341
- const acceptsCredentials = plugin => {
3342
- return typeof plugin === 'object' && plugin !== null && 'setCredentials' in plugin && typeof plugin.setCredentials === 'function';
3229
+ var isArray = isArray$2;
3230
+ var isConstructor = isConstructor$2;
3231
+ var isObject = isObject$a;
3232
+ var wellKnownSymbol = wellKnownSymbol$h;
3233
+
3234
+ var SPECIES = wellKnownSymbol('species');
3235
+ var $Array = Array;
3236
+
3237
+ // a part of `ArraySpeciesCreate` abstract operation
3238
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
3239
+ var arraySpeciesConstructor$1 = function (originalArray) {
3240
+ var C;
3241
+ if (isArray(originalArray)) {
3242
+ C = originalArray.constructor;
3243
+ // cross-realm fallback
3244
+ if (isConstructor(C) && (C === $Array || isArray(C.prototype))) C = undefined;
3245
+ else if (isObject(C)) {
3246
+ C = C[SPECIES];
3247
+ if (C === null) C = undefined;
3248
+ }
3249
+ } return C === undefined ? $Array : C;
3343
3250
  };
3344
3251
 
3345
- const isInterestedInHiddenPage = arg => {
3346
- return typeof arg === 'object' && arg !== null && PAGE_HIDDEN in arg && typeof arg[PAGE_HIDDEN] === 'function';
3252
+ var arraySpeciesConstructor = arraySpeciesConstructor$1;
3253
+
3254
+ // `ArraySpeciesCreate` abstract operation
3255
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
3256
+ var arraySpeciesCreate$1 = function (originalArray, length) {
3257
+ return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length);
3347
3258
  };
3348
3259
 
3260
+ var $$2 = _export;
3261
+ var flattenIntoArray = flattenIntoArray_1;
3262
+ var toObject$1 = toObject$5;
3263
+ var lengthOfArrayLike$1 = lengthOfArrayLike$5;
3264
+ var toIntegerOrInfinity = toIntegerOrInfinity$3;
3265
+ var arraySpeciesCreate = arraySpeciesCreate$1;
3266
+
3267
+ // `Array.prototype.flat` method
3268
+ // https://tc39.es/ecma262/#sec-array.prototype.flat
3269
+ $$2({ target: 'Array', proto: true }, {
3270
+ flat: function flat(/* depthArg = 1 */) {
3271
+ var depthArg = arguments.length ? arguments[0] : undefined;
3272
+ var O = toObject$1(this);
3273
+ var sourceLen = lengthOfArrayLike$1(O);
3274
+ var A = arraySpeciesCreate(O, 0);
3275
+ A.length = flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
3276
+ return A;
3277
+ }
3278
+ });
3279
+
3280
+ // this method was added to unscopables after implementation
3281
+ // in popular engines, so it's moved to a separate module
3282
+ var addToUnscopables = addToUnscopables$3;
3283
+
3284
+ // https://tc39.es/ecma262/#sec-array.prototype-@@unscopables
3285
+ addToUnscopables('flat');
3286
+
3349
3287
  class Ninetailed {
3350
3288
  constructor(ninetailedApiClientInstanceOrOptions, {
3351
3289
  plugins,
@@ -3401,28 +3339,6 @@ class Ninetailed {
3401
3339
  type: HAS_SEEN_EXPERIENCE
3402
3340
  }));
3403
3341
  };
3404
- this.observeElement = (payload, options) => {
3405
- const {
3406
- element
3407
- } = payload,
3408
- remaingPayload = __rest(payload, ["element"]);
3409
- this.observedElements.set(element, remaingPayload);
3410
- this.elementSeenObserver.observe(element, options);
3411
- };
3412
- this.unobserveElement = element => {
3413
- this.observedElements.delete(element);
3414
- this.elementSeenObserver.unobserve(element);
3415
- };
3416
- this.onElementSeen = element => {
3417
- const payload = this.observedElements.get(element);
3418
- if (typeof payload !== 'undefined') {
3419
- this.instance.dispatch(Object.assign(Object.assign({
3420
- element
3421
- }, payload), {
3422
- type: HAS_SEEN_ELEMENT
3423
- }));
3424
- }
3425
- };
3426
3342
  this.identify = (uid, traits, options) => __awaiter(this, void 0, void 0, function* () {
3427
3343
  try {
3428
3344
  const result = Traits.default({}).safeParse(traits);
@@ -3490,18 +3406,6 @@ class Ninetailed {
3490
3406
  this.onIsInitialized(resolve);
3491
3407
  });
3492
3408
  };
3493
- this.onVisibilityChange = () => {
3494
- if (typeof document === 'undefined') {
3495
- return;
3496
- }
3497
- document.addEventListener('visibilitychange', () => {
3498
- if (document.visibilityState === 'hidden') {
3499
- this.instance.dispatch({
3500
- type: PAGE_HIDDEN
3501
- });
3502
- }
3503
- });
3504
- };
3505
3409
  if (ninetailedApiClientInstanceOrOptions instanceof NinetailedApiClient) {
3506
3410
  this.apiClient = ninetailedApiClientInstanceOrOptions;
3507
3411
  } else {
@@ -3519,15 +3423,15 @@ class Ninetailed {
3519
3423
  preview
3520
3424
  });
3521
3425
  }
3522
- this.plugins = (plugins !== null && plugins !== void 0 ? plugins : []).flat();
3523
- this.plugins.forEach(plugin => {
3524
- if (acceptsCredentials(plugin) && this.clientId && this.environment) {
3525
- plugin.setCredentials({
3426
+ this.plugins = [...(plugins || []).map(plugin => {
3427
+ if ('setCredentials' in plugin && typeof plugin['setCredentials'] === 'function') {
3428
+ plugin['setCredentials']({
3526
3429
  clientId: this.clientId,
3527
3430
  environment: this.environment
3528
3431
  });
3529
3432
  }
3530
- });
3433
+ return plugin;
3434
+ }).flat()];
3531
3435
  if (profile) {
3532
3436
  this._profileState = {
3533
3437
  status: 'success',
@@ -3575,14 +3479,6 @@ class Ninetailed {
3575
3479
  });
3576
3480
  }
3577
3481
  });
3578
- this.observedElements = new WeakMap();
3579
- this.elementSeenObserver = new ElementSeenObserver({
3580
- onElementSeen: this.onElementSeen.bind(this)
3581
- });
3582
- const hasPluginsInterestedInHiddenPage = this.plugins.some(isInterestedInHiddenPage);
3583
- if (hasPluginsInterestedInHiddenPage) {
3584
- this.onVisibilityChange();
3585
- }
3586
3482
  this.registerWindowHandlers();
3587
3483
  }
3588
3484
  get profileState() {
@@ -3981,4 +3877,4 @@ const makeExperienceSelectMiddleware = ({
3981
3877
  };
3982
3878
  };
3983
3879
 
3984
- export { ANONYMOUS_ID, CONSENT, DEBUG_FLAG, EMPTY_MERGE_ID, HAS_SEEN_COMPONENT, HAS_SEEN_ELEMENT, HAS_SEEN_EXPERIENCE, LEGACY_ANONYMOUS_ID, Ninetailed, NinetailedPlugin, OnChangeEmitter, PAGE_HIDDEN, PLUGIN_NAME, PROFILE_CHANGE, PROFILE_FALLBACK_CACHE, PROFILE_RESET, SET_ENABLED_FEATURES, TrackComponentProperties, TrackExperienceProperties, buildClientNinetailedRequestContext, decodeExperienceVariantsMap, makeExperienceSelectMiddleware, ninetailedPlugin, selectPluginsHavingExperienceSelectionMiddleware, selectPluginsHavingOnChangeEmitter, selectVariant };
3880
+ export { ANONYMOUS_ID, CONSENT, DEBUG_FLAG, EMPTY_MERGE_ID, HAS_SEEN_COMPONENT, HAS_SEEN_EXPERIENCE, LEGACY_ANONYMOUS_ID, Ninetailed, NinetailedPlugin, OnChangeEmitter, PLUGIN_NAME, PROFILE_CHANGE, PROFILE_FALLBACK_CACHE, PROFILE_RESET, SET_ENABLED_FEATURES, TrackComponentProperties, TrackExperienceProperties, decodeExperienceVariantsMap, makeExperienceSelectMiddleware, ninetailedPlugin, selectPluginsHavingExperienceSelectionMiddleware, selectPluginsHavingOnChangeEmitter, selectVariant };
@@ -1,7 +1,6 @@
1
1
  /// <reference types="analytics" />
2
2
  import { Locale, Traits, Profile, OnLogHandler, OnErrorHandler, Logger, PageviewProperties, Properties, NinetailedApiClient, NinetailedApiClientOptions } from '@ninetailed/experience.js-shared';
3
- import { EventFunctionOptions, NinetailedInstance, NinetailedPlugin, OnIsInitializedCallback, OnProfileChangeCallback, ProfileState, TrackHasSeenComponent, TrackHasSeenExperience, ElementSeenPayload } from './types';
4
- import { ObserveOptions } from './ElementSeenObserver';
3
+ import { EventFunctionOptions, NinetailedInstance, NinetailedPlugin, OnIsInitializedCallback, OnProfileChangeCallback, ProfileState, TrackHasSeenComponent, TrackHasSeenExperience } from './types';
5
4
  declare global {
6
5
  interface Window {
7
6
  ninetailed?: {
@@ -28,8 +27,6 @@ export declare class Ninetailed implements NinetailedInstance {
28
27
  private isInitialized;
29
28
  private readonly apiClient;
30
29
  private readonly eventQueue;
31
- private readonly elementSeenObserver;
32
- private readonly observedElements;
33
30
  private readonly clientId;
34
31
  private readonly environment;
35
32
  readonly plugins: NinetailedPlugin[];
@@ -39,9 +36,6 @@ export declare class Ninetailed implements NinetailedInstance {
39
36
  track: (event: string, properties?: Properties, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
40
37
  trackHasSeenComponent: TrackHasSeenComponent;
41
38
  trackHasSeenExperience: TrackHasSeenExperience;
42
- observeElement: (payload: ElementSeenPayload, options?: ObserveOptions) => void;
43
- unobserveElement: (element: Element) => void;
44
- private onElementSeen;
45
39
  identify: (uid: string, traits?: Traits, options?: EventFunctionOptions) => Promise<import("./types").FlushResult>;
46
40
  reset: () => Promise<void>;
47
41
  debug: (enabled: boolean) => Promise<void>;
@@ -51,6 +45,5 @@ export declare class Ninetailed implements NinetailedInstance {
51
45
  get profileState(): ProfileState;
52
46
  private buildOptions;
53
47
  private registerWindowHandlers;
54
- private onVisibilityChange;
55
48
  }
56
49
  export {};
@@ -1,3 +1,2 @@
1
1
  export * from './get-analytics-plugin';
2
2
  export * from './constants';
3
- export * from './Events';
@@ -1,4 +1,2 @@
1
1
  export declare const HAS_SEEN_EXPERIENCE = "has_seen_experience";
2
2
  export declare const HAS_SEEN_COMPONENT = "has_seen_component";
3
- export declare const HAS_SEEN_ELEMENT = "has_seen_element";
4
- export declare const PAGE_HIDDEN = "page_hidden";
@@ -6,73 +6,73 @@ export declare const TrackExperienceProperties: z.ZodObject<{
6
6
  name: z.ZodString;
7
7
  description: z.ZodOptional<z.ZodString>;
8
8
  }, "strip", z.ZodTypeAny, {
9
+ description?: string | undefined;
9
10
  type: "nt_experiment" | "nt_personalization";
10
11
  id: string;
11
12
  name: string;
12
- description?: string | undefined;
13
13
  }, {
14
+ description?: string | undefined;
14
15
  type: "nt_experiment" | "nt_personalization";
15
16
  id: string;
16
17
  name: string;
17
- description?: string | undefined;
18
18
  }>;
19
19
  audience: z.ZodDefault<z.ZodOptional<z.ZodObject<{
20
20
  id: z.ZodString;
21
21
  name: z.ZodOptional<z.ZodString>;
22
22
  description: z.ZodOptional<z.ZodString>;
23
23
  }, "strip", z.ZodTypeAny, {
24
- id: string;
25
24
  name?: string | undefined;
26
25
  description?: string | undefined;
27
- }, {
28
26
  id: string;
27
+ }, {
29
28
  name?: string | undefined;
30
29
  description?: string | undefined;
30
+ id: string;
31
31
  }>>>;
32
32
  selectedVariant: z.ZodObject<{
33
33
  id: z.ZodString;
34
- }, "strip", z.ZodUnknown, z.objectOutputType<{
35
- id: z.ZodString;
36
- }, z.ZodUnknown, "strip">, z.objectInputType<{
37
- id: z.ZodString;
38
- }, z.ZodUnknown, "strip">>;
34
+ }, "strip", z.ZodUnknown, {
35
+ [x: string]: unknown;
36
+ id: string;
37
+ }, {
38
+ [x: string]: unknown;
39
+ id: string;
40
+ }>;
39
41
  selectedVariantIndex: z.ZodNumber;
40
42
  }, "strip", z.ZodTypeAny, {
41
43
  experience: {
44
+ description?: string | undefined;
42
45
  type: "nt_experiment" | "nt_personalization";
43
46
  id: string;
44
47
  name: string;
45
- description?: string | undefined;
46
48
  };
47
49
  audience: {
48
- id: string;
49
50
  name?: string | undefined;
50
51
  description?: string | undefined;
52
+ id: string;
51
53
  };
52
54
  selectedVariant: {
55
+ [x: string]: unknown;
53
56
  id: string;
54
- } & {
55
- [k: string]: unknown;
56
57
  };
57
58
  selectedVariantIndex: number;
58
59
  }, {
60
+ audience?: {
61
+ name?: string | undefined;
62
+ description?: string | undefined;
63
+ id: string;
64
+ } | undefined;
59
65
  experience: {
66
+ description?: string | undefined;
60
67
  type: "nt_experiment" | "nt_personalization";
61
68
  id: string;
62
69
  name: string;
63
- description?: string | undefined;
64
70
  };
65
71
  selectedVariant: {
72
+ [x: string]: unknown;
66
73
  id: string;
67
- } & {
68
- [k: string]: unknown;
69
74
  };
70
75
  selectedVariantIndex: number;
71
- audience?: {
72
- id: string;
73
- name?: string | undefined;
74
- description?: string | undefined;
75
- } | undefined;
76
76
  }>;
77
77
  export type TrackExperienceProperties = z.input<typeof TrackExperienceProperties>;
78
78
  export type SanitizedTrackExperienceProperties = z.infer<typeof TrackExperienceProperties> & {