@microsoft/omnichannel-chat-sdk 1.0.1-main.fa78d5f → 1.1.1-main.063303c
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 +36 -4
- package/README.md +482 -306
- package/lib/OmnichannelChatSDK.d.ts +10 -6
- package/lib/OmnichannelChatSDK.js +379 -317
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/api/createVoiceVideoCalling.js +6 -2
- package/lib/api/createVoiceVideoCalling.js.map +1 -1
- package/lib/config/settings.d.ts +1 -1
- package/lib/config/settings.js +1 -1
- package/lib/core/ChatConfig.d.ts +4 -0
- package/lib/core/ChatSDKExceptionDetails.d.ts +5 -0
- package/lib/core/ChatSDKExceptionDetails.js +3 -0
- package/lib/core/ChatSDKExceptionDetails.js.map +1 -0
- package/lib/core/ChatTranscriptBody.d.ts +1 -1
- package/lib/core/GetLiveChatConfigOptionalParams.d.ts +5 -0
- package/lib/core/GetLiveChatConfigOptionalParams.js +3 -0
- package/lib/core/GetLiveChatConfigOptionalParams.js.map +1 -0
- package/lib/core/InitializeOptionalParams.d.ts +5 -0
- package/lib/core/InitializeOptionalParams.js +3 -0
- package/lib/core/InitializeOptionalParams.js.map +1 -0
- package/lib/core/LiveWorkItemDetails.d.ts +2 -0
- package/lib/core/OmnichannelErrorCodes.d.ts +4 -0
- package/lib/core/OmnichannelErrorCodes.js +8 -0
- package/lib/core/OmnichannelErrorCodes.js.map +1 -0
- package/lib/core/PostChatContext.d.ts +1 -0
- package/lib/core/StartChatOptionalParams.d.ts +1 -0
- package/lib/core/messaging/ACSClient.d.ts +1 -0
- package/lib/core/messaging/ACSClient.js +3 -0
- package/lib/core/messaging/ACSClient.js.map +1 -1
- package/lib/core/messaging/ChatAdapterOptionalParams.d.ts +14 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.js +3 -0
- package/lib/core/messaging/ChatAdapterOptionalParams.js.map +1 -0
- package/lib/core/messaging/MessageTags.d.ts +2 -0
- package/lib/core/messaging/MessageTags.js +4 -2
- package/lib/core/messaging/MessageTags.js.map +1 -1
- package/lib/external/ACSAdapter/AMSFileManager.js +12 -0
- package/lib/external/ACSAdapter/AMSFileManager.js.map +1 -1
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.d.ts +5 -0
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js +34 -0
- package/lib/external/ACSAdapter/createChannelDataEgressMiddleware.js.map +1 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.d.ts +7 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.js +3 -0
- package/lib/external/CallingSDK/ICallingSDKLogData.js.map +1 -0
- package/lib/external/IC3Adapter/IIC3AdapterOptions.d.ts +12 -0
- package/lib/index.d.ts +7 -6
- package/lib/index.js +13 -8
- package/lib/index.js.map +1 -1
- package/lib/telemetry/AriaTelemetry.d.ts +1 -0
- package/lib/telemetry/AriaTelemetry.js +55 -0
- package/lib/telemetry/AriaTelemetry.js.map +1 -1
- package/lib/telemetry/ScenarioMarker.d.ts +2 -0
- package/lib/telemetry/ScenarioMarker.js +7 -3
- package/lib/telemetry/ScenarioMarker.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 +1 -3
- package/lib/telemetry/TelemetryEvent.js +0 -2
- package/lib/telemetry/TelemetryEvent.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +203 -76
- package/lib/utils/WebUtils.d.ts +3 -1
- package/lib/utils/WebUtils.js +8 -2
- package/lib/utils/WebUtils.js.map +1 -1
- package/lib/utils/libraries.d.ts +1 -3
- package/lib/utils/libraries.js +2 -11
- package/lib/utils/libraries.js.map +1 -1
- package/lib/utils/locale.d.ts +2 -0
- package/lib/utils/locale.js +5 -3
- package/lib/utils/locale.js.map +1 -1
- package/lib/utils/loggers.d.ts +26 -1
- package/lib/utils/loggers.js +94 -2
- package/lib/utils/loggers.js.map +1 -1
- package/package.json +2 -2
@@ -58,7 +58,8 @@ 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
|
61
|
+
var locale_1 = require("./utils/locale");
|
62
|
+
var WebUtils_1 = require("./utils/WebUtils");
|
62
63
|
var platform_1 = require("./utils/platform");
|
63
64
|
var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
|
64
65
|
var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
|
@@ -66,8 +67,6 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
|
|
66
67
|
var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
|
67
68
|
var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
|
68
69
|
var ConversationMode_1 = require("./core/ConversationMode");
|
69
|
-
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
70
|
-
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
71
70
|
var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
|
72
71
|
var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
|
73
72
|
var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
|
@@ -76,23 +75,26 @@ var LiveChatVersion_1 = require("./core/LiveChatVersion");
|
|
76
75
|
var LiveWorkItemState_1 = require("./core/LiveWorkItemState");
|
77
76
|
var MessageContentType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageContentType");
|
78
77
|
var MessageType_1 = require("@microsoft/omnichannel-ic3core/lib/model/MessageType");
|
78
|
+
var OmnichannelErrorCodes_1 = require("./core/OmnichannelErrorCodes");
|
79
79
|
var PersonType_1 = require("@microsoft/omnichannel-ic3core/lib/model/PersonType");
|
80
80
|
var ProtocoleType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/ProtocoleType");
|
81
81
|
var ScenarioMarker_1 = require("./telemetry/ScenarioMarker");
|
82
82
|
var TelemetryEvent_1 = require("./telemetry/TelemetryEvent");
|
83
83
|
var omnichannel_amsclient_1 = require("@microsoft/omnichannel-amsclient");
|
84
|
+
var createChannelDataEgressMiddleware_1 = require("./external/ACSAdapter/createChannelDataEgressMiddleware");
|
85
|
+
var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
|
86
|
+
var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
|
84
87
|
var createOmnichannelMessage_1 = require("./utils/createOmnichannelMessage");
|
85
88
|
var createTelemetry_1 = require("./utils/createTelemetry");
|
86
89
|
var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
|
87
90
|
var MessageTags_1 = require("./core/messaging/MessageTags");
|
88
|
-
var locale_1 = require("./utils/locale");
|
89
91
|
var utilities_1 = require("./utils/utilities");
|
90
|
-
var
|
92
|
+
var libraries_1 = require("./utils/libraries");
|
91
93
|
var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
|
92
94
|
var OmnichannelChatSDK = /** @class */ (function () {
|
93
95
|
function OmnichannelChatSDK(omnichannelConfig, chatSDKConfig) {
|
94
96
|
if (chatSDKConfig === void 0) { chatSDKConfig = SDKConfigValidators_1.defaultChatSDKConfig; }
|
95
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
97
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
96
98
|
this.ACSClient = null;
|
97
99
|
this.AMSClient = null;
|
98
100
|
this.authSettings = null;
|
@@ -104,16 +106,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
104
106
|
this.ocSdkLogger = null;
|
105
107
|
this.acsClientLogger = null;
|
106
108
|
this.acsAdapterLogger = null;
|
109
|
+
this.callingSdkLogger = null;
|
107
110
|
this.isPersistentChat = false;
|
108
111
|
this.isChatReconnect = false;
|
109
112
|
this.reconnectId = null;
|
110
113
|
this.refreshTokenTimer = null;
|
111
114
|
this.debug = false;
|
115
|
+
this.runtimeId = ocsdk_1.uuidv4();
|
112
116
|
this.omnichannelConfig = omnichannelConfig;
|
113
117
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
114
118
|
);
|
115
119
|
this.isInitialized = false;
|
116
120
|
this.liveChatVersion = LiveChatVersion_1.default.V1;
|
121
|
+
this.localeId = locale_1.defaultLocaleId;
|
117
122
|
this.requestId = ocsdk_1.uuidv4();
|
118
123
|
this.chatToken = {};
|
119
124
|
this.liveChatConfig = {};
|
@@ -126,11 +131,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
126
131
|
this.ocSdkLogger = loggers_1.createOCSDKLogger(this.omnichannelConfig);
|
127
132
|
this.acsClientLogger = loggers_1.createACSClientLogger(this.omnichannelConfig);
|
128
133
|
this.acsAdapterLogger = loggers_1.createACSAdapterLogger(this.omnichannelConfig);
|
134
|
+
this.callingSdkLogger = loggers_1.createCallingSDKLogger(this.omnichannelConfig);
|
129
135
|
this.scenarioMarker.useTelemetry(this.telemetry);
|
130
136
|
this.ic3ClientLogger.useTelemetry(this.telemetry);
|
131
137
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
132
138
|
this.acsClientLogger.useTelemetry(this.telemetry);
|
133
139
|
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
140
|
+
this.callingSdkLogger.useTelemetry(this.telemetry);
|
141
|
+
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
142
|
+
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
143
|
+
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
144
|
+
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
145
|
+
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
146
|
+
this.callingSdkLogger.setRuntimeId(this.runtimeId);
|
134
147
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
135
148
|
SDKConfigValidators_1.default(chatSDKConfig);
|
136
149
|
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
|
@@ -141,10 +154,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
141
154
|
(_e = this.ocSdkLogger) === null || _e === void 0 ? void 0 : _e.setRequestId(this.requestId);
|
142
155
|
(_f = this.acsClientLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
143
156
|
(_g = this.acsAdapterLogger) === null || _g === void 0 ? void 0 : _g.setRequestId(this.requestId);
|
157
|
+
(_h = this.callingSdkLogger) === null || _h === void 0 ? void 0 : _h.setRequestId(this.requestId);
|
144
158
|
}
|
145
159
|
/* istanbul ignore next */
|
146
160
|
OmnichannelChatSDK.prototype.setDebug = function (flag) {
|
147
|
-
var _a, _b, _c, _d, _e, _f;
|
161
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
148
162
|
this.debug = flag;
|
149
163
|
(_a = this.AMSClient) === null || _a === void 0 ? void 0 : _a.setDebug(flag);
|
150
164
|
(_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.setDebug(flag);
|
@@ -153,10 +167,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
153
167
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setDebug(flag);
|
154
168
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setDebug(flag);
|
155
169
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setDebug(flag);
|
170
|
+
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setDebug(flag);
|
156
171
|
};
|
157
|
-
OmnichannelChatSDK.prototype.initialize = function () {
|
172
|
+
OmnichannelChatSDK.prototype.initialize = function (optionalParams) {
|
173
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
158
174
|
return __awaiter(this, void 0, void 0, function () {
|
159
|
-
var _a, _b, _c, _d;
|
175
|
+
var _a, getLiveChatConfigOptionalParams, _b, _c, _d;
|
160
176
|
return __generator(this, function (_e) {
|
161
177
|
switch (_e.label) {
|
162
178
|
case 0:
|
@@ -173,7 +189,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
173
189
|
return [4 /*yield*/, ocsdk_1.SDKProvider.getSDK(this.omnichannelConfig, {}, this.ocSdkLogger)];
|
174
190
|
case 2:
|
175
191
|
_a.OCClient = _e.sent();
|
176
|
-
|
192
|
+
getLiveChatConfigOptionalParams = optionalParams.getLiveChatConfigOptionalParams;
|
193
|
+
return [4 /*yield*/, this.getChatConfig(getLiveChatConfigOptionalParams || {})];
|
177
194
|
case 3:
|
178
195
|
_e.sent();
|
179
196
|
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 5];
|
@@ -291,47 +308,55 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
291
308
|
});
|
292
309
|
};
|
293
310
|
OmnichannelChatSDK.prototype.startChat = function (optionalParams) {
|
294
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
311
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
295
312
|
if (optionalParams === void 0) { optionalParams = {}; }
|
296
313
|
return __awaiter(this, void 0, void 0, function () {
|
297
|
-
var reconnectableChatsParams, reconnectableChatsResponse,
|
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;
|
298
315
|
var _this = this;
|
299
|
-
return __generator(this, function (
|
300
|
-
switch (
|
316
|
+
return __generator(this, function (_y) {
|
317
|
+
switch (_y.label) {
|
301
318
|
case 0:
|
302
319
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
303
320
|
RequestId: this.requestId
|
304
321
|
});
|
322
|
+
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
323
|
+
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
324
|
+
_t = this;
|
325
|
+
return [4 /*yield*/, this.getIC3Client()];
|
326
|
+
case 1:
|
327
|
+
_t.IC3Client = _y.sent();
|
328
|
+
_y.label = 2;
|
329
|
+
case 2:
|
305
330
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
306
331
|
this.reconnectId = optionalParams.reconnectId;
|
307
332
|
}
|
308
|
-
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/,
|
309
|
-
|
310
|
-
case
|
311
|
-
|
333
|
+
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
334
|
+
_y.label = 3;
|
335
|
+
case 3:
|
336
|
+
_y.trys.push([3, 5, , 6]);
|
312
337
|
reconnectableChatsParams = {
|
313
338
|
authenticatedUserToken: this.authenticatedUserToken
|
314
339
|
};
|
315
340
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
316
|
-
case
|
317
|
-
reconnectableChatsResponse =
|
341
|
+
case 4:
|
342
|
+
reconnectableChatsResponse = _y.sent();
|
318
343
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
319
344
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
320
345
|
}
|
321
|
-
return [3 /*break*/,
|
322
|
-
case
|
323
|
-
|
346
|
+
return [3 /*break*/, 6];
|
347
|
+
case 5:
|
348
|
+
_u = _y.sent();
|
324
349
|
exceptionDetails = {
|
325
350
|
response: "OCClientGetReconnectableChatsFailed"
|
326
351
|
};
|
327
352
|
throw Error(exceptionDetails.response);
|
328
|
-
case
|
329
|
-
if (!(optionalParams.liveChatContext &&
|
353
|
+
case 6:
|
354
|
+
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0 && !this.reconnectId)) return [3 /*break*/, 8];
|
330
355
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
331
356
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
332
357
|
return [4 /*yield*/, this.getConversationDetails()];
|
333
|
-
case
|
334
|
-
conversationDetails =
|
358
|
+
case 7:
|
359
|
+
conversationDetails = _y.sent();
|
335
360
|
if (Object.keys(conversationDetails).length === 0) {
|
336
361
|
exceptionDetails = {
|
337
362
|
response: "InvalidConversation"
|
@@ -356,25 +381,60 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
356
381
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
357
382
|
throw Error(exceptionDetails.response);
|
358
383
|
}
|
359
|
-
|
360
|
-
case 6:
|
361
|
-
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 8];
|
362
|
-
return [4 /*yield*/, this.getChatToken(false)];
|
363
|
-
case 7:
|
364
|
-
_s.sent();
|
365
|
-
_s.label = 8;
|
384
|
+
_y.label = 8;
|
366
385
|
case 8:
|
386
|
+
if (!this.authSettings) return [3 /*break*/, 14];
|
387
|
+
if (!!this.authenticatedUserToken) return [3 /*break*/, 10];
|
388
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
389
|
+
case 9:
|
390
|
+
_y.sent();
|
391
|
+
_y.label = 10;
|
392
|
+
case 10:
|
393
|
+
if (!(optionalParams.liveChatContext && Object.keys(optionalParams.liveChatContext).length > 0)) return [3 /*break*/, 14];
|
394
|
+
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
395
|
+
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
396
|
+
_y.label = 11;
|
397
|
+
case 11:
|
398
|
+
_y.trys.push([11, 13, , 14]);
|
399
|
+
return [4 /*yield*/, this.OCClient.validateAuthChatRecord(this.requestId, {
|
400
|
+
authenticatedUserToken: this.authenticatedUserToken,
|
401
|
+
chatId: this.chatToken.chatId
|
402
|
+
})];
|
403
|
+
case 12:
|
404
|
+
_y.sent();
|
405
|
+
return [3 /*break*/, 14];
|
406
|
+
case 13:
|
407
|
+
_v = _y.sent();
|
408
|
+
exceptionDetails = {
|
409
|
+
response: "OCClientValidateAuthChatRecordFailed",
|
410
|
+
message: "InvalidAuthChatRecord"
|
411
|
+
};
|
412
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
413
|
+
RequestId: this.requestId,
|
414
|
+
ChatId: this.chatToken.chatId,
|
415
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
416
|
+
});
|
417
|
+
throw Error(exceptionDetails.response);
|
418
|
+
case 14:
|
419
|
+
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 16];
|
420
|
+
return [4 /*yield*/, this.getChatToken(false)];
|
421
|
+
case 15:
|
422
|
+
_y.sent();
|
423
|
+
_y.label = 16;
|
424
|
+
case 16:
|
367
425
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
368
426
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
369
427
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
370
428
|
(_f = this.acsAdapterLogger) === null || _f === void 0 ? void 0 : _f.setChatId(this.chatToken.chatId || '');
|
429
|
+
(_g = this.callingSdkLogger) === null || _g === void 0 ? void 0 : _g.setChatId(this.chatToken.chatId || '');
|
371
430
|
sessionInitOptionalParams = {
|
372
431
|
initContext: {}
|
373
432
|
};
|
374
|
-
|
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)) {
|
375
435
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
376
436
|
}
|
377
|
-
if (this.isChatReconnect && !((
|
437
|
+
if (this.isChatReconnect && !((_j = this.chatSDKConfig.chatReconnect) === null || _j === void 0 ? void 0 : _j.disable) && !this.isPersistentChat) {
|
378
438
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
379
439
|
}
|
380
440
|
if (optionalParams.customContext) {
|
@@ -395,6 +455,22 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
395
455
|
if (optionalParams.preChatResponse) {
|
396
456
|
sessionInitOptionalParams.initContext.preChatResponse = optionalParams.preChatResponse;
|
397
457
|
}
|
458
|
+
if (optionalParams.sendDefaultInitContext) {
|
459
|
+
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
460
|
+
exceptionDetails = {
|
461
|
+
response: "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
|
+
}
|
398
474
|
// Override initContext completely
|
399
475
|
if (optionalParams.initContext) {
|
400
476
|
sessionInitOptionalParams.initContext = optionalParams.initContext;
|
@@ -402,46 +478,56 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
402
478
|
if (this.authenticatedUserToken) {
|
403
479
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
404
480
|
}
|
405
|
-
|
406
|
-
|
407
|
-
|
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;
|
487
|
+
case 17:
|
488
|
+
_y.trys.push([17, 19, , 20]);
|
408
489
|
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
409
|
-
case
|
410
|
-
|
411
|
-
return [3 /*break*/,
|
412
|
-
case
|
413
|
-
error_3 =
|
490
|
+
case 18:
|
491
|
+
_y.sent();
|
492
|
+
return [3 /*break*/, 20];
|
493
|
+
case 19:
|
494
|
+
error_3 = _y.sent();
|
414
495
|
exceptionDetails = {
|
415
496
|
response: "OCClientSessionInitFailed"
|
416
497
|
};
|
498
|
+
// 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);
|
503
|
+
}
|
417
504
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.StartChat, {
|
418
505
|
RequestId: this.requestId,
|
419
506
|
ChatId: this.chatToken.chatId,
|
420
507
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
421
508
|
});
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 23];
|
509
|
+
throw new Error(exceptionDetails.response);
|
510
|
+
case 20:
|
511
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 31];
|
426
512
|
chatAdapterConfig = {
|
427
513
|
token: this.chatToken.token,
|
428
514
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
429
515
|
threadId: this.chatToken.chatId,
|
430
516
|
environmentUrl: this.chatToken.acsEndpoint,
|
431
|
-
pollingInterval:
|
517
|
+
pollingInterval: 30000
|
432
518
|
};
|
433
|
-
|
434
|
-
case
|
435
|
-
|
436
|
-
return [4 /*yield*/, ((
|
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({
|
437
523
|
token: chatAdapterConfig.token,
|
438
524
|
environmentUrl: chatAdapterConfig.environmentUrl
|
439
525
|
}))];
|
440
|
-
case
|
441
|
-
|
442
|
-
return [3 /*break*/,
|
443
|
-
case
|
444
|
-
error_4 =
|
526
|
+
case 22:
|
527
|
+
_y.sent();
|
528
|
+
return [3 /*break*/, 24];
|
529
|
+
case 23:
|
530
|
+
error_4 = _y.sent();
|
445
531
|
exceptionDetails = {
|
446
532
|
response: "ACSClientInitializeFailed"
|
447
533
|
};
|
@@ -452,23 +538,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
452
538
|
});
|
453
539
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
454
540
|
return [2 /*return*/, error_4];
|
455
|
-
case
|
456
|
-
|
457
|
-
|
458
|
-
return [4 /*yield*/, ((
|
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({
|
459
545
|
id: chatAdapterConfig.id,
|
460
546
|
threadId: chatAdapterConfig.threadId,
|
461
547
|
pollingInterval: chatAdapterConfig.pollingInterval
|
462
548
|
}))];
|
463
|
-
case
|
464
|
-
|
549
|
+
case 25:
|
550
|
+
_w.conversation = (_y.sent());
|
465
551
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
466
552
|
RequestId: this.requestId,
|
467
553
|
ChatId: this.chatToken.chatId
|
468
554
|
});
|
469
|
-
return [3 /*break*/,
|
470
|
-
case
|
471
|
-
error_5 =
|
555
|
+
return [3 /*break*/, 27];
|
556
|
+
case 26:
|
557
|
+
error_5 = _y.sent();
|
472
558
|
exceptionDetails = {
|
473
559
|
response: "ACSClientJoinConversationFailed"
|
474
560
|
};
|
@@ -479,16 +565,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
479
565
|
});
|
480
566
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
481
567
|
throw Error(exceptionDetails.response);
|
482
|
-
case
|
483
|
-
|
484
|
-
return [4 /*yield*/, ((
|
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({
|
485
571
|
chatToken: this.chatToken
|
486
572
|
}))];
|
487
|
-
case
|
488
|
-
|
489
|
-
return [3 /*break*/,
|
490
|
-
case
|
491
|
-
error_6 =
|
573
|
+
case 28:
|
574
|
+
_y.sent();
|
575
|
+
return [3 /*break*/, 30];
|
576
|
+
case 29:
|
577
|
+
error_6 = _y.sent();
|
492
578
|
exceptionDetails = {
|
493
579
|
response: "AMSClientInitializeFailed"
|
494
580
|
};
|
@@ -498,19 +584,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
498
584
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
499
585
|
});
|
500
586
|
throw Error(exceptionDetails.response);
|
501
|
-
case
|
502
|
-
case
|
503
|
-
|
587
|
+
case 30: return [3 /*break*/, 37];
|
588
|
+
case 31:
|
589
|
+
_y.trys.push([31, 33, , 34]);
|
504
590
|
return [4 /*yield*/, this.IC3Client.initialize({
|
505
591
|
token: this.chatToken.token,
|
506
592
|
regionGtms: this.chatToken.regionGTMS,
|
507
593
|
visitor: true
|
508
594
|
})];
|
509
|
-
case
|
510
|
-
|
511
|
-
return [3 /*break*/,
|
512
|
-
case
|
513
|
-
error_7 =
|
595
|
+
case 32:
|
596
|
+
_y.sent();
|
597
|
+
return [3 /*break*/, 34];
|
598
|
+
case 33:
|
599
|
+
error_7 = _y.sent();
|
514
600
|
exceptionDetails = {
|
515
601
|
response: "IC3ClientInitializeFailed"
|
516
602
|
};
|
@@ -521,19 +607,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
521
607
|
});
|
522
608
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
523
609
|
return [2 /*return*/, error_7];
|
524
|
-
case
|
525
|
-
|
526
|
-
|
610
|
+
case 34:
|
611
|
+
_y.trys.push([34, 36, , 37]);
|
612
|
+
_x = this;
|
527
613
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
528
|
-
case
|
529
|
-
|
614
|
+
case 35:
|
615
|
+
_x.conversation = _y.sent();
|
530
616
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
531
617
|
RequestId: this.requestId,
|
532
618
|
ChatId: this.chatToken.chatId
|
533
619
|
});
|
534
|
-
return [3 /*break*/,
|
535
|
-
case
|
536
|
-
error_8 =
|
620
|
+
return [3 /*break*/, 37];
|
621
|
+
case 36:
|
622
|
+
error_8 = _y.sent();
|
537
623
|
exceptionDetails = {
|
538
624
|
response: "IC3ClientJoinConversationFailed"
|
539
625
|
};
|
@@ -544,8 +630,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
544
630
|
});
|
545
631
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
546
632
|
return [2 /*return*/, error_8];
|
547
|
-
case
|
548
|
-
if (this.isPersistentChat && !((
|
633
|
+
case 37:
|
634
|
+
if (this.isPersistentChat && !((_r = this.chatSDKConfig.persistentChat) === null || _r === void 0 ? void 0 : _r.disable)) {
|
549
635
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
550
636
|
return __generator(this, function (_a) {
|
551
637
|
switch (_a.label) {
|
@@ -556,7 +642,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
556
642
|
return [2 /*return*/];
|
557
643
|
}
|
558
644
|
});
|
559
|
-
}); }, (
|
645
|
+
}); }, (_s = this.chatSDKConfig.persistentChat) === null || _s === void 0 ? void 0 : _s.tokenUpdateTime);
|
560
646
|
}
|
561
647
|
return [2 /*return*/];
|
562
648
|
}
|
@@ -564,11 +650,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
564
650
|
});
|
565
651
|
};
|
566
652
|
OmnichannelChatSDK.prototype.endChat = function () {
|
567
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
653
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
568
654
|
return __awaiter(this, void 0, void 0, function () {
|
569
655
|
var sessionCloseOptionalParams, isReconnectChat, isChatReconnect, error_9, exceptionDetails;
|
570
|
-
return __generator(this, function (
|
571
|
-
switch (
|
656
|
+
return __generator(this, function (_p) {
|
657
|
+
switch (_p.label) {
|
572
658
|
case 0:
|
573
659
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.EndChat, {
|
574
660
|
RequestId: this.requestId,
|
@@ -582,17 +668,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
582
668
|
}
|
583
669
|
if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
|
584
670
|
isChatReconnect = this.reconnectId !== null ? true : false;
|
671
|
+
this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
|
585
672
|
sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
|
586
673
|
}
|
587
674
|
if (this.authenticatedUserToken) {
|
588
675
|
sessionCloseOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
589
676
|
}
|
590
|
-
|
677
|
+
_p.label = 1;
|
591
678
|
case 1:
|
592
|
-
|
679
|
+
_p.trys.push([1, 3, , 4]);
|
593
680
|
return [4 /*yield*/, this.OCClient.sessionClose(this.requestId, sessionCloseOptionalParams)];
|
594
681
|
case 2:
|
595
|
-
|
682
|
+
_p.sent();
|
596
683
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EndChat, {
|
597
684
|
RequestId: this.requestId,
|
598
685
|
ChatId: this.chatToken.chatId
|
@@ -602,6 +689,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
602
689
|
this.requestId = ocsdk_1.uuidv4();
|
603
690
|
this.chatToken = {};
|
604
691
|
this.reconnectId = null;
|
692
|
+
if (this.IC3Client) {
|
693
|
+
this.IC3Client.dispose();
|
694
|
+
!platform_1.default.isNode() && !platform_1.default.isReactNative() && WebUtils_1.removeElementById(this.IC3Client.id);
|
695
|
+
this.IC3Client = null;
|
696
|
+
}
|
605
697
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
606
698
|
(_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
|
607
699
|
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
@@ -610,9 +702,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
610
702
|
(_j = this.acsClientLogger) === null || _j === void 0 ? void 0 : _j.setChatId('');
|
611
703
|
(_k = this.acsAdapterLogger) === null || _k === void 0 ? void 0 : _k.setRequestId(this.requestId);
|
612
704
|
(_l = this.acsAdapterLogger) === null || _l === void 0 ? void 0 : _l.setChatId('');
|
705
|
+
(_m = this.callingSdkLogger) === null || _m === void 0 ? void 0 : _m.setRequestId(this.requestId);
|
706
|
+
(_o = this.callingSdkLogger) === null || _o === void 0 ? void 0 : _o.setChatId('');
|
613
707
|
return [3 /*break*/, 4];
|
614
708
|
case 3:
|
615
|
-
error_9 =
|
709
|
+
error_9 = _p.sent();
|
616
710
|
exceptionDetails = {
|
617
711
|
response: "OCClientSessionCloseFailed"
|
618
712
|
};
|
@@ -663,23 +757,33 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
663
757
|
});
|
664
758
|
};
|
665
759
|
OmnichannelChatSDK.prototype.getConversationDetails = function () {
|
666
|
-
var _a, _b;
|
760
|
+
var _a, _b, _c, _d;
|
667
761
|
return __awaiter(this, void 0, void 0, function () {
|
668
|
-
var lwiDetails, state, conversationId, agentAcceptedOn, liveWorkItemDetails, error_10;
|
669
|
-
return __generator(this, function (
|
670
|
-
switch (
|
762
|
+
var getLWIDetailsOptionalParams, lwiDetails, state, conversationId, agentAcceptedOn, canRenderPostChat, participantType, liveWorkItemDetails, error_10;
|
763
|
+
return __generator(this, function (_e) {
|
764
|
+
switch (_e.label) {
|
671
765
|
case 0:
|
672
766
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
673
767
|
RequestId: this.requestId,
|
674
768
|
ChatId: ((_a = this.chatToken) === null || _a === void 0 ? void 0 : _a.chatId) || '',
|
675
769
|
});
|
676
|
-
|
770
|
+
getLWIDetailsOptionalParams = {};
|
771
|
+
if (this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable) && this.reconnectId) {
|
772
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
773
|
+
}
|
774
|
+
if (this.isChatReconnect && !((_c = this.chatSDKConfig.chatReconnect) === null || _c === void 0 ? void 0 : _c.disable) && !this.isPersistentChat && this.reconnectId) {
|
775
|
+
getLWIDetailsOptionalParams.reconnectId = this.reconnectId;
|
776
|
+
}
|
777
|
+
if (this.authenticatedUserToken) {
|
778
|
+
getLWIDetailsOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
779
|
+
}
|
780
|
+
_e.label = 1;
|
677
781
|
case 1:
|
678
|
-
|
679
|
-
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
782
|
+
_e.trys.push([1, 3, , 4]);
|
783
|
+
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId, getLWIDetailsOptionalParams)];
|
680
784
|
case 2:
|
681
|
-
lwiDetails =
|
682
|
-
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn;
|
785
|
+
lwiDetails = _e.sent();
|
786
|
+
state = lwiDetails.State, conversationId = lwiDetails.ConversationId, agentAcceptedOn = lwiDetails.AgentAcceptedOn, canRenderPostChat = lwiDetails.CanRenderPostChat, participantType = lwiDetails.ParticipantType;
|
683
787
|
liveWorkItemDetails = {
|
684
788
|
state: state,
|
685
789
|
conversationId: conversationId
|
@@ -687,13 +791,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
687
791
|
if (agentAcceptedOn) {
|
688
792
|
liveWorkItemDetails.agentAcceptedOn = agentAcceptedOn;
|
689
793
|
}
|
794
|
+
if (canRenderPostChat) {
|
795
|
+
liveWorkItemDetails.canRenderPostChat = canRenderPostChat;
|
796
|
+
}
|
797
|
+
if (participantType) {
|
798
|
+
liveWorkItemDetails.participantType = participantType;
|
799
|
+
}
|
690
800
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
691
801
|
RequestId: this.requestId,
|
692
|
-
ChatId: ((
|
802
|
+
ChatId: ((_d = this.chatToken) === null || _d === void 0 ? void 0 : _d.chatId) || '',
|
693
803
|
});
|
694
804
|
return [2 /*return*/, liveWorkItemDetails];
|
695
805
|
case 3:
|
696
|
-
error_10 =
|
806
|
+
error_10 = _e.sent();
|
697
807
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetConversationDetails, {
|
698
808
|
RequestId: this.requestId,
|
699
809
|
ChatId: this.chatToken.chatId || '',
|
@@ -727,14 +837,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
727
837
|
});
|
728
838
|
});
|
729
839
|
};
|
730
|
-
OmnichannelChatSDK.prototype.getLiveChatConfig = function (
|
731
|
-
if (cached === void 0) { cached = true; }
|
840
|
+
OmnichannelChatSDK.prototype.getLiveChatConfig = function (optionalParams) {
|
732
841
|
return __awaiter(this, void 0, void 0, function () {
|
733
842
|
return __generator(this, function (_a) {
|
734
|
-
if (
|
843
|
+
if (!optionalParams || optionalParams.useRuntimeCache === true) {
|
735
844
|
return [2 /*return*/, this.liveChatConfig];
|
736
845
|
}
|
737
|
-
return [2 /*return*/, this.getChatConfig()];
|
846
|
+
return [2 /*return*/, this.getChatConfig({ sendCacheHeaders: (optionalParams === null || optionalParams === void 0 ? void 0 : optionalParams.sendCacheHeaders) || false })];
|
738
847
|
});
|
739
848
|
});
|
740
849
|
};
|
@@ -1449,7 +1558,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1449
1558
|
ChatId: this.chatToken.chatId,
|
1450
1559
|
EmailAddress: body.emailAddress,
|
1451
1560
|
DefaultAttachmentMessage: body.attachmentMessage,
|
1452
|
-
CustomerLocale: body.locale
|
1561
|
+
CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
|
1453
1562
|
};
|
1454
1563
|
emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
|
1455
1564
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
@@ -1499,51 +1608,52 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1499
1608
|
});
|
1500
1609
|
});
|
1501
1610
|
};
|
1502
|
-
OmnichannelChatSDK.prototype.createChatAdapter = function (
|
1503
|
-
if (
|
1611
|
+
OmnichannelChatSDK.prototype.createChatAdapter = function (optionalParams) {
|
1612
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1504
1613
|
return __awaiter(this, void 0, void 0, function () {
|
1505
|
-
var supportedChatAdapterProtocols;
|
1614
|
+
var protocol, supportedChatAdapterProtocols;
|
1506
1615
|
var _this = this;
|
1507
1616
|
return __generator(this, function (_a) {
|
1508
1617
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1509
1618
|
return [2 /*return*/, Promise.reject('ChatAdapter is only supported on browser')];
|
1510
1619
|
}
|
1620
|
+
protocol = optionalParams.protocol;
|
1511
1621
|
supportedChatAdapterProtocols = [ChatAdapterProtocols_1.default.ACS, ChatAdapterProtocols_1.default.IC3];
|
1512
1622
|
if (protocol && !supportedChatAdapterProtocols.includes(protocol)) {
|
1513
1623
|
return [2 /*return*/, Promise.reject("ChatAdapter for protocol " + protocol + " currently not supported")];
|
1514
1624
|
}
|
1515
1625
|
if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
|
1516
1626
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1517
|
-
var
|
1627
|
+
var options, defaultEgressMiddlewares, defaultIngressMiddlewares, egressMiddleware, ingressMiddleware, featuresOption, acsAdapterCDNUrl;
|
1518
1628
|
var _this = this;
|
1519
1629
|
var _a;
|
1520
1630
|
return __generator(this, function (_b) {
|
1521
1631
|
switch (_b.label) {
|
1522
1632
|
case 0:
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
1530
|
-
|
1531
|
-
};
|
1633
|
+
options = optionalParams.ACSAdapter ? optionalParams.ACSAdapter.options : {};
|
1634
|
+
defaultEgressMiddlewares = [createChannelDataEgressMiddleware_1.default({ widgetId: this.omnichannelConfig.widgetId }), createFormatEgressTagsMiddleware_1.default()];
|
1635
|
+
defaultIngressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
|
1636
|
+
egressMiddleware = (options === null || options === void 0 ? void 0 : options.egressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultEgressMiddlewares) : __spreadArrays(defaultEgressMiddlewares);
|
1637
|
+
ingressMiddleware = (options === null || options === void 0 ? void 0 : options.ingressMiddleware) ? __spreadArrays(options.egressMiddleware, defaultIngressMiddlewares) : __spreadArrays(defaultIngressMiddlewares);
|
1638
|
+
featuresOption = __assign(__assign({ enableAdaptiveCards: true, enableThreadMemberUpdateNotification: true, enableLeaveThreadOnWindowClosed: false }, options), { // overrides
|
1639
|
+
ingressMiddleware: ingressMiddleware,
|
1640
|
+
egressMiddleware: egressMiddleware });
|
1532
1641
|
acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
|
1533
1642
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1534
1643
|
ACSAdapter: acsAdapterCDNUrl
|
1535
1644
|
});
|
1536
1645
|
return [4 /*yield*/, WebUtils_1.loadScript(acsAdapterCDNUrl, function () {
|
1646
|
+
var _a;
|
1537
1647
|
/* istanbul ignore next */
|
1538
1648
|
_this.debug && console.debug('ACSAdapter loaded!');
|
1539
1649
|
try {
|
1540
1650
|
var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
|
1541
1651
|
var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
|
1542
|
-
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager,
|
1652
|
+
var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 30000, ACSParticipantDisplayName_1.default.Customer, (_a = _this.ACSClient) === null || _a === void 0 ? void 0 : _a.getChatClient(), _this.acsAdapterLogger, // logger
|
1543
1653
|
featuresOption);
|
1544
1654
|
resolve(adapter);
|
1545
1655
|
}
|
1546
|
-
catch (
|
1656
|
+
catch (_b) {
|
1547
1657
|
throw new Error('Failed to load ACSAdapter');
|
1548
1658
|
}
|
1549
1659
|
}, function () {
|
@@ -1558,12 +1668,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1558
1668
|
}
|
1559
1669
|
else if (protocol === ChatAdapterProtocols_1.default.IC3 || this.liveChatVersion === LiveChatVersion_1.default.V1) {
|
1560
1670
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1561
|
-
var ic3AdapterCDNUrl;
|
1671
|
+
var options, ic3AdapterCDNUrl;
|
1562
1672
|
var _this = this;
|
1563
1673
|
var _a;
|
1564
1674
|
return __generator(this, function (_b) {
|
1565
1675
|
switch (_b.label) {
|
1566
1676
|
case 0:
|
1677
|
+
options = optionalParams.IC3Adapter ? optionalParams.IC3Adapter.options : {};
|
1567
1678
|
ic3AdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.IC3);
|
1568
1679
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1569
1680
|
IC3Adapter: ic3AdapterCDNUrl
|
@@ -1572,17 +1683,10 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1572
1683
|
return [4 /*yield*/, WebUtils_1.loadScript(ic3AdapterCDNUrl, function () {
|
1573
1684
|
/* istanbul ignore next */
|
1574
1685
|
_this.debug && console.debug('IC3Adapter loaded!');
|
1575
|
-
var adapterConfig = {
|
1576
|
-
|
1577
|
-
userDisplayName: 'Customer',
|
1578
|
-
userId: 'teamsvisitor',
|
1579
|
-
sdkURL: _this.resolveIC3ClientUrl(),
|
1580
|
-
sdk: _this.IC3Client
|
1581
|
-
};
|
1686
|
+
var adapterConfig = __assign({ chatToken: _this.chatToken, userDisplayName: 'Customer', userId: _this.chatToken.visitorId || 'teamsvisitor', sdkURL: _this.resolveIC3ClientUrl(), sdk: _this.IC3Client }, options // overrides
|
1687
|
+
);
|
1582
1688
|
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
|
1583
1689
|
adapter.logger = _this.ic3ClientLogger;
|
1584
|
-
// Keep iframe communication alive to reuse the same IC3Client instance
|
1585
|
-
window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
|
1586
1690
|
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1587
1691
|
resolve(adapter);
|
1588
1692
|
}, function () {
|
@@ -1603,16 +1707,31 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1603
1707
|
OmnichannelChatSDK.prototype.getVoiceVideoCalling = function (params) {
|
1604
1708
|
if (params === void 0) { params = {}; }
|
1605
1709
|
return __awaiter(this, void 0, void 0, function () {
|
1606
|
-
var chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1710
|
+
var exceptionDetails, exceptionDetails, chatConfig, liveWSAndLiveChatEngJoin, msdyn_widgetsnippet, widgetSnippetSourceRegex, result;
|
1607
1711
|
var _this = this;
|
1608
1712
|
return __generator(this, function (_a) {
|
1609
1713
|
switch (_a.label) {
|
1610
1714
|
case 0:
|
1715
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1611
1716
|
if (platform_1.default.isNode() || platform_1.default.isReactNative()) {
|
1612
|
-
|
1717
|
+
exceptionDetails = {
|
1718
|
+
response: "UnsupportedPlatform",
|
1719
|
+
message: "VoiceVideoCalling is only supported on browser"
|
1720
|
+
};
|
1721
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1722
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1723
|
+
});
|
1724
|
+
throw new Error(exceptionDetails.response);
|
1613
1725
|
}
|
1614
1726
|
if (this.callingOption.toString() === CallingOptionsOptionSetNumber_1.default.NoCalling.toString()) {
|
1615
|
-
|
1727
|
+
exceptionDetails = {
|
1728
|
+
response: "FeatureDisabled",
|
1729
|
+
message: "Voice and video call is not enabled"
|
1730
|
+
};
|
1731
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1732
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1733
|
+
});
|
1734
|
+
throw new Error(exceptionDetails.response);
|
1616
1735
|
}
|
1617
1736
|
return [4 /*yield*/, this.getChatConfig()];
|
1618
1737
|
case 1:
|
@@ -1622,25 +1741,27 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1622
1741
|
widgetSnippetSourceRegex = new RegExp("src=\"(https:\\/\\/[\\w-.]+)[\\w-.\\/]+\"");
|
1623
1742
|
result = msdyn_widgetsnippet.match(widgetSnippetSourceRegex);
|
1624
1743
|
if (result && result.length) {
|
1625
|
-
return [2 /*return*/, new Promise(function (resolve
|
1626
|
-
var LiveChatWidgetLibCDNUrl;
|
1744
|
+
return [2 /*return*/, new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
|
1745
|
+
var LiveChatWidgetLibCDNUrl, defaultParams;
|
1627
1746
|
var _this = this;
|
1628
1747
|
var _a;
|
1629
1748
|
return __generator(this, function (_b) {
|
1630
1749
|
switch (_b.label) {
|
1631
1750
|
case 0:
|
1632
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
1633
1751
|
LiveChatWidgetLibCDNUrl = result[1] + "/livechatwidget/WebChatControl/lib/CallingBundle.js";
|
1634
1752
|
(_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
|
1635
1753
|
VoiceVideoCalling: LiveChatWidgetLibCDNUrl
|
1636
1754
|
});
|
1755
|
+
defaultParams = {
|
1756
|
+
logger: this.callingSdkLogger
|
1757
|
+
};
|
1637
1758
|
return [4 /*yield*/, WebUtils_1.loadScript(LiveChatWidgetLibCDNUrl, function () { return __awaiter(_this, void 0, void 0, function () {
|
1638
1759
|
var VoiceVideoCalling;
|
1639
1760
|
return __generator(this, function (_a) {
|
1640
1761
|
switch (_a.label) {
|
1641
1762
|
case 0:
|
1642
1763
|
this.debug && console.debug(LiveChatWidgetLibCDNUrl + " loaded!");
|
1643
|
-
return [4 /*yield*/, createVoiceVideoCalling_1.default(params)];
|
1764
|
+
return [4 /*yield*/, createVoiceVideoCalling_1.default(__assign(__assign({}, params), defaultParams))];
|
1644
1765
|
case 1:
|
1645
1766
|
VoiceVideoCalling = _a.sent();
|
1646
1767
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetVoiceVideoCalling);
|
@@ -1653,13 +1774,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1653
1774
|
var exceptionDetails;
|
1654
1775
|
return __generator(this, function (_a) {
|
1655
1776
|
exceptionDetails = {
|
1656
|
-
response: "VoiceVideoCallingLoadFailed"
|
1777
|
+
response: "VoiceVideoCallingLoadFailed",
|
1778
|
+
message: "Failed to load VoiceVideoCalling"
|
1657
1779
|
};
|
1658
1780
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetVoiceVideoCalling, {
|
1659
1781
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1660
1782
|
});
|
1661
|
-
|
1662
|
-
return [2 /*return*/];
|
1783
|
+
throw new Error(exceptionDetails.response);
|
1663
1784
|
});
|
1664
1785
|
}); })];
|
1665
1786
|
case 1:
|
@@ -1676,7 +1797,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1676
1797
|
};
|
1677
1798
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1678
1799
|
return __awaiter(this, void 0, void 0, function () {
|
1679
|
-
var conversationId, chatConfig, liveWSAndLiveChatEngJoin,
|
1800
|
+
var conversationId, chatConfig, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId, postConversationBotSurveyOwnerId, liveWorkItemDetails, participantJoined, participantType, surveyInviteLinkRequest, optionalParams, ownerId, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1680
1801
|
return __generator(this, function (_a) {
|
1681
1802
|
switch (_a.label) {
|
1682
1803
|
case 0:
|
@@ -1687,20 +1808,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1687
1808
|
case 1:
|
1688
1809
|
_a.trys.push([1, 6, , 7]);
|
1689
1810
|
chatConfig = this.liveChatConfig;
|
1690
|
-
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin
|
1691
|
-
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
|
1692
|
-
|
1693
|
-
|
1694
|
-
if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
|
1695
|
-
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
1811
|
+
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin;
|
1812
|
+
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, msfp_botsourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_botsourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId, postConversationBotSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationBotSurveyOwnerId;
|
1813
|
+
if (!(msdyn_postconversationsurveyenable === "true")) return [3 /*break*/, 4];
|
1814
|
+
return [4 /*yield*/, this.getConversationDetails()];
|
1696
1815
|
case 2:
|
1697
1816
|
liveWorkItemDetails = _a.sent();
|
1698
|
-
participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.
|
1699
|
-
|
1817
|
+
participantJoined = (liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.canRenderPostChat) === "True";
|
1818
|
+
participantType = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.participantType;
|
1819
|
+
conversationId = liveWorkItemDetails === null || liveWorkItemDetails === void 0 ? void 0 : liveWorkItemDetails.conversationId;
|
1700
1820
|
surveyInviteLinkRequest = {
|
1701
|
-
"FormId": msfp_sourcesurveyidentifier,
|
1821
|
+
"FormId": participantType === "Bot" ? msfp_botsourcesurveyidentifier : msfp_sourcesurveyidentifier,
|
1702
1822
|
"ConversationId": conversationId,
|
1703
|
-
"OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
|
1823
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId)
|
1704
1824
|
};
|
1705
1825
|
optionalParams = {
|
1706
1826
|
"requestId": this.requestId
|
@@ -1708,7 +1828,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1708
1828
|
if (this.authenticatedUserToken) {
|
1709
1829
|
optionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
1710
1830
|
}
|
1711
|
-
|
1831
|
+
ownerId = participantType === "Bot" ? postConversationBotSurveyOwnerId : postConversationSurveyOwnerId;
|
1832
|
+
return [4 /*yield*/, this.OCClient.getSurveyInviteLink(ownerId, surveyInviteLinkRequest, optionalParams)];
|
1712
1833
|
case 3:
|
1713
1834
|
surveyInviteLinkResponse = _a.sent();
|
1714
1835
|
surveyInviteLink = void 0, formsProLocale = void 0;
|
@@ -1729,6 +1850,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1729
1850
|
}
|
1730
1851
|
postChatContext = {
|
1731
1852
|
participantJoined: participantJoined,
|
1853
|
+
participantType: participantType,
|
1732
1854
|
surveyInviteLink: surveyInviteLink,
|
1733
1855
|
formsProLocale: formsProLocale
|
1734
1856
|
};
|
@@ -1753,7 +1875,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1753
1875
|
case 6:
|
1754
1876
|
ex_1 = _a.sent();
|
1755
1877
|
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetPostChatSurveyContext, {
|
1756
|
-
ConversationId: conversationId,
|
1878
|
+
ConversationId: conversationId !== null && conversationId !== void 0 ? conversationId : "",
|
1757
1879
|
RequestId: this.requestId,
|
1758
1880
|
ExceptionDetails: JSON.stringify(ex_1)
|
1759
1881
|
});
|
@@ -1763,102 +1885,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1763
1885
|
});
|
1764
1886
|
});
|
1765
1887
|
};
|
1766
|
-
OmnichannelChatSDK.prototype.initializePostChatRenderer = function () {
|
1767
|
-
return __awaiter(this, void 0, void 0, function () {
|
1768
|
-
var msfpEmbedScript, elm, scriptNodes, styleNodes, i, node, tmpNode, tmpNode, i, node, tmpNode;
|
1769
|
-
return __generator(this, function (_a) {
|
1770
|
-
if (!platform_1.isBrowser()) {
|
1771
|
-
return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
|
1772
|
-
}
|
1773
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
|
1774
|
-
RequestId: this.requestId
|
1775
|
-
});
|
1776
|
-
try {
|
1777
|
-
msfpEmbedScript = libraries_1.getMsfpEmbedScript();
|
1778
|
-
elm = document.createElement('div');
|
1779
|
-
elm.innerHTML = msfpEmbedScript;
|
1780
|
-
scriptNodes = elm.getElementsByTagName('script');
|
1781
|
-
styleNodes = elm.getElementsByTagName('link');
|
1782
|
-
for (i = 0; i < scriptNodes.length; i++) {
|
1783
|
-
node = scriptNodes[i];
|
1784
|
-
if (node.src) {
|
1785
|
-
tmpNode = document.createElement('script');
|
1786
|
-
tmpNode.type = node.type;
|
1787
|
-
tmpNode.src = node.src;
|
1788
|
-
tmpNode.async = false;
|
1789
|
-
if (!window.document.head.contains(tmpNode)) {
|
1790
|
-
document.getElementsByTagName('head')[0].appendChild(tmpNode);
|
1791
|
-
}
|
1792
|
-
}
|
1793
|
-
if (node.innerHTML) {
|
1794
|
-
tmpNode = document.createElement('script');
|
1795
|
-
tmpNode.innerHTML = node.innerHTML;
|
1796
|
-
tmpNode.async = false;
|
1797
|
-
if (!window.document.head.contains(tmpNode)) {
|
1798
|
-
window.document.head.appendChild(tmpNode);
|
1799
|
-
}
|
1800
|
-
}
|
1801
|
-
}
|
1802
|
-
for (i = 0; i < styleNodes.length; i++) {
|
1803
|
-
node = styleNodes[i];
|
1804
|
-
if (node.href) {
|
1805
|
-
tmpNode = document.createElement('link');
|
1806
|
-
tmpNode.type = node.type;
|
1807
|
-
tmpNode.rel = node.rel;
|
1808
|
-
tmpNode.href = node.href;
|
1809
|
-
if (!window.document.head.contains(tmpNode)) {
|
1810
|
-
document.getElementsByTagName('head')[0].appendChild(tmpNode);
|
1811
|
-
}
|
1812
|
-
}
|
1813
|
-
}
|
1814
|
-
}
|
1815
|
-
catch (ex) {
|
1816
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
|
1817
|
-
RequestId: this.requestId,
|
1818
|
-
ExceptionDetails: JSON.stringify(ex)
|
1819
|
-
});
|
1820
|
-
return [2 /*return*/, Promise.reject("Error occurred when initializer post chat renderer. " + JSON.stringify(ex))];
|
1821
|
-
}
|
1822
|
-
return [2 /*return*/];
|
1823
|
-
});
|
1824
|
-
});
|
1825
|
-
};
|
1826
|
-
OmnichannelChatSDK.prototype.renderPostChatSurvey = function (containerId, postChatContext) {
|
1827
|
-
return __awaiter(this, void 0, void 0, function () {
|
1828
|
-
var ex_2;
|
1829
|
-
return __generator(this, function (_a) {
|
1830
|
-
switch (_a.label) {
|
1831
|
-
case 0:
|
1832
|
-
if (!platform_1.isBrowser()) {
|
1833
|
-
return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
|
1834
|
-
}
|
1835
|
-
this.scenarioMarker.startScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1836
|
-
RequestId: this.requestId
|
1837
|
-
});
|
1838
|
-
_a.label = 1;
|
1839
|
-
case 1:
|
1840
|
-
_a.trys.push([1, 3, , 4]);
|
1841
|
-
if (!postChatContext) {
|
1842
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1843
|
-
RequestId: this.requestId,
|
1844
|
-
ExceptionDetails: "Post Chat Context is null."
|
1845
|
-
});
|
1846
|
-
return [2 /*return*/, Promise.reject("Post Chat Context is null.")];
|
1847
|
-
}
|
1848
|
-
return [4 /*yield*/, renderSurvey(containerId, postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.surveyInviteLink, "", "", postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.formsProLocale)];
|
1849
|
-
case 2: return [2 /*return*/, _a.sent()];
|
1850
|
-
case 3:
|
1851
|
-
ex_2 = _a.sent();
|
1852
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
|
1853
|
-
RequestId: this.requestId,
|
1854
|
-
ExceptionDetails: JSON.stringify(ex_2)
|
1855
|
-
});
|
1856
|
-
return [2 /*return*/, Promise.reject("Error occurred when rendering post chat survey. " + JSON.stringify(ex_2))];
|
1857
|
-
case 4: return [2 /*return*/];
|
1858
|
-
}
|
1859
|
-
});
|
1860
|
-
});
|
1861
|
-
};
|
1862
1888
|
OmnichannelChatSDK.prototype.getIC3Client = function () {
|
1863
1889
|
return __awaiter(this, void 0, void 0, function () {
|
1864
1890
|
var IC3Client;
|
@@ -1885,7 +1911,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1885
1911
|
this.debug && console.debug('IC3Client');
|
1886
1912
|
// Use IC3Client if browser is detected
|
1887
1913
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1888
|
-
var ic3ClientCDNUrl;
|
1914
|
+
var ic3ClientCDNUrl, IC3Client;
|
1889
1915
|
var _this = this;
|
1890
1916
|
var _a;
|
1891
1917
|
return __generator(this, function (_b) {
|
@@ -1896,6 +1922,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1896
1922
|
IC3Client: ic3ClientCDNUrl
|
1897
1923
|
});
|
1898
1924
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
|
1925
|
+
if (!this.IC3SDKProvider) return [3 /*break*/, 2];
|
1926
|
+
return [4 /*yield*/, this.IC3SDKProvider.getSDK({
|
1927
|
+
hostType: HostType_1.default.IFrame,
|
1928
|
+
protocolType: ProtocoleType_1.default.IC3V1SDK,
|
1929
|
+
logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
|
1930
|
+
})];
|
1931
|
+
case 1:
|
1932
|
+
IC3Client = _b.sent();
|
1933
|
+
return [2 /*return*/, resolve(IC3Client)];
|
1934
|
+
case 2:
|
1899
1935
|
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
|
1900
1936
|
var ic3sdk, IC3SDKProvider, IC3Client;
|
1901
1937
|
return __generator(this, function (_a) {
|
@@ -1932,7 +1968,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1932
1968
|
});
|
1933
1969
|
reject('Failed to load IC3Client');
|
1934
1970
|
})];
|
1935
|
-
case
|
1971
|
+
case 3:
|
1936
1972
|
_b.sent();
|
1937
1973
|
return [2 /*return*/];
|
1938
1974
|
}
|
@@ -1942,17 +1978,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1942
1978
|
});
|
1943
1979
|
});
|
1944
1980
|
};
|
1945
|
-
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1981
|
+
OmnichannelChatSDK.prototype.getChatConfig = function (optionalParams) {
|
1982
|
+
if (optionalParams === void 0) { optionalParams = {}; }
|
1946
1983
|
return __awaiter(this, void 0, void 0, function () {
|
1947
|
-
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled,
|
1948
|
-
return __generator(this, function (
|
1949
|
-
switch (
|
1984
|
+
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;
|
1985
|
+
return __generator(this, function (_a) {
|
1986
|
+
switch (_a.label) {
|
1950
1987
|
case 0:
|
1951
|
-
|
1952
|
-
|
1988
|
+
sendCacheHeaders = optionalParams.sendCacheHeaders;
|
1989
|
+
_a.label = 1;
|
1953
1990
|
case 1:
|
1954
|
-
|
1955
|
-
|
1991
|
+
_a.trys.push([1, 5, , 6]);
|
1992
|
+
bypassCache = sendCacheHeaders === true;
|
1993
|
+
return [4 /*yield*/, this.OCClient.getChatConfig(this.requestId, bypassCache)];
|
1994
|
+
case 2:
|
1995
|
+
liveChatConfig = _a.sent();
|
1996
|
+
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1997
|
+
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1998
|
+
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
1956
1999
|
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
|
1957
2000
|
/* istanbul ignore next */
|
1958
2001
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
@@ -1975,47 +2018,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1975
2018
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1976
2019
|
this.preChatSurvey = preChatSurvey;
|
1977
2020
|
}
|
1978
|
-
if (!this.authSettings) return [3 /*break*/,
|
1979
|
-
this.
|
1980
|
-
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1981
|
-
_b.label = 2;
|
1982
|
-
case 2:
|
1983
|
-
_b.trys.push([2, 4, , 5]);
|
1984
|
-
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
2021
|
+
if (!this.authSettings) return [3 /*break*/, 4];
|
2022
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1985
2023
|
case 3:
|
1986
|
-
|
1987
|
-
|
1988
|
-
this.authenticatedUserToken = token;
|
1989
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
1990
|
-
}
|
1991
|
-
else {
|
1992
|
-
exceptionDetails = {
|
1993
|
-
response: "UndefinedAuthToken"
|
1994
|
-
};
|
1995
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1996
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1997
|
-
});
|
1998
|
-
}
|
1999
|
-
return [3 /*break*/, 5];
|
2024
|
+
_a.sent();
|
2025
|
+
_a.label = 4;
|
2000
2026
|
case 4:
|
2001
|
-
_a = _b.sent();
|
2002
|
-
exceptionDetails = {
|
2003
|
-
response: "GetAuthTokenFailed"
|
2004
|
-
};
|
2005
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2006
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2007
|
-
});
|
2008
|
-
return [3 /*break*/, 5];
|
2009
|
-
case 5: return [3 /*break*/, 7];
|
2010
|
-
case 6:
|
2011
|
-
exceptionDetails = {
|
2012
|
-
response: "GetAuthTokenNotFound"
|
2013
|
-
};
|
2014
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2015
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2016
|
-
});
|
2017
|
-
_b.label = 7;
|
2018
|
-
case 7:
|
2019
2027
|
if (this.preChatSurvey) {
|
2020
2028
|
/* istanbul ignore next */
|
2021
2029
|
this.debug && console.log('Prechat Survey!');
|
@@ -2023,11 +2031,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2023
2031
|
this.callingOption = msdyn_callingoptions;
|
2024
2032
|
this.liveChatConfig = liveChatConfig;
|
2025
2033
|
return [2 /*return*/, this.liveChatConfig];
|
2026
|
-
case
|
2027
|
-
error_18 =
|
2034
|
+
case 5:
|
2035
|
+
error_18 = _a.sent();
|
2028
2036
|
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
2029
2037
|
return [2 /*return*/, error_18];
|
2030
|
-
case
|
2038
|
+
case 6: return [2 /*return*/];
|
2031
2039
|
}
|
2032
2040
|
});
|
2033
2041
|
});
|
@@ -2078,21 +2086,24 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2078
2086
|
});
|
2079
2087
|
_a.label = 1;
|
2080
2088
|
case 1:
|
2081
|
-
_a.trys.push([1,
|
2089
|
+
_a.trys.push([1, 4, , 5]);
|
2082
2090
|
sessionInfo = {
|
2083
2091
|
token: newToken,
|
2084
2092
|
regionGtms: newRegionGTMS,
|
2085
2093
|
visitor: true
|
2086
2094
|
};
|
2095
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V1)) return [3 /*break*/, 3];
|
2087
2096
|
return [4 /*yield*/, this.IC3Client.initialize(sessionInfo)];
|
2088
2097
|
case 2:
|
2089
2098
|
_a.sent();
|
2099
|
+
_a.label = 3;
|
2100
|
+
case 3:
|
2090
2101
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.UpdateChatToken, {
|
2091
2102
|
RequestId: this.requestId,
|
2092
2103
|
ChatId: this.chatToken.chatId
|
2093
2104
|
});
|
2094
|
-
return [3 /*break*/,
|
2095
|
-
case
|
2105
|
+
return [3 /*break*/, 5];
|
2106
|
+
case 4:
|
2096
2107
|
error_19 = _a.sent();
|
2097
2108
|
exceptionDetails = {
|
2098
2109
|
response: "UpdateChatTokenFailed"
|
@@ -2103,8 +2114,59 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2103
2114
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2104
2115
|
});
|
2105
2116
|
console.error("OmnichannelChatSDK/updateChatToken/error " + error_19);
|
2117
|
+
return [3 /*break*/, 5];
|
2118
|
+
case 5: return [2 /*return*/];
|
2119
|
+
}
|
2120
|
+
});
|
2121
|
+
});
|
2122
|
+
};
|
2123
|
+
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
|
2124
|
+
return __awaiter(this, void 0, void 0, function () {
|
2125
|
+
var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
|
2126
|
+
return __generator(this, function (_b) {
|
2127
|
+
switch (_b.label) {
|
2128
|
+
case 0:
|
2129
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
|
2130
|
+
this.chatSDKConfig.getAuthToken = provider;
|
2131
|
+
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
|
2132
|
+
_b.label = 1;
|
2133
|
+
case 1:
|
2134
|
+
_b.trys.push([1, 3, , 4]);
|
2135
|
+
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
2136
|
+
case 2:
|
2137
|
+
token = _b.sent();
|
2138
|
+
if (token) {
|
2139
|
+
this.authenticatedUserToken = token;
|
2140
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
2141
|
+
}
|
2142
|
+
else {
|
2143
|
+
exceptionDetails = {
|
2144
|
+
response: "UndefinedAuthToken"
|
2145
|
+
};
|
2146
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2147
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2148
|
+
});
|
2149
|
+
}
|
2106
2150
|
return [3 /*break*/, 4];
|
2107
|
-
case
|
2151
|
+
case 3:
|
2152
|
+
_a = _b.sent();
|
2153
|
+
exceptionDetails = {
|
2154
|
+
response: "GetAuthTokenFailed"
|
2155
|
+
};
|
2156
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2157
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2158
|
+
});
|
2159
|
+
return [3 /*break*/, 4];
|
2160
|
+
case 4: return [3 /*break*/, 6];
|
2161
|
+
case 5:
|
2162
|
+
exceptionDetails = {
|
2163
|
+
response: "GetAuthTokenNotFound"
|
2164
|
+
};
|
2165
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2166
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2167
|
+
});
|
2168
|
+
_b.label = 6;
|
2169
|
+
case 6: return [2 /*return*/];
|
2108
2170
|
}
|
2109
2171
|
});
|
2110
2172
|
});
|