@ninetailed/experience.js 7.7.1-beta.0 → 7.7.2-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.cjs.js CHANGED
@@ -101,10 +101,10 @@ const EXPERIENCES_FALLBACK_CACHE = '__nt_experiences__';
101
101
  const PROFILE_CHANGE = 'profile-change';
102
102
  const PROFILE_RESET = 'profile-reset';
103
103
  const CONSENT = '__nt-consent__';
104
- const SET_ENABLED_FEATURES = 'set-enabled-features';
104
+ const SET_ENABLED_FEATURES = 'setEnabledFeatures';
105
105
  const EMPTY_MERGE_ID = 'nt:empty-merge-id';
106
106
 
107
- var _a;
107
+ var _a, _b;
108
108
  const PLUGIN_NAME = 'ninetailed:core';
109
109
  const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
110
110
  class NinetailedCorePlugin extends experience_jsPluginAnalytics.NinetailedAnalyticsPlugin {
@@ -120,10 +120,15 @@ class NinetailedCorePlugin extends experience_jsPluginAnalytics.NinetailedAnalyt
120
120
  this.queue = [];
121
121
  this.enabledFeatures = Object.values(experience_jsShared.FEATURES);
122
122
  this.buildContext = buildClientNinetailedRequestContext;
123
+ this[_a] = ({
124
+ payload
125
+ }) => __awaiter(this, void 0, void 0, function* () {
126
+ this.enabledFeatures = payload.features || [];
127
+ });
123
128
  this.getComponentViewTrackingThreshold = () => {
124
129
  return 0;
125
130
  };
126
- this[_a] = ({
131
+ this[_b] = ({
127
132
  payload
128
133
  }) => __awaiter(this, void 0, void 0, function* () {
129
134
  const ctx = this.buildContext();
@@ -205,11 +210,6 @@ class NinetailedCorePlugin extends experience_jsPluginAnalytics.NinetailedAnalyt
205
210
  instance.storage.setItem(ANONYMOUS_ID, profileId);
206
211
  }
207
212
  }
208
- instance.on(SET_ENABLED_FEATURES, ({
209
- payload
210
- }) => {
211
- this.enabledFeatures = payload.features || [];
212
- });
213
213
  experience_jsShared.logger.debug('Ninetailed Core plugin initialized.');
214
214
  });
215
215
  }
@@ -379,7 +379,7 @@ class NinetailedCorePlugin extends experience_jsPluginAnalytics.NinetailedAnalyt
379
379
  });
380
380
  }
381
381
  }
382
- _a = HAS_SEEN_STICKY_COMPONENT;
382
+ _a = SET_ENABLED_FEATURES, _b = HAS_SEEN_STICKY_COMPONENT;
383
383
 
384
384
  class ElementSeenObserver {
385
385
  constructor(_options) {
@@ -1026,6 +1026,13 @@ class Ninetailed {
1026
1026
  }
1027
1027
  });
1028
1028
  };
1029
+ if (typeof onLog === 'function') {
1030
+ experience_jsShared.logger.addSink(new experience_jsShared.OnLogLogSink(onLog));
1031
+ }
1032
+ if (typeof onError === 'function') {
1033
+ experience_jsShared.logger.addSink(new experience_jsShared.OnErrorLogSink(onError));
1034
+ }
1035
+ this.logger = experience_jsShared.logger;
1029
1036
  this.useSDKEvaluation = useSDKEvaluation;
1030
1037
  if (ninetailedApiClientInstanceOrOptions instanceof experience_jsShared.NinetailedApiClient) {
1031
1038
  this.apiClient = ninetailedApiClientInstanceOrOptions;
@@ -1063,14 +1070,7 @@ class Ninetailed {
1063
1070
  error: null,
1064
1071
  from: 'api'
1065
1072
  };
1066
- if (typeof onLog === 'function') {
1067
- experience_jsShared.logger.addSink(new experience_jsShared.OnLogLogSink(onLog));
1068
- }
1069
- if (typeof onError === 'function') {
1070
- experience_jsShared.logger.addSink(new experience_jsShared.OnErrorLogSink(onError));
1071
- }
1072
1073
  this.eventBuilder = new EventBuilder(buildClientContext);
1073
- this.logger = experience_jsShared.logger;
1074
1074
  this.ninetailedCorePlugin = new NinetailedCorePlugin({
1075
1075
  apiClient: this.apiClient,
1076
1076
  locale,
package/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { FEATURES, buildComponentViewEvent, logger, ConsoleLogSink, buildPageEvent, buildTrackEvent, buildIdentifyEvent, unionBy, pipe, PageviewProperties, Properties, Traits, isPageViewEvent, isTrackEvent, isIdentifyEvent, isComponentViewEvent, selectHasVariants, selectExperience, selectVariant as selectVariant$1, selectBaselineWithVariants, NinetailedApiClient, OnLogLogSink, OnErrorLogSink } from '@ninetailed/experience.js-shared';
1
+ import { FEATURES, buildComponentViewEvent, logger, ConsoleLogSink, buildPageEvent, buildTrackEvent, buildIdentifyEvent, unionBy, pipe, PageviewProperties, Properties, Traits, isPageViewEvent, isTrackEvent, isIdentifyEvent, isComponentViewEvent, selectHasVariants, selectExperience, selectVariant as selectVariant$1, selectBaselineWithVariants, OnLogLogSink, OnErrorLogSink, NinetailedApiClient } from '@ninetailed/experience.js-shared';
2
2
  export { EXPERIENCE_TRAIT_PREFIX, isExperienceMatch, selectActiveExperiments, selectDistribution, selectExperience, selectBaselineWithVariants as selectExperienceBaselineWithVariants, selectVariant as selectExperienceVariant, selectVariants as selectExperienceVariants, selectHasVariants as selectHasExperienceVariants } from '@ninetailed/experience.js-shared';
3
3
  import { NinetailedAnalyticsPlugin, HAS_SEEN_COMPONENT, HAS_SEEN_ELEMENT, hasComponentViewTrackingThreshold } from '@ninetailed/experience.js-plugin-analytics';
4
4
  import Analytics from 'analytics';
@@ -57,7 +57,7 @@ const EXPERIENCES_FALLBACK_CACHE = '__nt_experiences__';
57
57
  const PROFILE_CHANGE = 'profile-change';
58
58
  const PROFILE_RESET = 'profile-reset';
59
59
  const CONSENT = '__nt-consent__';
60
- const SET_ENABLED_FEATURES = 'set-enabled-features';
60
+ const SET_ENABLED_FEATURES = 'setEnabledFeatures';
61
61
  const EMPTY_MERGE_ID = 'nt:empty-merge-id';
62
62
 
63
63
  const PLUGIN_NAME = 'ninetailed:core';
@@ -82,6 +82,11 @@ class NinetailedCorePlugin extends NinetailedAnalyticsPlugin {
82
82
  this.apiClient = void 0;
83
83
  this.locale = void 0;
84
84
  this.ninetailed = void 0;
85
+ this[SET_ENABLED_FEATURES] = async function ({
86
+ payload
87
+ }) {
88
+ _this.enabledFeatures = payload.features || [];
89
+ };
85
90
  this.getComponentViewTrackingThreshold = () => {
86
91
  return 0;
87
92
  };
@@ -167,11 +172,6 @@ class NinetailedCorePlugin extends NinetailedAnalyticsPlugin {
167
172
  instance.storage.setItem(ANONYMOUS_ID, profileId);
168
173
  }
169
174
  }
170
- instance.on(SET_ENABLED_FEATURES, ({
171
- payload
172
- }) => {
173
- this.enabledFeatures = payload.features || [];
174
- });
175
175
  logger.debug('Ninetailed Core plugin initialized.');
176
176
  }
177
177
  pageStart(params) {
@@ -1008,6 +1008,13 @@ class Ninetailed {
1008
1008
  }
1009
1009
  });
1010
1010
  };
1011
+ if (typeof onLog === 'function') {
1012
+ logger.addSink(new OnLogLogSink(onLog));
1013
+ }
1014
+ if (typeof onError === 'function') {
1015
+ logger.addSink(new OnErrorLogSink(onError));
1016
+ }
1017
+ this.logger = logger;
1011
1018
  this.useSDKEvaluation = useSDKEvaluation;
1012
1019
  if (ninetailedApiClientInstanceOrOptions instanceof NinetailedApiClient) {
1013
1020
  this.apiClient = ninetailedApiClientInstanceOrOptions;
@@ -1045,14 +1052,7 @@ class Ninetailed {
1045
1052
  error: null,
1046
1053
  from: 'api'
1047
1054
  };
1048
- if (typeof onLog === 'function') {
1049
- logger.addSink(new OnLogLogSink(onLog));
1050
- }
1051
- if (typeof onError === 'function') {
1052
- logger.addSink(new OnErrorLogSink(onError));
1053
- }
1054
1055
  this.eventBuilder = new EventBuilder(buildClientContext);
1055
- this.logger = logger;
1056
1056
  this.ninetailedCorePlugin = new NinetailedCorePlugin({
1057
1057
  apiClient: this.apiClient,
1058
1058
  locale,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "7.7.1-beta.0",
3
+ "version": "7.7.2-beta.1",
4
4
  "description": "Ninetailed SDK for javascript",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -9,8 +9,8 @@
9
9
  "directory": "packages/sdks/javascript"
10
10
  },
11
11
  "dependencies": {
12
- "@ninetailed/experience.js-plugin-analytics": "7.7.1-beta.0",
13
- "@ninetailed/experience.js-shared": "7.7.1-beta.0",
12
+ "@ninetailed/experience.js-plugin-analytics": "7.7.2-beta.1",
13
+ "@ninetailed/experience.js-shared": "7.7.2-beta.1",
14
14
  "analytics": "0.8.1",
15
15
  "uuid": "9.0.0"
16
16
  },
@@ -1,6 +1,7 @@
1
1
  import { AnalyticsInstance } from 'analytics';
2
2
  import { Locale, NinetailedApiClient, NinetailedRequestContext } from '@ninetailed/experience.js-shared';
3
3
  import { NinetailedAnalyticsPlugin, SanitizedElementSeenPayload } from '@ninetailed/experience.js-plugin-analytics';
4
+ import { SET_ENABLED_FEATURES } from './constants';
4
5
  import { NinetailedInstance, FlushResult } from '../types';
5
6
  import { HAS_SEEN_STICKY_COMPONENT } from '../constants';
6
7
  export type OnInitProfileId = (profileId?: string) => Promise<string | undefined> | string | undefined;
@@ -41,6 +42,7 @@ export declare class NinetailedCorePlugin extends NinetailedAnalyticsPlugin impl
41
42
  initialize({ instance, }: {
42
43
  instance: InternalAnalyticsInstance;
43
44
  }): Promise<void>;
45
+ [SET_ENABLED_FEATURES]: ({ payload }: EventFn) => Promise<void>;
44
46
  pageStart(params: AbortableFnParams): unknown;
45
47
  page({ payload }: EventFn): Promise<void>;
46
48
  trackStart(params: AbortableFnParams): unknown;
@@ -6,5 +6,5 @@ export declare const EXPERIENCES_FALLBACK_CACHE = "__nt_experiences__";
6
6
  export declare const PROFILE_CHANGE = "profile-change";
7
7
  export declare const PROFILE_RESET = "profile-reset";
8
8
  export declare const CONSENT = "__nt-consent__";
9
- export declare const SET_ENABLED_FEATURES = "set-enabled-features";
9
+ export declare const SET_ENABLED_FEATURES = "setEnabledFeatures";
10
10
  export declare const EMPTY_MERGE_ID = "nt:empty-merge-id";