@microsoft/omnichannel-chat-sdk 1.2.1-main.a42cdc5 → 1.2.1-main.b505510

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.
@@ -95,7 +95,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
95
95
  function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
96
96
  var _this = this;
97
97
  if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
98
- var _a, _b, _c, _d, _e, _f, _g, _h;
98
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
99
99
  this.ACSClient = null;
100
100
  this.AMSClient = null;
101
101
  this.authSettings = null;
@@ -108,6 +108,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
108
108
  this.acsClientLogger = null;
109
109
  this.acsAdapterLogger = null;
110
110
  this.callingSdkLogger = null;
111
+ this.amsClientLogger = null;
111
112
  this.isPersistentChat = false;
112
113
  this.isChatReconnect = false;
113
114
  this.reconnectId = null;
@@ -132,6 +133,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
132
133
  if (optionalParams.preChatResponse) {
133
134
  requestOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
134
135
  }
136
+ if (optionalParams.portalContactId) {
137
+ requestOptionalParams.initContext.portalcontactid = optionalParams.portalContactId;
138
+ }
135
139
  if (optionalParams.sendDefaultInitContext) {
136
140
  if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
137
141
  var exceptionDetails = {
@@ -182,18 +186,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
182
186
  this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
183
187
  this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
184
188
  this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
189
+ this.amsClientLogger = loggers_1.createAMSClientLogger(this.omnichannelConfig);
185
190
  this.scenarioMarker.useTelemetry(this.telemetry);
186
191
  this.ic3ClientLogger.useTelemetry(this.telemetry);
187
192
  this.ocSdkLogger.useTelemetry(this.telemetry);
188
193
  this.acsClientLogger.useTelemetry(this.telemetry);
189
194
  this.acsAdapterLogger.useTelemetry(this.telemetry);
190
195
  this.callingSdkLogger.useTelemetry(this.telemetry);
196
+ this.amsClientLogger.useTelemetry(this.telemetry);
191
197
  this.scenarioMarker.setRuntimeId(this.runtimeId);
192
198
  this.ic3ClientLogger.setRuntimeId(this.runtimeId);
193
199
  this.ocSdkLogger.setRuntimeId(this.runtimeId);
194
200
  this.acsClientLogger.setRuntimeId(this.runtimeId);
195
201
  this.acsAdapterLogger.setRuntimeId(this.runtimeId);
196
202
  this.callingSdkLogger.setRuntimeId(this.runtimeId);
203
+ this.amsClientLogger.setRuntimeId(this.runtimeId);
197
204
  OmnichannelConfigValidator_1.default(omnichannelConfig);
198
205
  SDKConfigValidators_1.default(chatSDKConfig);
199
206
  ((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
@@ -205,10 +212,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
205
212
  (_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
206
213
  (_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
207
214
  (_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
215
+ (_j = this.amsClientLogger) === null || _j === void 0 ? void 0 : _j.setRequestId(this.requestId);
208
216
  }
209
217
  /* istanbul ignore next */
210
218
  OmnichannelChatSDK.prototype.setDebug = function (flag) {
211
- var _a, _b, _c, _d, _e, _f, _g;
219
+ var _a, _b, _c, _d, _e, _f, _g, _h;
212
220
  this.debug = flag;
213
221
  (_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
214
222
  (_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
@@ -218,31 +226,32 @@ var OmnichannelChatSDK = /** @class */ (function () {
218
226
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
219
227
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
220
228
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
229
+ (_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setDebug(flag);
221
230
  };
222
231
  OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
223
232
  if (optionalParams === void 0) { optionalParams = {}; }
224
233
  return __awaiter(this, void 0, void 0, function () {
225
- var _a, getLiveChatConfigOptionalParams, _b, _c, _d;
226
- return __generator(this, function (_e) {
227
- switch (_e.label) {
234
+ var _a, getLiveChatConfigOptionalParams, _b, _c, e_1;
235
+ return __generator(this, function (_d) {
236
+ switch (_d.label) {
228
237
  case 0:
229
238
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDK);
230
239
  if (this.isInitialized) {
231
240
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
232
241
  return [2 /*return*/, this.liveChatConfig];
233
242
  }
234
- _e.label = 1;
243
+ _d.label = 1;
235
244
  case 1:
236
- _e.trys.push([1, 8, , 9]);
245
+ _d.trys.push([1, 9, , 10]);
237
246
  this.OCSDKProvider = ocsdk_1.SDKProvider;
238
247
  _a = this;
239
248
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
240
249
  case 2:
241
- _a.OCClient = _e.sent();
250
+ _a.OCClient = _d.sent();
242
251
  getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
243
252
  return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
244
253
  case 3:
245
- _e.sent();
254
+ _d.sent();
246
255
  if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
247
256
  this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
248
257
  _b = this;
@@ -250,26 +259,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
250
259
  framedMode: platform_1.isBrowser(),
251
260
  multiClient: true,
252
261
  debug: false,
253
- logger: undefined
262
+ logger: this.amsClientLogger
254
263
  })];
255
264
  case 4:
256
- _b.AMSClient = _e.sent();
257
- return [3 /*break*/, 7];
265
+ _b.AMSClient = _d.sent();
266
+ return [3 /*break*/, 8];
258
267
  case 5:
268
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 7];
259
269
  _c = this;
260
270
  return [4 /*yield*/, this.getIC3Client()];
261
271
  case 6:
262
- _c.IC3Client = _e.sent();
263
- _e.label = 7;
264
- case 7:
272
+ _c.IC3Client = _d.sent();
273
+ return [3 /*break*/, 8];
274
+ case 7: throw new Error("Unsupported LiveChatVersion");
275
+ case 8:
265
276
  this.isInitialized = true;
266
277
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
267
- return [3 /*break*/, 9];
268
- case 8:
269
- _d = _e.sent();
270
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK);
271
- return [3 /*break*/, 9];
272
- case 9: return [2 /*return*/, this.liveChatConfig];
278
+ return [3 /*break*/, 10];
279
+ case 9:
280
+ e_1 = _d.sent();
281
+ this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK, {
282
+ ExceptionDetails: JSON.stringify(e_1)
283
+ });
284
+ return [3 /*break*/, 10];
285
+ case 10: return [2 /*return*/, this.liveChatConfig];
273
286
  }
274
287
  });
275
288
  });
@@ -359,44 +372,44 @@ var OmnichannelChatSDK = /** @class */ (function () {
359
372
  });
360
373
  };
361
374
  OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
362
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
375
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
363
376
  if (optionalParams === void 0) { optionalParams = {}; }
364
377
  return __awaiter(this, void 0, void 0, function () {
365
- var shouldReinitIC3Client, _v, reconnectableChatsParams, reconnectableChatsResponse, _w, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, _x, exceptionDetails, sessionInitOptionalParams, location_2, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _y, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _z, error_8, exceptionDetails;
378
+ var shouldReinitIC3Client, _w, reconnectableChatsParams, reconnectableChatsResponse, _x, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, _y, exceptionDetails, sessionInitOptionalParams, location_2, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _z, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _0, error_8, exceptionDetails;
366
379
  var _this = this;
367
- return __generator(this, function (_0) {
368
- switch (_0.label) {
380
+ return __generator(this, function (_1) {
381
+ switch (_1.label) {
369
382
  case 0:
370
383
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
371
384
  RequestId: this.requestId
372
385
  });
373
386
  shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
374
387
  if (!shouldReinitIC3Client) return [3 /*break*/, 2];
375
- _v = this;
388
+ _w = this;
376
389
  return [4 /*yield*/, this.getIC3Client()];
377
390
  case 1:
378
- _v.IC3Client = _0.sent();
379
- _0.label = 2;
391
+ _w.IC3Client = _1.sent();
392
+ _1.label = 2;
380
393
  case 2:
381
394
  if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
382
395
  this.reconnectId = optionalParams.reconnectId;
383
396
  }
384
397
  if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
385
- _0.label = 3;
398
+ _1.label = 3;
386
399
  case 3:
387
- _0.trys.push([3, 5, , 6]);
400
+ _1.trys.push([3, 5, , 6]);
388
401
  reconnectableChatsParams = {
389
402
  authenticatedUserToken: this.authenticatedUserToken
390
403
  };
391
404
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
392
405
  case 4:
393
- reconnectableChatsResponse = _0.sent();
406
+ reconnectableChatsResponse = _1.sent();
394
407
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
395
408
  this.reconnectId = reconnectableChatsResponse.reconnectid;
396
409
  }
397
410
  return [3 /*break*/, 6];
398
411
  case 5:
399
- _w = _0.sent();
412
+ _x = _1.sent();
400
413
  exceptionDetails = {
401
414
  response: "OCClientGetReconnectableChatsFailed"
402
415
  };
@@ -407,7 +420,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
407
420
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
408
421
  return [4 /*yield*/, this.getConversationDetails()];
409
422
  case 7:
410
- conversationDetails = _0.sent();
423
+ conversationDetails = _1.sent();
411
424
  if (Object.keys(conversationDetails).length === 0) {
412
425
  exceptionDetails = {
413
426
  response: "InvalidConversation"
@@ -432,30 +445,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
432
445
  console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
433
446
  throw Error(exceptionDetails.response);
434
447
  }
435
- _0.label = 8;
448
+ _1.label = 8;
436
449
  case 8:
437
450
  if (!this.authSettings) return [3 /*break*/, 14];
438
451
  if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
439
452
  return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
440
453
  case 9:
441
- _0.sent();
442
- _0.label = 10;
454
+ _1.sent();
455
+ _1.label = 10;
443
456
  case 10:
444
457
  if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
445
458
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
446
459
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
447
- _0.label = 11;
460
+ _1.label = 11;
448
461
  case 11:
449
- _0.trys.push([11, 13, , 14]);
462
+ _1.trys.push([11, 13, , 14]);
450
463
  return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
451
464
  authenticatedUserToken: this.authenticatedUserToken,
452
465
  chatId: this.chatToken.chatId
453
466
  })];
454
467
  case 12:
455
- _0.sent();
468
+ _1.sent();
456
469
  return [3 /*break*/, 14];
457
470
  case 13:
458
- _x = _0.sent();
471
+ _y = _1.sent();
459
472
  exceptionDetails = {
460
473
  response: "OCClientValidateAuthChatRecordFailed",
461
474
  message: "InvalidAuthChatRecord"
@@ -470,48 +483,49 @@ var OmnichannelChatSDK = /** @class */ (function () {
470
483
  if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
471
484
  return [4 /*yield*/, this.getChatToken(false)];
472
485
  case 15:
473
- _0.sent();
474
- _0.label = 16;
486
+ _1.sent();
487
+ _1.label = 16;
475
488
  case 16:
476
489
  (_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
477
490
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
478
491
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
479
492
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
480
493
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
494
+ (_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setChatId(this.chatToken.chatId || '');
481
495
  sessionInitOptionalParams = {
482
496
  initContext: {}
483
497
  };
484
498
  sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams);
485
499
  sessionInitOptionalParams.initContext.isProactiveChat = !!optionalParams.isProactiveChat;
486
- if (this.isPersistentChat && !((_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.disable)) {
500
+ if (this.isPersistentChat && !((_j = this.chatSDKConfig.persistentChat) === null || _j === void 0 ? void 0 : _j.disable)) {
487
501
  sessionInitOptionalParams.reconnectId = this.reconnectId;
488
502
  }
489
- else if (this.isChatReconnect && !((_j = this.chatSDKConfig.chatReconnect) === null || _j === void 0 ? void 0 : _j.disable) && !this.isPersistentChat) {
503
+ else if (this.isChatReconnect && !((_k = this.chatSDKConfig.chatReconnect) === null || _k === void 0 ? void 0 : _k.disable) && !this.isPersistentChat) {
490
504
  sessionInitOptionalParams.reconnectId = this.reconnectId;
491
505
  }
492
- if (!(((_l = (_k = this.liveChatConfig) === null || _k === void 0 ? void 0 : _k.LiveWSAndLiveChatEngJoin) === null || _l === void 0 ? void 0 : _l.msdyn_requestvisitorlocation) === "true")) return [3 /*break*/, 18];
506
+ if (!(((_m = (_l = this.liveChatConfig) === null || _l === void 0 ? void 0 : _l.LiveWSAndLiveChatEngJoin) === null || _m === void 0 ? void 0 : _m.msdyn_requestvisitorlocation) === "true")) return [3 /*break*/, 18];
493
507
  return [4 /*yield*/, location_1.getLocationInfo(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
494
508
  case 17:
495
- location_2 = _0.sent();
509
+ location_2 = _1.sent();
496
510
  sessionInitOptionalParams.initContext.latitude = location_2.latitude;
497
511
  sessionInitOptionalParams.initContext.longitude = location_2.longitude;
498
- _0.label = 18;
512
+ _1.label = 18;
499
513
  case 18:
500
514
  if (!!optionalParams.liveChatContext) return [3 /*break*/, 22];
501
- _0.label = 19;
515
+ _1.label = 19;
502
516
  case 19:
503
- _0.trys.push([19, 21, , 22]);
517
+ _1.trys.push([19, 21, , 22]);
504
518
  return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
505
519
  case 20:
506
- _0.sent();
520
+ _1.sent();
507
521
  return [3 /*break*/, 22];
508
522
  case 21:
509
- error_3 = _0.sent();
523
+ error_3 = _1.sent();
510
524
  exceptionDetails = {
511
525
  response: "OCClientSessionInitFailed"
512
526
  };
513
527
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
514
- if (((_m = error_3) === null || _m === void 0 ? void 0 : _m.isAxiosError) && ((_p = (_o = error_3.response) === null || _o === void 0 ? void 0 : _o.headers) === null || _p === void 0 ? void 0 : _p.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
528
+ if (((_o = error_3) === null || _o === void 0 ? void 0 : _o.isAxiosError) && ((_q = (_p = error_3.response) === null || _p === void 0 ? void 0 : _p.headers) === null || _q === void 0 ? void 0 : _q.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
515
529
  exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
516
530
  exceptionDetails.message = 'Widget used outside of operating hours';
517
531
  console.error(exceptionDetails.message);
@@ -531,18 +545,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
531
545
  environmentUrl: this.chatToken.acsEndpoint,
532
546
  pollingInterval: 30000
533
547
  };
534
- _0.label = 23;
548
+ _1.label = 23;
535
549
  case 23:
536
- _0.trys.push([23, 25, , 26]);
537
- return [4 /*yield*/, ((_q = this.ACSClient) === null || _q === void 0 ? void 0 : _q.initialize({
550
+ _1.trys.push([23, 25, , 26]);
551
+ return [4 /*yield*/, ((_r = this.ACSClient) === null || _r === void 0 ? void 0 : _r.initialize({
538
552
  token: chatAdapterConfig.token,
539
553
  environmentUrl: chatAdapterConfig.environmentUrl
540
554
  }))];
541
555
  case 24:
542
- _0.sent();
556
+ _1.sent();
543
557
  return [3 /*break*/, 26];
544
558
  case 25:
545
- error_4 = _0.sent();
559
+ error_4 = _1.sent();
546
560
  exceptionDetails = {
547
561
  response: "ACSClientInitializeFailed"
548
562
  };
@@ -554,22 +568,22 @@ var OmnichannelChatSDK = /** @class */ (function () {
554
568
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
555
569
  return [2 /*return*/, error_4];
556
570
  case 26:
557
- _0.trys.push([26, 28, , 29]);
558
- _y = this;
559
- return [4 /*yield*/, ((_r = this.ACSClient) === null || _r === void 0 ? void 0 : _r.joinConversation({
571
+ _1.trys.push([26, 28, , 29]);
572
+ _z = this;
573
+ return [4 /*yield*/, ((_s = this.ACSClient) === null || _s === void 0 ? void 0 : _s.joinConversation({
560
574
  id: chatAdapterConfig.id,
561
575
  threadId: chatAdapterConfig.threadId,
562
576
  pollingInterval: chatAdapterConfig.pollingInterval
563
577
  }))];
564
578
  case 27:
565
- _y.conversation = (_0.sent());
579
+ _z.conversation = (_1.sent());
566
580
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
567
581
  RequestId: this.requestId,
568
582
  ChatId: this.chatToken.chatId
569
583
  });
570
584
  return [3 /*break*/, 29];
571
585
  case 28:
572
- error_5 = _0.sent();
586
+ error_5 = _1.sent();
573
587
  exceptionDetails = {
574
588
  response: "ACSClientJoinConversationFailed"
575
589
  };
@@ -581,15 +595,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
581
595
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
582
596
  throw Error(exceptionDetails.response);
583
597
  case 29:
584
- _0.trys.push([29, 31, , 32]);
585
- return [4 /*yield*/, ((_s = this.AMSClient) === null || _s === void 0 ? void 0 : _s.initialize({
598
+ _1.trys.push([29, 31, , 32]);
599
+ return [4 /*yield*/, ((_t = this.AMSClient) === null || _t === void 0 ? void 0 : _t.initialize({
586
600
  chatToken: this.chatToken
587
601
  }))];
588
602
  case 30:
589
- _0.sent();
603
+ _1.sent();
590
604
  return [3 /*break*/, 32];
591
605
  case 31:
592
- error_6 = _0.sent();
606
+ error_6 = _1.sent();
593
607
  exceptionDetails = {
594
608
  response: "AMSClientInitializeFailed"
595
609
  };
@@ -601,17 +615,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
601
615
  throw Error(exceptionDetails.response);
602
616
  case 32: return [3 /*break*/, 39];
603
617
  case 33:
604
- _0.trys.push([33, 35, , 36]);
618
+ _1.trys.push([33, 35, , 36]);
605
619
  return [4 /*yield*/, this.IC3Client.initialize({
606
620
  token: this.chatToken.token,
607
621
  regionGtms: this.chatToken.regionGTMS,
608
622
  visitor: true
609
623
  })];
610
624
  case 34:
611
- _0.sent();
625
+ _1.sent();
612
626
  return [3 /*break*/, 36];
613
627
  case 35:
614
- error_7 = _0.sent();
628
+ error_7 = _1.sent();
615
629
  exceptionDetails = {
616
630
  response: "IC3ClientInitializeFailed"
617
631
  };
@@ -623,18 +637,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
623
637
  console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
624
638
  return [2 /*return*/, error_7];
625
639
  case 36:
626
- _0.trys.push([36, 38, , 39]);
627
- _z = this;
640
+ _1.trys.push([36, 38, , 39]);
641
+ _0 = this;
628
642
  return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
629
643
  case 37:
630
- _z.conversation = _0.sent();
644
+ _0.conversation = _1.sent();
631
645
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
632
646
  RequestId: this.requestId,
633
647
  ChatId: this.chatToken.chatId
634
648
  });
635
649
  return [3 /*break*/, 39];
636
650
  case 38:
637
- error_8 = _0.sent();
651
+ error_8 = _1.sent();
638
652
  exceptionDetails = {
639
653
  response: "IC3ClientJoinConversationFailed"
640
654
  };
@@ -646,7 +660,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
646
660
  console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
647
661
  return [2 /*return*/, error_8];
648
662
  case 39:
649
- if (this.isPersistentChat && !((_t = this.chatSDKConfig.persistentChat) === null || _t === void 0 ? void 0 : _t.disable)) {
663
+ if (this.isPersistentChat && !((_u = this.chatSDKConfig.persistentChat) === null || _u === void 0 ? void 0 : _u.disable)) {
650
664
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
651
665
  return __generator(this, function (_a) {
652
666
  switch (_a.label) {
@@ -657,7 +671,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
657
671
  return [2 /*return*/];
658
672
  }
659
673
  });
660
- }); }, (_u = this.chatSDKConfig.persistentChat) === null || _u === void 0 ? void 0 : _u.tokenUpdateTime);
674
+ }); }, (_v = this.chatSDKConfig.persistentChat) === null || _v === void 0 ? void 0 : _v.tokenUpdateTime);
661
675
  }
662
676
  return [2 /*return*/];
663
677
  }
@@ -665,11 +679,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
665
679
  });
666
680
  };
667
681
  OmnichannelChatSDK.prototype.endChat = function () {
668
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
682
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
669
683
  return __awaiter(this, void 0, void 0, function () {
670
684
  var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
671
- return __generator(this, function (_p) {
672
- switch (_p.label) {
685
+ return __generator(this, function (_r) {
686
+ switch (_r.label) {
673
687
  case 0:
674
688
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
675
689
  RequestId: this.requestId,
@@ -689,12 +703,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
689
703
  if (this.authenticatedUserToken) {
690
704
  sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
691
705
  }
692
- _p.label = 1;
706
+ _r.label = 1;
693
707
  case 1:
694
- _p.trys.push([1, 3, , 4]);
708
+ _r.trys.push([1, 3, , 4]);
695
709
  return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
696
710
  case 2:
697
- _p.sent();
711
+ _r.sent();
698
712
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
699
713
  RequestId: this.requestId,
700
714
  ChatId: this.chatToken.chatId
@@ -719,9 +733,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
719
733
  (_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
720
734
  (_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
721
735
  (_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
736
+ (_p = this.amsClientLogger) === null || _p === void 0 ? void 0 : _p.setRequestId(this.requestId);
737
+ (_q = this.amsClientLogger) === null || _q === void 0 ? void 0 : _q.setChatId('');
722
738
  return [3 /*break*/, 4];
723
739
  case 3:
724
- error_9 = _p.sent();
740
+ error_9 = _r.sent();
725
741
  exceptionDetails = {
726
742
  response: "OCClientSessionCloseFailed"
727
743
  };
@@ -1745,28 +1761,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
1745
1761
  };
1746
1762
  OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
1747
1763
  return __awaiter(this, void 0, void 0, function () {
1748
- var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, surveyInviteLinkRequest, optionalParams, ownerId, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1749
- return __generator(this, function (_a) {
1750
- switch (_a.label) {
1764
+ var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, agentSurveyInviteLinkRequest, botSurveyInviteLinkRequest, optionalParams, agentSurveyInviteLinkResponse, botSurveyInviteLinkResponse, _a, agentSurveyInviteLink, agentFormsProLocale, botSurveyInviteLink, botFormsProLocale, postChatContext, ex_1;
1765
+ return __generator(this, function (_b) {
1766
+ switch (_b.label) {
1751
1767
  case 0:
1752
1768
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1753
1769
  RequestId: this.requestId
1754
1770
  });
1755
- _a.label = 1;
1771
+ _b.label = 1;
1756
1772
  case 1:
1757
- _a.trys.push([1, 6, , 7]);
1773
+ _b.trys.push([1, 8, , 9]);
1758
1774
  chatConfig = this.liveChatConfig;
1759
1775
  liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
1760
1776
  msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId;
1761
- if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 4];
1777
+ if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 6];
1762
1778
  return [4 /*yield*/, this.getConversationDetails()];
1763
1779
  case 2:
1764
- liveWorkItemDetails = _a.sent();
1780
+ liveWorkItemDetails = _b.sent();
1765
1781
  participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.canRenderPostChat) === "True";
1766
1782
  participantType = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.participantType;
1767
1783
  conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.conversationId;
1768
- surveyInviteLinkRequest = {
1769
- "FormId": participantType === "Bot" ? msfp_botsourcesurveyidentifier : msfp_sourcesurveyidentifier,
1784
+ agentSurveyInviteLinkRequest = {
1785
+ "FormId": msfp_sourcesurveyidentifier,
1786
+ "ConversationId": conversationId,
1787
+ "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
1788
+ };
1789
+ botSurveyInviteLinkRequest = {
1790
+ "FormId": msfp_botsourcesurveyidentifier,
1770
1791
  "ConversationId": conversationId,
1771
1792
  "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
1772
1793
  };
@@ -1776,14 +1797,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
1776
1797
  if (this.authenticatedUserToken) {
1777
1798
  optionalParams.authenticatedUserToken = this.authenticatedUserToken;
1778
1799
  }
1779
- ownerId = participantType === "Bot" ? postConversationBotSurveyOwnerId : postConversationSurveyOwnerId;
1780
- return [4 /*yield*/, this.OCClient.getSurveyInviteLink(ownerId, surveyInviteLinkRequest, optionalParams)];
1800
+ return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, agentSurveyInviteLinkRequest, optionalParams)];
1781
1801
  case 3:
1782
- surveyInviteLinkResponse = _a.sent();
1783
- surveyInviteLink = void 0, formsProLocale = void 0;
1784
- if (surveyInviteLinkResponse != null) {
1785
- if (surveyInviteLinkResponse.inviteList != null && surveyInviteLinkResponse.inviteList.length == 1) {
1786
- surveyInviteLink = surveyInviteLinkResponse.inviteList[0].invitationLink;
1802
+ agentSurveyInviteLinkResponse = _b.sent();
1803
+ _a = postConversationBotSurveyOwnerId && msfp_botsourcesurveyidentifier;
1804
+ if (!_a) return [3 /*break*/, 5];
1805
+ return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationBotSurveyOwnerId, botSurveyInviteLinkRequest, optionalParams)];
1806
+ case 4:
1807
+ _a = (_b.sent());
1808
+ _b.label = 5;
1809
+ case 5:
1810
+ botSurveyInviteLinkResponse = _a;
1811
+ agentSurveyInviteLink = void 0, agentFormsProLocale = void 0, botSurveyInviteLink = void 0, botFormsProLocale = void 0;
1812
+ if (agentSurveyInviteLinkResponse != null) {
1813
+ if (agentSurveyInviteLinkResponse.inviteList != null && agentSurveyInviteLinkResponse.inviteList.length == 1) {
1814
+ agentSurveyInviteLink = agentSurveyInviteLinkResponse.inviteList[0].invitationLink;
1787
1815
  }
1788
1816
  else {
1789
1817
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
@@ -1793,14 +1821,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
1793
1821
  });
1794
1822
  return [2 /*return*/, Promise.reject("Survey Invite link failed to send response.")];
1795
1823
  }
1796
- if (surveyInviteLinkResponse.formsProLocaleCode != null) {
1797
- formsProLocale = surveyInviteLinkResponse.formsProLocaleCode;
1824
+ if (agentSurveyInviteLinkResponse.formsProLocaleCode != null) {
1825
+ agentFormsProLocale = agentSurveyInviteLinkResponse.formsProLocaleCode;
1826
+ }
1827
+ if (botSurveyInviteLinkResponse != null) {
1828
+ if (botSurveyInviteLinkResponse.inviteList != null && botSurveyInviteLinkResponse.inviteList.length == 1) {
1829
+ botSurveyInviteLink = botSurveyInviteLinkResponse.inviteList[0].invitationLink;
1830
+ }
1831
+ if (botSurveyInviteLinkResponse.formsProLocaleCode != null) {
1832
+ botFormsProLocale = botSurveyInviteLinkResponse.formsProLocaleCode;
1833
+ }
1798
1834
  }
1799
1835
  postChatContext = {
1800
1836
  participantJoined: participantJoined,
1801
1837
  participantType: participantType,
1802
- surveyInviteLink: surveyInviteLink,
1803
- formsProLocale: formsProLocale
1838
+ surveyInviteLink: agentSurveyInviteLink,
1839
+ botSurveyInviteLink: botSurveyInviteLink,
1840
+ formsProLocale: agentFormsProLocale,
1841
+ botFormsProLocale: botFormsProLocale
1804
1842
  };
1805
1843
  return [2 /*return*/, Promise.resolve(postChatContext)];
1806
1844
  }
@@ -1812,23 +1850,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
1812
1850
  });
1813
1851
  return [2 /*return*/, Promise.reject("surveyInviteLinkResponse is null.")];
1814
1852
  }
1815
- return [3 /*break*/, 5];
1816
- case 4:
1853
+ return [3 /*break*/, 7];
1854
+ case 6:
1817
1855
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1818
1856
  RequestId: this.requestId,
1819
1857
  ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
1820
1858
  });
1821
1859
  return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side.")];
1822
- case 5: return [3 /*break*/, 7];
1823
- case 6:
1824
- ex_1 = _a.sent();
1860
+ case 7: return [3 /*break*/, 9];
1861
+ case 8:
1862
+ ex_1 = _b.sent();
1825
1863
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1826
1864
  ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
1827
1865
  RequestId: this.requestId,
1828
1866
  ExceptionDetails: JSON.stringify(ex_1)
1829
1867
  });
1830
1868
  return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_1))];
1831
- case 7: return [2 /*return*/];
1869
+ case 9: return [2 /*return*/];
1832
1870
  }
1833
1871
  });
1834
1872
  });
@@ -1836,7 +1874,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1836
1874
  OmnichannelChatSDK.prototype.getAgentAvailability = function (optionalParams) {
1837
1875
  if (optionalParams === void 0) { optionalParams = {}; }
1838
1876
  return __awaiter(this, void 0, void 0, function () {
1839
- var reportError, getAgentAvailabilityOptionalParams, response, e_1;
1877
+ var reportError, getAgentAvailabilityOptionalParams, response, e_2;
1840
1878
  var _this = this;
1841
1879
  return __generator(this, function (_a) {
1842
1880
  switch (_a.label) {
@@ -1878,9 +1916,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
1878
1916
  response = _a.sent();
1879
1917
  return [2 /*return*/, response];
1880
1918
  case 3:
1881
- e_1 = _a.sent();
1919
+ e_2 = _a.sent();
1882
1920
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1883
- reportError("GetAgentAvailabilityFailed", e_1.message);
1921
+ reportError("GetAgentAvailabilityFailed", e_2.message);
1884
1922
  return [3 /*break*/, 4];
1885
1923
  case 4: return [2 /*return*/];
1886
1924
  }