@miso.ai/client-sdk-ui 1.10.0-beta.9 → 1.10.1-beta.0

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 (51) hide show
  1. package/dist/cjs/actor/index.js +0 -7
  2. package/dist/cjs/actor/tracker.js +47 -102
  3. package/dist/cjs/actor/utils.js +1 -1
  4. package/dist/cjs/actor/view.js +12 -1
  5. package/dist/cjs/actor/views.js +24 -2
  6. package/dist/cjs/asset/svgs.js +14 -4
  7. package/dist/cjs/constants.js +3 -2
  8. package/dist/cjs/layout/affiliation/affiliation.js +152 -58
  9. package/dist/cjs/layout/input/option-list.js +34 -49
  10. package/dist/cjs/layout/list/collection.js +22 -43
  11. package/dist/cjs/layout/templates.js +54 -32
  12. package/dist/cjs/layout/text/typewriter/index.js +12 -7
  13. package/dist/cjs/layout/trackable.js +124 -0
  14. package/dist/cjs/util/bindings.js +58 -110
  15. package/dist/cjs/util/states.js +31 -24
  16. package/dist/cjs/util/trackers.js +75 -0
  17. package/dist/cjs/util/viewables.js +55 -0
  18. package/dist/cjs/version.js +1 -1
  19. package/dist/cjs/workflow/ask.js +1 -5
  20. package/dist/cjs/workflow/base.js +2 -7
  21. package/dist/cjs/workflow/recommendation.js +2 -0
  22. package/package.json +2 -2
  23. package/src/actor/index.js +0 -1
  24. package/src/actor/tracker.js +37 -94
  25. package/src/actor/utils.js +1 -1
  26. package/src/actor/view.js +14 -1
  27. package/src/actor/views.js +30 -1
  28. package/src/asset/svgs.js +13 -2
  29. package/src/constants.js +7 -1
  30. package/src/layout/affiliation/affiliation.js +140 -55
  31. package/src/layout/input/option-list.js +35 -43
  32. package/src/layout/list/collection.js +20 -38
  33. package/src/layout/templates.js +25 -19
  34. package/src/layout/text/typewriter/index.js +8 -6
  35. package/src/layout/trackable.js +106 -0
  36. package/src/util/bindings.js +47 -103
  37. package/src/util/states.js +26 -20
  38. package/src/util/trackers.js +69 -0
  39. package/src/util/viewables.js +47 -0
  40. package/src/version.js +1 -1
  41. package/src/workflow/ask.js +1 -4
  42. package/src/workflow/base.js +3 -5
  43. package/src/workflow/recommendation.js +1 -0
  44. package/dist/cjs/actor/trackers.js +0 -51
  45. package/dist/cjs/layout/affiliation/viewable.js +0 -65
  46. package/dist/cjs/layout/text/typewriter/progress.js +0 -45
  47. package/dist/cjs/util/tracker.js +0 -348
  48. package/src/actor/trackers.js +0 -45
  49. package/src/layout/affiliation/viewable.js +0 -61
  50. package/src/layout/text/typewriter/progress.js +0 -33
  51. package/src/util/tracker.js +0 -318
@@ -39,12 +39,6 @@ Object.defineProperty(exports, "SessionMaker", {
39
39
  return _sessions.default;
40
40
  }
41
41
  });
42
- Object.defineProperty(exports, "Trackers", {
43
- enumerable: true,
44
- get: function () {
45
- return _trackers.default;
46
- }
47
- });
48
42
  Object.defineProperty(exports, "ViewsActor", {
49
43
  enumerable: true,
50
44
  get: function () {
@@ -58,7 +52,6 @@ var _hub = _interopRequireDefault(require("./hub.js"));
58
52
  var _sessions = _interopRequireDefault(require("./sessions.js"));
59
53
  var _data = _interopRequireDefault(require("./data.js"));
60
54
  var _views = _interopRequireDefault(require("./views.js"));
61
- var _trackers = _interopRequireDefault(require("./trackers.js"));
62
55
  var _feedback = _interopRequireDefault(require("./feedback.js"));
63
56
  var _autocomplete = _interopRequireDefault(require("./autocomplete.js"));
64
57
  var _interactions = _interopRequireDefault(require("./interactions.js"));
@@ -4,100 +4,61 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ var _commons = require("@miso.ai/commons");
7
8
  var _constants = require("../constants.js");
8
9
  var fields = _interopRequireWildcard(require("./fields.js"));
9
- var _tracker = _interopRequireDefault(require("../util/tracker.js"));
10
- var _bindings = require("../util/bindings.js");
10
+ var _states = _interopRequireDefault(require("../util/states.js"));
11
11
  var _utils = require("./utils.js");
12
- const _excluded = ["active", "bindings"];
13
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.includes(n)) continue; t[n] = r[n]; } return t; }
17
- function isReady(viewState) {
18
- return viewState && viewState.status === _constants.STATUS.READY;
19
- }
20
15
  class Tracker {
21
- constructor(hub, view) {
22
- let _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
23
- let {
24
- active,
25
- bindings
26
- } = _ref,
27
- options = _objectWithoutPropertiesLoose(_ref, _excluded);
28
- this._hub = hub;
16
+ constructor(view) {
29
17
  this._view = view;
30
- this._bindings = bindings;
31
- const role = this._role = view.role;
18
+ this._role = view.role;
32
19
  // TODO: know item type
33
20
 
34
- this._tracker = new _tracker.default(Object.assign({
35
- bindings: {
36
- list: element => this._listBindingsFn()(element)
37
- },
38
- proxyElement: view.proxyElement,
39
- sessionId: () => this._getSessionId(),
40
- active: active || (() => this._isViewReady())
41
- }, options));
42
- this._unsubscribes = [this._tracker.on('*', data => this._handleEvent(data)),
43
- // TODO: view actor has another click event that does not comply to this data format
44
- ...[_constants.EVENT_TYPE.VIEWABLE].map(type => this._view.on(type, values => this._handleViewActorEvent(type, values))), hub.on(fields.view(role), () => this.refresh())];
45
- this.refresh();
46
- }
47
- config(options) {
48
- this._tracker.config(options);
49
- }
50
- start() {
51
- throw new Error(`workflow.tracker.start() is deprecated. Use workflow.startTracker() instead.`);
52
- }
53
- refresh() {
54
- this._tracker.refresh();
21
+ this._states = new _states.default(this._getSessionId());
55
22
  }
56
- impression(productIds, options) {
57
- this._assertViewReady();
58
- this._tracker.impression(productIds.map(product_id => ({
59
- product_id
60
- })), options);
23
+ get options() {
24
+ return this._view._getTrackerOptions();
61
25
  }
62
- viewable(productIds, options) {
63
- this._assertViewReady();
64
- this._tracker.viewable(productIds.map(product_id => ({
65
- product_id
66
- })), options);
26
+ getState(item) {
27
+ return this._states.getFullState(item);
67
28
  }
68
- click(productIds, options) {
69
- this._assertViewReady();
70
- this._tracker.click(productIds.map(product_id => ({
71
- product_id
72
- })), options);
73
- }
74
- _listBindingsFn() {
75
- if (this._bindings && typeof this._bindings.list === 'function') {
76
- return this._bindings.list;
77
- }
78
- const {
79
- layout
80
- } = this._view;
81
- if (layout && layout.bindings && typeof layout.bindings.list === 'function') {
82
- return layout.bindings.list;
29
+ _trigger(type, items) {
30
+ let meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
31
+ (0, _constants.validateEventType)(type);
32
+ this._syncSession();
33
+ items = this._states.untriggered((0, _commons.asArray)(items), type);
34
+ if (items.length === 0) {
35
+ return;
83
36
  }
84
- // TODO: only if item is product typed
85
- return (0, _bindings.fallbackListFunction)(_constants.ATTR_DATA_MISO_PRODUCT_ID);
86
- }
87
- _assertViewReady() {
88
- if (!this._hub.active) {
89
- throw new Error(`Workflow is not active. Call workflow.start() to activate it.`);
37
+ this._states.set(items, type, _constants.TRACKING_STATUS.TRIGGERED);
38
+ const property = this._role === 'results' ? 'products' : this._role; // TODO: ad-hoc, see #83
39
+ const misoId = this._getMisoId();
40
+ const request = this._getRequestPayload();
41
+
42
+ // TODO: should trigger 'tracker' and let workflow translate to interactions
43
+ this._view.hub.trigger(fields.interaction(), (0, _utils.toInteraction)({
44
+ property,
45
+ misoId,
46
+ request
47
+ }, {
48
+ event: type,
49
+ values: items,
50
+ meta
51
+ }));
52
+ }
53
+ _syncSession() {
54
+ const sessionId = this._getSessionId();
55
+ if (!sessionId) {
56
+ return;
90
57
  }
91
- if (!isReady(this._getViewState())) {
92
- throw new Error(`Workflow is not rendered yet. If you handle rendering by yourself, call workflow.notifyViewUpdate() when DOM is ready.`);
58
+ if (!this._states || sessionId !== this._states.sessionId) {
59
+ this._states = new _states.default(sessionId);
93
60
  }
94
61
  }
95
- _getViewState() {
96
- return this._hub.states[fields.view(this._role)];
97
- }
98
- _isViewReady() {
99
- return this._hub.active && isReady(this._getViewState());
100
- }
101
62
  _getSessionId() {
102
63
  const {
103
64
  session
@@ -106,7 +67,7 @@ class Tracker {
106
67
  }
107
68
  _getMisoId() {
108
69
  const state = this._getViewState();
109
- return state && state.meta && state.meta.miso_id || this._element && this._element.getAttribute('miso-id') || undefined;
70
+ return state && state.meta && state.meta.miso_id || undefined;
110
71
  }
111
72
  _getRequestPayload() {
112
73
  const {
@@ -114,29 +75,13 @@ class Tracker {
114
75
  } = this._getViewState() || {};
115
76
  return request && request.payload;
116
77
  }
117
- getState(productId) {
118
- return this._tracker.getState(productId);
119
- }
120
- _handleViewActorEvent(type, values) {
121
- this._tracker._trigger(type, values);
122
- }
123
- _handleEvent(data) {
124
- const property = this._role === 'results' ? 'products' : this._role; // TODO: ad-hoc, see #83
125
- const misoId = this._getMisoId();
126
- const request = this._getRequestPayload();
127
- // TODO: should trigger 'tracker' and let workflow translate to interactions
128
- this._hub.trigger(fields.interaction(), (0, _utils.toInteraction)({
129
- property,
130
- misoId,
131
- request
132
- }, data));
133
- }
134
- _destroy() {
135
- for (const unsubscribe of this._unsubscribes) {
136
- unsubscribe();
137
- }
138
- this._unsubscribes = [];
139
- this._tracker.destroy();
78
+ _getViewState() {
79
+ return this._view.hub.states[fields.view(this._role)];
140
80
  }
141
81
  }
142
- exports.default = Tracker;
82
+ exports.default = Tracker;
83
+ for (const type of _constants.TRACKING_EVENT_TYPES) {
84
+ Tracker.prototype[type] = function (items, meta) {
85
+ this._trigger(type, items, meta);
86
+ };
87
+ }
@@ -34,7 +34,7 @@ function toInteraction(_ref, _ref2) {
34
34
  // TODO: ad-hoc
35
35
  const question_source = request && request._meta && request._meta.question_source;
36
36
  const isProductType = isProduct(property);
37
- const product_ids = isProductType ? values.map(v => v.product_id).filter(v => v) : [];
37
+ const product_ids = isProductType ? values.map(v => typeof v === 'string' ? v : v.product_id).filter(v => v) : [];
38
38
  const items = isProductType ? undefined : values.map(v => v.text || v.id || v);
39
39
  const channel = property === _constants.ROLE.AFFILIATION ? values[0] && values[0].channel : undefined;
40
40
  const positions = property === _constants.ROLE.AFFILIATION ? values.map(v => v.position) : undefined;
@@ -8,6 +8,7 @@ var _commons = require("@miso.ai/commons");
8
8
  var _constants = require("../constants.js");
9
9
  var fields = _interopRequireWildcard(require("./fields.js"));
10
10
  var _proxy = _interopRequireDefault(require("../util/proxy.js"));
11
+ var _tracker = _interopRequireDefault(require("./tracker.js"));
11
12
  const _excluded = ["value", "error", "status", "meta"];
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -88,6 +89,12 @@ class ViewActor {
88
89
  force: true
89
90
  });
90
91
  }
92
+ get tracker() {
93
+ if (!this._tracker) {
94
+ this._tracker = new _tracker.default(this);
95
+ }
96
+ return this._tracker;
97
+ }
91
98
  async refresh() {
92
99
  var _this = this;
93
100
  let {
@@ -182,6 +189,10 @@ class ViewActor {
182
189
  silent
183
190
  });
184
191
  }
192
+ _getTrackerOptions() {
193
+ // used by tracker to expose tracker options to layout
194
+ return this._views._getTrackerOptions(this.role);
195
+ }
185
196
  _sliceData(_ref2) {
186
197
  let {
187
198
  value,
@@ -258,6 +269,6 @@ class ViewActor {
258
269
  exports.default = ViewActor;
259
270
  class View {
260
271
  constructor(actor) {
261
- (0, _commons.delegateGetters)(this, actor, ['role', 'layout', 'element', 'proxyElement', 'refresh', 'on']);
272
+ (0, _commons.delegateGetters)(this, actor, ['role', 'layout', 'element', 'proxyElement', 'refresh', 'on', 'tracker']);
262
273
  }
263
274
  }
@@ -8,6 +8,7 @@ var _commons = require("@miso.ai/commons");
8
8
  var _constants = require("../constants.js");
9
9
  var fields = _interopRequireWildcard(require("./fields.js"));
10
10
  var _view = _interopRequireDefault(require("./view.js"));
11
+ var _trackers = require("../util/trackers.js");
11
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
14
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
@@ -27,6 +28,7 @@ class ViewsActor {
27
28
  this._options = options;
28
29
  this._containers = new Map();
29
30
  this._views = {};
31
+ this._trackers = new Trackers(this, roles);
30
32
  for (const role of roles) {
31
33
  this._views[role] = new _view.default(this, role);
32
34
  }
@@ -35,9 +37,13 @@ class ViewsActor {
35
37
  });
36
38
  const syncSize = () => this.syncSize();
37
39
  window.addEventListener('resize', syncSize);
38
- this._unsubscribes = [() => window.removeEventListener('resize', syncSize), hub.on(fields.data(), () => this.refresh()), options.on('layouts', () => this._syncLayouts())];
40
+ this._unsubscribes = [() => window.removeEventListener('resize', syncSize), hub.on(fields.data(), () => this.refresh()), options.on('trackers', () => this._syncTrackers()), options.on('layouts', () => this._syncLayouts())];
41
+ this._syncTrackers();
39
42
  this._syncLayouts();
40
43
  }
44
+ get trackers() {
45
+ return this._trackers;
46
+ }
41
47
 
42
48
  // elements //
43
49
  addContainer(element) {
@@ -190,6 +196,12 @@ class ViewsActor {
190
196
  }
191
197
  return this._data;
192
198
  }
199
+ _syncTrackers() {
200
+ this._trackerOptions = this._options.resolved.trackers;
201
+ }
202
+ _getTrackerOptions(role) {
203
+ return (0, _trackers.normalizeTrackerOptions)(this._trackerOptions && this._trackerOptions[role] || false);
204
+ }
193
205
  _error(e) {
194
206
  // TODO: hub trigger error event
195
207
  console.error(e);
@@ -213,7 +225,7 @@ exports.default = ViewsActor;
213
225
  class Views {
214
226
  constructor(actor) {
215
227
  this._actor = actor;
216
- (0, _commons.delegateGetters)(this, actor, ['syncSize', 'refresh']);
228
+ (0, _commons.delegateGetters)(this, actor, ['syncSize', 'refresh', 'trackers']);
217
229
  }
218
230
  get(role) {
219
231
  return this._actor.get(role).interface;
@@ -221,4 +233,14 @@ class Views {
221
233
  get all() {
222
234
  return this._actor.views.map(view => view.interface);
223
235
  }
236
+ }
237
+ class Trackers {
238
+ constructor(views, roles) {
239
+ this._views = views;
240
+ for (const role of roles) {
241
+ Object.defineProperty(this, role, {
242
+ get: () => views.get(role).tracker
243
+ });
244
+ }
245
+ }
224
246
  }
@@ -3,16 +3,25 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.SEND = exports.SEARCH = void 0;
6
+ exports.TRIANGLE = exports.SEND = exports.SEARCH = void 0;
7
7
  var _version = _interopRequireDefault(require("../version.js"));
8
8
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function trianglePath(r) {
10
+ const l = 100;
11
+ const d = r * Math.tan(3 * Math.PI / 8);
12
+ const e = d * Math.sin(Math.PI / 4);
13
+ return `M${r} 0L${l - d} 0A${r} ${r} 0 0 1 ${l - e} ${e}L${e} ${l - e}A${r} ${r} 0 0 1 0 ${l - d}L0 ${r}Z`;
14
+ }
9
15
  const PREFIX = 'miso-ui-icon';
10
16
  const ID = `${PREFIX}-svg-${_version.default.replaceAll('.', '_')}`;
11
17
 
12
- // all are CC0 SVGs
18
+ // CC0 SVGs
13
19
  const ICON_SEND = `<symbol id="${PREFIX}-send" viewBox="0 0 32 32"><path fill="currentColor" d="M11.499,19.173l5.801,-5.849c0.389,-0.392 1.022,-0.394 1.414,-0.006c0.392,0.389 0.395,1.022 0.006,1.414l-5.798,5.847l5.306,8.002c0.207,0.313 0.572,0.483 0.945,0.441c0.373,-0.042 0.691,-0.289 0.824,-0.64l9.024,-23.904c0.138,-0.366 0.05,-0.78 -0.226,-1.058c-0.276,-0.278 -0.689,-0.369 -1.057,-0.233l-24.004,8.892c-0.353,0.13 -0.602,0.448 -0.646,0.821c-0.044,0.373 0.125,0.74 0.438,0.948l7.973,5.325Z"/></symbol>`;
14
20
  const ICON_SEARCH = `<symbol id="${PREFIX}-search" viewBox="0 0 24 24"><path fill="currentColor" d="M4 11C4 7.13401 7.13401 4 11 4C14.866 4 18 7.13401 18 11C18 14.866 14.866 18 11 18C7.13401 18 4 14.866 4 11ZM11 2C6.02944 2 2 6.02944 2 11C2 15.9706 6.02944 20 11 20C13.125 20 15.078 19.2635 16.6177 18.0319L20.2929 21.7071C20.6834 22.0976 21.3166 22.0976 21.7071 21.7071C22.0976 21.3166 22.0976 20.6834 21.7071 20.2929L18.0319 16.6177C19.2635 15.078 20 13.125 20 11C20 6.02944 15.9706 2 11 2Z"/></symbol>`;
15
- const ICONS = [ICON_SEND, ICON_SEARCH];
21
+
22
+ // Custom SVGs
23
+ const ICON_TRIANGLE = `<symbol id="${PREFIX}-triangle" viewBox="-5 -5 105 105"><path d="${trianglePath(5)}"/></symbol>`;
24
+ const ICONS = [ICON_SEND, ICON_SEARCH, ICON_TRIANGLE];
16
25
  const SPRITES_SVG = `<svg id="${ID}" style="display:none;">${ICONS.join('')}</svg>`;
17
26
  let loaded = false;
18
27
  function loadSvgSprites() {
@@ -27,4 +36,5 @@ function getSvg(name) {
27
36
  return `<svg class="miso-ui-icon miso-ui-icon-${name}"><use href="#${PREFIX}-${name}"></use></svg>`;
28
37
  }
29
38
  const SEND = exports.SEND = getSvg('send');
30
- const SEARCH = exports.SEARCH = getSvg('search');
39
+ const SEARCH = exports.SEARCH = getSvg('search');
40
+ const TRIANGLE = exports.TRIANGLE = getSvg('triangle');
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.TRACKING_STATUS = exports.STATUS = exports.ROLE = exports.ORGANIC_QUESTION_SOURCE = exports.LAYOUT_CATEGORY = exports.EVENT_TYPE = exports.DEFAULT_UNIT_ID = exports.ATTR_DATA_MISO_UNIT_ID = exports.ATTR_DATA_MISO_PRODUCT_ID = void 0;
6
+ exports.TRACKING_STATUS = exports.TRACKING_EVENT_TYPES = exports.STATUS = exports.ROLE = exports.ORGANIC_QUESTION_SOURCE = exports.LAYOUT_CATEGORY = exports.EVENT_TYPE = exports.DEFAULT_UNIT_ID = exports.ATTR_DATA_MISO_UNIT_ID = exports.ATTR_DATA_MISO_PRODUCT_ID = void 0;
7
7
  exports.isDataRole = isDataRole;
8
8
  exports.validateEventType = validateEventType;
9
9
  exports.validateTrackingStatus = validateTrackingStatus;
@@ -49,6 +49,7 @@ const EVENT_TYPE = exports.EVENT_TYPE = Object.freeze({
49
49
  VIEWABLE: 'viewable',
50
50
  CLICK: 'click'
51
51
  });
52
+ const TRACKING_EVENT_TYPES = exports.TRACKING_EVENT_TYPES = [EVENT_TYPE.IMPRESSION, EVENT_TYPE.VIEWABLE, EVENT_TYPE.CLICK];
52
53
  const TRACKING_STATUS = exports.TRACKING_STATUS = Object.freeze({
53
54
  UNTRACKED: 'untracked',
54
55
  TRACKING: 'tracking',
@@ -65,7 +66,7 @@ const STATUS = exports.STATUS = Object.freeze({
65
66
  NONEMPTY: 'nonempty'
66
67
  });
67
68
  function validateEventType(value) {
68
- if (value !== EVENT_TYPE.IMPRESSION && value !== EVENT_TYPE.VIEWABLE && value !== EVENT_TYPE.CLICK) {
69
+ if (TRACKING_EVENT_TYPES.indexOf(value) < 0) {
69
70
  throw new Error(`Unrecognized event type: ${value}`);
70
71
  }
71
72
  }