@hellotext/hellotext 2.3.7 → 2.3.8

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.
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _stimulus = require("@hotwired/stimulus");
8
+ var _hellotext = _interopRequireDefault(require("../hellotext"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
10
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
11
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
10
12
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -58,6 +60,23 @@ let _default = /*#__PURE__*/function (_Controller) {
58
60
  }
59
61
  });
60
62
  }
63
+ }, {
64
+ key: "addToCart",
65
+ value: function addToCart({
66
+ currentTarget
67
+ }) {
68
+ const card = currentTarget.closest('[data-hellotext--message-target="carouselCard"]');
69
+ const payload = {
70
+ object_parameters: {
71
+ items: [{
72
+ product: card.dataset.id,
73
+ quantity: 1
74
+ }]
75
+ }
76
+ };
77
+ _hellotext.default.track('cart.added', payload);
78
+ _hellotext.default.eventEmitter.dispatch('cart.added', payload);
79
+ }
61
80
  }, {
62
81
  key: "moveToLeft",
63
82
  value: function moveToLeft() {
@@ -11,6 +11,7 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen
11
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
12
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13
13
  import { Controller } from '@hotwired/stimulus';
14
+ import Hellotext from '../hellotext';
14
15
  var _default = /*#__PURE__*/function (_Controller) {
15
16
  _inherits(_default, _Controller);
16
17
  var _super = _createSuper(_default);
@@ -54,6 +55,24 @@ var _default = /*#__PURE__*/function (_Controller) {
54
55
  }
55
56
  });
56
57
  }
58
+ }, {
59
+ key: "addToCart",
60
+ value: function addToCart(_ref3) {
61
+ var {
62
+ currentTarget
63
+ } = _ref3;
64
+ var card = currentTarget.closest('[data-hellotext--message-target="carouselCard"]');
65
+ var payload = {
66
+ object_parameters: {
67
+ items: [{
68
+ product: card.dataset.id,
69
+ quantity: 1
70
+ }]
71
+ }
72
+ };
73
+ Hellotext.track('cart.added', payload);
74
+ Hellotext.eventEmitter.dispatch('cart.added', payload);
75
+ }
57
76
  }, {
58
77
  key: "moveToLeft",
59
78
  value: function moveToLeft() {
@@ -68,4 +68,4 @@ let Event = /*#__PURE__*/function () {
68
68
  return Event;
69
69
  }();
70
70
  exports.default = Event;
71
- Event.events = ['session-set', 'utm-set', 'forms:collected', 'form:completed', 'webchat:mounted', 'webchat:opened', 'webchat:closed', 'webchat:message:sent', 'webchat:message:received'];
71
+ Event.events = ['session-set', 'utm-set', 'forms:collected', 'form:completed', 'webchat:mounted', 'webchat:opened', 'webchat:closed', 'webchat:message:sent', 'webchat:message:received', 'cart.added'];
package/lib/core/event.js CHANGED
@@ -63,5 +63,5 @@ var Event = /*#__PURE__*/function () {
63
63
  }]);
64
64
  return Event;
65
65
  }();
66
- Event.events = ['session-set', 'utm-set', 'forms:collected', 'form:completed', 'webchat:mounted', 'webchat:opened', 'webchat:closed', 'webchat:message:sent', 'webchat:message:received'];
66
+ Event.events = ['session-set', 'utm-set', 'forms:collected', 'form:completed', 'webchat:mounted', 'webchat:opened', 'webchat:closed', 'webchat:message:sent', 'webchat:message:received', 'cart.added'];
67
67
  export { Event as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellotext/hellotext",
3
- "version": "2.3.7",
3
+ "version": "2.3.8",
4
4
  "description": "Hellotext JavaScript Client",
5
5
  "source": "src/index.js",
6
6
  "main": "lib/index.cjs",
@@ -1,5 +1,7 @@
1
1
  import { Controller } from '@hotwired/stimulus'
2
2
 
3
+ import Hellotext from '../hellotext'
4
+
3
5
  export default class extends Controller {
4
6
  static values = {
5
7
  id: String,
@@ -34,6 +36,24 @@ export default class extends Controller {
34
36
  })
35
37
  }
36
38
 
39
+ addToCart({ currentTarget }) {
40
+ const card = currentTarget.closest('[data-hellotext--message-target="carouselCard"]')
41
+
42
+ const payload = {
43
+ object_parameters: {
44
+ items: [
45
+ {
46
+ product: card.dataset.id,
47
+ quantity: 1,
48
+ },
49
+ ],
50
+ },
51
+ }
52
+
53
+ Hellotext.track('cart.added', payload)
54
+ Hellotext.eventEmitter.dispatch('cart.added', payload)
55
+ }
56
+
37
57
  moveToLeft() {
38
58
  if (!this.hasCarouselContainerTarget) return
39
59
 
package/src/core/event.js CHANGED
@@ -11,6 +11,7 @@ export default class Event {
11
11
  'webchat:closed',
12
12
  'webchat:message:sent',
13
13
  'webchat:message:received',
14
+ 'cart.added',
14
15
  ]
15
16
 
16
17
  static valid(name) {