@microsoft/omnichannel-chat-sdk 1.0.1-main.6b8a4cf → 1.0.1-main.7615829

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +13 -3
  2. package/README.md +38 -38
  3. package/lib/OmnichannelChatSDK.d.ts +2 -3
  4. package/lib/OmnichannelChatSDK.js +38 -111
  5. package/lib/OmnichannelChatSDK.js.map +1 -1
  6. package/lib/config/settings.d.ts +1 -1
  7. package/lib/config/settings.js +1 -1
  8. package/lib/config/settings.js.map +1 -1
  9. package/lib/core/ChatConfig.d.ts +3 -0
  10. package/lib/core/messaging/ACSClient.js +1 -1
  11. package/lib/core/messaging/ACSClient.js.map +1 -1
  12. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.d.ts +2 -0
  13. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js +31 -0
  14. package/lib/external/ACSAdapter/createFormatEgressTagsMiddleware.js.map +1 -0
  15. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.d.ts +2 -0
  16. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js +25 -0
  17. package/lib/external/ACSAdapter/createFormatIngressTagsMiddleware.js.map +1 -0
  18. package/lib/telemetry/AriaTelemetry.js +5 -0
  19. package/lib/telemetry/AriaTelemetry.js.map +1 -1
  20. package/lib/telemetry/ScenarioMarker.d.ts +2 -0
  21. package/lib/telemetry/ScenarioMarker.js +7 -3
  22. package/lib/telemetry/ScenarioMarker.js.map +1 -1
  23. package/lib/telemetry/TelemetryEvent.d.ts +1 -3
  24. package/lib/telemetry/TelemetryEvent.js +0 -2
  25. package/lib/telemetry/TelemetryEvent.js.map +1 -1
  26. package/lib/tsconfig.tsbuildinfo +758 -1073
  27. package/lib/utils/libraries.d.ts +1 -3
  28. package/lib/utils/libraries.js +2 -11
  29. package/lib/utils/libraries.js.map +1 -1
  30. package/lib/utils/locale.d.ts +1 -0
  31. package/lib/utils/locale.js +2 -1
  32. package/lib/utils/locale.js.map +1 -1
  33. package/lib/utils/loggers.d.ts +8 -0
  34. package/lib/utils/loggers.js +24 -0
  35. package/lib/utils/loggers.js.map +1 -1
  36. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -4,12 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
  ## [Unreleased]
5
5
 
6
6
  ### Added
7
- - Add Post Chat Survey Support
8
- - Add `getPostChatSurveyContext` & `initializePostChatRenderer` and `renderPostChatSurvey` API methods
9
- - Add `GetPostChatSurveyContext`, `RenderPostChatSurvey`, and `InitializePostChatRenderer` telemetry events
7
+ - Add `getPostChatSurveyContext` API method
8
+ - Add `GetPostChatSurveyContext` telemetry event
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
+
14
+ ### Fix
15
+ - Add `acs_webchat-chat-adapter` middlewares to format `channelData.tags`
16
+ - Skip `session init` call on existing conversation
17
+ - Fix `chat reconnect` not ending the conversation on calling `ChatSDK.endChat()`
10
18
 
11
19
  ### Changed
12
20
  - README: added examples on usages of the post chat APIs.
21
+ - Uptake [@azure/communication-chat@1.1.1](https://www.npmjs.com/package/@azure/communication-chat/v/1.1.1)
22
+ - Uptake [acs_webchat-chat-adapter@0.0.35-beta.2](https://unpkg.com/acs_webchat-chat-adapter@0.0.35-beta.2/dist/chat-adapter.js)
13
23
 
14
24
  ## [1.0.0] - 2021-10-08
15
25
  ### Added
package/README.md CHANGED
@@ -14,7 +14,7 @@ Please make sure you have a chat widget configured before using this package or
14
14
  - [Installation on React Native](#installation-on-react-native)
15
15
  - [API Reference](#api-reference)
16
16
  - [API Examples](#api-examples)
17
- - [Sample Apps](samples/)
17
+ - [Sample Apps](https://github.com/microsoft/omnichannel-chat-sdk-samples)
18
18
  - [Common Scenarios](#common-scenarios)
19
19
  - [Feature Comparisons](#feature-comparisons)
20
20
  - [Telemetry](#telemetry)
@@ -35,14 +35,12 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
35
35
  | Bring Your Own Widget | ❌ | ✔ | |
36
36
  | Web Support | ✔ | ✔ |
37
37
  | React Native Support | ❌ | ✔ |
38
- | Escalation to Voice & Video | ✔ | Web Only |
39
- | Co-browse | ✔ | Web Only |
40
- | Screen Sharing | ✔ | Web Only |
38
+ | Escalation to Voice & Video | ✔ | | Only supported on Web |
39
+ | Co-browse | ✔ | 3rd party add-on | Only supported on Web |
40
+ | Screen Sharing | ✔ | 3rd party add-on | Only supported on Web |
41
41
  | Authenticated Chat | ✔ | ✔ |
42
42
  | Pre-chat Survey | ✔ | ✔ |
43
- | Post-chat Survey | ✔ | Web Only for In-line Render |
44
- | Queue Position | ✔ | ✔ |
45
- | Average Wait Time | ✔ | ✔ |
43
+ | Post-chat Survey | ✔ | |
46
44
  | Download Transcript | ✔ | ✔ |
47
45
  | Email Transcript | ✔ | ✔ |
48
46
  | Data Masking | ✔ | ✔ |
@@ -52,6 +50,8 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
52
50
  | Persistent Chat | ✔ | ✔ |
53
51
  | Chat Reconnect | ✔ | ✔ |
54
52
  | Operating Hours | ✔ | ✔ |
53
+ | Queue Position | ✔ | ✔ | No SDK method. Handled as *system message* |
54
+ | Average Wait Time | ✔ | ✔ | No SDK method. Handled as *system message* |
55
55
 
56
56
  **\*** BYOI: Bring Your Own Implementation
57
57
 
@@ -65,7 +65,26 @@ Omnichannel offers an live chat widget (LCW) by default. You can use the Chat SD
65
65
 
66
66
  The following steps will be required to run Omnichannel Chat SDK on React Native:
67
67
 
68
- 1. Run `npm install node-libs-react-native --save-dev`
68
+ 1. Install `node-libs-react-native`
69
+ ```
70
+ npm install node-libs-react-native --save-dev
71
+ ```
72
+
73
+ 1. Install `react-native-randomBytes`
74
+ ```
75
+ npm install react-native-randombytes --save-dev
76
+ ```
77
+
78
+ 1. Install `react-native-get-random-values`
79
+ ```
80
+ npm install react-native-get-random-values --save-dev
81
+ ```
82
+
83
+ 1. Install `react-native-url-polyfill`
84
+ ```
85
+ npm install react-native-url-polyfill --save-dev
86
+ ```
87
+
69
88
  1. Update *metro.config.js* to use React Native compatible Node Core modules
70
89
  ```ts
71
90
  module.exports = {
@@ -80,14 +99,11 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
80
99
  };
81
100
  ```
82
101
 
83
- 1. Import 'node-libs-react-native/globals' on top of your entry point file
102
+ 1. Add following *import* on top of your entry point file
84
103
  ```ts
85
104
  import 'node-libs-react-native/globals';
86
- ```
87
-
88
- 1. Install `react-native-randomBytes`
89
- ```
90
- npm install react-native-randombytes --save-dev
105
+ import 'react-native-get-random-values';
106
+ import 'react-native-url-polyfill';
91
107
  ```
92
108
 
93
109
  ## API Reference
@@ -117,10 +133,7 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
117
133
  | OmnichannelChatSDK.downloadFileAttachment() | Download file attachment | |
118
134
  | OmnichannelChatSDK.createChatAdapter() | Get IC3Adapter | **Web only** |
119
135
  | OmnichannelChatSDK.getVoiceVideoCalling() | Get VoiceVideoCall SDK for Escalation to Voice & Video | **Web only** |
120
- | OmnichannelChatSDK.getPostChatSurveyContext() | Get post chat survey link and locale | |
121
- | OmnichannelChatSDK.initializePostChatRenderer() | Load necessary scripts and styles to render the FormsPro survey | **Web only** |
122
- | OmnichannelChatSDK.renderPostChatSurvey() | Render the FormsPro survey | **Web only** |
123
-
136
+ | OmnichannelChatSDK.getPostChatSurveyContext() | Get post chat survey link, survey locale, and whether an agent has joined the survey | |
124
137
 
125
138
  ## API examples
126
139
 
@@ -198,31 +211,18 @@ The following steps will be required to run Omnichannel Chat SDK on React Native
198
211
  const preChatSurvey = await getPreChatSurvey(parseToJSON); // Adaptive Cards payload data as string
199
212
  ```
200
213
 
201
- ### Show PostChat Survey
202
- `Option 1: Directly use the survey link`
203
- ```ts
204
- try {
205
- const context = await chatSDK.getPostChatSurveyContext();
206
- if (context?.participantJoined) { // participantJoined will be true if an agent has joined the conversation, or a bot has joined the conversation and the bot survey flag has been turned on on the admin side.
207
- const linkToSend = context.surveyInviteLink + "&lang=" + context.formsProLocale;
208
- // This link is accessible and will redirect to the survey in another tab. Use it as you see fit.
209
- }
210
- } catch (ex) {
211
- // If the post chat should not show by any reason (e.g. post chat is not enabled), promise will be rejected.
212
- }
213
- ```
214
-
215
- `Option 2: Render the FormsPro Survey in a specified container`
214
+ ### Get PostChat Survey
216
215
  ```ts
217
- await chatSDK.initializePostChatRenderer(); // This method is needed to embed FormsPro survey in the widget. It can be called anytime before actually rendering the survey for best performance of you page.
218
-
219
216
  try {
220
217
  const context = await chatSDK.getPostChatSurveyContext();
221
- if (context?.participantJoined) {
222
- await chatSDK?.renderPostChatSurvey('containerId', context); // The survey will be embedded in the element with Id "containerId"
218
+ if (context.participantJoined) { // participantJoined will be true if an agent has joined the conversation, or a bot has joined the conversation and the bot survey flag has been turned on on the admin side.
219
+ // formsProLocale is the default language you have set on the CustomerVoice portal. You can override this url parameter with any locale that CustomerVoice supports.
220
+ // If "&lang=" is not set on the url, the locale will be English.
221
+ const linkToSend = context.surveyInviteLink + "&lang=" + context.formsProLocale;
222
+ // This link is accessible and will redirect to the survey page. Use it as you see fit.
223
223
  }
224
224
  } catch (ex) {
225
-
225
+ // If the post chat should not be shown by any reason (e.g. post chat is not enabled), promise will be rejected.
226
226
  }
227
227
  ```
228
228
 
@@ -20,10 +20,10 @@ import LiveWorkItemDetails from "./core/LiveWorkItemDetails";
20
20
  import OmnichannelConfig from "./core/OmnichannelConfig";
21
21
  import OmnichannelMessage from "./core/messaging/OmnichannelMessage";
22
22
  import OnNewMessageOptionalParams from "./core/messaging/OnNewMessageOptionalParams";
23
- import PostChatContext from "./core/PostChatContext";
24
23
  import StartChatOptionalParams from "./core/StartChatOptionalParams";
25
24
  declare class OmnichannelChatSDK {
26
25
  private debug;
26
+ runtimeId: string;
27
27
  OCSDKProvider: unknown;
28
28
  IC3SDKProvider: unknown;
29
29
  OCClient: any;
@@ -33,6 +33,7 @@ declare class OmnichannelChatSDK {
33
33
  omnichannelConfig: OmnichannelConfig;
34
34
  chatSDKConfig: ChatSDKConfig;
35
35
  isInitialized: boolean;
36
+ localeId: string;
36
37
  requestId: string;
37
38
  private chatToken;
38
39
  private liveChatConfig;
@@ -83,8 +84,6 @@ declare class OmnichannelChatSDK {
83
84
  createChatAdapter(protocol?: string | null): Promise<unknown>;
84
85
  getVoiceVideoCalling(params?: any): Promise<any>;
85
86
  getPostChatSurveyContext(): Promise<any>;
86
- initializePostChatRenderer(): Promise<void>;
87
- renderPostChatSurvey(containerId: string, postChatContext: PostChatContext): Promise<void>;
88
87
  private getIC3Client;
89
88
  private getChatConfig;
90
89
  private resolveIC3ClientUrl;
@@ -58,7 +58,6 @@ 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 libraries_1 = require("./utils/libraries");
62
61
  var platform_1 = require("./utils/platform");
63
62
  var SDKConfigValidators_1 = require("./validators/SDKConfigValidators");
64
63
  var ACSParticipantDisplayName_1 = require("./core/messaging/ACSParticipantDisplayName");
@@ -66,6 +65,8 @@ var AMSFileManager_1 = require("./external/ACSAdapter/AMSFileManager");
66
65
  var CallingOptionsOptionSetNumber_1 = require("./core/CallingOptionsOptionSetNumber");
67
66
  var ChatAdapterProtocols_1 = require("./core/messaging/ChatAdapterProtocols");
68
67
  var ConversationMode_1 = require("./core/ConversationMode");
68
+ var createFormatEgressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatEgressTagsMiddleware");
69
+ var createFormatIngressTagsMiddleware_1 = require("./external/ACSAdapter/createFormatIngressTagsMiddleware");
69
70
  var DeliveryMode_1 = require("@microsoft/omnichannel-ic3core/lib/model/DeliveryMode");
70
71
  var FileSharingProtocolType_1 = require("@microsoft/omnichannel-ic3core/lib/model/FileSharingProtocolType");
71
72
  var HostType_1 = require("@microsoft/omnichannel-ic3core/lib/interfaces/HostType");
@@ -85,6 +86,7 @@ var createVoiceVideoCalling_1 = require("./api/createVoiceVideoCalling");
85
86
  var MessageTags_1 = require("./core/messaging/MessageTags");
86
87
  var locale_1 = require("./utils/locale");
87
88
  var utilities_1 = require("./utils/utilities");
89
+ var libraries_1 = require("./utils/libraries");
88
90
  var WebUtils_1 = require("./utils/WebUtils");
89
91
  var OmnichannelConfigValidator_1 = require("./validators/OmnichannelConfigValidator");
90
92
  var OmnichannelChatSDK = /** @class */ (function () {
@@ -107,11 +109,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
107
109
  this.reconnectId = null;
108
110
  this.refreshTokenTimer = null;
109
111
  this.debug = false;
112
+ this.runtimeId = ocsdk_1.uuidv4();
110
113
  this.omnichannelConfig = omnichannelConfig;
111
114
  this.chatSDKConfig = __assign(__assign({}, SDKConfigValidators_1.defaultChatSDKConfig), chatSDKConfig // overrides
112
115
  );
113
116
  this.isInitialized = false;
114
117
  this.liveChatVersion = LiveChatVersion_1.default.V1;
118
+ this.localeId = locale_1.defaultLocaleId;
115
119
  this.requestId = ocsdk_1.uuidv4();
116
120
  this.chatToken = {};
117
121
  this.liveChatConfig = {};
@@ -129,6 +133,11 @@ var OmnichannelChatSDK = /** @class */ (function () {
129
133
  this.ocSdkLogger.useTelemetry(this.telemetry);
130
134
  this.acsClientLogger.useTelemetry(this.telemetry);
131
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);
132
141
  OmnichannelConfigValidator_1.default(omnichannelConfig);
133
142
  SDKConfigValidators_1.default(chatSDKConfig);
134
143
  ((_a = this.chatSDKConfig.telemetry) === null || _a === void 0 ? void 0 : _a.disable) && ((_b = this.telemetry) === null || _b === void 0 ? void 0 : _b.disable());
@@ -324,7 +333,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
324
333
  };
325
334
  throw Error(exceptionDetails.response);
326
335
  case 4:
327
- if (!(optionalParams.liveChatContext && !this.isPersistentChat && !this.isChatReconnect)) return [3 /*break*/, 6];
336
+ if (!(optionalParams.liveChatContext && !this.reconnectId)) return [3 /*break*/, 6];
328
337
  this.chatToken = optionalParams.liveChatContext.chatToken || {};
329
338
  this.requestId = optionalParams.liveChatContext.requestId || ocsdk_1.uuidv4();
330
339
  return [4 /*yield*/, this.getConversationDetails()];
@@ -369,6 +378,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
369
378
  sessionInitOptionalParams = {
370
379
  initContext: {}
371
380
  };
381
+ sessionInitOptionalParams.initContext.locale = locale_1.getLocaleStringFromId(this.localeId);
372
382
  if (this.isPersistentChat && !((_g = this.chatSDKConfig.persistentChat) === null || _g === void 0 ? void 0 : _g.disable)) {
373
383
  sessionInitOptionalParams.reconnectId = this.reconnectId;
374
384
  }
@@ -400,6 +410,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
400
410
  if (this.authenticatedUserToken) {
401
411
  sessionInitOptionalParams.authenticatedUserToken = this.authenticatedUserToken;
402
412
  }
413
+ if (!!optionalParams.liveChatContext) return [3 /*break*/, 12];
403
414
  _s.label = 9;
404
415
  case 9:
405
416
  _s.trys.push([9, 11, , 12]);
@@ -580,6 +591,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
580
591
  }
581
592
  if (this.isChatReconnect && !((_b = this.chatSDKConfig.chatReconnect) === null || _b === void 0 ? void 0 : _b.disable) && !this.isPersistentChat) {
582
593
  isChatReconnect = this.reconnectId !== null ? true : false;
594
+ this.requestId = isChatReconnect ? this.reconnectId : this.requestId; // Chat Reconnect session to close
583
595
  sessionCloseOptionalParams.isReconnectChat = isChatReconnect;
584
596
  }
585
597
  if (this.authenticatedUserToken) {
@@ -897,6 +909,13 @@ var OmnichannelChatSDK = /** @class */ (function () {
897
909
  sendMessageRequest = {
898
910
  content: message.content,
899
911
  };
912
+ sendMessageRequest.metadata = {
913
+ widgetId: this.omnichannelConfig.widgetId,
914
+ clientMessageId: Date.now().toString()
915
+ };
916
+ if (message.metadata) {
917
+ sendMessageRequest.metadata = __assign(__assign({}, sendMessageRequest.metadata), message.metadata);
918
+ }
900
919
  _e.label = 1;
901
920
  case 1:
902
921
  _e.trys.push([1, 3, , 4]);
@@ -1279,7 +1298,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1279
1298
  };
1280
1299
  sendMessageRequest = {
1281
1300
  content: '',
1282
- metadata: __assign(__assign({}, fileIdsProperty), fileMetaProperty)
1301
+ metadata: __assign(__assign({ widgetId: this.omnichannelConfig.widgetId, clientMessageId: Date.now().toString() }, fileIdsProperty), fileMetaProperty)
1283
1302
  };
1284
1303
  messageToSend = {
1285
1304
  content: "",
@@ -1505,16 +1524,20 @@ var OmnichannelChatSDK = /** @class */ (function () {
1505
1524
  }
1506
1525
  if (protocol === ChatAdapterProtocols_1.default.ACS || this.liveChatVersion === LiveChatVersion_1.default.V2) {
1507
1526
  return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
1508
- var featuresOption, acsAdapterCDNUrl;
1527
+ var egressMiddlewares, ingressMiddlewares, featuresOption, acsAdapterCDNUrl;
1509
1528
  var _this = this;
1510
1529
  var _a;
1511
1530
  return __generator(this, function (_b) {
1512
1531
  switch (_b.label) {
1513
1532
  case 0:
1533
+ egressMiddlewares = [createFormatEgressTagsMiddleware_1.default()];
1534
+ ingressMiddlewares = [createFormatIngressTagsMiddleware_1.default()];
1514
1535
  featuresOption = {
1515
- enableAdaptiveCards: false,
1536
+ enableAdaptiveCards: true,
1516
1537
  enableThreadMemberUpdateNotification: true,
1517
- enableLeaveThreadOnWindowClosed: false
1538
+ enableLeaveThreadOnWindowClosed: false,
1539
+ egressMiddleware: egressMiddlewares,
1540
+ ingressMiddleware: ingressMiddlewares
1518
1541
  };
1519
1542
  acsAdapterCDNUrl = this.resolveChatAdapterUrl(protocol || ChatAdapterProtocols_1.default.ACS);
1520
1543
  (_a = this.telemetry) === null || _a === void 0 ? void 0 : _a.setCDNPackages({
@@ -1526,7 +1549,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1526
1549
  try {
1527
1550
  var ChatAdapter = window.ChatAdapter; // eslint-disable-line @typescript-eslint/no-explicit-any
1528
1551
  var fileManager = new AMSFileManager_1.default(_this.AMSClient, _this.acsAdapterLogger);
1529
- var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, featuresOption);
1552
+ var adapter = ChatAdapter.createACSAdapter(_this.chatToken.token, _this.chatToken.visitorId || 'teamsvisitor', _this.chatToken.chatId, _this.chatToken.acsEndpoint, fileManager, 1000, ACSParticipantDisplayName_1.default.Customer, undefined, undefined, // logger
1553
+ featuresOption);
1530
1554
  resolve(adapter);
1531
1555
  }
1532
1556
  catch (_a) {
@@ -1662,7 +1686,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1662
1686
  };
1663
1687
  OmnichannelChatSDK.prototype.getPostChatSurveyContext = function () {
1664
1688
  return __awaiter(this, void 0, void 0, function () {
1665
- var conversationId, chatConfig, liveWSAndLiveChatEngJoin, chatWidgetLanguage, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, msdyn_localeid, localeId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1689
+ var conversationId, liveWSAndLiveChatEngJoin, msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier, postConversationSurveyOwnerId, liveWorkItemDetails, participantJoined, surveyInviteLinkRequest, optionalParams, surveyInviteLinkResponse, surveyInviteLink, formsProLocale, postChatContext, ex_1;
1666
1690
  return __generator(this, function (_a) {
1667
1691
  switch (_a.label) {
1668
1692
  case 0:
@@ -1672,11 +1696,8 @@ var OmnichannelChatSDK = /** @class */ (function () {
1672
1696
  _a.label = 1;
1673
1697
  case 1:
1674
1698
  _a.trys.push([1, 6, , 7]);
1675
- chatConfig = this.liveChatConfig;
1676
- liveWSAndLiveChatEngJoin = chatConfig.LiveWSAndLiveChatEngJoin, chatWidgetLanguage = chatConfig.ChatWidgetLanguage;
1699
+ liveWSAndLiveChatEngJoin = this.liveChatConfig.LiveWSAndLiveChatEngJoin;
1677
1700
  msdyn_postconversationsurveyenable = liveWSAndLiveChatEngJoin.msdyn_postconversationsurveyenable, msfp_sourcesurveyidentifier = liveWSAndLiveChatEngJoin.msfp_sourcesurveyidentifier, postConversationSurveyOwnerId = liveWSAndLiveChatEngJoin.postConversationSurveyOwnerId;
1678
- msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
1679
- localeId = msdyn_localeid !== null && msdyn_localeid !== void 0 ? msdyn_localeid : "1033";
1680
1701
  if (!msdyn_postconversationsurveyenable) return [3 /*break*/, 4];
1681
1702
  return [4 /*yield*/, this.OCClient.getLWIDetails(this.requestId)];
1682
1703
  case 2:
@@ -1686,7 +1707,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1686
1707
  surveyInviteLinkRequest = {
1687
1708
  "FormId": msfp_sourcesurveyidentifier,
1688
1709
  "ConversationId": conversationId,
1689
- "OCLocaleCode": locale_1.getLocaleStringFromId(localeId)
1710
+ "OCLocaleCode": locale_1.getLocaleStringFromId(this.localeId) || locale_1.getLocaleStringFromId(locale_1.defaultLocaleId)
1690
1711
  };
1691
1712
  optionalParams = {
1692
1713
  "requestId": this.requestId
@@ -1749,102 +1770,6 @@ var OmnichannelChatSDK = /** @class */ (function () {
1749
1770
  });
1750
1771
  });
1751
1772
  };
1752
- OmnichannelChatSDK.prototype.initializePostChatRenderer = function () {
1753
- return __awaiter(this, void 0, void 0, function () {
1754
- var msfpEmbedScript, elm, scriptNodes, styleNodes, i, node, tmpNode, tmpNode, i, node, tmpNode;
1755
- return __generator(this, function (_a) {
1756
- if (!platform_1.isBrowser()) {
1757
- return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
1758
- }
1759
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
1760
- RequestId: this.requestId
1761
- });
1762
- try {
1763
- msfpEmbedScript = libraries_1.getMsfpEmbedScript();
1764
- elm = document.createElement('div');
1765
- elm.innerHTML = msfpEmbedScript;
1766
- scriptNodes = elm.getElementsByTagName('script');
1767
- styleNodes = elm.getElementsByTagName('link');
1768
- for (i = 0; i < scriptNodes.length; i++) {
1769
- node = scriptNodes[i];
1770
- if (node.src) {
1771
- tmpNode = document.createElement('script');
1772
- tmpNode.type = node.type;
1773
- tmpNode.src = node.src;
1774
- tmpNode.async = false;
1775
- if (!window.document.head.contains(tmpNode)) {
1776
- document.getElementsByTagName('head')[0].appendChild(tmpNode);
1777
- }
1778
- }
1779
- if (node.innerHTML) {
1780
- tmpNode = document.createElement('script');
1781
- tmpNode.innerHTML = node.innerHTML;
1782
- tmpNode.async = false;
1783
- if (!window.document.head.contains(tmpNode)) {
1784
- window.document.head.appendChild(tmpNode);
1785
- }
1786
- }
1787
- }
1788
- for (i = 0; i < styleNodes.length; i++) {
1789
- node = styleNodes[i];
1790
- if (node.href) {
1791
- tmpNode = document.createElement('link');
1792
- tmpNode.type = node.type;
1793
- tmpNode.rel = node.rel;
1794
- tmpNode.href = node.href;
1795
- if (!window.document.head.contains(tmpNode)) {
1796
- document.getElementsByTagName('head')[0].appendChild(tmpNode);
1797
- }
1798
- }
1799
- }
1800
- }
1801
- catch (ex) {
1802
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.InitializePostChatRenderer, {
1803
- RequestId: this.requestId,
1804
- ExceptionDetails: JSON.stringify(ex)
1805
- });
1806
- return [2 /*return*/, Promise.reject("Error occurred when initializer post chat renderer. " + JSON.stringify(ex))];
1807
- }
1808
- return [2 /*return*/];
1809
- });
1810
- });
1811
- };
1812
- OmnichannelChatSDK.prototype.renderPostChatSurvey = function (containerId, postChatContext) {
1813
- return __awaiter(this, void 0, void 0, function () {
1814
- var ex_2;
1815
- return __generator(this, function (_a) {
1816
- switch (_a.label) {
1817
- case 0:
1818
- if (!platform_1.isBrowser()) {
1819
- return [2 /*return*/, Promise.reject("In-line rendering is only supported on web browsers")];
1820
- }
1821
- this.scenarioMarker.startScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1822
- RequestId: this.requestId
1823
- });
1824
- _a.label = 1;
1825
- case 1:
1826
- _a.trys.push([1, 3, , 4]);
1827
- if (!postChatContext) {
1828
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1829
- RequestId: this.requestId,
1830
- ExceptionDetails: "Post Chat Context is null."
1831
- });
1832
- return [2 /*return*/, Promise.reject("Post Chat Context is null.")];
1833
- }
1834
- return [4 /*yield*/, renderSurvey(containerId, postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.surveyInviteLink, "", "", postChatContext === null || postChatContext === void 0 ? void 0 : postChatContext.formsProLocale)];
1835
- case 2: return [2 /*return*/, _a.sent()];
1836
- case 3:
1837
- ex_2 = _a.sent();
1838
- this.scenarioMarker.failScenario(TelemetryEvent_1.default.RenderPostChatSurvey, {
1839
- RequestId: this.requestId,
1840
- ExceptionDetails: JSON.stringify(ex_2)
1841
- });
1842
- return [2 /*return*/, Promise.reject("Error occurred when rendering post chat survey. " + JSON.stringify(ex_2))];
1843
- case 4: return [2 /*return*/];
1844
- }
1845
- });
1846
- });
1847
- };
1848
1773
  OmnichannelChatSDK.prototype.getIC3Client = function () {
1849
1774
  return __awaiter(this, void 0, void 0, function () {
1850
1775
  var IC3Client;
@@ -1930,7 +1855,7 @@ var OmnichannelChatSDK = /** @class */ (function () {
1930
1855
  };
1931
1856
  OmnichannelChatSDK.prototype.getChatConfig = function () {
1932
1857
  return __awaiter(this, void 0, void 0, function () {
1933
- var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, token, exceptionDetails, _a, exceptionDetails, exceptionDetails, error_18;
1858
+ var liveChatConfig, dataMaskingConfig, authSettings, liveWSAndLiveChatEngJoin, liveChatVersion, chatWidgetLanguage, msdyn_localeid, setting, preChatSurvey, msdyn_prechatenabled, msdyn_callingoptions, msdyn_conversationmode, msdyn_enablechatreconnect, isPreChatEnabled, isChatReconnectEnabled, token, exceptionDetails, _a, exceptionDetails, exceptionDetails, error_18;
1934
1859
  return __generator(this, function (_b) {
1935
1860
  switch (_b.label) {
1936
1861
  case 0:
@@ -1938,7 +1863,9 @@ var OmnichannelChatSDK = /** @class */ (function () {
1938
1863
  return [4 /*yield*/, this.OCClient.getChatConfig()];
1939
1864
  case 1:
1940
1865
  liveChatConfig = _b.sent();
1941
- dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion;
1866
+ dataMaskingConfig = liveChatConfig.DataMaskingInfo, authSettings = liveChatConfig.LiveChatConfigAuthSettings, liveWSAndLiveChatEngJoin = liveChatConfig.LiveWSAndLiveChatEngJoin, liveChatVersion = liveChatConfig.LiveChatVersion, chatWidgetLanguage = liveChatConfig.ChatWidgetLanguage;
1867
+ msdyn_localeid = chatWidgetLanguage.msdyn_localeid;
1868
+ this.localeId = msdyn_localeid || locale_1.defaultLocaleId;
1942
1869
  this.liveChatVersion = liveChatVersion || LiveChatVersion_1.default.V1;
1943
1870
  /* istanbul ignore next */
1944
1871
  this.debug && console.log("[OmnichannelChatSDK][getChatConfig][liveChatVersion] " + this.liveChatVersion);