@microsoft/omnichannel-chat-sdk 1.2.1-main.6149875 → 1.2.1-main.7251853
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -0
- package/lib/OmnichannelChatSDK.d.ts +1 -0
- package/lib/OmnichannelChatSDK.js +107 -88
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/core/StartChatOptionalParams.d.ts +3 -0
- package/lib/telemetry/AriaTelemetry.d.ts +1 -0
- package/lib/telemetry/AriaTelemetry.js +49 -0
- package/lib/telemetry/AriaTelemetry.js.map +1 -1
- package/lib/telemetry/ScenarioType.d.ts +1 -0
- package/lib/telemetry/ScenarioType.js +1 -0
- package/lib/telemetry/ScenarioType.js.map +1 -1
- package/lib/telemetry/TelemetryEvent.d.ts +2 -1
- package/lib/telemetry/TelemetryEvent.js +1 -0
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +62 -22
- package/lib/utils/location.d.ts +7 -0
- package/lib/utils/location.js +96 -0
- package/lib/utils/location.js.map +1 -0
- package/lib/utils/loggers.d.ts +16 -0
- package/lib/utils/loggers.js +69 -1
- package/lib/utils/loggers.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
|
7
7
|
- Add `CreateACSAdapter` telemetry event
|
8
8
|
- Improve `ChatSDK.createChatAdapter()` with retries using exponential backoff & additional details on failures
|
9
9
|
- Add `GetAgentAvailability` SDK method for auth chat
|
10
|
+
- Pass `logger` to AMSClient
|
10
11
|
|
11
12
|
### Fixed
|
12
13
|
- Fix `ChatAdapterOptionalParams.ACSAdapter.options.egressMiddleware` being used as `ingressMiddleware`
|
@@ -87,6 +87,7 @@ 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 location_1 = require("./utils/location");
|
90
91
|
var utilities_1 = require("./utils/utilities");
|
91
92
|
var urlResolvers_1 = require("./utils/urlResolvers");
|
92
93
|
var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
|
@@ -94,7 +95,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
94
95
|
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
|
95
96
|
var _this = this;
|
96
97
|
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
|
97
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
98
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
98
99
|
this.ACSClient = null;
|
99
100
|
this.AMSClient = null;
|
100
101
|
this.authSettings = null;
|
@@ -107,6 +108,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
107
108
|
this.acsClientLogger = null;
|
108
109
|
this.acsAdapterLogger = null;
|
109
110
|
this.callingSdkLogger = null;
|
111
|
+
this.amsClientLogger = null;
|
110
112
|
this.isPersistentChat = false;
|
111
113
|
this.isChatReconnect = false;
|
112
114
|
this.reconnectId = null;
|
@@ -181,18 +183,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
181
183
|
this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
|
182
184
|
this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
|
183
185
|
this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
|
186
|
+
this.amsClientLogger = loggers_1.createAMSClientLogger(this.omnichannelConfig);
|
184
187
|
this.scenarioMarker.useTelemetry(this.telemetry);
|
185
188
|
this.ic3ClientLogger.useTelemetry(this.telemetry);
|
186
189
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
187
190
|
this.acsClientLogger.useTelemetry(this.telemetry);
|
188
191
|
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
189
192
|
this.callingSdkLogger.useTelemetry(this.telemetry);
|
193
|
+
this.amsClientLogger.useTelemetry(this.telemetry);
|
190
194
|
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
191
195
|
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
192
196
|
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
193
197
|
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
194
198
|
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
195
199
|
this.callingSdkLogger.setRuntimeId(this.runtimeId);
|
200
|
+
this.amsClientLogger.setRuntimeId(this.runtimeId);
|
196
201
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
197
202
|
SDKConfigValidators_1.default(chatSDKConfig);
|
198
203
|
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
|
@@ -204,10 +209,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
204
209
|
(_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
205
210
|
(_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
|
206
211
|
(_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
|
212
|
+
(_j = this.amsClientLogger) === null || _j === void 0 ? void 0 : _j.setRequestId(this.requestId);
|
207
213
|
}
|
208
214
|
/* istanbul ignore next */
|
209
215
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
210
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
216
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
211
217
|
this.debug = flag;
|
212
218
|
(_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
213
219
|
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
|
@@ -217,6 +223,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
217
223
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
|
218
224
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
|
219
225
|
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
|
226
|
+
(_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setDebug(flag);
|
220
227
|
};
|
221
228
|
OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
|
222
229
|
if (optionalParams === void 0) { optionalParams = {}; }
|
@@ -249,7 +256,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
249
256
|
framedMode: platform_1.isBrowser(),
|
250
257
|
multiClient: true,
|
251
258
|
debug: false,
|
252
|
-
logger:
|
259
|
+
logger: this.amsClientLogger
|
253
260
|
})];
|
254
261
|
case 4:
|
255
262
|
_b.AMSClient = _e.sent();
|
@@ -358,44 +365,44 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
358
365
|
});
|
359
366
|
};
|
360
367
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
361
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
368
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
362
369
|
if (optionalParams === void 0) { optionalParams = {}; }
|
363
370
|
return __awaiter(this, void 0, void 0, function () {
|
364
|
-
var shouldReinitIC3Client,
|
371
|
+
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;
|
365
372
|
var _this = this;
|
366
|
-
return __generator(this, function (
|
367
|
-
switch (
|
373
|
+
return __generator(this, function (_1) {
|
374
|
+
switch (_1.label) {
|
368
375
|
case 0:
|
369
376
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
370
377
|
RequestId: this.requestId
|
371
378
|
});
|
372
379
|
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
373
380
|
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
374
|
-
|
381
|
+
_w = this;
|
375
382
|
return [4 /*yield*/, this.getIC3Client()];
|
376
383
|
case 1:
|
377
|
-
|
378
|
-
|
384
|
+
_w.IC3Client = _1.sent();
|
385
|
+
_1.label = 2;
|
379
386
|
case 2:
|
380
387
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
381
388
|
this.reconnectId = optionalParams.reconnectId;
|
382
389
|
}
|
383
390
|
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
384
|
-
|
391
|
+
_1.label = 3;
|
385
392
|
case 3:
|
386
|
-
|
393
|
+
_1.trys.push([3, 5, , 6]);
|
387
394
|
reconnectableChatsParams = {
|
388
395
|
authenticatedUserToken: this.authenticatedUserToken
|
389
396
|
};
|
390
397
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
391
398
|
case 4:
|
392
|
-
reconnectableChatsResponse =
|
399
|
+
reconnectableChatsResponse = _1.sent();
|
393
400
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
394
401
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
395
402
|
}
|
396
403
|
return [3 /*break*/, 6];
|
397
404
|
case 5:
|
398
|
-
|
405
|
+
_x = _1.sent();
|
399
406
|
exceptionDetails = {
|
400
407
|
response: "OCClientGetReconnectableChatsFailed"
|
401
408
|
};
|
@@ -406,7 +413,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
406
413
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
407
414
|
return [4 /*yield*/, this.getConversationDetails()];
|
408
415
|
case 7:
|
409
|
-
conversationDetails =
|
416
|
+
conversationDetails = _1.sent();
|
410
417
|
if (Object.keys(conversationDetails).length === 0) {
|
411
418
|
exceptionDetails = {
|
412
419
|
response: "InvalidConversation"
|
@@ -431,30 +438,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
431
438
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
432
439
|
throw Error(exceptionDetails.response);
|
433
440
|
}
|
434
|
-
|
441
|
+
_1.label = 8;
|
435
442
|
case 8:
|
436
443
|
if (!this.authSettings) return [3 /*break*/, 14];
|
437
444
|
if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
|
438
445
|
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
439
446
|
case 9:
|
440
|
-
|
441
|
-
|
447
|
+
_1.sent();
|
448
|
+
_1.label = 10;
|
442
449
|
case 10:
|
443
450
|
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
|
444
451
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
445
452
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
446
|
-
|
453
|
+
_1.label = 11;
|
447
454
|
case 11:
|
448
|
-
|
455
|
+
_1.trys.push([11, 13, , 14]);
|
449
456
|
return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
|
450
457
|
authenticatedUserToken: this.authenticatedUserToken,
|
451
458
|
chatId: this.chatToken.chatId
|
452
459
|
})];
|
453
460
|
case 12:
|
454
|
-
|
461
|
+
_1.sent();
|
455
462
|
return [3 /*break*/, 14];
|
456
463
|
case 13:
|
457
|
-
|
464
|
+
_y = _1.sent();
|
458
465
|
exceptionDetails = {
|
459
466
|
response: "OCClientValidateAuthChatRecordFailed",
|
460
467
|
message: "InvalidAuthChatRecord"
|
@@ -469,39 +476,49 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
469
476
|
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
|
470
477
|
return [4 /*yield*/, this.getChatToken(false)];
|
471
478
|
case 15:
|
472
|
-
|
473
|
-
|
479
|
+
_1.sent();
|
480
|
+
_1.label = 16;
|
474
481
|
case 16:
|
475
482
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
476
483
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
477
484
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
478
485
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
|
479
486
|
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
|
487
|
+
(_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setChatId(this.chatToken.chatId || '');
|
480
488
|
sessionInitOptionalParams = {
|
481
489
|
initContext: {}
|
482
490
|
};
|
483
491
|
sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams);
|
484
|
-
|
492
|
+
sessionInitOptionalParams.initContext.isProactiveChat = !!optionalParams.isProactiveChat;
|
493
|
+
if (this.isPersistentChat && !((_j = this.chatSDKConfig.persistentChat) === null || _j === void 0 ? void 0 : _j.disable)) {
|
485
494
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
486
495
|
}
|
487
|
-
else if (this.isChatReconnect && !((
|
496
|
+
else if (this.isChatReconnect && !((_k = this.chatSDKConfig.chatReconnect) === null || _k === void 0 ? void 0 : _k.disable) && !this.isPersistentChat) {
|
488
497
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
489
498
|
}
|
490
|
-
if (
|
491
|
-
|
499
|
+
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];
|
500
|
+
return [4 /*yield*/, location_1.getLocationInfo(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
|
492
501
|
case 17:
|
493
|
-
|
494
|
-
|
502
|
+
location_2 = _1.sent();
|
503
|
+
sessionInitOptionalParams.initContext.latitude = location_2.latitude;
|
504
|
+
sessionInitOptionalParams.initContext.longitude = location_2.longitude;
|
505
|
+
_1.label = 18;
|
495
506
|
case 18:
|
496
|
-
|
497
|
-
|
507
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 22];
|
508
|
+
_1.label = 19;
|
498
509
|
case 19:
|
499
|
-
|
510
|
+
_1.trys.push([19, 21, , 22]);
|
511
|
+
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
512
|
+
case 20:
|
513
|
+
_1.sent();
|
514
|
+
return [3 /*break*/, 22];
|
515
|
+
case 21:
|
516
|
+
error_3 = _1.sent();
|
500
517
|
exceptionDetails = {
|
501
518
|
response: "OCClientSessionInitFailed"
|
502
519
|
};
|
503
520
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
504
|
-
if (((
|
521
|
+
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()) {
|
505
522
|
exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
|
506
523
|
exceptionDetails.message = 'Widget used outside of operating hours';
|
507
524
|
console.error(exceptionDetails.message);
|
@@ -512,8 +529,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
512
529
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
513
530
|
});
|
514
531
|
throw new Error(exceptionDetails.response);
|
515
|
-
case
|
516
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/,
|
532
|
+
case 22:
|
533
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 33];
|
517
534
|
chatAdapterConfig = {
|
518
535
|
token: this.chatToken.token,
|
519
536
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
@@ -521,18 +538,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
521
538
|
environmentUrl: this.chatToken.acsEndpoint,
|
522
539
|
pollingInterval: 30000
|
523
540
|
};
|
524
|
-
|
525
|
-
case
|
526
|
-
|
527
|
-
return [4 /*yield*/, ((
|
541
|
+
_1.label = 23;
|
542
|
+
case 23:
|
543
|
+
_1.trys.push([23, 25, , 26]);
|
544
|
+
return [4 /*yield*/, ((_r = this.ACSClient) === null || _r === void 0 ? void 0 : _r.initialize({
|
528
545
|
token: chatAdapterConfig.token,
|
529
546
|
environmentUrl: chatAdapterConfig.environmentUrl
|
530
547
|
}))];
|
531
|
-
case
|
532
|
-
|
533
|
-
return [3 /*break*/,
|
534
|
-
case
|
535
|
-
error_4 =
|
548
|
+
case 24:
|
549
|
+
_1.sent();
|
550
|
+
return [3 /*break*/, 26];
|
551
|
+
case 25:
|
552
|
+
error_4 = _1.sent();
|
536
553
|
exceptionDetails = {
|
537
554
|
response: "ACSClientInitializeFailed"
|
538
555
|
};
|
@@ -543,23 +560,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
543
560
|
});
|
544
561
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
545
562
|
return [2 /*return*/, error_4];
|
546
|
-
case
|
547
|
-
|
548
|
-
|
549
|
-
return [4 /*yield*/, ((
|
563
|
+
case 26:
|
564
|
+
_1.trys.push([26, 28, , 29]);
|
565
|
+
_z = this;
|
566
|
+
return [4 /*yield*/, ((_s = this.ACSClient) === null || _s === void 0 ? void 0 : _s.joinConversation({
|
550
567
|
id: chatAdapterConfig.id,
|
551
568
|
threadId: chatAdapterConfig.threadId,
|
552
569
|
pollingInterval: chatAdapterConfig.pollingInterval
|
553
570
|
}))];
|
554
|
-
case
|
555
|
-
|
571
|
+
case 27:
|
572
|
+
_z.conversation = (_1.sent());
|
556
573
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
557
574
|
RequestId: this.requestId,
|
558
575
|
ChatId: this.chatToken.chatId
|
559
576
|
});
|
560
|
-
return [3 /*break*/,
|
561
|
-
case
|
562
|
-
error_5 =
|
577
|
+
return [3 /*break*/, 29];
|
578
|
+
case 28:
|
579
|
+
error_5 = _1.sent();
|
563
580
|
exceptionDetails = {
|
564
581
|
response: "ACSClientJoinConversationFailed"
|
565
582
|
};
|
@@ -570,16 +587,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
570
587
|
});
|
571
588
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
572
589
|
throw Error(exceptionDetails.response);
|
573
|
-
case
|
574
|
-
|
575
|
-
return [4 /*yield*/, ((
|
590
|
+
case 29:
|
591
|
+
_1.trys.push([29, 31, , 32]);
|
592
|
+
return [4 /*yield*/, ((_t = this.AMSClient) === null || _t === void 0 ? void 0 : _t.initialize({
|
576
593
|
chatToken: this.chatToken
|
577
594
|
}))];
|
578
|
-
case
|
579
|
-
|
580
|
-
return [3 /*break*/,
|
581
|
-
case
|
582
|
-
error_6 =
|
595
|
+
case 30:
|
596
|
+
_1.sent();
|
597
|
+
return [3 /*break*/, 32];
|
598
|
+
case 31:
|
599
|
+
error_6 = _1.sent();
|
583
600
|
exceptionDetails = {
|
584
601
|
response: "AMSClientInitializeFailed"
|
585
602
|
};
|
@@ -589,19 +606,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
589
606
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
590
607
|
});
|
591
608
|
throw Error(exceptionDetails.response);
|
592
|
-
case
|
593
|
-
case
|
594
|
-
|
609
|
+
case 32: return [3 /*break*/, 39];
|
610
|
+
case 33:
|
611
|
+
_1.trys.push([33, 35, , 36]);
|
595
612
|
return [4 /*yield*/, this.IC3Client.initialize({
|
596
613
|
token: this.chatToken.token,
|
597
614
|
regionGtms: this.chatToken.regionGTMS,
|
598
615
|
visitor: true
|
599
616
|
})];
|
600
|
-
case
|
601
|
-
|
602
|
-
return [3 /*break*/,
|
603
|
-
case
|
604
|
-
error_7 =
|
617
|
+
case 34:
|
618
|
+
_1.sent();
|
619
|
+
return [3 /*break*/, 36];
|
620
|
+
case 35:
|
621
|
+
error_7 = _1.sent();
|
605
622
|
exceptionDetails = {
|
606
623
|
response: "IC3ClientInitializeFailed"
|
607
624
|
};
|
@@ -612,19 +629,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
612
629
|
});
|
613
630
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
614
631
|
return [2 /*return*/, error_7];
|
615
|
-
case
|
616
|
-
|
617
|
-
|
632
|
+
case 36:
|
633
|
+
_1.trys.push([36, 38, , 39]);
|
634
|
+
_0 = this;
|
618
635
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
619
|
-
case
|
620
|
-
|
636
|
+
case 37:
|
637
|
+
_0.conversation = _1.sent();
|
621
638
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
622
639
|
RequestId: this.requestId,
|
623
640
|
ChatId: this.chatToken.chatId
|
624
641
|
});
|
625
|
-
return [3 /*break*/,
|
626
|
-
case
|
627
|
-
error_8 =
|
642
|
+
return [3 /*break*/, 39];
|
643
|
+
case 38:
|
644
|
+
error_8 = _1.sent();
|
628
645
|
exceptionDetails = {
|
629
646
|
response: "IC3ClientJoinConversationFailed"
|
630
647
|
};
|
@@ -635,8 +652,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
635
652
|
});
|
636
653
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
637
654
|
return [2 /*return*/, error_8];
|
638
|
-
case
|
639
|
-
if (this.isPersistentChat && !((
|
655
|
+
case 39:
|
656
|
+
if (this.isPersistentChat && !((_u = this.chatSDKConfig.persistentChat) === null || _u === void 0 ? void 0 : _u.disable)) {
|
640
657
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
641
658
|
return __generator(this, function (_a) {
|
642
659
|
switch (_a.label) {
|
@@ -647,7 +664,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
647
664
|
return [2 /*return*/];
|
648
665
|
}
|
649
666
|
});
|
650
|
-
}); }, (
|
667
|
+
}); }, (_v = this.chatSDKConfig.persistentChat) === null || _v === void 0 ? void 0 : _v.tokenUpdateTime);
|
651
668
|
}
|
652
669
|
return [2 /*return*/];
|
653
670
|
}
|
@@ -655,11 +672,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
655
672
|
});
|
656
673
|
};
|
657
674
|
OmnichannelChatSDK.prototype.endChat = function () {
|
658
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
675
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
659
676
|
return __awaiter(this, void 0, void 0, function () {
|
660
677
|
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
|
661
|
-
return __generator(this, function (
|
662
|
-
switch (
|
678
|
+
return __generator(this, function (_r) {
|
679
|
+
switch (_r.label) {
|
663
680
|
case 0:
|
664
681
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
|
665
682
|
RequestId: this.requestId,
|
@@ -679,12 +696,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
679
696
|
if (this.authenticatedUserToken) {
|
680
697
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
681
698
|
}
|
682
|
-
|
699
|
+
_r.label = 1;
|
683
700
|
case 1:
|
684
|
-
|
701
|
+
_r.trys.push([1, 3, , 4]);
|
685
702
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
686
703
|
case 2:
|
687
|
-
|
704
|
+
_r.sent();
|
688
705
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
|
689
706
|
RequestId: this.requestId,
|
690
707
|
ChatId: this.chatToken.chatId
|
@@ -709,9 +726,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
709
726
|
(_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
|
710
727
|
(_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
|
711
728
|
(_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
|
729
|
+
(_p = this.amsClientLogger) === null || _p === void 0 ? void 0 : _p.setRequestId(this.requestId);
|
730
|
+
(_q = this.amsClientLogger) === null || _q === void 0 ? void 0 : _q.setChatId('');
|
712
731
|
return [3 /*break*/, 4];
|
713
732
|
case 3:
|
714
|
-
error_9 =
|
733
|
+
error_9 = _r.sent();
|
715
734
|
exceptionDetails = {
|
716
735
|
response: "OCClientSessionCloseFailed"
|
717
736
|
};
|