@microsoft/omnichannel-chat-sdk 1.0.1-main.ba42aae → 1.0.1-main.d137e38
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/README.md +1 -2
- package/lib/OmnichannelChatSDK.d.ts +3 -0
- package/lib/OmnichannelChatSDK.js +176 -133
- package/lib/OmnichannelChatSDK.js.map +1 -1
- package/lib/core/ChatConfig.d.ts +3 -0
- package/lib/telemetry/AriaTelemetry.js +5 -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/tsconfig.tsbuildinfo +13 -13
- 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/locale.d.ts +1 -0
- package/lib/utils/locale.js +2 -1
- package/lib/utils/locale.js.map +1 -1
- package/lib/utils/loggers.d.ts +8 -0
- package/lib/utils/loggers.js +24 -0
- package/lib/utils/loggers.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -7,10 +7,16 @@ All notable changes to this project will be documented in this file.
|
|
7
7
|
- Add `getPostChatSurveyContext` API method
|
8
8
|
- Add `GetPostChatSurveyContext` telemetry event
|
9
9
|
- Add `widgetId` & `clientMessageId` as metadata on sending message
|
10
|
+
- Update `ChatConfig` interface with `LiveChatVersion`, `allowedFileExtensions` & `maxUploadFileSize` properties
|
11
|
+
- Add ability to automatically detect locale from chat config
|
12
|
+
- Add `runtimeId` attribute in `OmnichannelChatSDK` & `ChatSDKRuntimeId` field in telemetry
|
13
|
+
- Add ability to automatically pass locale from chat config on calling `ChatSDK.emailLiveChatTranscript()`
|
10
14
|
|
11
15
|
### Fix
|
12
16
|
- Add `acs_webchat-chat-adapter` middlewares to format `channelData.tags`
|
13
17
|
- Skip `session init` call on existing conversation
|
18
|
+
- Fix `chat reconnect` not ending the conversation on calling `ChatSDK.endChat()`
|
19
|
+
- Fix on messaging client not sending heartbeat on new conversations subsequent to the first conversation
|
14
20
|
|
15
21
|
### Changed
|
16
22
|
- README: added examples on usages of the post chat APIs.
|
package/README.md
CHANGED
@@ -335,8 +335,7 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
|
|
335
335
|
```ts
|
336
336
|
const body = {
|
337
337
|
emailAddress: 'contoso@microsoft.com',
|
338
|
-
attachmentMessage: 'Attachment Message'
|
339
|
-
locale: 'en-us'
|
338
|
+
attachmentMessage: 'Attachment Message'
|
340
339
|
};
|
341
340
|
await chatSDK.emailLiveChatTranscript(body);
|
342
341
|
```
|
@@ -23,6 +23,7 @@ import OnNewMessageOptionalParams from "./core/messaging/OnNewMessageOptionalPar
|
|
23
23
|
import StartChatOptionalParams from "./core/StartChatOptionalParams";
|
24
24
|
declare class OmnichannelChatSDK {
|
25
25
|
private debug;
|
26
|
+
runtimeId: string;
|
26
27
|
OCSDKProvider: unknown;
|
27
28
|
IC3SDKProvider: unknown;
|
28
29
|
OCClient: any;
|
@@ -32,6 +33,7 @@ declare class OmnichannelChatSDK {
|
|
32
33
|
omnichannelConfig: OmnichannelConfig;
|
33
34
|
chatSDKConfig: ChatSDKConfig;
|
34
35
|
isInitialized: boolean;
|
36
|
+
localeId: string;
|
35
37
|
requestId: string;
|
36
38
|
private chatToken;
|
37
39
|
private liveChatConfig;
|
@@ -87,5 +89,6 @@ declare class OmnichannelChatSDK {
|
|
87
89
|
private resolveIC3ClientUrl;
|
88
90
|
private resolveChatAdapterUrl;
|
89
91
|
private updateChatToken;
|
92
|
+
private setAuthTokenProvider;
|
90
93
|
}
|
91
94
|
export default OmnichannelChatSDK;
|
@@ -109,11 +109,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
109
109
|
this.reconnectId = null;
|
110
110
|
this.refreshTokenTimer = null;
|
111
111
|
this.debug = false;
|
112
|
+
this.runtimeId = ocsdk_1.uuidv4();
|
112
113
|
this.omnichannelConfig = omnichannelConfig;
|
113
114
|
this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
|
114
115
|
);
|
115
116
|
this.isInitialized = false;
|
116
117
|
this.liveChatVersion = LiveChatVersion_1.default.V1;
|
118
|
+
this.localeId = locale_1.defaultLocaleId;
|
117
119
|
this.requestId = ocsdk_1.uuidv4();
|
118
120
|
this.chatToken = {};
|
119
121
|
this.liveChatConfig = {};
|
@@ -131,6 +133,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
131
133
|
this.ocSdkLogger.useTelemetry(this.telemetry);
|
132
134
|
this.acsClientLogger.useTelemetry(this.telemetry);
|
133
135
|
this.acsAdapterLogger.useTelemetry(this.telemetry);
|
136
|
+
this.scenarioMarker.setRuntimeId(this.runtimeId);
|
137
|
+
this.ic3ClientLogger.setRuntimeId(this.runtimeId);
|
138
|
+
this.ocSdkLogger.setRuntimeId(this.runtimeId);
|
139
|
+
this.acsClientLogger.setRuntimeId(this.runtimeId);
|
140
|
+
this.acsAdapterLogger.setRuntimeId(this.runtimeId);
|
134
141
|
OmnichannelConfigValidator_1.default(omnichannelConfig);
|
135
142
|
SDKConfigValidators_1.default(chatSDKConfig);
|
136
143
|
((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
|
@@ -294,44 +301,52 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
294
301
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
295
302
|
if (optionalParams === void 0) { optionalParams = {}; }
|
296
303
|
return __awaiter(this, void 0, void 0, function () {
|
297
|
-
var reconnectableChatsParams, reconnectableChatsResponse,
|
304
|
+
var shouldReinitIC3Client, _p, reconnectableChatsParams, reconnectableChatsResponse, _q, exceptionDetails, conversationDetails, exceptionDetails, exceptionDetails, sessionInitOptionalParams, error_3, exceptionDetails, chatAdapterConfig, error_4, exceptionDetails, _r, error_5, exceptionDetails, error_6, exceptionDetails, error_7, exceptionDetails, _s, error_8, exceptionDetails;
|
298
305
|
var _this = this;
|
299
|
-
return __generator(this, function (
|
300
|
-
switch (
|
306
|
+
return __generator(this, function (_t) {
|
307
|
+
switch (_t.label) {
|
301
308
|
case 0:
|
302
309
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.StartChat, {
|
303
310
|
RequestId: this.requestId
|
304
311
|
});
|
312
|
+
shouldReinitIC3Client = !platform_1.default.isNode() && !platform_1.default.isReactNative() && !this.IC3Client && this.liveChatVersion === LiveChatVersion_1.default.V1;
|
313
|
+
if (!shouldReinitIC3Client) return [3 /*break*/, 2];
|
314
|
+
_p = this;
|
315
|
+
return [4 /*yield*/, this.getIC3Client()];
|
316
|
+
case 1:
|
317
|
+
_p.IC3Client = _t.sent();
|
318
|
+
_t.label = 2;
|
319
|
+
case 2:
|
305
320
|
if (this.isChatReconnect && !((_a = this.chatSDKConfig.chatReconnect) === null || _a === void 0 ? void 0 : _a.disable) && !this.isPersistentChat && optionalParams.reconnectId) {
|
306
321
|
this.reconnectId = optionalParams.reconnectId;
|
307
322
|
}
|
308
|
-
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/,
|
309
|
-
|
310
|
-
case
|
311
|
-
|
323
|
+
if (!(this.isPersistentChat && !((_b = this.chatSDKConfig.persistentChat) === null || _b === void 0 ? void 0 : _b.disable))) return [3 /*break*/, 6];
|
324
|
+
_t.label = 3;
|
325
|
+
case 3:
|
326
|
+
_t.trys.push([3, 5, , 6]);
|
312
327
|
reconnectableChatsParams = {
|
313
328
|
authenticatedUserToken: this.authenticatedUserToken
|
314
329
|
};
|
315
330
|
return [4 /*yield*/, this.OCClient.getReconnectableChats(reconnectableChatsParams)];
|
316
|
-
case
|
317
|
-
reconnectableChatsResponse =
|
331
|
+
case 4:
|
332
|
+
reconnectableChatsResponse = _t.sent();
|
318
333
|
if (reconnectableChatsResponse && reconnectableChatsResponse.reconnectid) {
|
319
334
|
this.reconnectId = reconnectableChatsResponse.reconnectid;
|
320
335
|
}
|
321
|
-
return [3 /*break*/,
|
322
|
-
case
|
323
|
-
|
336
|
+
return [3 /*break*/, 6];
|
337
|
+
case 5:
|
338
|
+
_q = _t.sent();
|
324
339
|
exceptionDetails = {
|
325
340
|
response: "OCClientGetReconnectableChatsFailed"
|
326
341
|
};
|
327
342
|
throw Error(exceptionDetails.response);
|
328
|
-
case
|
329
|
-
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/,
|
343
|
+
case 6:
|
344
|
+
if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 8];
|
330
345
|
this.chatToken = optionalParams.liveChatContext.chatToken || {};
|
331
346
|
this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
|
332
347
|
return [4 /*yield*/, this.getConversationDetails()];
|
333
|
-
case
|
334
|
-
conversationDetails =
|
348
|
+
case 7:
|
349
|
+
conversationDetails = _t.sent();
|
335
350
|
if (Object.keys(conversationDetails).length === 0) {
|
336
351
|
exceptionDetails = {
|
337
352
|
response: "InvalidConversation"
|
@@ -356,14 +371,14 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
356
371
|
console.error("Unable to join conversation that's in '" + conversationDetails.state + "' state");
|
357
372
|
throw Error(exceptionDetails.response);
|
358
373
|
}
|
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;
|
374
|
+
_t.label = 8;
|
366
375
|
case 8:
|
376
|
+
if (!(this.chatToken && Object.keys(this.chatToken).length === 0)) return [3 /*break*/, 10];
|
377
|
+
return [4 /*yield*/, this.getChatToken(false)];
|
378
|
+
case 9:
|
379
|
+
_t.sent();
|
380
|
+
_t.label = 10;
|
381
|
+
case 10:
|
367
382
|
(_c = this.ic3ClientLogger) === null || _c === void 0 ? void 0 : _c.setChatId(this.chatToken.chatId || '');
|
368
383
|
(_d = this.ocSdkLogger) === null || _d === void 0 ? void 0 : _d.setChatId(this.chatToken.chatId || '');
|
369
384
|
(_e = this.acsClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId(this.chatToken.chatId || '');
|
@@ -371,6 +386,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
371
386
|
sessionInitOptionalParams = {
|
372
387
|
initContext: {}
|
373
388
|
};
|
389
|
+
sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
|
374
390
|
if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
|
375
391
|
sessionInitOptionalParams.reconnectId = this.reconnectId;
|
376
392
|
}
|
@@ -402,16 +418,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
402
418
|
if (this.authenticatedUserToken) {
|
403
419
|
sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
|
404
420
|
}
|
405
|
-
if (!!optionalParams.liveChatContext) return [3 /*break*/,
|
406
|
-
|
407
|
-
case 9:
|
408
|
-
_s.trys.push([9, 11, , 12]);
|
409
|
-
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
410
|
-
case 10:
|
411
|
-
_s.sent();
|
412
|
-
return [3 /*break*/, 12];
|
421
|
+
if (!!optionalParams.liveChatContext) return [3 /*break*/, 14];
|
422
|
+
_t.label = 11;
|
413
423
|
case 11:
|
414
|
-
|
424
|
+
_t.trys.push([11, 13, , 14]);
|
425
|
+
return [4 /*yield*/, this.OCClient.sessionInit(this.requestId, sessionInitOptionalParams)];
|
426
|
+
case 12:
|
427
|
+
_t.sent();
|
428
|
+
return [3 /*break*/, 14];
|
429
|
+
case 13:
|
430
|
+
error_3 = _t.sent();
|
415
431
|
exceptionDetails = {
|
416
432
|
response: "OCClientSessionInitFailed"
|
417
433
|
};
|
@@ -422,8 +438,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
422
438
|
});
|
423
439
|
console.error("OmnichannelChatSDK/startChat/sessionInit/error " + error_3);
|
424
440
|
return [2 /*return*/, error_3];
|
425
|
-
case
|
426
|
-
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/,
|
441
|
+
case 14:
|
442
|
+
if (!(this.liveChatVersion === LiveChatVersion_1.default.V2)) return [3 /*break*/, 25];
|
427
443
|
chatAdapterConfig = {
|
428
444
|
token: this.chatToken.token,
|
429
445
|
id: this.chatToken.visitorId || 'teamsvisitor',
|
@@ -431,18 +447,18 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
431
447
|
environmentUrl: this.chatToken.acsEndpoint,
|
432
448
|
pollingInterval: 1000
|
433
449
|
};
|
434
|
-
|
435
|
-
case
|
436
|
-
|
450
|
+
_t.label = 15;
|
451
|
+
case 15:
|
452
|
+
_t.trys.push([15, 17, , 18]);
|
437
453
|
return [4 /*yield*/, ((_j = this.ACSClient) === null || _j === void 0 ? void 0 : _j.initialize({
|
438
454
|
token: chatAdapterConfig.token,
|
439
455
|
environmentUrl: chatAdapterConfig.environmentUrl
|
440
456
|
}))];
|
441
|
-
case
|
442
|
-
|
443
|
-
return [3 /*break*/,
|
444
|
-
case
|
445
|
-
error_4 =
|
457
|
+
case 16:
|
458
|
+
_t.sent();
|
459
|
+
return [3 /*break*/, 18];
|
460
|
+
case 17:
|
461
|
+
error_4 = _t.sent();
|
446
462
|
exceptionDetails = {
|
447
463
|
response: "ACSClientInitializeFailed"
|
448
464
|
};
|
@@ -453,23 +469,23 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
453
469
|
});
|
454
470
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_4);
|
455
471
|
return [2 /*return*/, error_4];
|
456
|
-
case
|
457
|
-
|
458
|
-
|
472
|
+
case 18:
|
473
|
+
_t.trys.push([18, 20, , 21]);
|
474
|
+
_r = this;
|
459
475
|
return [4 /*yield*/, ((_k = this.ACSClient) === null || _k === void 0 ? void 0 : _k.joinConversation({
|
460
476
|
id: chatAdapterConfig.id,
|
461
477
|
threadId: chatAdapterConfig.threadId,
|
462
478
|
pollingInterval: chatAdapterConfig.pollingInterval
|
463
479
|
}))];
|
464
|
-
case
|
465
|
-
|
480
|
+
case 19:
|
481
|
+
_r.conversation = (_t.sent());
|
466
482
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
467
483
|
RequestId: this.requestId,
|
468
484
|
ChatId: this.chatToken.chatId
|
469
485
|
});
|
470
|
-
return [3 /*break*/,
|
471
|
-
case
|
472
|
-
error_5 =
|
486
|
+
return [3 /*break*/, 21];
|
487
|
+
case 20:
|
488
|
+
error_5 = _t.sent();
|
473
489
|
exceptionDetails = {
|
474
490
|
response: "ACSClientJoinConversationFailed"
|
475
491
|
};
|
@@ -480,16 +496,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
480
496
|
});
|
481
497
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_5);
|
482
498
|
throw Error(exceptionDetails.response);
|
483
|
-
case
|
484
|
-
|
499
|
+
case 21:
|
500
|
+
_t.trys.push([21, 23, , 24]);
|
485
501
|
return [4 /*yield*/, ((_l = this.AMSClient) === null || _l === void 0 ? void 0 : _l.initialize({
|
486
502
|
chatToken: this.chatToken
|
487
503
|
}))];
|
488
|
-
case
|
489
|
-
|
490
|
-
return [3 /*break*/,
|
491
|
-
case
|
492
|
-
error_6 =
|
504
|
+
case 22:
|
505
|
+
_t.sent();
|
506
|
+
return [3 /*break*/, 24];
|
507
|
+
case 23:
|
508
|
+
error_6 = _t.sent();
|
493
509
|
exceptionDetails = {
|
494
510
|
response: "AMSClientInitializeFailed"
|
495
511
|
};
|
@@ -499,19 +515,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
499
515
|
ExceptionDetails: JSON.stringify(exceptionDetails)
|
500
516
|
});
|
501
517
|
throw Error(exceptionDetails.response);
|
502
|
-
case
|
503
|
-
case
|
504
|
-
|
518
|
+
case 24: return [3 /*break*/, 31];
|
519
|
+
case 25:
|
520
|
+
_t.trys.push([25, 27, , 28]);
|
505
521
|
return [4 /*yield*/, this.IC3Client.initialize({
|
506
522
|
token: this.chatToken.token,
|
507
523
|
regionGtms: this.chatToken.regionGTMS,
|
508
524
|
visitor: true
|
509
525
|
})];
|
510
|
-
case
|
511
|
-
|
512
|
-
return [3 /*break*/,
|
513
|
-
case
|
514
|
-
error_7 =
|
526
|
+
case 26:
|
527
|
+
_t.sent();
|
528
|
+
return [3 /*break*/, 28];
|
529
|
+
case 27:
|
530
|
+
error_7 = _t.sent();
|
515
531
|
exceptionDetails = {
|
516
532
|
response: "IC3ClientInitializeFailed"
|
517
533
|
};
|
@@ -522,19 +538,19 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
522
538
|
});
|
523
539
|
console.error("OmnichannelChatSDK/startChat/initialize/error " + error_7);
|
524
540
|
return [2 /*return*/, error_7];
|
525
|
-
case
|
526
|
-
|
527
|
-
|
541
|
+
case 28:
|
542
|
+
_t.trys.push([28, 30, , 31]);
|
543
|
+
_s = this;
|
528
544
|
return [4 /*yield*/, this.IC3Client.joinConversation(this.chatToken.chatId)];
|
529
|
-
case
|
530
|
-
|
545
|
+
case 29:
|
546
|
+
_s.conversation = _t.sent();
|
531
547
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.StartChat, {
|
532
548
|
RequestId: this.requestId,
|
533
549
|
ChatId: this.chatToken.chatId
|
534
550
|
});
|
535
|
-
return [3 /*break*/,
|
536
|
-
case
|
537
|
-
error_8 =
|
551
|
+
return [3 /*break*/, 31];
|
552
|
+
case 30:
|
553
|
+
error_8 = _t.sent();
|
538
554
|
exceptionDetails = {
|
539
555
|
response: "IC3ClientJoinConversationFailed"
|
540
556
|
};
|
@@ -545,7 +561,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
545
561
|
});
|
546
562
|
console.error("OmnichannelChatSDK/startChat/joinConversation/error " + error_8);
|
547
563
|
return [2 /*return*/, error_8];
|
548
|
-
case
|
564
|
+
case 31:
|
549
565
|
if (this.isPersistentChat && !((_m = this.chatSDKConfig.persistentChat) === null || _m === void 0 ? void 0 : _m.disable)) {
|
550
566
|
this.refreshTokenTimer = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
551
567
|
return __generator(this, function (_a) {
|
@@ -583,6 +599,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
583
599
|
}
|
584
600
|
if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
|
585
601
|
isChatReconnect = this.reconnectId !== null ? true : false;
|
602
|
+
this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
|
586
603
|
sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
|
587
604
|
}
|
588
605
|
if (this.authenticatedUserToken) {
|
@@ -603,6 +620,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
603
620
|
this.requestId = ocsdk_1.uuidv4();
|
604
621
|
this.chatToken = {};
|
605
622
|
this.reconnectId = null;
|
623
|
+
this.IC3Client.dispose();
|
624
|
+
!platform_1.default.isNode() && !platform_1.default.isReactNative() && WebUtils_1.removeElementById(this.IC3Client.id);
|
625
|
+
this.IC3Client = null;
|
606
626
|
(_d = this.ic3ClientLogger) === null || _d === void 0 ? void 0 : _d.setRequestId(this.requestId);
|
607
627
|
(_e = this.ic3ClientLogger) === null || _e === void 0 ? void 0 : _e.setChatId('');
|
608
628
|
(_f = this.ocSdkLogger) === null || _f === void 0 ? void 0 : _f.setRequestId(this.requestId);
|
@@ -1450,7 +1470,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1450
1470
|
ChatId: this.chatToken.chatId,
|
1451
1471
|
EmailAddress: body.emailAddress,
|
1452
1472
|
DefaultAttachmentMessage: body.attachmentMessage,
|
1453
|
-
CustomerLocale: body.locale
|
1473
|
+
CustomerLocale: body.locale || locale_1.getLocaleStringFromId(this.localeId)
|
1454
1474
|
};
|
1455
1475
|
emailResponse = this.OCClient.emailTranscript(this.requestId, this.chatToken.token, emailRequestBody, emailTranscriptOptionalParams);
|
1456
1476
|
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.EmailLiveChatTranscript, {
|
@@ -1582,8 +1602,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1582
1602
|
};
|
1583
1603
|
var adapter = new window.Microsoft.BotFramework.WebChat.IC3Adapter(adapterConfig);
|
1584
1604
|
adapter.logger = _this.ic3ClientLogger;
|
1585
|
-
// Keep iframe communication alive to reuse the same IC3Client instance
|
1586
|
-
window.Microsoft.BotFramework.WebChat.IC3SDKProvider.disposeSdk = function () { }; // eslint-disable-line @typescript-eslint/no-empty-function
|
1587
1605
|
_this.scenarioMarker.completeScenario(TelemetryEvent_1.default.CreateIC3Adapter);
|
1588
1606
|
resolve(adapter);
|
1589
1607
|
}, function () {
|
@@ -1677,7 +1695,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1677
1695
|
};
|
1678
1696
|
OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
|
1679
1697
|
return __awaiter(this, void 0, void 0, function () {
|
1680
|
-
var conversationId,
|
1698
|
+
var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
|
1681
1699
|
return __generator(this, function (_a) {
|
1682
1700
|
switch (_a.label) {
|
1683
1701
|
case 0:
|
@@ -1687,11 +1705,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1687
1705
|
_a.label = 1;
|
1688
1706
|
case 1:
|
1689
1707
|
_a.trys.push([1, 6, , 7]);
|
1690
|
-
|
1691
|
-
liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin, chatWidgetLanguage = chatConfig.ChatWidgetLanguage;
|
1708
|
+
liveWSAndLiveChatEngJoin = this.liveChatConfig.LiveWSAndLiveChatEngJoin;
|
1692
1709
|
msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
|
1693
|
-
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1694
|
-
localeId = msdyn_localeid !== null && msdyn_localeid !== void 0 ? msdyn_localeid : "1033";
|
1695
1710
|
if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
|
1696
1711
|
return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
|
1697
1712
|
case 2:
|
@@ -1701,7 +1716,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1701
1716
|
surveyInviteLinkRequest = {
|
1702
1717
|
"FormId": msfp_sourcesurveyidentifier,
|
1703
1718
|
"ConversationId": conversationId,
|
1704
|
-
"OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
|
1719
|
+
"OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId) || locale_1.getLocaleStringFromId(locale_1.defaultLocaleId)
|
1705
1720
|
};
|
1706
1721
|
optionalParams = {
|
1707
1722
|
"requestId": this.requestId
|
@@ -1790,7 +1805,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1790
1805
|
this.debug && console.debug('IC3Client');
|
1791
1806
|
// Use IC3Client if browser is detected
|
1792
1807
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
1793
|
-
var ic3ClientCDNUrl;
|
1808
|
+
var ic3ClientCDNUrl, IC3Client;
|
1794
1809
|
var _this = this;
|
1795
1810
|
var _a;
|
1796
1811
|
return __generator(this, function (_b) {
|
@@ -1801,6 +1816,16 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1801
1816
|
IC3Client: ic3ClientCDNUrl
|
1802
1817
|
});
|
1803
1818
|
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetIC3Client);
|
1819
|
+
if (!this.IC3SDKProvider) return [3 /*break*/, 2];
|
1820
|
+
return [4 /*yield*/, this.IC3SDKProvider.getSDK({
|
1821
|
+
hostType: HostType_1.default.IFrame,
|
1822
|
+
protocolType: ProtocoleType_1.default.IC3V1SDK,
|
1823
|
+
logger: this.ic3ClientLogger // eslint-disable-line @typescript-eslint/no-explicit-any
|
1824
|
+
})];
|
1825
|
+
case 1:
|
1826
|
+
IC3Client = _b.sent();
|
1827
|
+
return [2 /*return*/, resolve(IC3Client)];
|
1828
|
+
case 2:
|
1804
1829
|
window.addEventListener("ic3:sdk:load", function () { return __awaiter(_this, void 0, void 0, function () {
|
1805
1830
|
var ic3sdk, IC3SDKProvider, IC3Client;
|
1806
1831
|
return __generator(this, function (_a) {
|
@@ -1837,7 +1862,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1837
1862
|
});
|
1838
1863
|
reject('Failed to load IC3Client');
|
1839
1864
|
})];
|
1840
|
-
case
|
1865
|
+
case 3:
|
1841
1866
|
_b.sent();
|
1842
1867
|
return [2 /*return*/];
|
1843
1868
|
}
|
@@ -1849,15 +1874,17 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1849
1874
|
};
|
1850
1875
|
OmnichannelChatSDK.prototype.getChatConfig = function () {
|
1851
1876
|
return __awaiter(this, void 0, void 0, function () {
|
1852
|
-
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled,
|
1853
|
-
return __generator(this, function (
|
1854
|
-
switch (
|
1877
|
+
var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, error_18;
|
1878
|
+
return __generator(this, function (_a) {
|
1879
|
+
switch (_a.label) {
|
1855
1880
|
case 0:
|
1856
|
-
|
1881
|
+
_a.trys.push([0, 4, , 5]);
|
1857
1882
|
return [4 /*yield*/, this.OCClient.getChatConfig()];
|
1858
1883
|
case 1:
|
1859
|
-
liveChatConfig =
|
1860
|
-
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
|
1884
|
+
liveChatConfig = _a.sent();
|
1885
|
+
dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
|
1886
|
+
msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
|
1887
|
+
this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
|
1861
1888
|
this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
|
1862
1889
|
/* istanbul ignore next */
|
1863
1890
|
this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);
|
@@ -1880,47 +1907,12 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1880
1907
|
if (isPreChatEnabled && preChatSurvey && preChatSurvey.trim().length > 0) {
|
1881
1908
|
this.preChatSurvey = preChatSurvey;
|
1882
1909
|
}
|
1883
|
-
if (!this.authSettings) return [3 /*break*/,
|
1884
|
-
this.
|
1885
|
-
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 6];
|
1886
|
-
_b.label = 2;
|
1910
|
+
if (!this.authSettings) return [3 /*break*/, 3];
|
1911
|
+
return [4 /*yield*/, this.setAuthTokenProvider(this.chatSDKConfig.getAuthToken)];
|
1887
1912
|
case 2:
|
1888
|
-
|
1889
|
-
|
1913
|
+
_a.sent();
|
1914
|
+
_a.label = 3;
|
1890
1915
|
case 3:
|
1891
|
-
token = _b.sent();
|
1892
|
-
if (token) {
|
1893
|
-
this.authenticatedUserToken = token;
|
1894
|
-
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
1895
|
-
}
|
1896
|
-
else {
|
1897
|
-
exceptionDetails = {
|
1898
|
-
response: "UndefinedAuthToken"
|
1899
|
-
};
|
1900
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1901
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1902
|
-
});
|
1903
|
-
}
|
1904
|
-
return [3 /*break*/, 5];
|
1905
|
-
case 4:
|
1906
|
-
_a = _b.sent();
|
1907
|
-
exceptionDetails = {
|
1908
|
-
response: "GetAuthTokenFailed"
|
1909
|
-
};
|
1910
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1911
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1912
|
-
});
|
1913
|
-
return [3 /*break*/, 5];
|
1914
|
-
case 5: return [3 /*break*/, 7];
|
1915
|
-
case 6:
|
1916
|
-
exceptionDetails = {
|
1917
|
-
response: "GetAuthTokenNotFound"
|
1918
|
-
};
|
1919
|
-
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
1920
|
-
ExceptionDetails: JSON.stringify(exceptionDetails)
|
1921
|
-
});
|
1922
|
-
_b.label = 7;
|
1923
|
-
case 7:
|
1924
1916
|
if (this.preChatSurvey) {
|
1925
1917
|
/* istanbul ignore next */
|
1926
1918
|
this.debug && console.log('Prechat Survey!');
|
@@ -1928,11 +1920,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
1928
1920
|
this.callingOption = msdyn_callingoptions;
|
1929
1921
|
this.liveChatConfig = liveChatConfig;
|
1930
1922
|
return [2 /*return*/, this.liveChatConfig];
|
1931
|
-
case
|
1932
|
-
error_18 =
|
1923
|
+
case 4:
|
1924
|
+
error_18 = _a.sent();
|
1933
1925
|
console.error("OmnichannelChatSDK/getChatConfig/error " + error_18);
|
1934
1926
|
return [2 /*return*/, error_18];
|
1935
|
-
case
|
1927
|
+
case 5: return [2 /*return*/];
|
1936
1928
|
}
|
1937
1929
|
});
|
1938
1930
|
});
|
@@ -2014,6 +2006,57 @@ var OmnichannelChatSDK = /** @class */ (function () {
|
|
2014
2006
|
});
|
2015
2007
|
});
|
2016
2008
|
};
|
2009
|
+
OmnichannelChatSDK.prototype.setAuthTokenProvider = function (provider) {
|
2010
|
+
return __awaiter(this, void 0, void 0, function () {
|
2011
|
+
var token, exceptionDetails, _a, exceptionDetails, exceptionDetails;
|
2012
|
+
return __generator(this, function (_b) {
|
2013
|
+
switch (_b.label) {
|
2014
|
+
case 0:
|
2015
|
+
this.scenarioMarker.startScenario(TelemetryEvent_1.default.GetAuthToken);
|
2016
|
+
this.chatSDKConfig.getAuthToken = provider;
|
2017
|
+
if (!this.chatSDKConfig.getAuthToken) return [3 /*break*/, 5];
|
2018
|
+
_b.label = 1;
|
2019
|
+
case 1:
|
2020
|
+
_b.trys.push([1, 3, , 4]);
|
2021
|
+
return [4 /*yield*/, this.chatSDKConfig.getAuthToken()];
|
2022
|
+
case 2:
|
2023
|
+
token = _b.sent();
|
2024
|
+
if (token) {
|
2025
|
+
this.authenticatedUserToken = token;
|
2026
|
+
this.scenarioMarker.completeScenario(TelemetryEvent_1.default.GetAuthToken);
|
2027
|
+
}
|
2028
|
+
else {
|
2029
|
+
exceptionDetails = {
|
2030
|
+
response: "UndefinedAuthToken"
|
2031
|
+
};
|
2032
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2033
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2034
|
+
});
|
2035
|
+
}
|
2036
|
+
return [3 /*break*/, 4];
|
2037
|
+
case 3:
|
2038
|
+
_a = _b.sent();
|
2039
|
+
exceptionDetails = {
|
2040
|
+
response: "GetAuthTokenFailed"
|
2041
|
+
};
|
2042
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2043
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2044
|
+
});
|
2045
|
+
return [3 /*break*/, 4];
|
2046
|
+
case 4: return [3 /*break*/, 6];
|
2047
|
+
case 5:
|
2048
|
+
exceptionDetails = {
|
2049
|
+
response: "GetAuthTokenNotFound"
|
2050
|
+
};
|
2051
|
+
this.scenarioMarker.failScenario(TelemetryEvent_1.default.GetAuthToken, {
|
2052
|
+
ExceptionDetails: JSON.stringify(exceptionDetails)
|
2053
|
+
});
|
2054
|
+
_b.label = 6;
|
2055
|
+
case 6: return [2 /*return*/];
|
2056
|
+
}
|
2057
|
+
});
|
2058
|
+
});
|
2059
|
+
};
|
2017
2060
|
return OmnichannelChatSDK;
|
2018
2061
|
}());
|
2019
2062
|
exports.default = OmnichannelChatSDK;
|