@microsoft/omnichannel-chat-sdk 1.8.1-main.dde2906 → 1.8.1
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 +6 -0
- package/lib/OmnichannelChatSDK.d.ts +4 -0
- package/lib/OmnichannelChatSDK.js +110 -109
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/config/ocSDKConfiguration.d.ts +7 -0
- package/lib/config/ocSDKConfiguration.js +10 -0
- package/lib/config/ocSDKConfiguration.js.map +1 -0
- package/lib/core/AxiosErrorCodes.d.ts +4 -0
- package/lib/core/AxiosErrorCodes.js +8 -0
- package/lib/core/AxiosErrorCodes.js.map +1 -0
- package/lib/core/ChatSDKConfig.d.ts +8 -0
- package/lib/tsconfig.tsbuildinfo +148 -76
- package/lib/utils/CoreServicesUtils.d.ts +6 -0
- package/lib/utils/CoreServicesUtils.js +36 -0
- package/lib/utils/CoreServicesUtils.js.map +1 -0
- package/lib/utils/internalUtils.d.ts +4 -0
- package/lib/utils/internalUtils.js +17 -0
- package/lib/utils/internalUtils.js.map +1 -0
- package/lib/utils/loggerUtils.d.ts +15 -0
- package/lib/utils/loggerUtils.js +56 -0
- package/lib/utils/loggerUtils.js.map +1 -0
- package/lib/utils/utilities.d.ts +2 -0
- package/lib/utils/utilities.js +11 -1
- package/lib/utils/utilities.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
## [Unreleased]
|
6
6
|
|
7
|
+
## [1.8.1] - 2024-04-24
|
8
|
+
### Added
|
9
|
+
|
10
|
+
- Adding new externalRuntimeId, allows to pass external runtimeId to ChatSDK and keep in sync sessions for telemetry.
|
11
|
+
- Add ability to use `CoreServices` orgUrl dynamically at runtime
|
12
|
+
|
7
13
|
## [1.8.0] - 2024-03-29
|
8
14
|
|
9
15
|
### Changed
|
@@ -44,6 +44,9 @@ declare class OmnichannelChatSDK {
|
|
44
44
|
localeId: string;
|
45
45
|
requestId: string;
|
46
46
|
sessionId: string | null;
|
47
|
+
private unqServicesOrgUrl;
|
48
|
+
private coreServicesOrgUrl;
|
49
|
+
private dynamicsLocationCode;
|
47
50
|
private chatToken;
|
48
51
|
private liveChatConfig;
|
49
52
|
private liveChatVersion;
|
@@ -106,5 +109,6 @@ declare class OmnichannelChatSDK {
|
|
106
109
|
private resolveChatAdapterUrl;
|
107
110
|
private updateChatToken;
|
108
111
|
private setAuthTokenProvider;
|
112
|
+
private useCoreServicesOrgUrlIfNotSet;
|
109
113
|
}
|
110
114
|
export default OmnichannelChatSDK;
|
@@ -95,14 +95,21 @@ var parsers_1 = require("./utils/parsers");
|
|
95
95
|
var retrieveCollectorUri_1 = require("./telemetry/retrieveCollectorUri");
|
96
96
|
var urlResolvers_1 = require("./utils/urlResolvers");
|
97
97
|
var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
|
98
|
+
var CoreServicesUtils_1 = require("./utils/CoreServicesUtils");
|
99
|
+
var loggerUtils_1 = require("./utils/loggerUtils");
|
100
|
+
var ocSDKConfiguration_1 = require("./config/ocSDKConfiguration");
|
101
|
+
var internalUtils_1 = require("./utils/internalUtils");
|
98
102
|
var OmnichannelChatSDK = /** @class */ (function () {
|
99
103
|
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
|
100
104
|
var _this = this;
|
101
105
|
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
|
102
|
-
var _a, _b, _c, _d, _e, _f, _g
|
106
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
103
107
|
this.ACSClient = null;
|
104
108
|
this.AMSClient = null;
|
105
109
|
this.sessionId = null;
|
110
|
+
this.unqServicesOrgUrl = null;
|
111
|
+
this.coreServicesOrgUrl = null;
|
112
|
+
this.dynamicsLocationCode = null;
|
106
113
|
this.authSettings = null;
|
107
114
|
this.authenticatedUserToken = null;
|
108
115
|
this.conversation = null;
|
@@ -175,7 +182,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
175
182
|
return requestOptionalParams;
|
176
183
|
};
|
177
184
|
this.debug = false;
|
178
|
-
this.runtimeId =
|
185
|
+
this.runtimeId = utilities_1.getRuntimeId((_b = (_a = chatSDKConfig === null || chatSDKConfig === void 0 ? void 0 : chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.runtimeId) !== null && _b !== void 0 ? _b : null);
|
179
186
|
this.omnichannelConfig = omnichannelConfig;
|
180
187
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
181
188
|
);
|
@@ -197,57 +204,37 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
197
204
|
this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
|
198
205
|
this.amsClientLogger = loggers_1.createAMSClientLogger(this.omnichannelConfig);
|
199
206
|
this.scenarioMarker.useTelemetry(this.telemetry);
|
200
|
-
|
201
|
-
this.ocSdkLogger.useTelemetry(this.telemetry);
|
202
|
-
this.acsClientLogger.useTelemetry(this.telemetry);
|
203
|
-
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
204
|
-
this.callingSdkLogger.useTelemetry(this.telemetry);
|
205
|
-
this.amsClientLogger.useTelemetry(this.telemetry);
|
207
|
+
loggerUtils_1.default.useTelemetry(this.telemetry, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
206
208
|
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
207
|
-
|
208
|
-
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
209
|
-
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
210
|
-
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
211
|
-
this.callingSdkLogger.setRuntimeId(this.runtimeId);
|
212
|
-
this.amsClientLogger.setRuntimeId(this.runtimeId);
|
209
|
+
loggerUtils_1.default.setRuntimeId(this.runtimeId, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
213
210
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
214
211
|
SDKConfigValidators_1.default(chatSDKConfig);
|
215
|
-
((
|
212
|
+
((_c = this.chatSDKConfig.telemetry) === null || _c === void 0 ? void 0 : _c.disable) && ((_d = this.telemetry) === null || _d === void 0 ? void 0 : _d.disable());
|
216
213
|
var collectorUri = retrieveCollectorUri_1.default(this.omnichannelConfig.orgUrl);
|
217
|
-
if ((
|
218
|
-
this.telemetry.setCollectorUri((
|
214
|
+
if ((_e = this.chatSDKConfig.telemetry) === null || _e === void 0 ? void 0 : _e.ariaCollectorUri) {
|
215
|
+
this.telemetry.setCollectorUri((_f = this.chatSDKConfig.telemetry) === null || _f === void 0 ? void 0 : _f.ariaCollectorUri);
|
219
216
|
}
|
220
217
|
else {
|
221
218
|
this.telemetry.setCollectorUri(collectorUri);
|
222
219
|
}
|
223
|
-
if ((
|
220
|
+
if ((_g = this.chatSDKConfig.telemetry) === null || _g === void 0 ? void 0 : _g.ariaTelemetryKey) {
|
224
221
|
this.telemetry.initialize(this.chatSDKConfig.telemetry.ariaTelemetryKey);
|
225
222
|
}
|
226
|
-
(
|
227
|
-
(_g = this.ocSdkLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
|
228
|
-
(_h = this.acsClientLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
|
229
|
-
(_j = this.acsAdapterLogger) === null || _j === void 0 ? void 0 : _j.setRequestId(this.requestId);
|
230
|
-
(_k = this.callingSdkLogger) === null || _k === void 0 ? void 0 : _k.setRequestId(this.requestId);
|
231
|
-
(_l = this.amsClientLogger) === null || _l === void 0 ? void 0 : _l.setRequestId(this.requestId);
|
223
|
+
loggerUtils_1.default.setRequestId(this.requestId, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
232
224
|
}
|
233
225
|
/* istanbul ignore next */
|
234
226
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
235
|
-
var _a, _b
|
227
|
+
var _a, _b;
|
236
228
|
this.debug = flag;
|
237
229
|
(_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
238
230
|
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
|
239
231
|
this.scenarioMarker.setDebug(flag);
|
240
|
-
(
|
241
|
-
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setDebug(flag);
|
242
|
-
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
|
243
|
-
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
|
244
|
-
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
|
245
|
-
(_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setDebug(flag);
|
232
|
+
loggerUtils_1.default.setDebug(flag, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
246
233
|
};
|
247
234
|
OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
|
248
235
|
if (optionalParams === void 0) { optionalParams = {}; }
|
249
236
|
return __awaiter(this, void 0, void 0, function () {
|
250
|
-
var
|
237
|
+
var _a, e_1, getLiveChatConfigOptionalParams, e_2, supportedLiveChatVersions, _b, _c, e_3;
|
251
238
|
return __generator(this, function (_d) {
|
252
239
|
switch (_d.label) {
|
253
240
|
case 0:
|
@@ -256,18 +243,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
256
243
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.InitializeChatSDK);
|
257
244
|
return [2 /*return*/, this.liveChatConfig];
|
258
245
|
}
|
259
|
-
|
260
|
-
getChatTokenRetryCount: 2,
|
261
|
-
getChatTokenTimeBetweenRetriesOnFailure: 2000,
|
262
|
-
getChatTokenRetryOn429: false,
|
263
|
-
useUnauthReconnectIdSigQueryParam: false
|
264
|
-
};
|
246
|
+
this.useCoreServicesOrgUrlIfNotSet();
|
265
247
|
_d.label = 1;
|
266
248
|
case 1:
|
267
249
|
_d.trys.push([1, 3, , 4]);
|
268
250
|
this.OCSDKProvider = ocsdk_1.SDKProvider;
|
269
251
|
_a = this;
|
270
|
-
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig,
|
252
|
+
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, ocSDKConfiguration_1.default, this.ocSdkLogger)];
|
271
253
|
case 2:
|
272
254
|
_a.OCClient = _d.sent();
|
273
255
|
return [3 /*break*/, 4];
|
@@ -472,13 +454,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
472
454
|
});
|
473
455
|
};
|
474
456
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
475
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
457
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
476
458
|
if (optionalParams === void 0) { optionalParams = {}; }
|
477
459
|
return __awaiter(this, void 0, void 0, function () {
|
478
|
-
var shouldReinitIC3Client,
|
460
|
+
var shouldReinitIC3Client, _j, reconnectableChatsParams, reconnectableChatsResponse, e_4, telemetryData, conversationDetails, telemetryData, telemetryData, e_5, telemetryData, sessionInitOptionalParams, location_2, sessionInitPromise, messagingClientPromise, attachmentClientPromise;
|
479
461
|
var _this = this;
|
480
|
-
return __generator(this, function (
|
481
|
-
switch (
|
462
|
+
return __generator(this, function (_k) {
|
463
|
+
switch (_k.label) {
|
482
464
|
case 0:
|
483
465
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
484
466
|
RequestId: this.requestId
|
@@ -488,31 +470,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
488
470
|
}
|
489
471
|
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
490
472
|
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
491
|
-
|
473
|
+
_j = this;
|
492
474
|
return [4 /*yield*/, this.getIC3Client()];
|
493
475
|
case 1:
|
494
|
-
|
495
|
-
|
476
|
+
_j.IC3Client = _k.sent();
|
477
|
+
_k.label = 2;
|
496
478
|
case 2:
|
497
479
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
498
480
|
this.reconnectId = optionalParams.reconnectId;
|
499
481
|
}
|
500
482
|
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
501
|
-
|
483
|
+
_k.label = 3;
|
502
484
|
case 3:
|
503
|
-
|
485
|
+
_k.trys.push([3, 5, , 6]);
|
504
486
|
reconnectableChatsParams = {
|
505
487
|
authenticatedUserToken: this.authenticatedUserToken
|
506
488
|
};
|
507
489
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
508
490
|
case 4:
|
509
|
-
reconnectableChatsResponse =
|
491
|
+
reconnectableChatsResponse = _k.sent();
|
510
492
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
511
493
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
512
494
|
}
|
513
495
|
return [3 /*break*/, 6];
|
514
496
|
case 5:
|
515
|
-
e_4 =
|
497
|
+
e_4 = _k.sent();
|
516
498
|
telemetryData = {
|
517
499
|
RequestId: this.requestId,
|
518
500
|
ChatId: this.chatToken.chatId,
|
@@ -526,7 +508,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
526
508
|
this.sessionId = optionalParams.liveChatContext.sessionId || null;
|
527
509
|
return [4 /*yield*/, this.getConversationDetails()];
|
528
510
|
case 7:
|
529
|
-
conversationDetails =
|
511
|
+
conversationDetails = _k.sent();
|
530
512
|
if (Object.keys(conversationDetails).length === 0) {
|
531
513
|
telemetryData = {
|
532
514
|
RequestId: this.requestId,
|
@@ -542,30 +524,30 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
542
524
|
};
|
543
525
|
exceptionThrowers_1.default.throwClosedConversation(this.scenarioMarker, TelemetryEvent_1.default.StartChat, telemetryData);
|
544
526
|
}
|
545
|
-
|
527
|
+
_k.label = 8;
|
546
528
|
case 8:
|
547
529
|
if (!this.authSettings) return [3 /*break*/, 14];
|
548
530
|
if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
|
549
531
|
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken, { throwError: true })];
|
550
532
|
case 9:
|
551
|
-
|
552
|
-
|
533
|
+
_k.sent();
|
534
|
+
_k.label = 10;
|
553
535
|
case 10:
|
554
536
|
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
|
555
537
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
556
538
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
557
|
-
|
539
|
+
_k.label = 11;
|
558
540
|
case 11:
|
559
|
-
|
541
|
+
_k.trys.push([11, 13, , 14]);
|
560
542
|
return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
|
561
543
|
authenticatedUserToken: this.authenticatedUserToken,
|
562
544
|
chatId: this.chatToken.chatId
|
563
545
|
})];
|
564
546
|
case 12:
|
565
|
-
|
547
|
+
_k.sent();
|
566
548
|
return [3 /*break*/, 14];
|
567
549
|
case 13:
|
568
|
-
e_5 =
|
550
|
+
e_5 = _k.sent();
|
569
551
|
telemetryData = {
|
570
552
|
RequestId: this.requestId,
|
571
553
|
ChatId: this.chatToken.chatId,
|
@@ -576,33 +558,28 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
576
558
|
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
|
577
559
|
return [4 /*yield*/, this.getChatToken(false)];
|
578
560
|
case 15:
|
579
|
-
|
580
|
-
|
561
|
+
_k.sent();
|
562
|
+
_k.label = 16;
|
581
563
|
case 16:
|
582
|
-
(
|
583
|
-
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
584
|
-
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
585
|
-
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
|
586
|
-
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
|
587
|
-
(_h = this.amsClientLogger) === null || _h === void 0 ? void 0 : _h.setChatId(this.chatToken.chatId || '');
|
564
|
+
loggerUtils_1.default.setChatId(this.chatToken.chatId || '', this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
588
565
|
sessionInitOptionalParams = {
|
589
566
|
initContext: {}
|
590
567
|
};
|
591
568
|
sessionInitOptionalParams = this.populateInitChatOptionalParam(sessionInitOptionalParams, optionalParams, TelemetryEvent_1.default.StartChat);
|
592
569
|
sessionInitOptionalParams.initContext.isProactiveChat = !!optionalParams.isProactiveChat;
|
593
|
-
if (this.isPersistentChat && !((
|
570
|
+
if (this.isPersistentChat && !((_c = this.chatSDKConfig.persistentChat) === null || _c === void 0 ? void 0 : _c.disable)) {
|
594
571
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
595
572
|
}
|
596
|
-
else if (this.isChatReconnect && !((
|
573
|
+
else if (this.isChatReconnect && !((_d = this.chatSDKConfig.chatReconnect) === null || _d === void 0 ? void 0 : _d.disable) && !this.isPersistentChat) {
|
597
574
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
598
575
|
}
|
599
|
-
if (!(parsers_1.parseLowerCaseString((
|
576
|
+
if (!(parsers_1.parseLowerCaseString((_f = (_e = this.liveChatConfig) === null || _e === void 0 ? void 0 : _e.LiveWSAndLiveChatEngJoin) === null || _f === void 0 ? void 0 : _f.msdyn_requestvisitorlocation) === "true")) return [3 /*break*/, 18];
|
600
577
|
return [4 /*yield*/, location_1.getLocationInfo(this.scenarioMarker, this.chatToken.chatId, this.requestId)];
|
601
578
|
case 17:
|
602
|
-
location_2 =
|
579
|
+
location_2 = _k.sent();
|
603
580
|
sessionInitOptionalParams.initContext.latitude = location_2.latitude;
|
604
581
|
sessionInitOptionalParams.initContext.longitude = location_2.longitude;
|
605
|
-
|
582
|
+
_k.label = 18;
|
606
583
|
case 18:
|
607
584
|
sessionInitPromise = function () { return __awaiter(_this, void 0, void 0, function () {
|
608
585
|
var error_3, telemetryData;
|
@@ -758,8 +735,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
758
735
|
}); };
|
759
736
|
return [4 /*yield*/, Promise.all([sessionInitPromise(), messagingClientPromise(), attachmentClientPromise()])];
|
760
737
|
case 19:
|
761
|
-
|
762
|
-
if (this.isPersistentChat && !((
|
738
|
+
_k.sent();
|
739
|
+
if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
|
763
740
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
764
741
|
return __generator(this, function (_a) {
|
765
742
|
switch (_a.label) {
|
@@ -770,7 +747,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
770
747
|
return [2 /*return*/];
|
771
748
|
}
|
772
749
|
});
|
773
|
-
}); }, (
|
750
|
+
}); }, (_h = this.chatSDKConfig.persistentChat) === null || _h === void 0 ? void 0 : _h.tokenUpdateTime);
|
774
751
|
}
|
775
752
|
return [2 /*return*/];
|
776
753
|
}
|
@@ -778,11 +755,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
778
755
|
});
|
779
756
|
};
|
780
757
|
OmnichannelChatSDK.prototype.endChat = function () {
|
781
|
-
var _a, _b, _c
|
758
|
+
var _a, _b, _c;
|
782
759
|
return __awaiter(this, void 0, void 0, function () {
|
783
760
|
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, telemetryData;
|
784
|
-
return __generator(this, function (
|
785
|
-
switch (
|
761
|
+
return __generator(this, function (_d) {
|
762
|
+
switch (_d.label) {
|
786
763
|
case 0:
|
787
764
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
|
788
765
|
RequestId: this.requestId,
|
@@ -802,12 +779,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
802
779
|
if (this.authenticatedUserToken) {
|
803
780
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
804
781
|
}
|
805
|
-
|
782
|
+
_d.label = 1;
|
806
783
|
case 1:
|
807
|
-
|
784
|
+
_d.trys.push([1, 3, , 4]);
|
808
785
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
809
786
|
case 2:
|
810
|
-
|
787
|
+
_d.sent();
|
811
788
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
|
812
789
|
RequestId: this.requestId,
|
813
790
|
ChatId: this.chatToken.chatId
|
@@ -826,21 +803,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
826
803
|
this.OCClient.sessionId = null;
|
827
804
|
this.sessionId = null;
|
828
805
|
}
|
829
|
-
(
|
830
|
-
(
|
831
|
-
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
832
|
-
(_g = this.ocSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId('');
|
833
|
-
(_h = this.acsClientLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
|
834
|
-
(_j = this.acsClientLogger) === null || _j === void 0 ? void 0 : _j.setChatId('');
|
835
|
-
(_k = this.acsAdapterLogger) === null || _k === void 0 ? void 0 : _k.setRequestId(this.requestId);
|
836
|
-
(_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
|
837
|
-
(_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
|
838
|
-
(_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
|
839
|
-
(_p = this.amsClientLogger) === null || _p === void 0 ? void 0 : _p.setRequestId(this.requestId);
|
840
|
-
(_q = this.amsClientLogger) === null || _q === void 0 ? void 0 : _q.setChatId('');
|
806
|
+
loggerUtils_1.default.setRequestId(this.requestId, this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
807
|
+
loggerUtils_1.default.setChatId('', this.ocSdkLogger, this.acsClientLogger, this.acsAdapterLogger, this.callingSdkLogger, this.amsClientLogger, this.ic3ClientLogger);
|
841
808
|
return [3 /*break*/, 4];
|
842
809
|
case 3:
|
843
|
-
error_9 =
|
810
|
+
error_9 = _d.sent();
|
844
811
|
telemetryData = {
|
845
812
|
RequestId: this.requestId,
|
846
813
|
ChatId: this.chatToken.chatId
|
@@ -2213,15 +2180,34 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2213
2180
|
OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
|
2214
2181
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2215
2182
|
return __awaiter(this, void 0, void 0, function () {
|
2216
|
-
var sendCacheHeaders, bypassCache, liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled;
|
2217
|
-
return __generator(this, function (
|
2218
|
-
switch (
|
2183
|
+
var sendCacheHeaders, bypassCache, liveChatConfig, error_20, _a, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled;
|
2184
|
+
return __generator(this, function (_b) {
|
2185
|
+
switch (_b.label) {
|
2219
2186
|
case 0:
|
2220
2187
|
sendCacheHeaders = optionalParams.sendCacheHeaders;
|
2221
2188
|
bypassCache = sendCacheHeaders === true;
|
2222
|
-
|
2189
|
+
_b.label = 1;
|
2223
2190
|
case 1:
|
2224
|
-
|
2191
|
+
_b.trys.push([1, 3, , 8]);
|
2192
|
+
return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
|
2193
|
+
case 2:
|
2194
|
+
liveChatConfig = _b.sent();
|
2195
|
+
return [3 /*break*/, 8];
|
2196
|
+
case 3:
|
2197
|
+
error_20 = _b.sent();
|
2198
|
+
if (!internalUtils_1.isCoreServicesOrgUrlDNSError(error_20, this.coreServicesOrgUrl, this.dynamicsLocationCode)) return [3 /*break*/, 6];
|
2199
|
+
this.omnichannelConfig.orgUrl = this.unqServicesOrgUrl;
|
2200
|
+
_a = this;
|
2201
|
+
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, ocSDKConfiguration_1.default, this.ocSdkLogger)];
|
2202
|
+
case 4:
|
2203
|
+
_a.OCClient = _b.sent();
|
2204
|
+
return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
|
2205
|
+
case 5:
|
2206
|
+
liveChatConfig = _b.sent(); // Bubble up error by default to throw ChatConfigRetrievalFailure
|
2207
|
+
return [3 /*break*/, 7];
|
2208
|
+
case 6: throw error_20; // Bubble up error by default to throw ChatConfigRetrievalFailure
|
2209
|
+
case 7: return [3 /*break*/, 8];
|
2210
|
+
case 8:
|
2225
2211
|
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
2226
2212
|
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
2227
2213
|
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
@@ -2247,12 +2233,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2247
2233
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
2248
2234
|
this.preChatSurvey = preChatSurvey;
|
2249
2235
|
}
|
2250
|
-
if (!(this.authSettings && this.chatSDKConfig.getAuthToken)) return [3 /*break*/,
|
2236
|
+
if (!(this.authSettings && this.chatSDKConfig.getAuthToken)) return [3 /*break*/, 10];
|
2251
2237
|
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken, { throwError: false })];
|
2252
|
-
case
|
2253
|
-
|
2254
|
-
|
2255
|
-
case
|
2238
|
+
case 9:
|
2239
|
+
_b.sent(); // throwError set to 'false` for backward compatibility
|
2240
|
+
_b.label = 10;
|
2241
|
+
case 10:
|
2256
2242
|
if (this.preChatSurvey) {
|
2257
2243
|
/* istanbul ignore next */
|
2258
2244
|
this.debug && console.log('Prechat Survey!');
|
@@ -2272,7 +2258,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2272
2258
|
};
|
2273
2259
|
OmnichannelChatSDK.prototype.updateChatToken = function (newToken, newRegionGTMS) {
|
2274
2260
|
return __awaiter(this, void 0, void 0, function () {
|
2275
|
-
var sessionInfo,
|
2261
|
+
var sessionInfo, error_21, exceptionDetails;
|
2276
2262
|
return __generator(this, function (_a) {
|
2277
2263
|
switch (_a.label) {
|
2278
2264
|
case 0:
|
@@ -2300,7 +2286,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2300
2286
|
});
|
2301
2287
|
return [3 /*break*/, 5];
|
2302
2288
|
case 4:
|
2303
|
-
|
2289
|
+
error_21 = _a.sent();
|
2304
2290
|
exceptionDetails = {
|
2305
2291
|
response: "UpdateChatTokenFailed"
|
2306
2292
|
};
|
@@ -2318,7 +2304,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2318
2304
|
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider, optionalParams) {
|
2319
2305
|
if (optionalParams === void 0) { optionalParams = {}; }
|
2320
2306
|
return __awaiter(this, void 0, void 0, function () {
|
2321
|
-
var token, exceptionDetails,
|
2307
|
+
var token, exceptionDetails, error_22, exceptionDetails, exceptionDetails;
|
2322
2308
|
return __generator(this, function (_a) {
|
2323
2309
|
switch (_a.label) {
|
2324
2310
|
case 0:
|
@@ -2349,12 +2335,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2349
2335
|
}
|
2350
2336
|
return [3 /*break*/, 4];
|
2351
2337
|
case 3:
|
2352
|
-
|
2338
|
+
error_22 = _a.sent();
|
2353
2339
|
exceptionDetails = {
|
2354
2340
|
response: ChatSDKError_1.ChatSDKErrorName.GetAuthTokenFailed
|
2355
2341
|
};
|
2356
|
-
if (
|
2357
|
-
exceptionDetails.response =
|
2342
|
+
if (error_22.message == ChatSDKError_1.ChatSDKErrorName.UndefinedAuthToken) {
|
2343
|
+
exceptionDetails.response = error_22.message;
|
2358
2344
|
}
|
2359
2345
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2360
2346
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
@@ -2380,6 +2366,21 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2380
2366
|
});
|
2381
2367
|
});
|
2382
2368
|
};
|
2369
|
+
OmnichannelChatSDK.prototype.useCoreServicesOrgUrlIfNotSet = function () {
|
2370
|
+
var _a;
|
2371
|
+
if (!this.omnichannelConfig.orgUrl.startsWith(CoreServicesUtils_1.coreServicesOrgUrlPrefix) && ((_a = this.chatSDKConfig.internalConfig) === null || _a === void 0 ? void 0 : _a.createCoreServicesOrgUrlAtRuntime) === true) {
|
2372
|
+
var result = CoreServicesUtils_1.unqOrgUrlPattern.exec(this.omnichannelConfig.orgUrl);
|
2373
|
+
if (result) {
|
2374
|
+
this.dynamicsLocationCode = result[1];
|
2375
|
+
var geoName = CoreServicesUtils_1.getCoreServicesGeoName(this.dynamicsLocationCode);
|
2376
|
+
if (geoName) {
|
2377
|
+
this.unqServicesOrgUrl = this.omnichannelConfig.orgUrl;
|
2378
|
+
this.coreServicesOrgUrl = CoreServicesUtils_1.createCoreServicesOrgUrl(this.omnichannelConfig.orgId, geoName);
|
2379
|
+
this.omnichannelConfig.orgUrl = this.coreServicesOrgUrl;
|
2380
|
+
}
|
2381
|
+
}
|
2382
|
+
}
|
2383
|
+
};
|
2383
2384
|
return OmnichannelChatSDK;
|
2384
2385
|
}());
|
2385
2386
|
exports.default = OmnichannelChatSDK;
|