@microsoft/omnichannel-chat-sdk 1.2.1-main.f777b2c → 1.3.1-main.15e43e2

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 (51) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +14 -3
  3. package/lib/OmnichannelChatSDK.d.ts +7 -2
  4. package/lib/OmnichannelChatSDK.js +411 -337
  5. package/lib/OmnichannelChatSDK.js.map +1 -1
  6. package/lib/config/settings.d.ts +1 -1
  7. package/lib/config/settings.js +1 -1
  8. package/lib/core/ChatSDKErrors.d.ts +47 -1
  9. package/lib/core/ChatSDKErrors.js +46 -0
  10. package/lib/core/ChatSDKErrors.js.map +1 -1
  11. package/lib/core/ChatSDKExceptionDetails.d.ts +8 -0
  12. package/lib/core/GetAgentAvailabilityOptionalParams.d.ts +13 -0
  13. package/lib/core/GetAgentAvailabilityOptionalParams.js +3 -0
  14. package/lib/core/GetAgentAvailabilityOptionalParams.js.map +1 -0
  15. package/lib/core/GetLiveChatTranscriptOptionalParams.d.ts +4 -0
  16. package/lib/core/GetLiveChatTranscriptOptionalParams.js +3 -0
  17. package/lib/core/GetLiveChatTranscriptOptionalParams.js.map +1 -0
  18. package/lib/core/PostChatContext.d.ts +2 -0
  19. package/lib/core/StartChatOptionalParams.d.ts +4 -0
  20. package/lib/core/messaging/ACSClient.js +5 -0
  21. package/lib/core/messaging/ACSClient.js.map +1 -1
  22. package/lib/external/ACSAdapter/AMSFileManager.js +2 -1
  23. package/lib/external/ACSAdapter/AMSFileManager.js.map +1 -1
  24. package/lib/telemetry/AriaTelemetry.d.ts +1 -0
  25. package/lib/telemetry/AriaTelemetry.js +49 -0
  26. package/lib/telemetry/AriaTelemetry.js.map +1 -1
  27. package/lib/telemetry/ScenarioType.d.ts +1 -0
  28. package/lib/telemetry/ScenarioType.js +1 -0
  29. package/lib/telemetry/ScenarioType.js.map +1 -1
  30. package/lib/telemetry/TelemetryEvent.d.ts +3 -1
  31. package/lib/telemetry/TelemetryEvent.js +2 -0
  32. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  33. package/lib/tsconfig.tsbuildinfo +217 -104
  34. package/lib/utils/WebUtils.d.ts +2 -2
  35. package/lib/utils/WebUtils.js +30 -4
  36. package/lib/utils/WebUtils.js.map +1 -1
  37. package/lib/utils/chatAdapterCreators.js +37 -39
  38. package/lib/utils/chatAdapterCreators.js.map +1 -1
  39. package/lib/utils/exceptionThrowers.d.ts +111 -0
  40. package/lib/utils/exceptionThrowers.js +129 -0
  41. package/lib/utils/exceptionThrowers.js.map +1 -0
  42. package/lib/utils/location.d.ts +7 -0
  43. package/lib/utils/location.js +96 -0
  44. package/lib/utils/location.js.map +1 -0
  45. package/lib/utils/loggers.d.ts +16 -0
  46. package/lib/utils/loggers.js +69 -1
  47. package/lib/utils/loggers.js.map +1 -1
  48. package/lib/utils/sleep.d.ts +2 -0
  49. package/lib/utils/sleep.js +5 -0
  50. package/lib/utils/sleep.js.map +1 -0
  51. package/package.json +3 -3
@@ -58,6 +58,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
58
58
  var loggers_1 = require("./utils/loggers");
59
59
  var ACSClient_1 = require("./core/messaging/ACSClient");
60
60
  var ocsdk_1 = require("@microsoft/ocsdk");
61
+ var chatAdapterCreators_1 = require("./utils/chatAdapterCreators");
61
62
  var locale_1 = require("./utils/locale");
62
63
  var WebUtils_1 = require("./utils/WebUtils");
63
64
  var platform_1 = require("./utils/platform");
@@ -67,7 +68,6 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
67
68
  var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
68
69
  var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
69
70
  var ChatSDKErrors_1 = require("./core/ChatSDKErrors");
70
- var chatAdapterCreators_1 = require("./utils/chatAdapterCreators");
71
71
  var ConversationMode_1 = require("./core/ConversationMode");
72
72
  var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
73
73
  var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
@@ -87,13 +87,16 @@ var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
87
87
  var createTelemetry_1 = require("./utils/createTelemetry");
88
88
  var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
89
89
  var MessageTags_1 = require("./core/messaging/MessageTags");
90
+ var exceptionThrowers_1 = require("./utils/exceptionThrowers");
91
+ var location_1 = require("./utils/location");
90
92
  var utilities_1 = require("./utils/utilities");
91
93
  var urlResolvers_1 = require("./utils/urlResolvers");
92
94
  var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
93
95
  var OmnichannelChatSDK = /** @class */ (function () {
94
96
  function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
97
+ var _this = this;
95
98
  if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
96
- var _a, _b, _c, _d, _e, _f, _g, _h;
99
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
97
100
  this.ACSClient = null;
98
101
  this.AMSClient = null;
99
102
  this.authSettings = null;
@@ -106,17 +109,65 @@ var OmnichannelChatSDK = /** @class */ (function () {
106
109
  this.acsClientLogger = null;
107
110
  this.acsAdapterLogger = null;
108
111
  this.callingSdkLogger = null;
112
+ this.amsClientLogger = null;
109
113
  this.isPersistentChat = false;
110
114
  this.isChatReconnect = false;
111
115
  this.reconnectId = null;
112
116
  this.refreshTokenTimer = null;
117
+ this.populateInitChatOptionalParam = function (requestOptionalParams, optionalParams, telemetryEvent) {
118
+ requestOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(_this.localeId);
119
+ if (optionalParams.customContext) {
120
+ requestOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any
121
+ }
122
+ if (optionalParams.browser) {
123
+ requestOptionalParams.initContext.browser = optionalParams.browser;
124
+ }
125
+ if (optionalParams.os) {
126
+ requestOptionalParams.initContext.os = optionalParams.os;
127
+ }
128
+ if (optionalParams.locale) {
129
+ requestOptionalParams.initContext.locale = optionalParams.locale;
130
+ }
131
+ if (optionalParams.device) {
132
+ requestOptionalParams.initContext.device = optionalParams.device;
133
+ }
134
+ if (optionalParams.preChatResponse) {
135
+ requestOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
136
+ }
137
+ if (optionalParams.portalContactId) {
138
+ requestOptionalParams.initContext.portalcontactid = optionalParams.portalContactId;
139
+ }
140
+ if (optionalParams.sendDefaultInitContext) {
141
+ if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
142
+ var message = "sendDefaultInitContext is only supported on browser";
143
+ var telemetryData = {
144
+ RequestId: _this.requestId,
145
+ ChatId: _this.chatToken.chatId
146
+ };
147
+ exceptionThrowers_1.default.throwUnsupportedPlatform(_this.scenarioMarker, telemetryEvent, message, telemetryData);
148
+ }
149
+ requestOptionalParams.getContext = true;
150
+ }
151
+ // Override initContext completely
152
+ if (optionalParams.initContext) {
153
+ requestOptionalParams.initContext = optionalParams.initContext;
154
+ }
155
+ if (_this.authenticatedUserToken) {
156
+ requestOptionalParams.authenticatedUserToken = _this.authenticatedUserToken;
157
+ }
158
+ if (_this.chatToken.chatId) {
159
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
160
+ requestOptionalParams.initContext.chatId = _this.chatToken.chatId;
161
+ }
162
+ return requestOptionalParams;
163
+ };
113
164
  this.debug = false;
114
165
  this.runtimeId = ocsdk_1.uuidv4();
115
166
  this.omnichannelConfig = omnichannelConfig;
116
167
  this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
117
168
  );
118
169
  this.isInitialized = false;
119
- this.liveChatVersion = LiveChatVersion_1.default.V1;
170
+ this.liveChatVersion = LiveChatVersion_1.default.V2;
120
171
  this.localeId = locale_1.defaultLocaleId;
121
172
  this.requestId = ocsdk_1.uuidv4();
122
173
  this.chatToken = {};
@@ -131,18 +182,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
131
182
  this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
132
183
  this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
133
184
  this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
185
+ this.amsClientLogger = loggers_1.createAMSClientLogger(this.omnichannelConfig);
134
186
  this.scenarioMarker.useTelemetry(this.telemetry);
135
187
  this.ic3ClientLogger.useTelemetry(this.telemetry);
136
188
  this.ocSdkLogger.useTelemetry(this.telemetry);
137
189
  this.acsClientLogger.useTelemetry(this.telemetry);
138
190
  this.acsAdapterLogger.useTelemetry(this.telemetry);
139
191
  this.callingSdkLogger.useTelemetry(this.telemetry);
192
+ this.amsClientLogger.useTelemetry(this.telemetry);
140
193
  this.scenarioMarker.setRuntimeId(this.runtimeId);
141
194
  this.ic3ClientLogger.setRuntimeId(this.runtimeId);
142
195
  this.ocSdkLogger.setRuntimeId(this.runtimeId);
143
196
  this.acsClientLogger.setRuntimeId(this.runtimeId);
144
197
  this.acsAdapterLogger.setRuntimeId(this.runtimeId);
145
198
  this.callingSdkLogger.setRuntimeId(this.runtimeId);
199
+ this.amsClientLogger.setRuntimeId(this.runtimeId);
146
200
  OmnichannelConfigValidator_1.default(omnichannelConfig);
147
201
  SDKConfigValidators_1.default(chatSDKConfig);
148
202
  ((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
@@ -154,10 +208,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
154
208
  (_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
155
209
  (_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
156
210
  (_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
211
+ (_j = this.amsClientLogger) === null || _j === void 0 ? void 0 : _j.setRequestId(this.requestId);
157
212
  }
158
213
  /* istanbul ignore next */
159
214
  OmnichannelChatSDK.prototype.setDebug = function (flag) {
160
- var _a, _b, _c, _d, _e, _f, _g;
215
+ var _a, _b, _c, _d, _e, _f, _g, _h;
161
216
  this.debug = flag;
162
217
  (_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
163
218
  (_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
@@ -167,58 +222,80 @@ var OmnichannelChatSDK = /** @class */ (function () {
167
222
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
168
223
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
169
224
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
225
+ (_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setDebug(flag);
170
226
  };
171
227
  OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
172
228
  if (optionalParams === void 0) { optionalParams = {}; }
173
229
  return __awaiter(this, void 0, void 0, function () {
174
- var _a, getLiveChatConfigOptionalParams, _b, _c, _d;
175
- return __generator(this, function (_e) {
176
- switch (_e.label) {
230
+ var _a, e_1, getLiveChatConfigOptionalParams, e_2, supportedLiveChatVersions, _b, _c, e_3;
231
+ return __generator(this, function (_d) {
232
+ switch (_d.label) {
177
233
  case 0:
178
234
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializeChatSDK);
179
235
  if (this.isInitialized) {
180
236
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
181
237
  return [2 /*return*/, this.liveChatConfig];
182
238
  }
183
- _e.label = 1;
239
+ _d.label = 1;
184
240
  case 1:
185
- _e.trys.push([1, 8, , 9]);
241
+ _d.trys.push([1, 3, , 4]);
186
242
  this.OCSDKProvider = ocsdk_1.SDKProvider;
187
243
  _a = this;
188
244
  return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
189
245
  case 2:
190
- _a.OCClient = _e.sent();
246
+ _a.OCClient = _d.sent();
247
+ return [3 /*break*/, 4];
248
+ case 3:
249
+ e_1 = _d.sent();
250
+ exceptionThrowers_1.default.throwOmnichannelClientInitializationFailure(e_1, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
251
+ return [3 /*break*/, 4];
252
+ case 4:
253
+ _d.trys.push([4, 6, , 7]);
191
254
  getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
192
255
  return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
193
- case 3:
194
- _e.sent();
195
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
256
+ case 5:
257
+ _d.sent();
258
+ return [3 /*break*/, 7];
259
+ case 6:
260
+ e_2 = _d.sent();
261
+ exceptionThrowers_1.default.throwChatConfigRetrievalFailure(e_2, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
262
+ return [3 /*break*/, 7];
263
+ case 7:
264
+ supportedLiveChatVersions = [LiveChatVersion_1.default.V1, LiveChatVersion_1.default.V2];
265
+ if (!supportedLiveChatVersions.includes(this.liveChatVersion)) {
266
+ exceptionThrowers_1.default.throwUnsupportedLiveChatVersionFailure(new Error(ChatSDKErrors_1.default.UnsupportedLiveChatVersion), this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
267
+ }
268
+ _d.label = 8;
269
+ case 8:
270
+ _d.trys.push([8, 13, , 14]);
271
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 10];
196
272
  this.ACSClient = new ACSClient_1.default(this.acsClientLogger);
197
273
  _b = this;
198
274
  return [4 /*yield*/, omnichannel_amsclient_1.default({
199
275
  framedMode: platform_1.isBrowser(),
200
276
  multiClient: true,
201
277
  debug: false,
202
- logger: undefined
278
+ logger: this.amsClientLogger
203
279
  })];
204
- case 4:
205
- _b.AMSClient = _e.sent();
206
- return [3 /*break*/, 7];
207
- case 5:
280
+ case 9:
281
+ _b.AMSClient = _d.sent();
282
+ return [3 /*break*/, 12];
283
+ case 10:
284
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 12];
208
285
  _c = this;
209
286
  return [4 /*yield*/, this.getIC3Client()];
210
- case 6:
211
- _c.IC3Client = _e.sent();
212
- _e.label = 7;
213
- case 7:
287
+ case 11:
288
+ _c.IC3Client = _d.sent();
289
+ _d.label = 12;
290
+ case 12:
214
291
  this.isInitialized = true;
215
292
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
216
- return [3 /*break*/, 9];
217
- case 8:
218
- _d = _e.sent();
219
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializeChatSDK);
220
- return [3 /*break*/, 9];
221
- case 9: return [2 /*return*/, this.liveChatConfig];
293
+ return [3 /*break*/, 14];
294
+ case 13:
295
+ e_3 = _d.sent();
296
+ exceptionThrowers_1.default.throwMessagingClientCreationFailure(e_3, this.scenarioMarker, TelemetryEvent_1.default.InitializeChatSDK);
297
+ return [3 /*break*/, 14];
298
+ case 14: return [2 /*return*/, this.liveChatConfig];
222
299
  }
223
300
  });
224
301
  });
@@ -308,207 +385,159 @@ var OmnichannelChatSDK = /** @class */ (function () {
308
385
  });
309
386
  };
310
387
  OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
311
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
388
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
312
389
  if (optionalParams === void 0) { optionalParams = {}; }
313
390
  return __awaiter(this, void 0, void 0, function () {
314
- var shouldReinitIC3Client, _t, reconnectableChatsParams, reconnectableChatsResponse, _u, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, _v, exceptionDetails, sessionInitOptionalParams, exceptionDetails, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _w, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _x, error_8, exceptionDetails;
391
+ var shouldReinitIC3Client, _w, reconnectableChatsParams, reconnectableChatsResponse, e_4, telemetryData, conversationDetails, telemetryData, telemetryData, e_5, telemetryData, sessionInitOptionalParams, location_2, error_3, telemetryData, chatAdapterConfig, error_4, telemetryData, _x, error_5, telemetryData, error_6, telemetryData, error_7, telemetryData, _y, error_8, telemetryData;
315
392
  var _this = this;
316
- return __generator(this, function (_y) {
317
- switch (_y.label) {
393
+ return __generator(this, function (_z) {
394
+ switch (_z.label) {
318
395
  case 0:
319
396
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
320
397
  RequestId: this.requestId
321
398
  });
399
+ if (!this.isInitialized) {
400
+ exceptionThrowers_1.default.throwUninitializedChatSDK(this.scenarioMarker, TelemetryEvent_1.default.StartChat);
401
+ }
322
402
  shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
323
403
  if (!shouldReinitIC3Client) return [3 /*break*/, 2];
324
- _t = this;
404
+ _w = this;
325
405
  return [4 /*yield*/, this.getIC3Client()];
326
406
  case 1:
327
- _t.IC3Client = _y.sent();
328
- _y.label = 2;
407
+ _w.IC3Client = _z.sent();
408
+ _z.label = 2;
329
409
  case 2:
330
410
  if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
331
411
  this.reconnectId = optionalParams.reconnectId;
332
412
  }
333
413
  if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
334
- _y.label = 3;
414
+ _z.label = 3;
335
415
  case 3:
336
- _y.trys.push([3, 5, , 6]);
416
+ _z.trys.push([3, 5, , 6]);
337
417
  reconnectableChatsParams = {
338
418
  authenticatedUserToken: this.authenticatedUserToken
339
419
  };
340
420
  return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
341
421
  case 4:
342
- reconnectableChatsResponse = _y.sent();
422
+ reconnectableChatsResponse = _z.sent();
343
423
  if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
344
424
  this.reconnectId = reconnectableChatsResponse.reconnectid;
345
425
  }
346
426
  return [3 /*break*/, 6];
347
427
  case 5:
348
- _u = _y.sent();
349
- exceptionDetails = {
350
- response: "OCClientGetReconnectableChatsFailed"
428
+ e_4 = _z.sent();
429
+ telemetryData = {
430
+ RequestId: this.requestId,
431
+ ChatId: this.chatToken.chatId,
351
432
  };
352
- throw Error(exceptionDetails.response);
433
+ exceptionThrowers_1.default.throwPersistentChatConversationRetrievalFailure(e_4, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
434
+ return [3 /*break*/, 6];
353
435
  case 6:
354
436
  if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0 && !this.reconnectId)) return [3 /*break*/, 8];
355
437
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
356
438
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
357
439
  return [4 /*yield*/, this.getConversationDetails()];
358
440
  case 7:
359
- conversationDetails = _y.sent();
441
+ conversationDetails = _z.sent();
360
442
  if (Object.keys(conversationDetails).length === 0) {
361
- exceptionDetails = {
362
- response: "InvalidConversation"
363
- };
364
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
443
+ telemetryData = {
365
444
  RequestId: this.requestId,
366
445
  ChatId: this.chatToken.chatId,
367
- ExceptionDetails: JSON.stringify(exceptionDetails)
368
- });
369
- console.error("Conversation not found");
370
- throw Error(exceptionDetails.response);
446
+ };
447
+ exceptionThrowers_1.default.throwInvalidConversation(this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
371
448
  }
372
449
  if (conversationDetails.state === LiveWorkItemState_1.default.WrapUp || conversationDetails.state === LiveWorkItemState_1.default.Closed) {
373
- exceptionDetails = {
374
- response: "ClosedConversation"
375
- };
376
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
450
+ console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
451
+ telemetryData = {
377
452
  RequestId: this.requestId,
378
453
  ChatId: this.chatToken.chatId,
379
- ExceptionDetails: JSON.stringify(exceptionDetails)
380
- });
381
- console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
382
- throw Error(exceptionDetails.response);
454
+ };
455
+ exceptionThrowers_1.default.throwClosedConversation(this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
383
456
  }
384
- _y.label = 8;
457
+ _z.label = 8;
385
458
  case 8:
386
459
  if (!this.authSettings) return [3 /*break*/, 14];
387
460
  if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
388
461
  return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
389
462
  case 9:
390
- _y.sent();
391
- _y.label = 10;
463
+ _z.sent();
464
+ _z.label = 10;
392
465
  case 10:
393
466
  if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
394
467
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
395
468
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
396
- _y.label = 11;
469
+ _z.label = 11;
397
470
  case 11:
398
- _y.trys.push([11, 13, , 14]);
471
+ _z.trys.push([11, 13, , 14]);
399
472
  return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
400
473
  authenticatedUserToken: this.authenticatedUserToken,
401
474
  chatId: this.chatToken.chatId
402
475
  })];
403
476
  case 12:
404
- _y.sent();
477
+ _z.sent();
405
478
  return [3 /*break*/, 14];
406
479
  case 13:
407
- _v = _y.sent();
408
- exceptionDetails = {
409
- response: "OCClientValidateAuthChatRecordFailed",
410
- message: "InvalidAuthChatRecord"
411
- };
412
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
480
+ e_5 = _z.sent();
481
+ telemetryData = {
413
482
  RequestId: this.requestId,
414
483
  ChatId: this.chatToken.chatId,
415
- ExceptionDetails: JSON.stringify(exceptionDetails)
416
- });
417
- throw Error(exceptionDetails.response);
484
+ };
485
+ exceptionThrowers_1.default.throwAuthenticatedChatConversationRetrievalFailure(e_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
486
+ return [3 /*break*/, 14];
418
487
  case 14:
419
488
  if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
420
489
  return [4 /*yield*/, this.getChatToken(false)];
421
490
  case 15:
422
- _y.sent();
423
- _y.label = 16;
491
+ _z.sent();
492
+ _z.label = 16;
424
493
  case 16:
425
494
  (_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
426
495
  (_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
427
496
  (_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
428
497
  (_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
429
498
  (_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
499
+ (_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setChatId(this.chatToken.chatId || '');
430
500
  sessionInitOptionalParams = {
431
501
  initContext: {}
432
502
  };
433
- sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
434
- if (this.isPersistentChat && !((_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.disable)) {
503
+ sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams, TelemetryEvent_1.default.StartChat);
504
+ sessionInitOptionalParams.initContext.isProactiveChat = !!optionalParams.isProactiveChat;
505
+ if (this.isPersistentChat && !((_j = this.chatSDKConfig.persistentChat) === null || _j === void 0 ? void 0 : _j.disable)) {
435
506
  sessionInitOptionalParams.reconnectId = this.reconnectId;
436
507
  }
437
- if (this.isChatReconnect && !((_j = this.chatSDKConfig.chatReconnect) === null || _j === void 0 ? void 0 : _j.disable) && !this.isPersistentChat) {
508
+ else if (this.isChatReconnect && !((_k = this.chatSDKConfig.chatReconnect) === null || _k === void 0 ? void 0 : _k.disable) && !this.isPersistentChat) {
438
509
  sessionInitOptionalParams.reconnectId = this.reconnectId;
439
510
  }
440
- if (optionalParams.customContext) {
441
- sessionInitOptionalParams.initContext.customContextData = optionalParams.customContext; // eslint-disable-line @typescript-eslint/no-explicit-any
442
- }
443
- if (optionalParams.browser) {
444
- sessionInitOptionalParams.initContext.browser = optionalParams.browser;
445
- }
446
- if (optionalParams.os) {
447
- sessionInitOptionalParams.initContext.os = optionalParams.os;
448
- }
449
- if (optionalParams.locale) {
450
- sessionInitOptionalParams.initContext.locale = optionalParams.locale;
451
- }
452
- if (optionalParams.device) {
453
- sessionInitOptionalParams.initContext.device = optionalParams.device;
454
- }
455
- if (optionalParams.preChatResponse) {
456
- sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
457
- }
458
- if (optionalParams.sendDefaultInitContext) {
459
- if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
460
- exceptionDetails = {
461
- response: ChatSDKErrors_1.default.UnsupportedPlatform,
462
- message: "sendDefaultInitContext is only supported on browser"
463
- };
464
- console.error(exceptionDetails.message);
465
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
466
- RequestId: this.requestId,
467
- ChatId: this.chatToken.chatId,
468
- ExceptionDetails: JSON.stringify(exceptionDetails)
469
- });
470
- throw new Error(exceptionDetails.response);
471
- }
472
- sessionInitOptionalParams.getContext = true;
473
- }
474
- // Override initContext completely
475
- if (optionalParams.initContext) {
476
- sessionInitOptionalParams.initContext = optionalParams.initContext;
477
- }
478
- if (this.authenticatedUserToken) {
479
- sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
480
- }
481
- if (this.chatToken.chatId) {
482
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
483
- sessionInitOptionalParams.initContext.chatId = this.chatToken.chatId;
484
- }
485
- if (!!optionalParams.liveChatContext) return [3 /*break*/, 20];
486
- _y.label = 17;
511
+ 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];
512
+ return [4 /*yield*/, location_1.getLocationInfo(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
487
513
  case 17:
488
- _y.trys.push([17, 19, , 20]);
489
- return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
514
+ location_2 = _z.sent();
515
+ sessionInitOptionalParams.initContext.latitude = location_2.latitude;
516
+ sessionInitOptionalParams.initContext.longitude = location_2.longitude;
517
+ _z.label = 18;
490
518
  case 18:
491
- _y.sent();
492
- return [3 /*break*/, 20];
519
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 22];
520
+ _z.label = 19;
493
521
  case 19:
494
- error_3 = _y.sent();
495
- exceptionDetails = {
496
- response: "OCClientSessionInitFailed"
522
+ _z.trys.push([19, 21, , 22]);
523
+ return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
524
+ case 20:
525
+ _z.sent();
526
+ return [3 /*break*/, 22];
527
+ case 21:
528
+ error_3 = _z.sent();
529
+ telemetryData = {
530
+ RequestId: this.requestId,
531
+ ChatId: this.chatToken.chatId,
497
532
  };
498
533
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
499
- if (((_k = error_3) === null || _k === void 0 ? void 0 : _k.isAxiosError) && ((_m = (_l = error_3.response) === null || _l === void 0 ? void 0 : _l.headers) === null || _m === void 0 ? void 0 : _m.errorcode.toString()) === OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour.toString()) {
500
- exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
501
- exceptionDetails.message = 'Widget used outside of operating hours';
502
- console.error(exceptionDetails.message);
534
+ 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()) {
535
+ exceptionThrowers_1.default.throwWidgetUseOutsideOperatingHour(error_3, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
503
536
  }
504
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
505
- RequestId: this.requestId,
506
- ChatId: this.chatToken.chatId,
507
- ExceptionDetails: JSON.stringify(exceptionDetails)
508
- });
509
- throw new Error(exceptionDetails.response);
510
- case 20:
511
- if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 31];
537
+ exceptionThrowers_1.default.throwConversationInitializationFailure(error_3, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
538
+ return [3 /*break*/, 22];
539
+ case 22:
540
+ if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 33];
512
541
  chatAdapterConfig = {
513
542
  token: this.chatToken.token,
514
543
  id: this.chatToken.visitorId || 'teamsvisitor',
@@ -516,122 +545,103 @@ var OmnichannelChatSDK = /** @class */ (function () {
516
545
  environmentUrl: this.chatToken.acsEndpoint,
517
546
  pollingInterval: 30000
518
547
  };
519
- _y.label = 21;
520
- case 21:
521
- _y.trys.push([21, 23, , 24]);
522
- return [4 /*yield*/, ((_o = this.ACSClient) === null || _o === void 0 ? void 0 : _o.initialize({
548
+ _z.label = 23;
549
+ case 23:
550
+ _z.trys.push([23, 25, , 26]);
551
+ return [4 /*yield*/, ((_r = this.ACSClient) === null || _r === void 0 ? void 0 : _r.initialize({
523
552
  token: chatAdapterConfig.token,
524
553
  environmentUrl: chatAdapterConfig.environmentUrl
525
554
  }))];
526
- case 22:
527
- _y.sent();
528
- return [3 /*break*/, 24];
529
- case 23:
530
- error_4 = _y.sent();
531
- exceptionDetails = {
532
- response: "ACSClientInitializeFailed"
533
- };
534
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
555
+ case 24:
556
+ _z.sent();
557
+ return [3 /*break*/, 26];
558
+ case 25:
559
+ error_4 = _z.sent();
560
+ telemetryData = {
535
561
  RequestId: this.requestId,
536
562
  ChatId: this.chatToken.chatId,
537
- ExceptionDetails: JSON.stringify(exceptionDetails)
538
- });
539
- console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
540
- return [2 /*return*/, error_4];
541
- case 24:
542
- _y.trys.push([24, 26, , 27]);
543
- _w = this;
544
- return [4 /*yield*/, ((_p = this.ACSClient) === null || _p === void 0 ? void 0 : _p.joinConversation({
563
+ };
564
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_4, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
565
+ return [3 /*break*/, 26];
566
+ case 26:
567
+ _z.trys.push([26, 28, , 29]);
568
+ _x = this;
569
+ return [4 /*yield*/, ((_s = this.ACSClient) === null || _s === void 0 ? void 0 : _s.joinConversation({
545
570
  id: chatAdapterConfig.id,
546
571
  threadId: chatAdapterConfig.threadId,
547
572
  pollingInterval: chatAdapterConfig.pollingInterval
548
573
  }))];
549
- case 25:
550
- _w.conversation = (_y.sent());
574
+ case 27:
575
+ _x.conversation = (_z.sent());
551
576
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
552
577
  RequestId: this.requestId,
553
578
  ChatId: this.chatToken.chatId
554
579
  });
555
- return [3 /*break*/, 27];
556
- case 26:
557
- error_5 = _y.sent();
558
- exceptionDetails = {
559
- response: "ACSClientJoinConversationFailed"
560
- };
561
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
580
+ return [3 /*break*/, 29];
581
+ case 28:
582
+ error_5 = _z.sent();
583
+ telemetryData = {
562
584
  RequestId: this.requestId,
563
585
  ChatId: this.chatToken.chatId,
564
- ExceptionDetails: JSON.stringify(exceptionDetails)
565
- });
566
- console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
567
- throw Error(exceptionDetails.response);
568
- case 27:
569
- _y.trys.push([27, 29, , 30]);
570
- return [4 /*yield*/, ((_q = this.AMSClient) === null || _q === void 0 ? void 0 : _q.initialize({
586
+ };
587
+ exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_5, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
588
+ return [3 /*break*/, 29];
589
+ case 29:
590
+ _z.trys.push([29, 31, , 32]);
591
+ return [4 /*yield*/, ((_t = this.AMSClient) === null || _t === void 0 ? void 0 : _t.initialize({
571
592
  chatToken: this.chatToken
572
593
  }))];
573
- case 28:
574
- _y.sent();
575
- return [3 /*break*/, 30];
576
- case 29:
577
- error_6 = _y.sent();
578
- exceptionDetails = {
579
- response: "AMSClientInitializeFailed"
580
- };
581
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
594
+ case 30:
595
+ _z.sent();
596
+ return [3 /*break*/, 32];
597
+ case 31:
598
+ error_6 = _z.sent();
599
+ telemetryData = {
582
600
  RequestId: this.requestId,
583
601
  ChatId: this.chatToken.chatId,
584
- ExceptionDetails: JSON.stringify(exceptionDetails)
585
- });
586
- throw Error(exceptionDetails.response);
587
- case 30: return [3 /*break*/, 37];
588
- case 31:
589
- _y.trys.push([31, 33, , 34]);
602
+ };
603
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_6, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
604
+ return [3 /*break*/, 32];
605
+ case 32: return [3 /*break*/, 39];
606
+ case 33:
607
+ _z.trys.push([33, 35, , 36]);
590
608
  return [4 /*yield*/, this.IC3Client.initialize({
591
609
  token: this.chatToken.token,
592
610
  regionGtms: this.chatToken.regionGTMS,
593
611
  visitor: true
594
612
  })];
595
- case 32:
596
- _y.sent();
597
- return [3 /*break*/, 34];
598
- case 33:
599
- error_7 = _y.sent();
600
- exceptionDetails = {
601
- response: "IC3ClientInitializeFailed"
602
- };
603
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
613
+ case 34:
614
+ _z.sent();
615
+ return [3 /*break*/, 36];
616
+ case 35:
617
+ error_7 = _z.sent();
618
+ telemetryData = {
604
619
  RequestId: this.requestId,
605
620
  ChatId: this.chatToken.chatId,
606
- ExceptionDetails: JSON.stringify(exceptionDetails)
607
- });
608
- console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
609
- return [2 /*return*/, error_7];
610
- case 34:
611
- _y.trys.push([34, 36, , 37]);
612
- _x = this;
621
+ };
622
+ exceptionThrowers_1.default.throwMessagingClientInitializationFailure(error_7, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
623
+ return [3 /*break*/, 36];
624
+ case 36:
625
+ _z.trys.push([36, 38, , 39]);
626
+ _y = this;
613
627
  return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
614
- case 35:
615
- _x.conversation = _y.sent();
628
+ case 37:
629
+ _y.conversation = _z.sent();
616
630
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
617
631
  RequestId: this.requestId,
618
632
  ChatId: this.chatToken.chatId
619
633
  });
620
- return [3 /*break*/, 37];
621
- case 36:
622
- error_8 = _y.sent();
623
- exceptionDetails = {
624
- response: "IC3ClientJoinConversationFailed"
625
- };
626
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
634
+ return [3 /*break*/, 39];
635
+ case 38:
636
+ error_8 = _z.sent();
637
+ telemetryData = {
627
638
  RequestId: this.requestId,
628
639
  ChatId: this.chatToken.chatId,
629
- ExceptionDetails: JSON.stringify(exceptionDetails)
630
- });
631
- console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
632
- return [2 /*return*/, error_8];
633
- case 37:
634
- if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
640
+ };
641
+ exceptionThrowers_1.default.throwMessagingClientConversationJoinFailure(error_8, this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
642
+ return [3 /*break*/, 39];
643
+ case 39:
644
+ if (this.isPersistentChat && !((_u = this.chatSDKConfig.persistentChat) === null || _u === void 0 ? void 0 : _u.disable)) {
635
645
  this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
636
646
  return __generator(this, function (_a) {
637
647
  switch (_a.label) {
@@ -642,7 +652,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
642
652
  return [2 /*return*/];
643
653
  }
644
654
  });
645
- }); }, (_s = this.chatSDKConfig.persistentChat) === null || _s === void 0 ? void 0 : _s.tokenUpdateTime);
655
+ }); }, (_v = this.chatSDKConfig.persistentChat) === null || _v === void 0 ? void 0 : _v.tokenUpdateTime);
646
656
  }
647
657
  return [2 /*return*/];
648
658
  }
@@ -650,11 +660,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
650
660
  });
651
661
  };
652
662
  OmnichannelChatSDK.prototype.endChat = function () {
653
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
663
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
654
664
  return __awaiter(this, void 0, void 0, function () {
655
- var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
656
- return __generator(this, function (_p) {
657
- switch (_p.label) {
665
+ var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, telemetryData;
666
+ return __generator(this, function (_r) {
667
+ switch (_r.label) {
658
668
  case 0:
659
669
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
660
670
  RequestId: this.requestId,
@@ -674,12 +684,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
674
684
  if (this.authenticatedUserToken) {
675
685
  sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
676
686
  }
677
- _p.label = 1;
687
+ _r.label = 1;
678
688
  case 1:
679
- _p.trys.push([1, 3, , 4]);
689
+ _r.trys.push([1, 3, , 4]);
680
690
  return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
681
691
  case 2:
682
- _p.sent();
692
+ _r.sent();
683
693
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
684
694
  RequestId: this.requestId,
685
695
  ChatId: this.chatToken.chatId
@@ -704,19 +714,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
704
714
  (_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
705
715
  (_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
706
716
  (_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
717
+ (_p = this.amsClientLogger) === null || _p === void 0 ? void 0 : _p.setRequestId(this.requestId);
718
+ (_q = this.amsClientLogger) === null || _q === void 0 ? void 0 : _q.setChatId('');
707
719
  return [3 /*break*/, 4];
708
720
  case 3:
709
- error_9 = _p.sent();
710
- exceptionDetails = {
711
- response: "OCClientSessionCloseFailed"
712
- };
713
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.EndChat, {
721
+ error_9 = _r.sent();
722
+ telemetryData = {
714
723
  RequestId: this.requestId,
715
- ChatId: this.chatToken.chatId,
716
- ExceptionDetails: JSON.stringify(exceptionDetails),
717
- });
718
- console.error("OmnichannelChatSDK/endChat/error " + error_9);
719
- return [2 /*return*/, error_9];
724
+ ChatId: this.chatToken.chatId
725
+ };
726
+ exceptionThrowers_1.default.throwConversationClosureFailure(error_9, this.scenarioMarker, TelemetryEvent_1.default.EndChat, telemetryData);
727
+ return [3 /*break*/, 4];
720
728
  case 4:
721
729
  if (this.refreshTokenTimer !== null) {
722
730
  clearInterval(this.refreshTokenTimer);
@@ -759,7 +767,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
759
767
  OmnichannelChatSDK.prototype.getConversationDetails = function () {
760
768
  var _a, _b, _c, _d;
761
769
  return __awaiter(this, void 0, void 0, function () {
762
- var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10;
770
+ var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10, exceptionDetails;
763
771
  return __generator(this, function (_e) {
764
772
  switch (_e.label) {
765
773
  case 0:
@@ -804,11 +812,15 @@ var OmnichannelChatSDK = /** @class */ (function () {
804
812
  return [2 /*return*/, liveWorkItemDetails];
805
813
  case 3:
806
814
  error_10 = _e.sent();
815
+ exceptionDetails = {
816
+ response: ChatSDKErrors_1.default.ConversationDetailsRetrievalFailure,
817
+ errorObject: "" + error_10
818
+ };
807
819
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
808
820
  RequestId: this.requestId,
809
821
  ChatId: this.chatToken.chatId || '',
822
+ ExceptionDetails: JSON.stringify(exceptionDetails)
810
823
  });
811
- console.error("OmnichannelChatSDK/getConversationDetails/error " + error_10);
812
824
  return [3 /*break*/, 4];
813
825
  case 4: return [2 /*return*/, {}];
814
826
  }
@@ -848,20 +860,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
848
860
  });
849
861
  };
850
862
  OmnichannelChatSDK.prototype.getChatToken = function (cached) {
851
- var _a, _b;
863
+ var _a, _b, _c;
852
864
  if (cached === void 0) { cached = true; }
853
865
  return __awaiter(this, void 0, void 0, function () {
854
- var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_11, exceptionDetails;
855
- return __generator(this, function (_c) {
856
- switch (_c.label) {
866
+ var getChatTokenOptionalParams, chatToken, chatId, token, regionGtms, expiresIn, visitorId, voiceVideoCallToken, acsEndpoint, attachmentConfiguration, error_11, telemetryData;
867
+ return __generator(this, function (_d) {
868
+ switch (_d.label) {
857
869
  case 0:
858
870
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetChatToken, {
859
871
  RequestId: this.requestId
860
872
  });
861
873
  if (!!cached) return [3 /*break*/, 5];
862
- _c.label = 1;
874
+ _d.label = 1;
863
875
  case 1:
864
- _c.trys.push([1, 3, , 4]);
876
+ _d.trys.push([1, 3, , 4]);
865
877
  getChatTokenOptionalParams = {};
866
878
  if (this.authenticatedUserToken) {
867
879
  getChatTokenOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
@@ -874,7 +886,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
874
886
  }
875
887
  return [4 /*yield*/, this.OCClient.getChatToken(this.requestId, getChatTokenOptionalParams)];
876
888
  case 2:
877
- chatToken = _c.sent();
889
+ chatToken = _d.sent();
878
890
  chatId = chatToken.ChatId, token = chatToken.Token, regionGtms = chatToken.RegionGtms, expiresIn = chatToken.ExpiresIn, visitorId = chatToken.VisitorId, voiceVideoCallToken = chatToken.VoiceVideoCallToken, acsEndpoint = chatToken.ACSEndpoint, attachmentConfiguration = chatToken.AttachmentConfiguration;
879
891
  this.chatToken = {
880
892
  chatId: chatId,
@@ -895,16 +907,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
895
907
  });
896
908
  return [3 /*break*/, 4];
897
909
  case 3:
898
- error_11 = _c.sent();
899
- exceptionDetails = {
900
- response: "OCClientGetChatTokenFailed"
901
- };
902
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetChatToken, {
910
+ error_11 = _d.sent();
911
+ telemetryData = {
903
912
  RequestId: this.requestId,
904
- ChatId: this.chatToken.chatId,
905
- ExceptionDetails: JSON.stringify(exceptionDetails),
906
- });
907
- console.error("OmnichannelChatSDK/getChatToken/error " + error_11);
913
+ ChatId: (_c = this.chatToken) === null || _c === void 0 ? void 0 : _c.chatId,
914
+ };
915
+ exceptionThrowers_1.default.throwChatTokenRetrievalFailure(error_11, this.scenarioMarker, TelemetryEvent_1.default.GetChatToken, telemetryData);
908
916
  return [3 /*break*/, 4];
909
917
  case 4: return [3 /*break*/, 6];
910
918
  case 5:
@@ -912,7 +920,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
912
920
  RequestId: this.requestId,
913
921
  ChatId: this.chatToken.chatId
914
922
  });
915
- _c.label = 6;
923
+ _d.label = 6;
916
924
  case 6: return [2 /*return*/, this.chatToken];
917
925
  }
918
926
  });
@@ -1579,31 +1587,41 @@ var OmnichannelChatSDK = /** @class */ (function () {
1579
1587
  });
1580
1588
  });
1581
1589
  };
1582
- OmnichannelChatSDK.prototype.getLiveChatTranscript = function () {
1590
+ OmnichannelChatSDK.prototype.getLiveChatTranscript = function (optionalParams) {
1591
+ if (optionalParams === void 0) { optionalParams = {}; }
1583
1592
  return __awaiter(this, void 0, void 0, function () {
1584
- var getChatTranscriptOptionalParams, transcriptResponse;
1593
+ var getChatTranscriptOptionalParams, requestId, chatToken, chatId, transcriptResponse, telemetryData;
1585
1594
  return __generator(this, function (_a) {
1586
1595
  getChatTranscriptOptionalParams = {};
1596
+ requestId = this.requestId;
1597
+ chatToken = this.chatToken;
1598
+ chatId = chatToken.chatId;
1599
+ if (optionalParams.liveChatContext) {
1600
+ requestId = optionalParams.liveChatContext.requestId;
1601
+ chatToken = optionalParams.liveChatContext.chatToken;
1602
+ chatId = chatToken.chatId;
1603
+ }
1587
1604
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetLiveChatTranscript, {
1588
- RequestId: this.requestId,
1589
- ChatId: this.chatToken.chatId
1605
+ RequestId: requestId,
1606
+ ChatId: chatId
1590
1607
  });
1591
1608
  try {
1592
1609
  if (this.authenticatedUserToken) {
1593
1610
  getChatTranscriptOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
1594
1611
  }
1595
- transcriptResponse = this.OCClient.getChatTranscripts(this.requestId, this.chatToken.chatId, this.chatToken.token, getChatTranscriptOptionalParams);
1612
+ transcriptResponse = this.OCClient.getChatTranscripts(requestId, chatToken.chatId, chatToken.token, getChatTranscriptOptionalParams);
1596
1613
  this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetLiveChatTranscript, {
1597
- RequestId: this.requestId,
1598
- ChatId: this.chatToken.chatId
1614
+ RequestId: requestId,
1615
+ ChatId: chatId
1599
1616
  });
1600
1617
  return [2 /*return*/, transcriptResponse];
1601
1618
  }
1602
1619
  catch (error) {
1603
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetLiveChatTranscript, {
1604
- RequestId: this.requestId,
1605
- ChatId: this.chatToken.chatId
1606
- });
1620
+ telemetryData = {
1621
+ RequestId: requestId,
1622
+ ChatId: chatId
1623
+ };
1624
+ exceptionThrowers_1.default.throwLiveChatTranscriptRetrievalFailure(error, this.scenarioMarker, TelemetryEvent_1.default.GetLiveChatTranscript, telemetryData);
1607
1625
  }
1608
1626
  return [2 /*return*/];
1609
1627
  });
@@ -1640,31 +1658,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
1640
1658
  OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
1641
1659
  if (params === void 0) { params = {}; }
1642
1660
  return __awaiter(this, void 0, void 0, function () {
1643
- var exceptionDetails, exceptionDetails, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
1661
+ var message, message, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
1644
1662
  var _this = this;
1645
1663
  return __generator(this, function (_a) {
1646
1664
  switch (_a.label) {
1647
1665
  case 0:
1648
1666
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
1649
1667
  if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
1650
- exceptionDetails = {
1651
- response: "UnsupportedPlatform",
1652
- message: "VoiceVideoCalling is only supported on browser"
1653
- };
1654
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
1655
- ExceptionDetails: JSON.stringify(exceptionDetails)
1656
- });
1657
- throw new Error(exceptionDetails.response);
1668
+ message = "VoiceVideoCalling is only supported on browser";
1669
+ exceptionThrowers_1.default.throwUnsupportedPlatform(this.scenarioMarker, TelemetryEvent_1.default.GetVoiceVideoCalling, message);
1658
1670
  }
1659
1671
  if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
1660
- exceptionDetails = {
1661
- response: "FeatureDisabled",
1662
- message: "Voice and video call is not enabled"
1663
- };
1664
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
1665
- ExceptionDetails: JSON.stringify(exceptionDetails)
1666
- });
1667
- throw new Error(exceptionDetails.response);
1672
+ message = "Voice and video call is not enabled";
1673
+ exceptionThrowers_1.default.throwFeatureDisabled(this.scenarioMarker, TelemetryEvent_1.default.GetVoiceVideoCalling, message);
1668
1674
  }
1669
1675
  return [4 /*yield*/, this.getChatConfig()];
1670
1676
  case 1:
@@ -1730,28 +1736,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
1730
1736
  };
1731
1737
  OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
1732
1738
  return __awaiter(this, void 0, void 0, function () {
1733
- var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, surveyInviteLinkRequest, optionalParams, ownerId, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1734
- return __generator(this, function (_a) {
1735
- switch (_a.label) {
1739
+ 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;
1740
+ return __generator(this, function (_b) {
1741
+ switch (_b.label) {
1736
1742
  case 0:
1737
1743
  this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1738
1744
  RequestId: this.requestId
1739
1745
  });
1740
- _a.label = 1;
1746
+ _b.label = 1;
1741
1747
  case 1:
1742
- _a.trys.push([1, 6, , 7]);
1748
+ _b.trys.push([1, 8, , 9]);
1743
1749
  chatConfig = this.liveChatConfig;
1744
1750
  liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
1745
1751
  msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId;
1746
- if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 4];
1752
+ if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 6];
1747
1753
  return [4 /*yield*/, this.getConversationDetails()];
1748
1754
  case 2:
1749
- liveWorkItemDetails = _a.sent();
1755
+ liveWorkItemDetails = _b.sent();
1750
1756
  participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.canRenderPostChat) === "True";
1751
1757
  participantType = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.participantType;
1752
1758
  conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.conversationId;
1753
- surveyInviteLinkRequest = {
1754
- "FormId": participantType === "Bot" ? msfp_botsourcesurveyidentifier : msfp_sourcesurveyidentifier,
1759
+ agentSurveyInviteLinkRequest = {
1760
+ "FormId": msfp_sourcesurveyidentifier,
1761
+ "ConversationId": conversationId,
1762
+ "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
1763
+ };
1764
+ botSurveyInviteLinkRequest = {
1765
+ "FormId": msfp_botsourcesurveyidentifier,
1755
1766
  "ConversationId": conversationId,
1756
1767
  "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
1757
1768
  };
@@ -1761,14 +1772,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
1761
1772
  if (this.authenticatedUserToken) {
1762
1773
  optionalParams.authenticatedUserToken = this.authenticatedUserToken;
1763
1774
  }
1764
- ownerId = participantType === "Bot" ? postConversationBotSurveyOwnerId : postConversationSurveyOwnerId;
1765
- return [4 /*yield*/, this.OCClient.getSurveyInviteLink(ownerId, surveyInviteLinkRequest, optionalParams)];
1775
+ return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationSurveyOwnerId, agentSurveyInviteLinkRequest, optionalParams)];
1766
1776
  case 3:
1767
- surveyInviteLinkResponse = _a.sent();
1768
- surveyInviteLink = void 0, formsProLocale = void 0;
1769
- if (surveyInviteLinkResponse != null) {
1770
- if (surveyInviteLinkResponse.inviteList != null && surveyInviteLinkResponse.inviteList.length == 1) {
1771
- surveyInviteLink = surveyInviteLinkResponse.inviteList[0].invitationLink;
1777
+ agentSurveyInviteLinkResponse = _b.sent();
1778
+ _a = postConversationBotSurveyOwnerId && msfp_botsourcesurveyidentifier;
1779
+ if (!_a) return [3 /*break*/, 5];
1780
+ return [4 /*yield*/, this.OCClient.getSurveyInviteLink(postConversationBotSurveyOwnerId, botSurveyInviteLinkRequest, optionalParams)];
1781
+ case 4:
1782
+ _a = (_b.sent());
1783
+ _b.label = 5;
1784
+ case 5:
1785
+ botSurveyInviteLinkResponse = _a;
1786
+ agentSurveyInviteLink = void 0, agentFormsProLocale = void 0, botSurveyInviteLink = void 0, botFormsProLocale = void 0;
1787
+ if (agentSurveyInviteLinkResponse != null) {
1788
+ if (agentSurveyInviteLinkResponse.inviteList != null && agentSurveyInviteLinkResponse.inviteList.length == 1) {
1789
+ agentSurveyInviteLink = agentSurveyInviteLinkResponse.inviteList[0].invitationLink;
1772
1790
  }
1773
1791
  else {
1774
1792
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
@@ -1778,14 +1796,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
1778
1796
  });
1779
1797
  return [2 /*return*/, Promise.reject("Survey Invite link failed to send response.")];
1780
1798
  }
1781
- if (surveyInviteLinkResponse.formsProLocaleCode != null) {
1782
- formsProLocale = surveyInviteLinkResponse.formsProLocaleCode;
1799
+ if (agentSurveyInviteLinkResponse.formsProLocaleCode != null) {
1800
+ agentFormsProLocale = agentSurveyInviteLinkResponse.formsProLocaleCode;
1801
+ }
1802
+ if (botSurveyInviteLinkResponse != null) {
1803
+ if (botSurveyInviteLinkResponse.inviteList != null && botSurveyInviteLinkResponse.inviteList.length == 1) {
1804
+ botSurveyInviteLink = botSurveyInviteLinkResponse.inviteList[0].invitationLink;
1805
+ }
1806
+ if (botSurveyInviteLinkResponse.formsProLocaleCode != null) {
1807
+ botFormsProLocale = botSurveyInviteLinkResponse.formsProLocaleCode;
1808
+ }
1783
1809
  }
1784
1810
  postChatContext = {
1785
1811
  participantJoined: participantJoined,
1786
1812
  participantType: participantType,
1787
- surveyInviteLink: surveyInviteLink,
1788
- formsProLocale: formsProLocale
1813
+ surveyInviteLink: agentSurveyInviteLink,
1814
+ botSurveyInviteLink: botSurveyInviteLink,
1815
+ formsProLocale: agentFormsProLocale,
1816
+ botFormsProLocale: botFormsProLocale
1789
1817
  };
1790
1818
  return [2 /*return*/, Promise.resolve(postChatContext)];
1791
1819
  }
@@ -1797,23 +1825,77 @@ var OmnichannelChatSDK = /** @class */ (function () {
1797
1825
  });
1798
1826
  return [2 /*return*/, Promise.reject("surveyInviteLinkResponse is null.")];
1799
1827
  }
1800
- return [3 /*break*/, 5];
1801
- case 4:
1828
+ return [3 /*break*/, 7];
1829
+ case 6:
1802
1830
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1803
1831
  RequestId: this.requestId,
1804
1832
  ExceptionDetails: "Post Chat Survey is disabled. Please check the Omnichannel Administration Portal."
1805
1833
  });
1806
1834
  return [2 /*return*/, Promise.reject("Post Chat is disabled from admin side.")];
1807
- case 5: return [3 /*break*/, 7];
1808
- case 6:
1809
- ex_1 = _a.sent();
1835
+ case 7: return [3 /*break*/, 9];
1836
+ case 8:
1837
+ ex_1 = _b.sent();
1810
1838
  this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
1811
1839
  ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
1812
1840
  RequestId: this.requestId,
1813
1841
  ExceptionDetails: JSON.stringify(ex_1)
1814
1842
  });
1815
1843
  return [2 /*return*/, Promise.reject("Retrieving post chat context failed " + JSON.stringify(ex_1))];
1816
- case 7: return [2 /*return*/];
1844
+ case 9: return [2 /*return*/];
1845
+ }
1846
+ });
1847
+ });
1848
+ };
1849
+ OmnichannelChatSDK.prototype.getAgentAvailability = function (optionalParams) {
1850
+ if (optionalParams === void 0) { optionalParams = {}; }
1851
+ return __awaiter(this, void 0, void 0, function () {
1852
+ var reportError, getAgentAvailabilityOptionalParams, response, e_6;
1853
+ var _this = this;
1854
+ return __generator(this, function (_a) {
1855
+ switch (_a.label) {
1856
+ case 0:
1857
+ reportError = function (response, message, chatId) {
1858
+ if (chatId === void 0) { chatId = ""; }
1859
+ var exceptionDetails = {
1860
+ response: response,
1861
+ message: message
1862
+ };
1863
+ _this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAgentAvailability, {
1864
+ RequestId: _this.requestId,
1865
+ ExceptionDetails: JSON.stringify(exceptionDetails),
1866
+ ChatId: chatId
1867
+ });
1868
+ throw new Error(exceptionDetails.message);
1869
+ };
1870
+ this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAgentAvailability, {
1871
+ RequestId: this.requestId
1872
+ });
1873
+ if (!this.authSettings) {
1874
+ reportError("Unsupported", "GetAgentAvailability is supported only for authenticated live chat widget.");
1875
+ }
1876
+ if (!this.authenticatedUserToken) {
1877
+ reportError("UndefinedAuthToken", "Missing AuthToken for GetAgentAvailability.");
1878
+ }
1879
+ if (this.conversation) {
1880
+ reportError("InvalidOperation", "GetAgentAvailability can only be called before a chat has started.", this.chatToken.chatId);
1881
+ }
1882
+ getAgentAvailabilityOptionalParams = {
1883
+ initContext: {}
1884
+ };
1885
+ getAgentAvailabilityOptionalParams = this.populateInitChatOptionalParam(getAgentAvailabilityOptionalParams, optionalParams, TelemetryEvent_1.default.GetAgentAvailability);
1886
+ _a.label = 1;
1887
+ case 1:
1888
+ _a.trys.push([1, 3, , 4]);
1889
+ return [4 /*yield*/, this.OCClient.getAgentAvailability(this.requestId, getAgentAvailabilityOptionalParams)];
1890
+ case 2:
1891
+ response = _a.sent();
1892
+ return [2 /*return*/, response];
1893
+ case 3:
1894
+ e_6 = _a.sent();
1895
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1896
+ reportError("GetAgentAvailabilityFailed", e_6.message);
1897
+ return [3 /*break*/, 4];
1898
+ case 4: return [2 /*return*/];
1817
1899
  }
1818
1900
  });
1819
1901
  });
@@ -1914,22 +1996,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
1914
1996
  OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
1915
1997
  if (optionalParams === void 0) { optionalParams = {}; }
1916
1998
  return __awaiter(this, void 0, void 0, function () {
1917
- var sendCacheHeaders, bypassCache, liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
1999
+ var sendCacheHeaders, bypassCache, liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled;
1918
2000
  return __generator(this, function (_a) {
1919
2001
  switch (_a.label) {
1920
2002
  case 0:
1921
2003
  sendCacheHeaders = optionalParams.sendCacheHeaders;
1922
- _a.label = 1;
1923
- case 1:
1924
- _a.trys.push([1, 5, , 6]);
1925
2004
  bypassCache = sendCacheHeaders === true;
1926
2005
  return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
1927
- case 2:
2006
+ case 1:
1928
2007
  liveChatConfig = _a.sent();
1929
2008
  dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
1930
2009
  msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
1931
2010
  this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
1932
- this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
2011
+ this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V2;
1933
2012
  /* istanbul ignore next */
1934
2013
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
1935
2014
  setting = dataMaskingConfig.setting;
@@ -1951,12 +2030,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
1951
2030
  if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
1952
2031
  this.preChatSurvey = preChatSurvey;
1953
2032
  }
1954
- if (!this.authSettings) return [3 /*break*/, 4];
2033
+ if (!this.authSettings) return [3 /*break*/, 3];
1955
2034
  return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
1956
- case 3:
2035
+ case 2:
1957
2036
  _a.sent();
1958
- _a.label = 4;
1959
- case 4:
2037
+ _a.label = 3;
2038
+ case 3:
1960
2039
  if (this.preChatSurvey) {
1961
2040
  /* istanbul ignore next */
1962
2041
  this.debug && console.log('Prechat Survey!');
@@ -1964,11 +2043,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
1964
2043
  this.callingOption = msdyn_callingoptions;
1965
2044
  this.liveChatConfig = liveChatConfig;
1966
2045
  return [2 /*return*/, this.liveChatConfig];
1967
- case 5:
1968
- error_18 = _a.sent();
1969
- console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
1970
- return [2 /*return*/, error_18];
1971
- case 6: return [2 /*return*/];
1972
2046
  }
1973
2047
  });
1974
2048
  });
@@ -1981,7 +2055,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1981
2055
  };
1982
2056
  OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
1983
2057
  return __awaiter(this, void 0, void 0, function () {
1984
- var sessionInfo, error_19, exceptionDetails;
2058
+ var sessionInfo, error_18, exceptionDetails;
1985
2059
  return __generator(this, function (_a) {
1986
2060
  switch (_a.label) {
1987
2061
  case 0:
@@ -2009,7 +2083,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2009
2083
  });
2010
2084
  return [3 /*break*/, 5];
2011
2085
  case 4:
2012
- error_19 = _a.sent();
2086
+ error_18 = _a.sent();
2013
2087
  exceptionDetails = {
2014
2088
  response: "UpdateChatTokenFailed"
2015
2089
  };
@@ -2018,7 +2092,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
2018
2092
  ChatId: this.chatToken.chatId,
2019
2093
  ExceptionDetails: JSON.stringify(exceptionDetails)
2020
2094
  });
2021
- console.error("OmnichannelChatSDK/updateChatToken/error " + error_19);
2095
+ console.error("OmnichannelChatSDK/updateChatToken/error " + error_18);
2022
2096
  return [3 /*break*/, 5];
2023
2097
  case 5: return [2 /*return*/];
2024
2098
  }