@microsoft/omnichannel-chat-sdk 1.2.1-main.6149875 → 1.2.1-main.6857ab9
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 +5 -0
- package/lib/OmnichannelChatSDK.d.ts +1 -0
- package/lib/OmnichannelChatSDK.js +110 -88
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/core/GetAgentAvailabilityOptionalParams.d.ts +1 -0
- package/lib/core/StartChatOptionalParams.d.ts +4 -0
- package/lib/external/ACSAdapter/AMSFileManager.js +2 -1
- package/lib/external/ACSAdapter/AMSFileManager.js.map +1 -1
- 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 +65 -25
- 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,11 +7,16 @@ 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
|
11
|
+
- Add `portalContactId` in `StartChatOptionalParams` and `GetAgentAvailabilityOptionalParams`
|
10
12
|
|
11
13
|
### Fixed
|
12
14
|
- Fix `ChatAdapterOptionalParams.ACSAdapter.options.egressMiddleware` being used as `ingressMiddleware`
|
13
15
|
- Fix `ChatSDK.onTypingEvent()` being triggered on current user typing
|
14
16
|
|
17
|
+
### Changed
|
18
|
+
- Uptake [@microsoft/omnichannel-amsclient@0.1.4](https://www.npmjs.com/package/@microsoft/omnichannel-amsclient/v/0.1.4)
|
19
|
+
|
15
20
|
## [1.2.0] - 2022-11-11
|
16
21
|
### Added
|
17
22
|
- Add `sendDefaultInitContext` optional parameter to `ChatSDK.startChat()` to automatically populate `browser`, `device`, `originurl` & `os` as default init context on web
|
@@ -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;
|
@@ -131,6 +133,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
131
133
|
if (optionalParams.preChatResponse) {
|
132
134
|
requestOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
|
133
135
|
}
|
136
|
+
if (optionalParams.portalContactId) {
|
137
|
+
requestOptionalParams.initContext.portalcontactid = optionalParams.portalContactId;
|
138
|
+
}
|
134
139
|
if (optionalParams.sendDefaultInitContext) {
|
135
140
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
136
141
|
var exceptionDetails = {
|
@@ -181,18 +186,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
181
186
|
this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
|
182
187
|
this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
|
183
188
|
this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
|
189
|
+
this.amsClientLogger = loggers_1.createAMSClientLogger(this.omnichannelConfig);
|
184
190
|
this.scenarioMarker.useTelemetry(this.telemetry);
|
185
191
|
this.ic3ClientLogger.useTelemetry(this.telemetry);
|
186
192
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
187
193
|
this.acsClientLogger.useTelemetry(this.telemetry);
|
188
194
|
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
189
195
|
this.callingSdkLogger.useTelemetry(this.telemetry);
|
196
|
+
this.amsClientLogger.useTelemetry(this.telemetry);
|
190
197
|
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
191
198
|
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
192
199
|
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
193
200
|
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
194
201
|
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
195
202
|
this.callingSdkLogger.setRuntimeId(this.runtimeId);
|
203
|
+
this.amsClientLogger.setRuntimeId(this.runtimeId);
|
196
204
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
197
205
|
SDKConfigValidators_1.default(chatSDKConfig);
|
198
206
|
((_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 +212,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
204
212
|
(_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
205
213
|
(_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
|
206
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);
|
207
216
|
}
|
208
217
|
/* istanbul ignore next */
|
209
218
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
210
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
219
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
211
220
|
this.debug = flag;
|
212
221
|
(_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
213
222
|
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
|
@@ -217,6 +226,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
217
226
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
|
218
227
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
|
219
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);
|
220
230
|
};
|
221
231
|
OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
|
222
232
|
if (optionalParams === void 0) { optionalParams = {}; }
|
@@ -249,7 +259,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
249
259
|
framedMode: platform_1.isBrowser(),
|
250
260
|
multiClient: true,
|
251
261
|
debug: false,
|
252
|
-
logger:
|
262
|
+
logger: this.amsClientLogger
|
253
263
|
})];
|
254
264
|
case 4:
|
255
265
|
_b.AMSClient = _e.sent();
|
@@ -358,44 +368,44 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
358
368
|
});
|
359
369
|
};
|
360
370
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
361
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
371
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
362
372
|
if (optionalParams === void 0) { optionalParams = {}; }
|
363
373
|
return __awaiter(this, void 0, void 0, function () {
|
364
|
-
var shouldReinitIC3Client,
|
374
|
+
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
375
|
var _this = this;
|
366
|
-
return __generator(this, function (
|
367
|
-
switch (
|
376
|
+
return __generator(this, function (_1) {
|
377
|
+
switch (_1.label) {
|
368
378
|
case 0:
|
369
379
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
370
380
|
RequestId: this.requestId
|
371
381
|
});
|
372
382
|
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
373
383
|
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
374
|
-
|
384
|
+
_w = this;
|
375
385
|
return [4 /*yield*/, this.getIC3Client()];
|
376
386
|
case 1:
|
377
|
-
|
378
|
-
|
387
|
+
_w.IC3Client = _1.sent();
|
388
|
+
_1.label = 2;
|
379
389
|
case 2:
|
380
390
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
381
391
|
this.reconnectId = optionalParams.reconnectId;
|
382
392
|
}
|
383
393
|
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
384
|
-
|
394
|
+
_1.label = 3;
|
385
395
|
case 3:
|
386
|
-
|
396
|
+
_1.trys.push([3, 5, , 6]);
|
387
397
|
reconnectableChatsParams = {
|
388
398
|
authenticatedUserToken: this.authenticatedUserToken
|
389
399
|
};
|
390
400
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
391
401
|
case 4:
|
392
|
-
reconnectableChatsResponse =
|
402
|
+
reconnectableChatsResponse = _1.sent();
|
393
403
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
394
404
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
395
405
|
}
|
396
406
|
return [3 /*break*/, 6];
|
397
407
|
case 5:
|
398
|
-
|
408
|
+
_x = _1.sent();
|
399
409
|
exceptionDetails = {
|
400
410
|
response: "OCClientGetReconnectableChatsFailed"
|
401
411
|
};
|
@@ -406,7 +416,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
406
416
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
407
417
|
return [4 /*yield*/, this.getConversationDetails()];
|
408
418
|
case 7:
|
409
|
-
conversationDetails =
|
419
|
+
conversationDetails = _1.sent();
|
410
420
|
if (Object.keys(conversationDetails).length === 0) {
|
411
421
|
exceptionDetails = {
|
412
422
|
response: "InvalidConversation"
|
@@ -431,30 +441,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
431
441
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
432
442
|
throw Error(exceptionDetails.response);
|
433
443
|
}
|
434
|
-
|
444
|
+
_1.label = 8;
|
435
445
|
case 8:
|
436
446
|
if (!this.authSettings) return [3 /*break*/, 14];
|
437
447
|
if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
|
438
448
|
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
439
449
|
case 9:
|
440
|
-
|
441
|
-
|
450
|
+
_1.sent();
|
451
|
+
_1.label = 10;
|
442
452
|
case 10:
|
443
453
|
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
|
444
454
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
445
455
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
446
|
-
|
456
|
+
_1.label = 11;
|
447
457
|
case 11:
|
448
|
-
|
458
|
+
_1.trys.push([11, 13, , 14]);
|
449
459
|
return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
|
450
460
|
authenticatedUserToken: this.authenticatedUserToken,
|
451
461
|
chatId: this.chatToken.chatId
|
452
462
|
})];
|
453
463
|
case 12:
|
454
|
-
|
464
|
+
_1.sent();
|
455
465
|
return [3 /*break*/, 14];
|
456
466
|
case 13:
|
457
|
-
|
467
|
+
_y = _1.sent();
|
458
468
|
exceptionDetails = {
|
459
469
|
response: "OCClientValidateAuthChatRecordFailed",
|
460
470
|
message: "InvalidAuthChatRecord"
|
@@ -469,39 +479,49 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
469
479
|
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
|
470
480
|
return [4 /*yield*/, this.getChatToken(false)];
|
471
481
|
case 15:
|
472
|
-
|
473
|
-
|
482
|
+
_1.sent();
|
483
|
+
_1.label = 16;
|
474
484
|
case 16:
|
475
485
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
476
486
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
477
487
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
478
488
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
|
479
489
|
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
|
490
|
+
(_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setChatId(this.chatToken.chatId || '');
|
480
491
|
sessionInitOptionalParams = {
|
481
492
|
initContext: {}
|
482
493
|
};
|
483
494
|
sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams);
|
484
|
-
|
495
|
+
sessionInitOptionalParams.initContext.isProactiveChat = !!optionalParams.isProactiveChat;
|
496
|
+
if (this.isPersistentChat && !((_j = this.chatSDKConfig.persistentChat) === null || _j === void 0 ? void 0 : _j.disable)) {
|
485
497
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
486
498
|
}
|
487
|
-
else if (this.isChatReconnect && !((
|
499
|
+
else if (this.isChatReconnect && !((_k = this.chatSDKConfig.chatReconnect) === null || _k === void 0 ? void 0 : _k.disable) && !this.isPersistentChat) {
|
488
500
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
489
501
|
}
|
490
|
-
if (
|
491
|
-
|
502
|
+
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];
|
503
|
+
return [4 /*yield*/, location_1.getLocationInfo(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
|
492
504
|
case 17:
|
493
|
-
|
494
|
-
|
505
|
+
location_2 = _1.sent();
|
506
|
+
sessionInitOptionalParams.initContext.latitude = location_2.latitude;
|
507
|
+
sessionInitOptionalParams.initContext.longitude = location_2.longitude;
|
508
|
+
_1.label = 18;
|
495
509
|
case 18:
|
496
|
-
|
497
|
-
|
510
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 22];
|
511
|
+
_1.label = 19;
|
498
512
|
case 19:
|
499
|
-
|
513
|
+
_1.trys.push([19, 21, , 22]);
|
514
|
+
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
515
|
+
case 20:
|
516
|
+
_1.sent();
|
517
|
+
return [3 /*break*/, 22];
|
518
|
+
case 21:
|
519
|
+
error_3 = _1.sent();
|
500
520
|
exceptionDetails = {
|
501
521
|
response: "OCClientSessionInitFailed"
|
502
522
|
};
|
503
523
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
504
|
-
if (((
|
524
|
+
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
525
|
exceptionDetails.response = OmnichannelErrorCodes_1.default[OmnichannelErrorCodes_1.default.WidgetUseOutsideOperatingHour].toString();
|
506
526
|
exceptionDetails.message = 'Widget used outside of operating hours';
|
507
527
|
console.error(exceptionDetails.message);
|
@@ -512,8 +532,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
512
532
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
513
533
|
});
|
514
534
|
throw new Error(exceptionDetails.response);
|
515
|
-
case
|
516
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/,
|
535
|
+
case 22:
|
536
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 33];
|
517
537
|
chatAdapterConfig = {
|
518
538
|
token: this.chatToken.token,
|
519
539
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
@@ -521,18 +541,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
521
541
|
environmentUrl: this.chatToken.acsEndpoint,
|
522
542
|
pollingInterval: 30000
|
523
543
|
};
|
524
|
-
|
525
|
-
case
|
526
|
-
|
527
|
-
return [4 /*yield*/, ((
|
544
|
+
_1.label = 23;
|
545
|
+
case 23:
|
546
|
+
_1.trys.push([23, 25, , 26]);
|
547
|
+
return [4 /*yield*/, ((_r = this.ACSClient) === null || _r === void 0 ? void 0 : _r.initialize({
|
528
548
|
token: chatAdapterConfig.token,
|
529
549
|
environmentUrl: chatAdapterConfig.environmentUrl
|
530
550
|
}))];
|
531
|
-
case
|
532
|
-
|
533
|
-
return [3 /*break*/,
|
534
|
-
case
|
535
|
-
error_4 =
|
551
|
+
case 24:
|
552
|
+
_1.sent();
|
553
|
+
return [3 /*break*/, 26];
|
554
|
+
case 25:
|
555
|
+
error_4 = _1.sent();
|
536
556
|
exceptionDetails = {
|
537
557
|
response: "ACSClientInitializeFailed"
|
538
558
|
};
|
@@ -543,23 +563,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
543
563
|
});
|
544
564
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
545
565
|
return [2 /*return*/, error_4];
|
546
|
-
case
|
547
|
-
|
548
|
-
|
549
|
-
return [4 /*yield*/, ((
|
566
|
+
case 26:
|
567
|
+
_1.trys.push([26, 28, , 29]);
|
568
|
+
_z = this;
|
569
|
+
return [4 /*yield*/, ((_s = this.ACSClient) === null || _s === void 0 ? void 0 : _s.joinConversation({
|
550
570
|
id: chatAdapterConfig.id,
|
551
571
|
threadId: chatAdapterConfig.threadId,
|
552
572
|
pollingInterval: chatAdapterConfig.pollingInterval
|
553
573
|
}))];
|
554
|
-
case
|
555
|
-
|
574
|
+
case 27:
|
575
|
+
_z.conversation = (_1.sent());
|
556
576
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
557
577
|
RequestId: this.requestId,
|
558
578
|
ChatId: this.chatToken.chatId
|
559
579
|
});
|
560
|
-
return [3 /*break*/,
|
561
|
-
case
|
562
|
-
error_5 =
|
580
|
+
return [3 /*break*/, 29];
|
581
|
+
case 28:
|
582
|
+
error_5 = _1.sent();
|
563
583
|
exceptionDetails = {
|
564
584
|
response: "ACSClientJoinConversationFailed"
|
565
585
|
};
|
@@ -570,16 +590,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
570
590
|
});
|
571
591
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
572
592
|
throw Error(exceptionDetails.response);
|
573
|
-
case
|
574
|
-
|
575
|
-
return [4 /*yield*/, ((
|
593
|
+
case 29:
|
594
|
+
_1.trys.push([29, 31, , 32]);
|
595
|
+
return [4 /*yield*/, ((_t = this.AMSClient) === null || _t === void 0 ? void 0 : _t.initialize({
|
576
596
|
chatToken: this.chatToken
|
577
597
|
}))];
|
578
|
-
case
|
579
|
-
|
580
|
-
return [3 /*break*/,
|
581
|
-
case
|
582
|
-
error_6 =
|
598
|
+
case 30:
|
599
|
+
_1.sent();
|
600
|
+
return [3 /*break*/, 32];
|
601
|
+
case 31:
|
602
|
+
error_6 = _1.sent();
|
583
603
|
exceptionDetails = {
|
584
604
|
response: "AMSClientInitializeFailed"
|
585
605
|
};
|
@@ -589,19 +609,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
589
609
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
590
610
|
});
|
591
611
|
throw Error(exceptionDetails.response);
|
592
|
-
case
|
593
|
-
case
|
594
|
-
|
612
|
+
case 32: return [3 /*break*/, 39];
|
613
|
+
case 33:
|
614
|
+
_1.trys.push([33, 35, , 36]);
|
595
615
|
return [4 /*yield*/, this.IC3Client.initialize({
|
596
616
|
token: this.chatToken.token,
|
597
617
|
regionGtms: this.chatToken.regionGTMS,
|
598
618
|
visitor: true
|
599
619
|
})];
|
600
|
-
case
|
601
|
-
|
602
|
-
return [3 /*break*/,
|
603
|
-
case
|
604
|
-
error_7 =
|
620
|
+
case 34:
|
621
|
+
_1.sent();
|
622
|
+
return [3 /*break*/, 36];
|
623
|
+
case 35:
|
624
|
+
error_7 = _1.sent();
|
605
625
|
exceptionDetails = {
|
606
626
|
response: "IC3ClientInitializeFailed"
|
607
627
|
};
|
@@ -612,19 +632,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
612
632
|
});
|
613
633
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
614
634
|
return [2 /*return*/, error_7];
|
615
|
-
case
|
616
|
-
|
617
|
-
|
635
|
+
case 36:
|
636
|
+
_1.trys.push([36, 38, , 39]);
|
637
|
+
_0 = this;
|
618
638
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
619
|
-
case
|
620
|
-
|
639
|
+
case 37:
|
640
|
+
_0.conversation = _1.sent();
|
621
641
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
622
642
|
RequestId: this.requestId,
|
623
643
|
ChatId: this.chatToken.chatId
|
624
644
|
});
|
625
|
-
return [3 /*break*/,
|
626
|
-
case
|
627
|
-
error_8 =
|
645
|
+
return [3 /*break*/, 39];
|
646
|
+
case 38:
|
647
|
+
error_8 = _1.sent();
|
628
648
|
exceptionDetails = {
|
629
649
|
response: "IC3ClientJoinConversationFailed"
|
630
650
|
};
|
@@ -635,8 +655,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
635
655
|
});
|
636
656
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
637
657
|
return [2 /*return*/, error_8];
|
638
|
-
case
|
639
|
-
if (this.isPersistentChat && !((
|
658
|
+
case 39:
|
659
|
+
if (this.isPersistentChat && !((_u = this.chatSDKConfig.persistentChat) === null || _u === void 0 ? void 0 : _u.disable)) {
|
640
660
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
641
661
|
return __generator(this, function (_a) {
|
642
662
|
switch (_a.label) {
|
@@ -647,7 +667,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
647
667
|
return [2 /*return*/];
|
648
668
|
}
|
649
669
|
});
|
650
|
-
}); }, (
|
670
|
+
}); }, (_v = this.chatSDKConfig.persistentChat) === null || _v === void 0 ? void 0 : _v.tokenUpdateTime);
|
651
671
|
}
|
652
672
|
return [2 /*return*/];
|
653
673
|
}
|
@@ -655,11 +675,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
655
675
|
});
|
656
676
|
};
|
657
677
|
OmnichannelChatSDK.prototype.endChat = function () {
|
658
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
678
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
659
679
|
return __awaiter(this, void 0, void 0, function () {
|
660
680
|
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
|
661
|
-
return __generator(this, function (
|
662
|
-
switch (
|
681
|
+
return __generator(this, function (_r) {
|
682
|
+
switch (_r.label) {
|
663
683
|
case 0:
|
664
684
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
|
665
685
|
RequestId: this.requestId,
|
@@ -679,12 +699,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
679
699
|
if (this.authenticatedUserToken) {
|
680
700
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
681
701
|
}
|
682
|
-
|
702
|
+
_r.label = 1;
|
683
703
|
case 1:
|
684
|
-
|
704
|
+
_r.trys.push([1, 3, , 4]);
|
685
705
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
686
706
|
case 2:
|
687
|
-
|
707
|
+
_r.sent();
|
688
708
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
|
689
709
|
RequestId: this.requestId,
|
690
710
|
ChatId: this.chatToken.chatId
|
@@ -709,9 +729,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
709
729
|
(_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
|
710
730
|
(_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
|
711
731
|
(_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
|
732
|
+
(_p = this.amsClientLogger) === null || _p === void 0 ? void 0 : _p.setRequestId(this.requestId);
|
733
|
+
(_q = this.amsClientLogger) === null || _q === void 0 ? void 0 : _q.setChatId('');
|
712
734
|
return [3 /*break*/, 4];
|
713
735
|
case 3:
|
714
|
-
error_9 =
|
736
|
+
error_9 = _r.sent();
|
715
737
|
exceptionDetails = {
|
716
738
|
response: "OCClientSessionCloseFailed"
|
717
739
|
};
|