@ninetailed/experience.js 3.0.1-beta.3 → 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.esm.js CHANGED
@@ -2951,6 +2951,8 @@ class Ninetailed {
2951
2951
  onLog,
2952
2952
  onError
2953
2953
  } = {}) {
2954
+ this.isInitialized = false;
2955
+
2954
2956
  this.page = (data, options) => __awaiter(this, void 0, void 0, function* () {
2955
2957
  yield this.waitUntilInitialized();
2956
2958
  return this.instance.page(data, this.buildOptions(options));
@@ -2981,11 +2983,14 @@ class Ninetailed {
2981
2983
 
2982
2984
  this.identify = (uid, traits, options) => __awaiter(this, void 0, void 0, function* () {
2983
2985
  yield this.waitUntilInitialized();
2986
+ /*console.log("Identify triggered");*/
2987
+
2984
2988
  return this.instance.identify(uid, traits, this.buildOptions(options));
2985
2989
  });
2986
2990
 
2987
2991
  this.reset = () => {
2988
2992
  this.onIsInitialized(() => {
2993
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2989
2994
  // @ts-ignore
2990
2995
  this.instance.plugins[PLUGIN_NAME].reset();
2991
2996
  });
@@ -2993,6 +2998,7 @@ class Ninetailed {
2993
2998
 
2994
2999
  this.debug = enabled => {
2995
3000
  this.onIsInitialized(() => {
3001
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2996
3002
  // @ts-ignore
2997
3003
  this.instance.plugins[PLUGIN_NAME].debug(enabled);
2998
3004
  });
@@ -3013,10 +3019,14 @@ class Ninetailed {
3013
3019
 
3014
3020
  this.onIsInitialized = onIsInitialized => {
3015
3021
  if (typeof onIsInitialized === 'function') {
3016
- const detachOnReadyListener = this.instance.ready(() => {
3022
+ if (this.isInitialized) {
3017
3023
  onIsInitialized();
3018
- detachOnReadyListener();
3019
- });
3024
+ } else {
3025
+ const detachOnReadyListener = this.instance.on('ready', () => {
3026
+ onIsInitialized();
3027
+ detachOnReadyListener();
3028
+ });
3029
+ }
3020
3030
  }
3021
3031
  };
3022
3032
 
@@ -3065,8 +3075,10 @@ class Ninetailed {
3065
3075
  preview
3066
3076
  })]
3067
3077
  });
3068
- this.instance.ready(() => {
3078
+ const detachOnReadyListener = this.instance.on('ready', () => {
3079
+ this.isInitialized = true;
3069
3080
  logger.info('Ninetailed Experience.js SDK is completely initialized.');
3081
+ detachOnReadyListener();
3070
3082
  }); // put in private method
3071
3083
 
3072
3084
  this.onProfileChange(profileState => {
package/index.umd.js CHANGED
@@ -2727,6 +2727,8 @@
2727
2727
  onLog = _c.onLog,
2728
2728
  onError = _c.onError;
2729
2729
 
2730
+ this.isInitialized = false;
2731
+
2730
2732
  this.page = function (data, options) {
2731
2733
  return __awaiter(_this, void 0, void 0, function () {
2732
2734
  return __generator(this, function (_a) {
@@ -2802,6 +2804,8 @@
2802
2804
 
2803
2805
  case 1:
2804
2806
  _a.sent();
2807
+ /*console.log("Identify triggered");*/
2808
+
2805
2809
 
2806
2810
  return [2
2807
2811
  /*return*/
@@ -2813,6 +2817,7 @@
2813
2817
 
2814
2818
  this.reset = function () {
2815
2819
  _this.onIsInitialized(function () {
2820
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2816
2821
  // @ts-ignore
2817
2822
  _this.instance.plugins[PLUGIN_NAME].reset();
2818
2823
  });
@@ -2820,6 +2825,7 @@
2820
2825
 
2821
2826
  this.debug = function (enabled) {
2822
2827
  _this.onIsInitialized(function () {
2828
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2823
2829
  // @ts-ignore
2824
2830
  _this.instance.plugins[PLUGIN_NAME].debug(enabled);
2825
2831
  });
@@ -2839,10 +2845,14 @@
2839
2845
 
2840
2846
  this.onIsInitialized = function (onIsInitialized) {
2841
2847
  if (typeof onIsInitialized === 'function') {
2842
- var detachOnReadyListener_1 = _this.instance.ready(function () {
2848
+ if (_this.isInitialized) {
2843
2849
  onIsInitialized();
2844
- detachOnReadyListener_1();
2845
- });
2850
+ } else {
2851
+ var detachOnReadyListener_1 = _this.instance.on('ready', function () {
2852
+ onIsInitialized();
2853
+ detachOnReadyListener_1();
2854
+ });
2855
+ }
2846
2856
  }
2847
2857
  };
2848
2858
 
@@ -2891,8 +2901,10 @@
2891
2901
  preview: preview
2892
2902
  })], false)
2893
2903
  });
2894
- this.instance.ready(function () {
2904
+ var detachOnReadyListener = this.instance.on('ready', function () {
2905
+ _this.isInitialized = true;
2895
2906
  experience_jsShared.logger.info('Ninetailed Experience.js SDK is completely initialized.');
2907
+ detachOnReadyListener();
2896
2908
  }); // put in private method
2897
2909
 
2898
2910
  this.onProfileChange(function (profileState) {
@@ -1,5 +1,5 @@
1
1
  import { PageData, AnalyticsPlugin, DetachListeners } from 'analytics';
2
- import { Locale, Traits, Profile, Variant, Logger, OnLogHandler, OnErrorHandler } from '@ninetailed/experience.js-shared';
2
+ import { Locale, Traits, Profile, Variant, OnLogHandler, OnErrorHandler, Logger } from '@ninetailed/experience.js-shared';
3
3
  import { ProfileState } from './types';
4
4
  import { ExperienceConfiguration } from './experience';
5
5
  declare global {
@@ -67,6 +67,7 @@ export interface NinetailedInstance {
67
67
  export declare class Ninetailed implements NinetailedInstance {
68
68
  private readonly instance;
69
69
  private _profileState;
70
+ private isInitialized;
70
71
  readonly plugins: AnalyticsPlugin[];
71
72
  readonly logger: Logger;
72
73
  constructor({ clientId, environment, preview, }: {
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "3.0.1-beta.3",
3
+ "version": "3.0.1-beta.4",
4
4
  "main": "./index.umd.js",
5
5
  "module": "./index.esm.js",
6
6
  "typings": "./index.d.ts",
7
7
  "dependencies": {
8
- "@ninetailed/experience.js-shared": "3.0.1-beta.3",
8
+ "@ninetailed/experience.js-shared": "3.0.1-beta.4",
9
9
  "ts-toolbelt": "^9.6.0",
10
10
  "diary": "^0.3.1",
11
11
  "zod": "^3.18.0",