@xapp/chat-widget 1.71.0 → 1.72.0

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/dist/index.js CHANGED
@@ -2363,7 +2363,7 @@ var StentorDirectChat = /** @class */ (function () {
2363
2363
  };
2364
2364
  StentorDirectChat.prototype.postMessage = function (message) {
2365
2365
  return __awaiter$1(this, void 0, void 0, function () {
2366
- var request, userId, sessionId, accessToken, attributes, now, permissionRequest, expired, text, granted, userProfile, isEmail, configurableMessages, botResponse, successResult, success, fail, i, timeout, responseMessage;
2366
+ var request, userId, sessionId, accessToken, attributes, rwgToken, merchantId, environment, now, permissionRequest, expired, text, granted, userProfile, isEmail, configurableMessages, botResponse, successResult, success, fail, i, timeout, responseMessage;
2367
2367
  var _this = this;
2368
2368
  var _a, _b, _c, _d, _e;
2369
2369
  return __generator$1(this, function (_f) {
@@ -2373,6 +2373,18 @@ var StentorDirectChat = /** @class */ (function () {
2373
2373
  sessionId = this._sessionId;
2374
2374
  accessToken = this._accessToken;
2375
2375
  attributes = this._attributes || {};
2376
+ rwgToken = localStorage.getItem("xa_rwg_token");
2377
+ if (rwgToken) {
2378
+ attributes["rwg_token"] = rwgToken;
2379
+ }
2380
+ merchantId = localStorage.getItem("xa_merchant_id");
2381
+ if (merchantId) {
2382
+ attributes["merchant_id"] = merchantId;
2383
+ }
2384
+ environment = localStorage.getItem("xa_environment");
2385
+ if (environment) {
2386
+ attributes["environment"] = environment;
2387
+ }
2376
2388
  now = new Date().getTime();
2377
2389
  if (this.isNewSession && !((_a = message === null || message === void 0 ? void 0 : message.msg) === null || _a === void 0 ? void 0 : _a.text)) {
2378
2390
  request = {
@@ -2832,7 +2844,7 @@ var StentorRouterChat = /** @class */ (function () {
2832
2844
  _this.dispatch(setConnectionStatus("offline"));
2833
2845
  }
2834
2846
  };
2835
- // Server ping (not sent peroidically - at least not for now)
2847
+ // Server ping (not sent periodically - at least not for now)
2836
2848
  this.handlers["account status"] = function (_data, _sender, ts) {
2837
2849
  dispatch({
2838
2850
  type: "account_status",
@@ -3162,9 +3174,11 @@ var StentorRouterChat = /** @class */ (function () {
3162
3174
  nick: senderToNick(serverInfo),
3163
3175
  avatarPath: serverInfo.avatarPath
3164
3176
  },
3165
- msg: { text: this.noOfServerErrors === 0 ?
3177
+ msg: {
3178
+ text: this.noOfServerErrors === 0 ?
3166
3179
  "I cannot connect to the server. Please try later." :
3167
- "Nope. Still no luck. I still cannot connect to the server. Please don't give up." },
3180
+ "Nope. Still no luck. I still cannot connect to the server. Please don't give up."
3181
+ },
3168
3182
  timestamp: new Date().getTime(),
3169
3183
  }
3170
3184
  });
@@ -3287,12 +3301,24 @@ var StentorRouterChat = /** @class */ (function () {
3287
3301
  };
3288
3302
  StentorRouterChat.prototype.postMessage = function (message) {
3289
3303
  return __awaiter$1(this, void 0, void 0, function () {
3290
- var userId, sessionId, accessToken, attributes, request;
3304
+ var userId, sessionId, accessToken, attributes, rwgToken, merchantId, environment, request;
3291
3305
  return __generator$1(this, function (_a) {
3292
3306
  userId = this._userId;
3293
3307
  sessionId = this._sessionId;
3294
3308
  accessToken = this.accessToken;
3295
3309
  attributes = this.attributes || {};
3310
+ rwgToken = localStorage.getItem("xa_rwg_token");
3311
+ if (rwgToken) {
3312
+ attributes["rwg_token"] = rwgToken;
3313
+ }
3314
+ merchantId = localStorage.getItem("xa_merchant_id");
3315
+ if (merchantId) {
3316
+ attributes["merchant_id"] = merchantId;
3317
+ }
3318
+ environment = localStorage.getItem("xa_environment");
3319
+ if (environment) {
3320
+ attributes["environment"] = environment;
3321
+ }
3296
3322
  request = requestFromMessage(message, userId, this.isNewSession, sessionId, accessToken, attributes, this.visitorInfo);
3297
3323
  this.emit("new message", request);
3298
3324
  return [2 /*return*/];