@hellotext/hellotext 2.3.0 → 2.3.2

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/lib/hellotext.cjs CHANGED
@@ -59,10 +59,14 @@ let Hellotext = /*#__PURE__*/function () {
59
59
  ...(params && params.headers || {}),
60
60
  ...this.headers
61
61
  };
62
+ const user = {
63
+ ..._models.User.identificationData,
64
+ ...(params.user || {})
65
+ };
62
66
  const pageInstance = params && params.url ? new _models.Page(params.url) : this.page;
63
67
  const body = {
64
68
  session: this.session,
65
- user: _models.User.identificationData,
69
+ user,
66
70
  action,
67
71
  ...params,
68
72
  ...pageInstance.trackingData
@@ -89,6 +93,13 @@ let Hellotext = /*#__PURE__*/function () {
89
93
  }, {
90
94
  key: "identify",
91
95
  value: async function identify(externalId, options = {}) {
96
+ if (_models.User.id === externalId) {
97
+ return new _api.Response(true, {
98
+ json: async () => {
99
+ already_identified: true;
100
+ }
101
+ });
102
+ }
92
103
  const response = await _api.default.identifications.create({
93
104
  user_id: externalId,
94
105
  ...options
package/lib/hellotext.js CHANGED
@@ -60,10 +60,11 @@ var Hellotext = /*#__PURE__*/function () {
60
60
  throw new NotInitializedError();
61
61
  }
62
62
  var headers = _objectSpread(_objectSpread({}, params && params.headers || {}), this.headers);
63
+ var user = _objectSpread(_objectSpread({}, User.identificationData), params.user || {});
63
64
  var pageInstance = params && params.url ? new Page(params.url) : this.page;
64
65
  var body = _objectSpread(_objectSpread({
65
66
  session: this.session,
66
- user: User.identificationData,
67
+ user,
67
68
  action
68
69
  }, params), pageInstance.trackingData);
69
70
  delete body.headers;
@@ -94,6 +95,19 @@ var Hellotext = /*#__PURE__*/function () {
94
95
  value: function () {
95
96
  var _identify = _asyncToGenerator(function* (externalId) {
96
97
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
98
+ if (User.id === externalId) {
99
+ return new Response(true, {
100
+ json: function () {
101
+ var _json = _asyncToGenerator(function* () {
102
+ already_identified: true;
103
+ });
104
+ function json() {
105
+ return _json.apply(this, arguments);
106
+ }
107
+ return json;
108
+ }()
109
+ });
110
+ }
97
111
  var response = yield API.identifications.create(_objectSpread({
98
112
  user_id: externalId
99
113
  }, options));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellotext/hellotext",
3
- "version": "2.3.0",
3
+ "version": "2.3.2",
4
4
  "description": "Hellotext JavaScript Client",
5
5
  "source": "src/index.js",
6
6
  "main": "lib/index.cjs",
package/src/hellotext.js CHANGED
@@ -52,11 +52,16 @@ class Hellotext {
52
52
  ...this.headers,
53
53
  }
54
54
 
55
+ const user = {
56
+ ...User.identificationData,
57
+ ...(params.user || {}),
58
+ }
59
+
55
60
  const pageInstance = params && params.url ? new Page(params.url) : this.page
56
61
 
57
62
  const body = {
58
63
  session: this.session,
59
- user: User.identificationData,
64
+ user,
60
65
  action,
61
66
  ...params,
62
67
  ...pageInstance.trackingData,
@@ -83,6 +88,14 @@ class Hellotext {
83
88
  * @returns {Promise<Response>}
84
89
  */
85
90
  static async identify(externalId, options = {}) {
91
+ if (User.id === externalId) {
92
+ return new Response(true, {
93
+ json: async () => {
94
+ already_identified: true
95
+ },
96
+ })
97
+ }
98
+
86
99
  const response = await API.identifications.create({
87
100
  user_id: externalId,
88
101
  ...options,