@hellotext/hellotext 2.5.6 → 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.
- package/README.md +5 -26
- package/dist/hellotext.js +1 -1
- package/dist/hellotext.js.LICENSE.txt +1 -1
- package/index.d.ts +15 -6
- package/lib/api/acks.cjs +17 -31
- package/lib/api/acks.js +17 -42
- package/lib/api/businesses.cjs +14 -28
- package/lib/api/businesses.js +13 -36
- package/lib/api/events.cjs +26 -40
- package/lib/api/events.js +28 -52
- package/lib/api/forms.cjs +24 -40
- package/lib/api/forms.js +24 -57
- package/lib/api/identifications.cjs +15 -29
- package/lib/api/identifications.js +15 -40
- package/lib/api/index.cjs +26 -46
- package/lib/api/index.js +28 -49
- package/lib/api/push/identities.cjs +43 -0
- package/lib/api/push/identities.js +35 -0
- package/lib/api/response.cjs +30 -52
- package/lib/api/response.js +31 -60
- package/lib/api/submissions.cjs +18 -34
- package/lib/api/submissions.js +18 -48
- package/lib/api/webchat/messages.cjs +44 -64
- package/lib/api/webchat/messages.js +44 -80
- package/lib/api/webchats.cjs +37 -56
- package/lib/api/webchats.js +37 -65
- package/lib/api/whatsapp_widgets.cjs +49 -72
- package/lib/api/whatsapp_widgets.js +48 -91
- package/lib/builders/input_builder.cjs +36 -48
- package/lib/builders/input_builder.js +36 -48
- package/lib/builders/logo_builder.cjs +10 -29
- package/lib/builders/logo_builder.js +20 -28
- package/lib/channels/application_channel.cjs +136 -178
- package/lib/channels/application_channel.js +137 -180
- package/lib/channels/webchat_channel.cjs +125 -170
- package/lib/channels/webchat_channel.js +125 -170
- package/lib/controllers/form_controller.cjs +82 -121
- package/lib/controllers/form_controller.js +82 -130
- package/lib/controllers/message_controller.cjs +211 -282
- package/lib/controllers/message_controller.js +209 -284
- package/lib/controllers/mixins/usePopover.cjs +3 -6
- package/lib/controllers/mixins/usePopover.js +17 -22
- package/lib/controllers/webchat/emoji_picker_controller.cjs +106 -150
- package/lib/controllers/webchat/emoji_picker_controller.js +105 -170
- package/lib/controllers/webchat/useBehaviour.js +5 -5
- package/lib/controllers/webchat/useOpeningSequence.js +6 -6
- package/lib/controllers/webchat/useTeaser.js +9 -9
- package/lib/controllers/webchat_controller.cjs +916 -1088
- package/lib/controllers/webchat_controller.js +926 -1152
- package/lib/core/configuration/forms.cjs +21 -35
- package/lib/core/configuration/forms.js +20 -35
- package/lib/core/configuration/locale.cjs +36 -71
- package/lib/core/configuration/locale.js +36 -70
- package/lib/core/configuration/push.cjs +16 -0
- package/lib/core/configuration/push.js +10 -0
- package/lib/core/configuration/webchat.cjs +142 -182
- package/lib/core/configuration/webchat.js +145 -189
- package/lib/core/configuration/whatsapp.cjs +76 -102
- package/lib/core/configuration/whatsapp.js +76 -105
- package/lib/core/configuration.cjs +62 -75
- package/lib/core/configuration.js +61 -75
- package/lib/core/event.cjs +36 -59
- package/lib/core/event.js +35 -61
- package/lib/core/sanitize_html.js +4 -4
- package/lib/errors/invalid_event.cjs +5 -26
- package/lib/errors/invalid_event.js +5 -26
- package/lib/errors/not_initialized_error.cjs +5 -26
- package/lib/errors/not_initialized_error.js +5 -26
- package/lib/hellotext.cjs +186 -211
- package/lib/hellotext.js +189 -236
- package/lib/index.js +1 -1
- package/lib/models/business.cjs +115 -152
- package/lib/models/business.js +118 -162
- package/lib/models/cookies.cjs +34 -51
- package/lib/models/cookies.js +34 -51
- package/lib/models/fingerprint.cjs +8 -23
- package/lib/models/fingerprint.js +25 -58
- package/lib/models/form.cjs +106 -142
- package/lib/models/form.js +105 -153
- package/lib/models/form_collection.cjs +63 -101
- package/lib/models/form_collection.js +61 -107
- package/lib/models/index.cjs +7 -0
- package/lib/models/index.js +1 -0
- package/lib/models/page.cjs +106 -129
- package/lib/models/page.js +106 -131
- package/lib/models/push.cjs +345 -0
- package/lib/models/push.js +339 -0
- package/lib/models/query.cjs +21 -41
- package/lib/models/query.js +21 -41
- package/lib/models/session.cjs +33 -65
- package/lib/models/session.js +30 -63
- package/lib/models/user.cjs +29 -51
- package/lib/models/user.js +29 -51
- package/lib/models/utm.cjs +15 -27
- package/lib/models/utm.js +17 -32
- package/lib/models/webchat.cjs +52 -76
- package/lib/models/webchat.js +52 -90
- package/lib/models/whatsapp_widget.cjs +41 -59
- package/lib/models/whatsapp_widget.js +41 -73
- package/lib/vanilla.cjs +4 -7
- package/lib/vanilla.js +2 -1
- package/package.json +2 -10
- package/src/api/index.js +5 -0
- package/src/api/push/identities.js +42 -0
- package/src/core/configuration/push.js +12 -0
- package/src/core/configuration.js +5 -0
- package/src/hellotext.js +15 -1
- package/src/index.bundle.js +0 -1
- package/src/models/business.js +1 -0
- package/src/models/index.js +1 -0
- package/src/models/push.js +397 -0
- package/src/vanilla.js +2 -1
- package/styles/index.css +0 -30
package/lib/models/query.cjs
CHANGED
|
@@ -4,47 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Query = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
package/lib/models/query.js
CHANGED
|
@@ -1,44 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 };
|
package/lib/models/session.cjs
CHANGED
|
@@ -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
|
|
10
|
-
var
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
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;
|
package/lib/models/session.js
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
class Session {
|
|
7
|
+
static #session;
|
|
8
|
+
static #query;
|
|
9
|
+
static #page;
|
|
10
|
+
static get session() {
|
|
11
|
+
return this.#session;
|
|
20
12
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
41
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
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 };
|
package/lib/models/user.cjs
CHANGED
|
@@ -5,58 +5,36 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.User = void 0;
|
|
7
7
|
var _cookies = require("./cookies");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|
package/lib/models/user.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
class User {
|
|
3
|
+
static get id() {
|
|
4
|
+
return Cookies.get('hello_user_id');
|
|
10
5
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 };
|
package/lib/models/utm.cjs
CHANGED
|
@@ -5,14 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.UTM = void 0;
|
|
7
7
|
var _cookies = require("./cookies");
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
42
|
-
}();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
43
28
|
export { UTM };
|