@miso.ai/client-sdk-ui 1.13.0-beta.5 → 1.13.0-beta.6

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.
@@ -59,21 +59,6 @@ class Tracker {
59
59
  items: itemless ? undefined : items
60
60
  }, meta));
61
61
  }
62
- submit({
63
- value
64
- }) {
65
- this._syncSession();
66
- this._sendToHub({
67
- type: _constants.EVENT_TYPE.SUBMIT,
68
- value
69
- });
70
- }
71
- heartbeat() {
72
- this._syncSession();
73
- this._sendToHub({
74
- type: _constants.EVENT_TYPE.HEARTBEAT
75
- });
76
- }
77
62
  _sendToHub(args) {
78
63
  this._hub.trigger(fields.tracker(), Object.freeze((0, _commons.trimObj)(Object.assign({
79
64
  role: this._role
@@ -110,7 +95,15 @@ class Tracker {
110
95
  }
111
96
  exports.default = Tracker;
112
97
  for (const type of _constants.PERFORMANCE_EVENT_TYPES) {
113
- Tracker.prototype[type] = function (items, meta) {
98
+ Tracker.prototype[(0, _commons.snakeToLowerCamel)(type)] = function (items, meta) {
114
99
  this._trigger(type, items, meta);
115
100
  };
101
+ }
102
+ for (const type of _constants.DIRECT_TRACKING_EVENT_TYPES) {
103
+ Tracker.prototype[(0, _commons.snakeToLowerCamel)(type)] = function (args) {
104
+ this._syncSession();
105
+ this._sendToHub(Object.assign({}, args, {
106
+ type
107
+ }));
108
+ };
116
109
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WORKFLOW_CONFIGURABLE = exports.TRACKING_STATUS = exports.TRACKING_EVENT_TYPES = exports.STATUS = exports.ROLE = exports.REQUEST_TYPE = exports.QUESTION_SOURCE = exports.PERFORMANCE_EVENT_TYPES = exports.EVENT_TYPE = exports.DEFAULT_UNIT_ID = exports.ATTR_DATA_MISO_UNIT_ID = exports.ATTR_DATA_MISO_PRODUCT_ID = void 0;
6
+ exports.WORKFLOW_CONFIGURABLE = exports.TRACKING_STATUS = exports.TRACKING_EVENT_TYPES = exports.STATUS = exports.ROLE = exports.REQUEST_TYPE = exports.QUESTION_SOURCE = exports.PERFORMANCE_EVENT_TYPES = exports.EVENT_TYPE = exports.DIRECT_TRACKING_EVENT_TYPES = 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.isPerformanceEventType = isPerformanceEventType;
9
9
  exports.isProductRole = isProductRole;
@@ -53,10 +53,12 @@ const EVENT_TYPE = exports.EVENT_TYPE = Object.freeze({
53
53
  CLICK: 'click',
54
54
  SUBMIT: 'submit',
55
55
  FEEDBACK: 'feedback',
56
- HEARTBEAT: 'heartbeat'
56
+ HEARTBEAT: 'heartbeat',
57
+ GENERIC_CLICK: 'generic_click'
57
58
  });
58
59
  const TRACKING_EVENT_TYPES = exports.TRACKING_EVENT_TYPES = [EVENT_TYPE.IMPRESSION, EVENT_TYPE.VIEWABLE, EVENT_TYPE.CLICK, EVENT_TYPE.SUBMIT, EVENT_TYPE.FEEDBACK, EVENT_TYPE.HEARTBEAT];
59
60
  const PERFORMANCE_EVENT_TYPES = exports.PERFORMANCE_EVENT_TYPES = [EVENT_TYPE.IMPRESSION, EVENT_TYPE.VIEWABLE, EVENT_TYPE.CLICK];
61
+ const DIRECT_TRACKING_EVENT_TYPES = exports.DIRECT_TRACKING_EVENT_TYPES = [EVENT_TYPE.SUBMIT, EVENT_TYPE.HEARTBEAT, EVENT_TYPE.GENERIC_CLICK];
60
62
  const PERFORMANCE_EVENT_TYPE_SET = new Set(PERFORMANCE_EVENT_TYPES);
61
63
  function isPerformanceEventType(type) {
62
64
  return PERFORMANCE_EVENT_TYPE_SET.has(type);
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '1.13.0-beta.5';
7
+ var _default = exports.default = '1.13.0-beta.6';
@@ -35,7 +35,8 @@ exports.writeUnanswerableToMeta = writeUnanswerableToMeta;
35
35
  var _commons = require("@miso.ai/commons");
36
36
  var _constants = require("../constants.js");
37
37
  var _index = require("../actor/index.js");
38
- const _excluded = ["qs"];
38
+ const _excluded = ["qs"],
39
+ _excluded2 = ["role", "type", "items"];
39
40
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
40
41
  // role mappings //
41
42
  function mappingSortData(_, {
@@ -401,10 +402,11 @@ function carryOverQuestionIdToData(data, oldData) {
401
402
  // interactions //
402
403
  function buildBaseInteraction(args) {
403
404
  const {
404
- role,
405
- type,
406
- items
407
- } = args;
405
+ role,
406
+ type,
407
+ items
408
+ } = args,
409
+ rest = _objectWithoutPropertiesLoose(args, _excluded2);
408
410
  const payload = {
409
411
  type: type === 'viewable' ? 'viewable_impression' : type,
410
412
  context: {
@@ -433,6 +435,11 @@ function buildBaseInteraction(args) {
433
435
  payload.type = 'custom';
434
436
  payload.custom_action_name = 'heartbeat';
435
437
  break;
438
+ case _constants.EVENT_TYPE.GENERIC_CLICK:
439
+ payload.type = 'custom';
440
+ payload.custom_action_name = 'generic_click';
441
+ payload.context.custom_context.href = args.href;
442
+ break;
436
443
  }
437
444
  return (0, _commons.trimObj)(payload);
438
445
  }
package/package.json CHANGED
@@ -30,7 +30,7 @@
30
30
  "url": "https://github.com/MisoAI/miso-client-js-sdk/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@miso.ai/commons": "1.13.0-beta.5"
33
+ "@miso.ai/commons": "1.13.0-beta.6"
34
34
  },
35
- "version": "1.13.0-beta.5"
35
+ "version": "1.13.0-beta.6"
36
36
  }
@@ -9,7 +9,7 @@ export default class FeedbackActor {
9
9
  hub.on(fields.feedback(), state => this._trigger(state)),
10
10
  ];
11
11
  }
12
-
12
+
13
13
  _trigger(state) {
14
14
  this._hub.trigger(fields.tracker(), {
15
15
  type: EVENT_TYPE.FEEDBACK,
@@ -1,5 +1,5 @@
1
- import { asArray, trimObj } from '@miso.ai/commons';
2
- import { PERFORMANCE_EVENT_TYPES, TRACKING_STATUS, EVENT_TYPE, validateEventType } from '../constants.js';
1
+ import { asArray, trimObj, snakeToLowerCamel } from '@miso.ai/commons';
2
+ import { PERFORMANCE_EVENT_TYPES, DIRECT_TRACKING_EVENT_TYPES, TRACKING_STATUS, EVENT_TYPE, validateEventType } from '../constants.js';
3
3
  import * as fields from './fields.js';
4
4
  import States from '../util/states.js';
5
5
 
@@ -55,21 +55,6 @@ export default class Tracker {
55
55
  });
56
56
  }
57
57
 
58
- submit({ value }) {
59
- this._syncSession();
60
- this._sendToHub({
61
- type: EVENT_TYPE.SUBMIT,
62
- value,
63
- });
64
- }
65
-
66
- heartbeat() {
67
- this._syncSession();
68
- this._sendToHub({
69
- type: EVENT_TYPE.HEARTBEAT,
70
- });
71
- }
72
-
73
58
  _sendToHub(args) {
74
59
  this._hub.trigger(fields.tracker(), Object.freeze(trimObj({ role: this._role, ...args })));
75
60
  }
@@ -106,7 +91,14 @@ export default class Tracker {
106
91
  }
107
92
 
108
93
  for (const type of PERFORMANCE_EVENT_TYPES) {
109
- Tracker.prototype[type] = function(items, meta) {
94
+ Tracker.prototype[snakeToLowerCamel(type)] = function(items, meta) {
110
95
  this._trigger(type, items, meta);
111
96
  };
112
97
  }
98
+
99
+ for (const type of DIRECT_TRACKING_EVENT_TYPES) {
100
+ Tracker.prototype[snakeToLowerCamel(type)] = function(args) {
101
+ this._syncSession();
102
+ this._sendToHub({ ...args, type });
103
+ };
104
+ }
package/src/constants.js CHANGED
@@ -72,6 +72,7 @@ export const EVENT_TYPE = Object.freeze({
72
72
  SUBMIT: 'submit',
73
73
  FEEDBACK: 'feedback',
74
74
  HEARTBEAT: 'heartbeat',
75
+ GENERIC_CLICK: 'generic_click',
75
76
  });
76
77
 
77
78
  export const TRACKING_EVENT_TYPES = [
@@ -89,6 +90,12 @@ export const PERFORMANCE_EVENT_TYPES = [
89
90
  EVENT_TYPE.CLICK,
90
91
  ];
91
92
 
93
+ export const DIRECT_TRACKING_EVENT_TYPES = [
94
+ EVENT_TYPE.SUBMIT,
95
+ EVENT_TYPE.HEARTBEAT,
96
+ EVENT_TYPE.GENERIC_CLICK,
97
+ ];
98
+
92
99
  const PERFORMANCE_EVENT_TYPE_SET = new Set(PERFORMANCE_EVENT_TYPES);
93
100
 
94
101
  export function isPerformanceEventType(type) {
package/src/version.js CHANGED
@@ -1 +1 @@
1
- export default '1.13.0-beta.5';
1
+ export default '1.13.0-beta.6';
@@ -302,7 +302,7 @@ export function carryOverQuestionIdToData(data, oldData) {
302
302
 
303
303
  // interactions //
304
304
  export function buildBaseInteraction(args) {
305
- const { role, type, items } = args;
305
+ const { role, type, items, ...rest } = args;
306
306
  const payload = {
307
307
  type: type === 'viewable' ? 'viewable_impression' : type,
308
308
  context: {
@@ -333,6 +333,11 @@ export function buildBaseInteraction(args) {
333
333
  payload.type = 'custom';
334
334
  payload.custom_action_name = 'heartbeat';
335
335
  break;
336
+ case EVENT_TYPE.GENERIC_CLICK:
337
+ payload.type = 'custom';
338
+ payload.custom_action_name = 'generic_click';
339
+ payload.context.custom_context.href = args.href;
340
+ break;
336
341
  }
337
342
 
338
343
  return trimObj(payload);