@hellotext/hellotext 2.5.7 → 2.5.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.
Files changed (102) hide show
  1. package/README.md +0 -25
  2. package/dist/hellotext.js +1 -1
  3. package/index.d.ts +0 -6
  4. package/lib/api/acks.cjs +17 -31
  5. package/lib/api/acks.js +17 -42
  6. package/lib/api/businesses.cjs +14 -28
  7. package/lib/api/businesses.js +13 -36
  8. package/lib/api/events.cjs +26 -40
  9. package/lib/api/events.js +28 -52
  10. package/lib/api/forms.cjs +24 -40
  11. package/lib/api/forms.js +24 -57
  12. package/lib/api/identifications.cjs +15 -29
  13. package/lib/api/identifications.js +15 -40
  14. package/lib/api/index.cjs +25 -51
  15. package/lib/api/index.js +27 -54
  16. package/lib/api/push/identities.cjs +30 -46
  17. package/lib/api/push/identities.js +30 -63
  18. package/lib/api/response.cjs +30 -52
  19. package/lib/api/response.js +31 -60
  20. package/lib/api/submissions.cjs +18 -34
  21. package/lib/api/submissions.js +18 -48
  22. package/lib/api/webchat/messages.cjs +44 -64
  23. package/lib/api/webchat/messages.js +44 -80
  24. package/lib/api/webchats.cjs +37 -56
  25. package/lib/api/webchats.js +37 -65
  26. package/lib/api/whatsapp_widgets.cjs +49 -72
  27. package/lib/api/whatsapp_widgets.js +48 -91
  28. package/lib/builders/input_builder.cjs +36 -48
  29. package/lib/builders/input_builder.js +36 -48
  30. package/lib/builders/logo_builder.cjs +10 -29
  31. package/lib/builders/logo_builder.js +20 -28
  32. package/lib/channels/application_channel.cjs +136 -178
  33. package/lib/channels/application_channel.js +137 -180
  34. package/lib/channels/webchat_channel.cjs +125 -170
  35. package/lib/channels/webchat_channel.js +125 -170
  36. package/lib/controllers/form_controller.cjs +82 -121
  37. package/lib/controllers/form_controller.js +82 -130
  38. package/lib/controllers/message_controller.cjs +211 -282
  39. package/lib/controllers/message_controller.js +209 -284
  40. package/lib/controllers/mixins/usePopover.cjs +3 -6
  41. package/lib/controllers/mixins/usePopover.js +17 -22
  42. package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
  43. package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
  44. package/lib/controllers/webchat/useBehaviour.js +5 -5
  45. package/lib/controllers/webchat/useOpeningSequence.js +6 -6
  46. package/lib/controllers/webchat/useTeaser.js +9 -9
  47. package/lib/controllers/webchat_controller.cjs +916 -1088
  48. package/lib/controllers/webchat_controller.js +926 -1152
  49. package/lib/core/configuration/forms.cjs +21 -35
  50. package/lib/core/configuration/forms.js +20 -35
  51. package/lib/core/configuration/locale.cjs +36 -71
  52. package/lib/core/configuration/locale.js +36 -70
  53. package/lib/core/configuration/push.cjs +9 -21
  54. package/lib/core/configuration/push.js +8 -20
  55. package/lib/core/configuration/webchat.cjs +142 -182
  56. package/lib/core/configuration/webchat.js +145 -189
  57. package/lib/core/configuration/whatsapp.cjs +76 -102
  58. package/lib/core/configuration/whatsapp.js +76 -105
  59. package/lib/core/configuration.cjs +60 -78
  60. package/lib/core/configuration.js +59 -78
  61. package/lib/core/event.cjs +36 -59
  62. package/lib/core/event.js +35 -61
  63. package/lib/core/sanitize_html.js +4 -4
  64. package/lib/errors/invalid_event.cjs +5 -26
  65. package/lib/errors/invalid_event.js +5 -26
  66. package/lib/errors/not_initialized_error.cjs +5 -26
  67. package/lib/errors/not_initialized_error.js +5 -26
  68. package/lib/hellotext.cjs +185 -223
  69. package/lib/hellotext.js +188 -247
  70. package/lib/index.js +1 -1
  71. package/lib/models/business.cjs +114 -152
  72. package/lib/models/business.js +117 -162
  73. package/lib/models/cookies.cjs +34 -51
  74. package/lib/models/cookies.js +34 -51
  75. package/lib/models/fingerprint.cjs +8 -23
  76. package/lib/models/fingerprint.js +25 -58
  77. package/lib/models/form.cjs +106 -142
  78. package/lib/models/form.js +105 -153
  79. package/lib/models/form_collection.cjs +63 -101
  80. package/lib/models/form_collection.js +61 -107
  81. package/lib/models/page.cjs +106 -129
  82. package/lib/models/page.js +106 -131
  83. package/lib/models/push.cjs +278 -322
  84. package/lib/models/push.js +284 -357
  85. package/lib/models/query.cjs +21 -41
  86. package/lib/models/query.js +21 -41
  87. package/lib/models/session.cjs +33 -65
  88. package/lib/models/session.js +30 -63
  89. package/lib/models/user.cjs +29 -51
  90. package/lib/models/user.js +29 -51
  91. package/lib/models/utm.cjs +15 -27
  92. package/lib/models/utm.js +17 -32
  93. package/lib/models/webchat.cjs +52 -76
  94. package/lib/models/webchat.js +52 -90
  95. package/lib/models/whatsapp_widget.cjs +41 -59
  96. package/lib/models/whatsapp_widget.js +41 -73
  97. package/lib/vanilla.cjs +4 -7
  98. package/lib/vanilla.js +2 -1
  99. package/package.json +1 -9
  100. package/src/index.bundle.js +0 -1
  101. package/src/vanilla.js +2 -1
  102. package/styles/index.css +0 -30
@@ -4,47 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Query = void 0;
7
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
- 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); } }
9
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
11
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
12
- let Query = /*#__PURE__*/function () {
13
- function Query() {
14
- _classCallCheck(this, Query);
7
+ class Query {
8
+ static get inPreviewMode() {
9
+ return new this().inPreviewMode;
10
+ }
11
+ constructor() {
15
12
  this.urlSearchParams = new URLSearchParams(window.location.search);
16
13
  }
17
- _createClass(Query, [{
18
- key: "get",
19
- value: function get(param) {
20
- return this.urlSearchParams.get(this.toHellotextParam(param));
21
- }
22
- }, {
23
- key: "has",
24
- value: function has(param) {
25
- return this.urlSearchParams.has(this.toHellotextParam(param));
26
- }
27
- }, {
28
- key: "inPreviewMode",
29
- get: function () {
30
- return this.has('preview');
31
- }
32
- }, {
33
- key: "session",
34
- get: function () {
35
- return this.get('session');
36
- }
37
- }, {
38
- key: "toHellotextParam",
39
- value: function toHellotextParam(param) {
40
- return `hello_${param}`;
41
- }
42
- }], [{
43
- key: "inPreviewMode",
44
- get: function () {
45
- return new this().inPreviewMode;
46
- }
47
- }]);
48
- return Query;
49
- }();
14
+ get(param) {
15
+ return this.urlSearchParams.get(this.toHellotextParam(param));
16
+ }
17
+ has(param) {
18
+ return this.urlSearchParams.has(this.toHellotextParam(param));
19
+ }
20
+ get inPreviewMode() {
21
+ return this.has('preview');
22
+ }
23
+ get session() {
24
+ return this.get('session');
25
+ }
26
+ toHellotextParam(param) {
27
+ return `hello_${param}`;
28
+ }
29
+ }
50
30
  exports.Query = Query;
@@ -1,44 +1,24 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
- 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); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- var Query = /*#__PURE__*/function () {
7
- function Query() {
8
- _classCallCheck(this, Query);
1
+ class Query {
2
+ static get inPreviewMode() {
3
+ return new this().inPreviewMode;
4
+ }
5
+ constructor() {
9
6
  this.urlSearchParams = new URLSearchParams(window.location.search);
10
7
  }
11
- _createClass(Query, [{
12
- key: "get",
13
- value: function get(param) {
14
- return this.urlSearchParams.get(this.toHellotextParam(param));
15
- }
16
- }, {
17
- key: "has",
18
- value: function has(param) {
19
- return this.urlSearchParams.has(this.toHellotextParam(param));
20
- }
21
- }, {
22
- key: "inPreviewMode",
23
- get: function get() {
24
- return this.has('preview');
25
- }
26
- }, {
27
- key: "session",
28
- get: function get() {
29
- return this.get('session');
30
- }
31
- }, {
32
- key: "toHellotextParam",
33
- value: function toHellotextParam(param) {
34
- return "hello_".concat(param);
35
- }
36
- }], [{
37
- key: "inPreviewMode",
38
- get: function get() {
39
- return new this().inPreviewMode;
40
- }
41
- }]);
42
- return Query;
43
- }();
8
+ get(param) {
9
+ return this.urlSearchParams.get(this.toHellotextParam(param));
10
+ }
11
+ has(param) {
12
+ return this.urlSearchParams.has(this.toHellotextParam(param));
13
+ }
14
+ get inPreviewMode() {
15
+ return this.has('preview');
16
+ }
17
+ get session() {
18
+ return this.get('session');
19
+ }
20
+ toHellotextParam(param) {
21
+ return `hello_${param}`;
22
+ }
23
+ }
44
24
  export { Query };
@@ -6,74 +6,42 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Session = void 0;
7
7
  var _core = require("../core");
8
8
  var _cookies = require("./cookies");
9
- var _page2 = require("./page");
10
- var _query2 = require("./query");
9
+ var _page = require("./page");
10
+ var _query = require("./query");
11
11
  var _api = _interopRequireDefault(require("../api"));
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
- 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); } }
15
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
16
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
17
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
18
- function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
19
- var id = 0;
20
- function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
21
- var _session = /*#__PURE__*/_classPrivateFieldLooseKey("session");
22
- var _query = /*#__PURE__*/_classPrivateFieldLooseKey("query");
23
- var _page = /*#__PURE__*/_classPrivateFieldLooseKey("page");
24
- let Session = /*#__PURE__*/function () {
25
- function Session() {
26
- _classCallCheck(this, Session);
13
+ class Session {
14
+ static #session;
15
+ static #query;
16
+ static #page;
17
+ static get session() {
18
+ return this.#session;
27
19
  }
28
- _createClass(Session, null, [{
29
- key: "session",
30
- get: function () {
31
- return _classPrivateFieldLooseBase(this, _session)[_session];
32
- },
33
- set: function (value) {
34
- const oldSession = _cookies.Cookies.get('hello_session');
35
- _classPrivateFieldLooseBase(this, _session)[_session] = value;
36
- _cookies.Cookies.set('hello_session', value);
37
- if (oldSession !== value) {
38
- _cookies.Cookies.delete('hello_session_ack_at');
39
- }
40
- if (!_cookies.Cookies.get('hello_session_ack_at')) {
41
- _api.default.acks.send(this.ackPayload);
42
- _cookies.Cookies.set('hello_session_ack_at', new Date().toISOString());
43
- }
44
- return _classPrivateFieldLooseBase(this, _session)[_session];
20
+ static get ackPayload() {
21
+ return {
22
+ utm_params: this.#page?.utmParams || {}
23
+ };
24
+ }
25
+ static set session(value) {
26
+ const oldSession = _cookies.Cookies.get('hello_session');
27
+ this.#session = value;
28
+ _cookies.Cookies.set('hello_session', value);
29
+ if (oldSession !== value) {
30
+ _cookies.Cookies.delete('hello_session_ack_at');
45
31
  }
46
- }, {
47
- key: "ackPayload",
48
- get: function () {
49
- var _classPrivateFieldLoo;
50
- return {
51
- utm_params: ((_classPrivateFieldLoo = _classPrivateFieldLooseBase(this, _page)[_page]) === null || _classPrivateFieldLoo === void 0 ? void 0 : _classPrivateFieldLoo.utmParams) || {}
52
- };
32
+ if (!_cookies.Cookies.get('hello_session_ack_at')) {
33
+ _api.default.acks.send(this.ackPayload);
34
+ _cookies.Cookies.set('hello_session_ack_at', new Date().toISOString());
53
35
  }
54
- }, {
55
- key: "initialize",
56
- value: function initialize(page = new _page2.Page()) {
57
- _classPrivateFieldLooseBase(this, _page)[_page] = page;
58
- _classPrivateFieldLooseBase(this, _query)[_query] = new _query2.Query();
59
- this.session = _classPrivateFieldLooseBase(this, _query)[_query].session || _core.Configuration.session || _cookies.Cookies.get('hello_session');
60
- if (!this.session && _core.Configuration.autoGenerateSession) {
61
- this.session = crypto.randomUUID();
62
- }
36
+ return this.#session;
37
+ }
38
+ static initialize(page = new _page.Page()) {
39
+ this.#page = page;
40
+ this.#query = new _query.Query();
41
+ this.session = this.#query.session || _core.Configuration.session || _cookies.Cookies.get('hello_session');
42
+ if (!this.session && _core.Configuration.autoGenerateSession) {
43
+ this.session = crypto.randomUUID();
63
44
  }
64
- }]);
65
- return Session;
66
- }();
67
- exports.Session = Session;
68
- Object.defineProperty(Session, _session, {
69
- writable: true,
70
- value: void 0
71
- });
72
- Object.defineProperty(Session, _query, {
73
- writable: true,
74
- value: void 0
75
- });
76
- Object.defineProperty(Session, _page, {
77
- writable: true,
78
- value: void 0
79
- });
45
+ }
46
+ }
47
+ exports.Session = Session;
@@ -1,73 +1,40 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
- 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); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
- function _classPrivateFieldLooseBase(receiver, privateKey) { if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) { throw new TypeError("attempted to use private field on non-instance"); } return receiver; }
7
- var id = 0;
8
- function _classPrivateFieldLooseKey(name) { return "__private_" + id++ + "_" + name; }
9
1
  import { Configuration } from '../core';
10
2
  import { Cookies } from './cookies';
11
3
  import { Page } from './page';
12
4
  import { Query } from './query';
13
5
  import API from '../api';
14
- var _session = /*#__PURE__*/_classPrivateFieldLooseKey("session");
15
- var _query = /*#__PURE__*/_classPrivateFieldLooseKey("query");
16
- var _page = /*#__PURE__*/_classPrivateFieldLooseKey("page");
17
- var Session = /*#__PURE__*/function () {
18
- function Session() {
19
- _classCallCheck(this, Session);
6
+ class Session {
7
+ static #session;
8
+ static #query;
9
+ static #page;
10
+ static get session() {
11
+ return this.#session;
20
12
  }
21
- _createClass(Session, null, [{
22
- key: "session",
23
- get: function get() {
24
- return _classPrivateFieldLooseBase(this, _session)[_session];
25
- },
26
- set: function set(value) {
27
- var oldSession = Cookies.get('hello_session');
28
- _classPrivateFieldLooseBase(this, _session)[_session] = value;
29
- Cookies.set('hello_session', value);
30
- if (oldSession !== value) {
31
- Cookies.delete('hello_session_ack_at');
32
- }
33
- if (!Cookies.get('hello_session_ack_at')) {
34
- API.acks.send(this.ackPayload);
35
- Cookies.set('hello_session_ack_at', new Date().toISOString());
36
- }
37
- return _classPrivateFieldLooseBase(this, _session)[_session];
13
+ static get ackPayload() {
14
+ return {
15
+ utm_params: this.#page?.utmParams || {}
16
+ };
17
+ }
18
+ static set session(value) {
19
+ const oldSession = Cookies.get('hello_session');
20
+ this.#session = value;
21
+ Cookies.set('hello_session', value);
22
+ if (oldSession !== value) {
23
+ Cookies.delete('hello_session_ack_at');
38
24
  }
39
- }, {
40
- key: "ackPayload",
41
- get: function get() {
42
- var _classPrivateFieldLoo;
43
- return {
44
- utm_params: ((_classPrivateFieldLoo = _classPrivateFieldLooseBase(this, _page)[_page]) === null || _classPrivateFieldLoo === void 0 ? void 0 : _classPrivateFieldLoo.utmParams) || {}
45
- };
25
+ if (!Cookies.get('hello_session_ack_at')) {
26
+ API.acks.send(this.ackPayload);
27
+ Cookies.set('hello_session_ack_at', new Date().toISOString());
46
28
  }
47
- }, {
48
- key: "initialize",
49
- value: function initialize() {
50
- var page = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Page();
51
- _classPrivateFieldLooseBase(this, _page)[_page] = page;
52
- _classPrivateFieldLooseBase(this, _query)[_query] = new Query();
53
- this.session = _classPrivateFieldLooseBase(this, _query)[_query].session || Configuration.session || Cookies.get('hello_session');
54
- if (!this.session && Configuration.autoGenerateSession) {
55
- this.session = crypto.randomUUID();
56
- }
29
+ return this.#session;
30
+ }
31
+ static initialize(page = new Page()) {
32
+ this.#page = page;
33
+ this.#query = new Query();
34
+ this.session = this.#query.session || Configuration.session || Cookies.get('hello_session');
35
+ if (!this.session && Configuration.autoGenerateSession) {
36
+ this.session = crypto.randomUUID();
57
37
  }
58
- }]);
59
- return Session;
60
- }();
61
- Object.defineProperty(Session, _session, {
62
- writable: true,
63
- value: void 0
64
- });
65
- Object.defineProperty(Session, _query, {
66
- writable: true,
67
- value: void 0
68
- });
69
- Object.defineProperty(Session, _page, {
70
- writable: true,
71
- value: void 0
72
- });
38
+ }
39
+ }
73
40
  export { Session };
@@ -5,58 +5,36 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.User = void 0;
7
7
  var _cookies = require("./cookies");
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
- 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
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
- let User = /*#__PURE__*/function () {
14
- function User() {
15
- _classCallCheck(this, User);
8
+ class User {
9
+ static get id() {
10
+ return _cookies.Cookies.get('hello_user_id');
16
11
  }
17
- _createClass(User, null, [{
18
- key: "id",
19
- get: function () {
20
- return _cookies.Cookies.get('hello_user_id');
21
- }
22
- }, {
23
- key: "source",
24
- get: function () {
25
- return _cookies.Cookies.get('hello_user_source');
26
- }
27
- }, {
28
- key: "fingerprint",
29
- get: function () {
30
- return _cookies.Cookies.get('hello_user_identification_hash');
31
- }
32
- }, {
33
- key: "remember",
34
- value: function remember(id, source, fingerprint) {
35
- if (source) {
36
- _cookies.Cookies.set('hello_user_source', source);
37
- }
38
- if (fingerprint) {
39
- _cookies.Cookies.set('hello_user_identification_hash', fingerprint);
40
- }
41
- _cookies.Cookies.set('hello_user_id', id);
42
- }
43
- }, {
44
- key: "forget",
45
- value: function forget() {
46
- _cookies.Cookies.delete('hello_user_id');
47
- _cookies.Cookies.delete('hello_user_source');
48
- _cookies.Cookies.delete('hello_user_identification_hash');
12
+ static get source() {
13
+ return _cookies.Cookies.get('hello_user_source');
14
+ }
15
+ static get fingerprint() {
16
+ return _cookies.Cookies.get('hello_user_identification_hash');
17
+ }
18
+ static remember(id, source, fingerprint) {
19
+ if (source) {
20
+ _cookies.Cookies.set('hello_user_source', source);
49
21
  }
50
- }, {
51
- key: "identificationData",
52
- get: function () {
53
- if (!this.id) return {};
54
- return {
55
- id: this.id,
56
- source: this.source
57
- };
22
+ if (fingerprint) {
23
+ _cookies.Cookies.set('hello_user_identification_hash', fingerprint);
58
24
  }
59
- }]);
60
- return User;
61
- }();
25
+ _cookies.Cookies.set('hello_user_id', id);
26
+ }
27
+ static forget() {
28
+ _cookies.Cookies.delete('hello_user_id');
29
+ _cookies.Cookies.delete('hello_user_source');
30
+ _cookies.Cookies.delete('hello_user_identification_hash');
31
+ }
32
+ static get identificationData() {
33
+ if (!this.id) return {};
34
+ return {
35
+ id: this.id,
36
+ source: this.source
37
+ };
38
+ }
39
+ }
62
40
  exports.User = User;
@@ -1,56 +1,34 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
- 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); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
1
  import { Cookies } from './cookies';
7
- var User = /*#__PURE__*/function () {
8
- function User() {
9
- _classCallCheck(this, User);
2
+ class User {
3
+ static get id() {
4
+ return Cookies.get('hello_user_id');
10
5
  }
11
- _createClass(User, null, [{
12
- key: "id",
13
- get: function get() {
14
- return Cookies.get('hello_user_id');
15
- }
16
- }, {
17
- key: "source",
18
- get: function get() {
19
- return Cookies.get('hello_user_source');
20
- }
21
- }, {
22
- key: "fingerprint",
23
- get: function get() {
24
- return Cookies.get('hello_user_identification_hash');
25
- }
26
- }, {
27
- key: "remember",
28
- value: function remember(id, source, fingerprint) {
29
- if (source) {
30
- Cookies.set('hello_user_source', source);
31
- }
32
- if (fingerprint) {
33
- Cookies.set('hello_user_identification_hash', fingerprint);
34
- }
35
- Cookies.set('hello_user_id', id);
36
- }
37
- }, {
38
- key: "forget",
39
- value: function forget() {
40
- Cookies.delete('hello_user_id');
41
- Cookies.delete('hello_user_source');
42
- Cookies.delete('hello_user_identification_hash');
6
+ static get source() {
7
+ return Cookies.get('hello_user_source');
8
+ }
9
+ static get fingerprint() {
10
+ return Cookies.get('hello_user_identification_hash');
11
+ }
12
+ static remember(id, source, fingerprint) {
13
+ if (source) {
14
+ Cookies.set('hello_user_source', source);
43
15
  }
44
- }, {
45
- key: "identificationData",
46
- get: function get() {
47
- if (!this.id) return {};
48
- return {
49
- id: this.id,
50
- source: this.source
51
- };
16
+ if (fingerprint) {
17
+ Cookies.set('hello_user_identification_hash', fingerprint);
52
18
  }
53
- }]);
54
- return User;
55
- }();
19
+ Cookies.set('hello_user_id', id);
20
+ }
21
+ static forget() {
22
+ Cookies.delete('hello_user_id');
23
+ Cookies.delete('hello_user_source');
24
+ Cookies.delete('hello_user_identification_hash');
25
+ }
26
+ static get identificationData() {
27
+ if (!this.id) return {};
28
+ return {
29
+ id: this.id,
30
+ source: this.source
31
+ };
32
+ }
33
+ }
56
34
  export { User };
@@ -5,14 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.UTM = void 0;
7
7
  var _cookies = require("./cookies");
8
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
9
- 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
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
11
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
12
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
- let UTM = /*#__PURE__*/function () {
14
- function UTM() {
15
- _classCallCheck(this, UTM);
8
+ class UTM {
9
+ constructor() {
16
10
  const urlSearchParams = new URLSearchParams(window.location.search);
17
11
  const utmsFromUrl = {
18
12
  source: urlSearchParams.get('utm_source'),
@@ -23,24 +17,18 @@ let UTM = /*#__PURE__*/function () {
23
17
  };
24
18
  this.save(utmsFromUrl);
25
19
  }
26
- _createClass(UTM, [{
27
- key: "save",
28
- value: function save(utmParams) {
29
- if (!utmParams.source || !utmParams.medium) return;
30
- const cleanUtms = Object.fromEntries(Object.entries(utmParams).filter(([_, value]) => value));
31
- cleanUtms.observed_at = new Date().toISOString();
32
- _cookies.Cookies.set('hello_utm', JSON.stringify(cleanUtms));
33
- }
34
- }, {
35
- key: "current",
36
- get: function () {
37
- try {
38
- return JSON.parse(_cookies.Cookies.get('hello_utm')) || {};
39
- } catch (e) {
40
- return {};
41
- }
20
+ save(utmParams) {
21
+ if (!utmParams.source || !utmParams.medium) return;
22
+ const cleanUtms = Object.fromEntries(Object.entries(utmParams).filter(([_, value]) => value));
23
+ cleanUtms.observed_at = new Date().toISOString();
24
+ _cookies.Cookies.set('hello_utm', JSON.stringify(cleanUtms));
25
+ }
26
+ get current() {
27
+ try {
28
+ return JSON.parse(_cookies.Cookies.get('hello_utm')) || {};
29
+ } catch (e) {
30
+ return {};
42
31
  }
43
- }]);
44
- return UTM;
45
- }();
32
+ }
33
+ }
46
34
  exports.UTM = UTM;
package/lib/models/utm.js CHANGED
@@ -1,14 +1,8 @@
1
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2
- 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); } }
3
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
4
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
5
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
6
1
  import { Cookies } from './cookies';
7
- var UTM = /*#__PURE__*/function () {
8
- function UTM() {
9
- _classCallCheck(this, UTM);
10
- var urlSearchParams = new URLSearchParams(window.location.search);
11
- var utmsFromUrl = {
2
+ class UTM {
3
+ constructor() {
4
+ const urlSearchParams = new URLSearchParams(window.location.search);
5
+ const utmsFromUrl = {
12
6
  source: urlSearchParams.get('utm_source'),
13
7
  medium: urlSearchParams.get('utm_medium'),
14
8
  campaign: urlSearchParams.get('utm_campaign'),
@@ -17,27 +11,18 @@ var UTM = /*#__PURE__*/function () {
17
11
  };
18
12
  this.save(utmsFromUrl);
19
13
  }
20
- _createClass(UTM, [{
21
- key: "save",
22
- value: function save(utmParams) {
23
- if (!utmParams.source || !utmParams.medium) return;
24
- var cleanUtms = Object.fromEntries(Object.entries(utmParams).filter(_ref => {
25
- var [_, value] = _ref;
26
- return value;
27
- }));
28
- cleanUtms.observed_at = new Date().toISOString();
29
- Cookies.set('hello_utm', JSON.stringify(cleanUtms));
30
- }
31
- }, {
32
- key: "current",
33
- get: function get() {
34
- try {
35
- return JSON.parse(Cookies.get('hello_utm')) || {};
36
- } catch (e) {
37
- return {};
38
- }
14
+ save(utmParams) {
15
+ if (!utmParams.source || !utmParams.medium) return;
16
+ const cleanUtms = Object.fromEntries(Object.entries(utmParams).filter(([_, value]) => value));
17
+ cleanUtms.observed_at = new Date().toISOString();
18
+ Cookies.set('hello_utm', JSON.stringify(cleanUtms));
19
+ }
20
+ get current() {
21
+ try {
22
+ return JSON.parse(Cookies.get('hello_utm')) || {};
23
+ } catch (e) {
24
+ return {};
39
25
  }
40
- }]);
41
- return UTM;
42
- }();
26
+ }
27
+ }
43
28
  export { UTM };