@ninetailed/experience.js 7.7.3 → 7.8.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.cjs.js CHANGED
@@ -595,6 +595,10 @@ class EventBuilder {
595
595
  }
596
596
  }
597
597
 
598
+ const requiresEventBuilder = plugin => {
599
+ return typeof plugin === 'object' && plugin !== null && 'setEventBuilder' in plugin && typeof plugin.setEventBuilder === 'function';
600
+ };
601
+
598
602
  const buildOverrideMiddleware = experienceSelectionMiddleware => _a => {
599
603
  var {
600
604
  experience: originalExperience,
@@ -1052,6 +1056,7 @@ class Ninetailed {
1052
1056
  });
1053
1057
  }
1054
1058
  this.plugins = (plugins !== null && plugins !== void 0 ? plugins : []).flat();
1059
+ this.eventBuilder = new EventBuilder(buildClientContext);
1055
1060
  this.plugins.forEach(plugin => {
1056
1061
  if (acceptsCredentials(plugin) && this.clientId && this.environment) {
1057
1062
  plugin.setCredentials({
@@ -1062,6 +1067,9 @@ class Ninetailed {
1062
1067
  if (experience_jsPluginAnalytics.hasComponentViewTrackingThreshold(plugin)) {
1063
1068
  plugin.setComponentViewTrackingThreshold(componentViewTrackingThreshold);
1064
1069
  }
1070
+ if (requiresEventBuilder(plugin)) {
1071
+ plugin.setEventBuilder(this.eventBuilder);
1072
+ }
1065
1073
  });
1066
1074
  this._profileState = {
1067
1075
  status: 'loading',
@@ -1070,7 +1078,6 @@ class Ninetailed {
1070
1078
  error: null,
1071
1079
  from: 'api'
1072
1080
  };
1073
- this.eventBuilder = new EventBuilder(buildClientContext);
1074
1081
  this.ninetailedCorePlugin = new NinetailedCorePlugin({
1075
1082
  apiClient: this.apiClient,
1076
1083
  locale,
@@ -1265,6 +1272,7 @@ exports.CONSENT = CONSENT;
1265
1272
  exports.DEBUG_FLAG = DEBUG_FLAG;
1266
1273
  exports.EMPTY_MERGE_ID = EMPTY_MERGE_ID;
1267
1274
  exports.EXPERIENCES_FALLBACK_CACHE = EXPERIENCES_FALLBACK_CACHE;
1275
+ exports.EventBuilder = EventBuilder;
1268
1276
  exports.HAS_SEEN_STICKY_COMPONENT = HAS_SEEN_STICKY_COMPONENT;
1269
1277
  exports.LEGACY_ANONYMOUS_ID = LEGACY_ANONYMOUS_ID;
1270
1278
  exports.Ninetailed = Ninetailed;
package/index.esm.js CHANGED
@@ -560,6 +560,10 @@ class EventBuilder {
560
560
  }
561
561
  }
562
562
 
563
+ const requiresEventBuilder = plugin => {
564
+ return typeof plugin === 'object' && plugin !== null && 'setEventBuilder' in plugin && typeof plugin.setEventBuilder === 'function';
565
+ };
566
+
563
567
  const _excluded = ["experience", "variant", "variantIndex"],
564
568
  _excluded2 = ["element"];
565
569
  const buildOverrideMiddleware = experienceSelectionMiddleware => _ref => {
@@ -1034,6 +1038,7 @@ class Ninetailed {
1034
1038
  });
1035
1039
  }
1036
1040
  this.plugins = (plugins != null ? plugins : []).flat();
1041
+ this.eventBuilder = new EventBuilder(buildClientContext);
1037
1042
  this.plugins.forEach(plugin => {
1038
1043
  if (acceptsCredentials(plugin) && this.clientId && this.environment) {
1039
1044
  plugin.setCredentials({
@@ -1044,6 +1049,9 @@ class Ninetailed {
1044
1049
  if (hasComponentViewTrackingThreshold(plugin)) {
1045
1050
  plugin.setComponentViewTrackingThreshold(componentViewTrackingThreshold);
1046
1051
  }
1052
+ if (requiresEventBuilder(plugin)) {
1053
+ plugin.setEventBuilder(this.eventBuilder);
1054
+ }
1047
1055
  });
1048
1056
  this._profileState = {
1049
1057
  status: 'loading',
@@ -1052,7 +1060,6 @@ class Ninetailed {
1052
1060
  error: null,
1053
1061
  from: 'api'
1054
1062
  };
1055
- this.eventBuilder = new EventBuilder(buildClientContext);
1056
1063
  this.ninetailedCorePlugin = new NinetailedCorePlugin({
1057
1064
  apiClient: this.apiClient,
1058
1065
  locale,
@@ -1206,4 +1213,4 @@ const selectVariant = (baseline, variants, {
1206
1213
  };
1207
1214
  };
1208
1215
 
1209
- export { ANONYMOUS_ID, COMPONENT, COMPONENT_START, CONSENT, DEBUG_FLAG, EMPTY_MERGE_ID, EXPERIENCES_FALLBACK_CACHE, HAS_SEEN_STICKY_COMPONENT, LEGACY_ANONYMOUS_ID, Ninetailed, NinetailedCorePlugin, OnChangeEmitter, PAGE_HIDDEN, PLUGIN_NAME, PROFILE_CHANGE, PROFILE_FALLBACK_CACHE, PROFILE_RESET, SET_ENABLED_FEATURES, buildClientNinetailedRequestContext, decodeExperienceVariantsMap, makeExperienceSelectMiddleware, selectPluginsHavingExperienceSelectionMiddleware, selectPluginsHavingOnChangeEmitter, selectVariant };
1216
+ export { ANONYMOUS_ID, COMPONENT, COMPONENT_START, CONSENT, DEBUG_FLAG, EMPTY_MERGE_ID, EXPERIENCES_FALLBACK_CACHE, EventBuilder, HAS_SEEN_STICKY_COMPONENT, LEGACY_ANONYMOUS_ID, Ninetailed, NinetailedCorePlugin, OnChangeEmitter, PAGE_HIDDEN, PLUGIN_NAME, PROFILE_CHANGE, PROFILE_FALLBACK_CACHE, PROFILE_RESET, SET_ENABLED_FEATURES, buildClientNinetailedRequestContext, decodeExperienceVariantsMap, makeExperienceSelectMiddleware, selectPluginsHavingExperienceSelectionMiddleware, selectPluginsHavingOnChangeEmitter, selectVariant };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "7.7.3",
3
+ "version": "7.8.0-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.3",
13
- "@ninetailed/experience.js-shared": "7.7.3",
12
+ "@ninetailed/experience.js-plugin-analytics": "7.8.0-beta.1",
13
+ "@ninetailed/experience.js-shared": "7.8.0-beta.1",
14
14
  "analytics": "0.8.1",
15
15
  "uuid": "9.0.0"
16
16
  },
package/src/index.d.ts CHANGED
@@ -6,10 +6,12 @@ export * from './lib/types';
6
6
  export * from './lib/experience';
7
7
  export * from './lib/plugins/selectPluginsHavingExperienceSelectionMiddleware';
8
8
  export * from './lib/plugins/selectPluginsHavingOnChangeEmitter';
9
+ export * from './lib/types/interfaces/RequiresEventBuilder';
9
10
  export * from './lib/types/interfaces/HasExperienceSelectionMiddleware';
10
11
  export * from './lib/types/interfaces/InterestedInSeenElements';
11
12
  export * from './lib/types/interfaces/InterestedInProfileChange';
12
13
  export * from './lib/types/interfaces/InterestedInHiddenPage';
13
14
  export * from './lib/types/interfaces/AcceptsCredentials';
14
15
  export * from './lib/utils/OnChangeEmitter';
16
+ export * from './lib/utils/EventBuilder';
15
17
  export type { Profile } from '@ninetailed/experience.js-shared';
@@ -0,0 +1,2 @@
1
+ import { RequiresEventBuilder } from '../types/interfaces/RequiresEventBuilder';
2
+ export declare const requiresEventBuilder: (plugin: unknown) => plugin is RequiresEventBuilder;
@@ -0,0 +1,4 @@
1
+ import { EventBuilder } from '../../utils/EventBuilder';
2
+ export interface RequiresEventBuilder {
3
+ setEventBuilder(eventBuilder: EventBuilder): void;
4
+ }