@microsoft/omnichannel-chat-widget 0.1.0-main.243d300 → 0.1.0-main.2b2f787

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 (80) hide show
  1. package/README.md +7 -34
  2. package/lib/cjs/common/Constants.js +3 -1
  3. package/lib/cjs/common/storage/default/defaultCacheManager.js +2 -2
  4. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +13 -0
  6. package/lib/cjs/common/telemetry/TelemetryHelper.js +2 -1
  7. package/lib/cjs/common/utils.js +23 -2
  8. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +1 -1
  9. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  10. package/lib/cjs/components/headerstateful/HeaderStateful.js +4 -2
  11. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
  12. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  13. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -10
  14. package/lib/cjs/components/livechatwidget/common/endChat.js +23 -17
  15. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +26 -13
  16. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +5 -5
  17. package/lib/cjs/components/livechatwidget/common/startChat.js +70 -59
  18. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +43 -37
  19. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
  20. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  21. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  22. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +1 -0
  23. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  24. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  25. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  26. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  27. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  28. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  29. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -4
  30. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
  31. package/lib/cjs/hooks/useDebounce.js +28 -0
  32. package/lib/cjs/hooks/useWindowDimensions.js +30 -0
  33. package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
  34. package/lib/esm/common/Constants.js +3 -1
  35. package/lib/esm/common/storage/default/defaultCacheManager.js +2 -2
  36. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  37. package/lib/esm/common/telemetry/TelemetryConstants.js +13 -0
  38. package/lib/esm/common/telemetry/TelemetryHelper.js +2 -1
  39. package/lib/esm/common/utils.js +20 -0
  40. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +1 -1
  41. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  42. package/lib/esm/components/headerstateful/HeaderStateful.js +4 -2
  43. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
  44. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  45. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +14 -10
  46. package/lib/esm/components/livechatwidget/common/endChat.js +23 -17
  47. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +26 -13
  48. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +6 -5
  49. package/lib/esm/components/livechatwidget/common/startChat.js +70 -59
  50. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +44 -38
  51. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
  52. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  53. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  54. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +1 -0
  55. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  56. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  57. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  58. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  59. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  60. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  61. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -5
  62. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +4 -2
  63. package/lib/esm/hooks/useDebounce.js +22 -0
  64. package/lib/esm/hooks/useWindowDimensions.js +23 -0
  65. package/lib/esm/plugins/newMessageEventHandler.js +14 -0
  66. package/lib/types/common/Constants.d.ts +2 -0
  67. package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
  68. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
  69. package/lib/types/common/telemetry/TelemetryConstants.d.ts +14 -1
  70. package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
  71. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  72. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  73. package/lib/types/common/utils.d.ts +1 -0
  74. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
  75. package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
  76. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
  77. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  78. package/lib/types/hooks/useDebounce.d.ts +3 -0
  79. package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
  80. package/package.json +3 -3
@@ -15,6 +15,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
15
15
  const isHistoryMessage = isActivityMessage && ((activity === null || activity === void 0 ? void 0 : (_activity$channelData = activity.channelData) === null || _activity$channelData === void 0 ? void 0 : (_activity$channelData2 = _activity$channelData.tags) === null || _activity$channelData2 === void 0 ? void 0 : _activity$channelData2.includes(_Constants.Constants.historyMessageTag)) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData3 = activity.channelData) === null || _activity$channelData3 === void 0 ? void 0 : _activity$channelData3.fromList));
16
16
  raiseMessageEvent(activity, isHistoryMessage);
17
17
  };
18
+ let isHistoryMessageReceivedEventRasied = false;
18
19
  const raiseMessageEvent = (activity, isHistoryMessage) => {
19
20
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
20
21
  var _text, _text2, _activity$channelData4, _activity$from;
@@ -45,6 +46,10 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
45
46
  if (activity !== null && activity !== void 0 && (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.systemMessageTag)) {
46
47
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
48
  payload.messageType = _Constants.Constants.systemMessageTag;
49
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
50
+ Event: _TelemetryConstants.TelemetryEvent.SystemMessageReceived,
51
+ Description: "System message received"
52
+ });
48
53
  } else {
49
54
  var _activity$channelData7, _activity$channelData8, _activity$channelData9;
50
55
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -69,6 +74,15 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
69
74
  Description: "New message received",
70
75
  Data: payload
71
76
  });
77
+ } else {
78
+ if (!isHistoryMessageReceivedEventRasied) {
79
+ isHistoryMessageReceivedEventRasied = true;
80
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
81
+ Event: _TelemetryConstants.TelemetryEvent.HistoryMessageReceived,
82
+ Description: "History message received",
83
+ Data: payload
84
+ });
85
+ }
72
86
  }
73
87
  }
74
88
  }
@@ -45,7 +45,7 @@ _defineProperty(Constants, "publicMessageTag", "public");
45
45
  _defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
46
46
  _defineProperty(Constants, "maxUploadFileSize", "500000");
47
47
  _defineProperty(Constants, "imageRegex", /(\.)(jpeg|jpg|jiff|png|gif|bmp|webp)$/i);
48
- _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|flac|mp2|mp3|pcm|wav|wma)$/i);
48
+ _defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|mp3|pcm|wav|wma)$/i);
49
49
  _defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
50
50
  _defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
51
51
  _defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
@@ -82,6 +82,7 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
82
82
  _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
83
83
  _defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
84
84
  _defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
85
+ _defineProperty(Constants, "CacheTtlInMinutes", 15);
85
86
  export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
86
87
  export class HtmlIdNames {}
87
88
  _defineProperty(HtmlIdNames, "MSLiveChatWidget", "MSLiveChatWidget");
@@ -122,6 +123,7 @@ _defineProperty(HtmlAttributeNames, "noreferrerTag", "noreferrer");
122
123
  _defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
123
124
  _defineProperty(HtmlAttributeNames, "adaptiveCardTextBlockClassName", "ac-textBlock");
124
125
  _defineProperty(HtmlAttributeNames, "adaptiveCardToggleInputClassName", "ac-toggleInput");
126
+ _defineProperty(HtmlAttributeNames, "adaptiveCardActionSetClassName", "ac-actionSet");
125
127
  export class WebChatMiddlewareConstants {}
126
128
  _defineProperty(WebChatMiddlewareConstants, "nextVisibleActivity", "nextVisibleActivity");
127
129
  _defineProperty(WebChatMiddlewareConstants, "timeBetweenTimestampGroups", 300000);
@@ -6,11 +6,11 @@ import { getWidgetCacheId } from "../../utils";
6
6
  import { defaultClientDataStoreProvider } from "./defaultClientDataStoreProvider";
7
7
  export class defaultCacheManager {}
8
8
  _defineProperty(defaultCacheManager, "InternalCache", {});
9
- export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
9
+ export const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId, ttlInMins) => {
10
10
  const widgetCacheId = getWidgetCacheId(orgid, widgetId, widgetInstanceId);
11
11
  BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
12
12
  try {
13
- defaultClientDataStoreProvider().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
13
+ defaultClientDataStoreProvider(ttlInMins).setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
14
14
  } catch (error) {
15
15
  console.error("Error in setting data to localstorage", error);
16
16
  }
@@ -1,18 +1,27 @@
1
- import { inMemoryDataStore } from "./defaultInMemoryDataStore";
2
- import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+
3
3
  import { LogLevel, TelemetryEvent } from "../../telemetry/TelemetryConstants";
4
- export const defaultClientDataStoreProvider = () => {
4
+ import { TelemetryHelper } from "../../telemetry/TelemetryHelper";
5
+ import { inMemoryDataStore } from "./defaultInMemoryDataStore";
6
+ export const defaultClientDataStoreProvider = function () {
7
+ let cacheTtlinMins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
8
+ let ttlInMs = 0;
5
9
  const isCookieAllowed = () => {
6
10
  try {
7
11
  localStorage;
8
12
  sessionStorage;
9
13
  return true;
10
14
  } catch (error) {
11
- console.error("Third party cookie blocked");
15
+ if (!window.TPCWarningShown) {
16
+ console.warn("Third party cookies blocked.");
17
+ window.TPCWarningShown = true;
18
+ }
12
19
  return false;
13
20
  }
14
21
  };
15
- const TtlInMs = 15 * 60 * 1000; // 15 mins
22
+ if (ttlInMs == 0) {
23
+ ttlInMs = cacheTtlinMins * 60 * 1000;
24
+ }
16
25
  const dataStoreProvider = {
17
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
27
  setData: (key, data, type) => {
@@ -22,7 +31,7 @@ export const defaultClientDataStoreProvider = () => {
22
31
  const now = new Date();
23
32
  const item = {
24
33
  data: data,
25
- expiry: now.getTime() + TtlInMs
34
+ expiry: now.getTime() + ttlInMs
26
35
  };
27
36
  const strItem = JSON.stringify(item);
28
37
  if (type === "localStorage") {
@@ -49,6 +49,11 @@ export let BroadcastEvent;
49
49
  BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
50
50
  BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
51
51
  BroadcastEvent["RaiseErrorEvent"] = "RaiseErrorEvent";
52
+ BroadcastEvent["NetworkDisconnected"] = "NetworkDisconnected";
53
+ BroadcastEvent["NetworkReconnected"] = "NetworkReconnected";
54
+ BroadcastEvent["SigninCardReceived"] = "SignInCardReceived";
55
+ BroadcastEvent["BotAuthConfigRequest"] = "BotAuthConfigRequest";
56
+ BroadcastEvent["BotAuthConfigResponse"] = "BotAuthConfigResponse";
52
57
  })(BroadcastEvent || (BroadcastEvent = {}));
53
58
  export let TelemetryEvent;
54
59
  (function (TelemetryEvent) {
@@ -109,6 +114,7 @@ export let TelemetryEvent;
109
114
  TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
110
115
  TelemetryEvent["EmailTranscriptSent"] = "EmailTranscriptSent";
111
116
  TelemetryEvent["EmailTranscriptFailed"] = "EmailTranscriptFailed";
117
+ TelemetryEvent["ErrorUIPaneLoaded"] = "ErrorUIPaneLoaded";
112
118
  TelemetryEvent["DownloadTranscriptFailed"] = "DownloadTranscriptFailed";
113
119
  TelemetryEvent["StartChatFailed"] = "StartChatFailed";
114
120
  TelemetryEvent["IC3ThreadUpdateEventReceived"] = "IC3ThreadUpdateEventReceived";
@@ -138,6 +144,11 @@ export let TelemetryEvent;
138
144
  TelemetryEvent["CustomerVoiceResponsePageLoaded"] = "CustomerVoiceResponsePageLoaded";
139
145
  TelemetryEvent["CustomerVoiceFormResponseSubmitted"] = "CustomerVoiceFormResponseSubmitted";
140
146
  TelemetryEvent["CustomerVoiceFormResponseError"] = "CustomerVoiceFormResponseError";
147
+ TelemetryEvent["BotAuthActivityEmptySasUrl"] = "BotAuthActivityEmptySasUrl";
148
+ TelemetryEvent["SetBotAuthProviderFetchConfig"] = "SetBotAuthProviderFetchConfig";
149
+ TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
150
+ TelemetryEvent["SetBotAuthProviderDisplayCard"] = "SetBotAuthProviderDisplayCard";
151
+ TelemetryEvent["SetBotAuthProviderNotFound"] = "SetBotAuthProviderNotFound";
141
152
  TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
142
153
  TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
143
154
  TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
@@ -164,6 +175,8 @@ export let TelemetryEvent;
164
175
  TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
165
176
  TelemetryEvent["MessageSent"] = "MessageSent";
166
177
  TelemetryEvent["MessageReceived"] = "MessageReceived";
178
+ TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
179
+ TelemetryEvent["HistoryMessageReceived"] = "HistoryMessageReceived";
167
180
  TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
168
181
  TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
169
182
  TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
@@ -56,6 +56,7 @@ export class TelemetryHelper {
56
56
  event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
57
57
  event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
58
58
  event.Description = payload.Description;
59
+ event.CustomProperties = JSON.stringify(payload.CustomProperties);
59
60
  });
60
61
  }
61
62
  static conformToWebChatContract(level, input) {
@@ -161,7 +162,7 @@ export class TelemetryHelper {
161
162
  telemetryDataLocal.widgetId = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.appId;
162
163
  telemetryDataLocal.orgId = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgId;
163
164
  telemetryDataLocal.orgUrl = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgUrl;
164
- telemetryDataLocal.lcwRuntimeId = newGuid();
165
+ telemetryDataLocal.lcwRuntimeId = telemetryConfig.LCWRuntimeId ?? newGuid();
165
166
  return telemetryDataLocal;
166
167
  }
167
168
  static addSessionDataToTelemetry(chatSession, telemetryInternalData) {
@@ -1,3 +1,4 @@
1
+ var _this = this;
1
2
  import { AriaTelemetryConstants, Constants, LocaleConstants } from "./Constants";
2
3
  import { DataStoreManager } from "./contextDataStore/DataStoreManager";
3
4
  import { KeyCodes } from "./KeyCodes";
@@ -304,4 +305,23 @@ export const addDelayInMs = ms => {
304
305
  };
305
306
  export const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
306
307
  return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
308
+ };
309
+
310
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
311
+ export const debounceLeading = function (fn) {
312
+ let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3000;
313
+ let timeoutId;
314
+ return function () {
315
+ // eslint-disable-line @typescript-eslint/no-explicit-any
316
+
317
+ if (!timeoutId) {
318
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
319
+ args[_key] = arguments[_key];
320
+ }
321
+ fn.apply(_this, args);
322
+ }
323
+ timeoutId = setTimeout(() => {
324
+ timeoutId = null;
325
+ }, ms);
326
+ };
307
327
  };
@@ -82,7 +82,7 @@ export const ConfirmationPaneStateful = props => {
82
82
  Event: TelemetryEvent.ConfirmationPaneLoaded
83
83
  });
84
84
  }, []);
85
- return /*#__PURE__*/React.createElement(React.Fragment, null, !(controlProps !== null && controlProps !== void 0 && controlProps.disableDimLayer) && /*#__PURE__*/React.createElement(DimLayer, {
85
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DimLayer, {
86
86
  brightness: (controlProps === null || controlProps === void 0 ? void 0 : controlProps.brightnessValueOnDim) ?? "0.2"
87
87
  }), /*#__PURE__*/React.createElement(ConfirmationPane, {
88
88
  componentOverrides: props === null || props === void 0 ? void 0 : props.componentOverrides,
@@ -88,7 +88,7 @@ export const EmailTranscriptPaneStateful = props => {
88
88
  Event: TelemetryEvent.EmailTranscriptLoaded
89
89
  });
90
90
  }, [initialEmail]);
91
- return /*#__PURE__*/React.createElement(React.Fragment, null, !(controlProps !== null && controlProps !== void 0 && controlProps.disableDimLayer) && /*#__PURE__*/React.createElement(DimLayer, {
91
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DimLayer, {
92
92
  brightness: (controlProps === null || controlProps === void 0 ? void 0 : controlProps.brightnessValueOnDim) ?? "0.2"
93
93
  }), /*#__PURE__*/React.createElement(InputValidationPane, {
94
94
  componentOverrides: props.componentOverrides,
@@ -21,6 +21,7 @@ export const HeaderStateful = props => {
21
21
  const [outOfOperatingHours, setOutOfOperatingHours] = useState(((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True");
22
22
  const outOfOfficeStyleProps = Object.assign({}, defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
23
23
  const conversationState = useRef(state.appStates.conversationState);
24
+ const conversationEndedByAgent = useRef(state.appStates.conversationEndedByAgent);
24
25
  const controlProps = {
25
26
  id: "oc-lcw-header",
26
27
  dir: state.domainStates.globalDir,
@@ -40,7 +41,7 @@ export const HeaderStateful = props => {
40
41
  Event: TelemetryEvent.HeaderCloseButtonClicked,
41
42
  Description: "Header Close button clicked."
42
43
  });
43
- if (conversationState.current === ConversationState.Active) {
44
+ if (conversationState.current === ConversationState.Active || conversationEndedByAgent.current) {
44
45
  dispatch({
45
46
  type: LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
46
47
  payload: true
@@ -62,7 +63,7 @@ export const HeaderStateful = props => {
62
63
  ...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
63
64
  hideTitle: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
64
65
  hideIcon: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
65
- hideCloseButton: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
66
+ hideCloseButton: state.appStates.conversationState === ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === ConversationState.PostchatLoading || state.appStates.conversationState === ConversationState.Prechat || state.appStates.conversationState === ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
66
67
  };
67
68
  const outOfOfficeControlProps = {
68
69
  id: "oc-lcw-header",
@@ -86,6 +87,7 @@ export const HeaderStateful = props => {
86
87
  if (state.appStates.conversationState) {
87
88
  conversationState.current = state.appStates.conversationState;
88
89
  }
90
+ conversationEndedByAgent.current = state.appStates.conversationEndedByAgent;
89
91
  }, [state.appStates]);
90
92
  return /*#__PURE__*/React.createElement(Header, {
91
93
  componentOverrides: headerProps === null || headerProps === void 0 ? void 0 : headerProps.componentOverrides,
@@ -0,0 +1,134 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
+ /* eslint-disable @typescript-eslint/no-unused-vars */
5
+ /* eslint-disable @typescript-eslint/no-explicit-any */
6
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
7
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../../common/telemetry/TelemetryConstants";
8
+ import { TelemetryHelper } from "../../../../common/telemetry/TelemetryHelper";
9
+ const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
10
+ const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
11
+ const delay = t => new Promise(resolve => setTimeout(resolve, t));
12
+ const fetchBotAuthConfigRetries = 3;
13
+ const fetchBotAuthConfigRetryInterval = 1000;
14
+ let response;
15
+ const extractSignInId = signInUrl => {
16
+ const result = botOauthUrlRegex.exec(signInUrl);
17
+ if (result && result[1]) {
18
+ return result[1];
19
+ }
20
+ return "";
21
+ };
22
+ const extractSasUrl = async attachment => {
23
+ let sasUrl = undefined;
24
+ if (attachment && attachment.content && attachment.content.tokenPostResource && attachment.content.tokenPostResource.sasUrl) {
25
+ sasUrl = attachment.content.tokenPostResource.sasUrl;
26
+ }
27
+ if (!sasUrl) {
28
+ const signInId = extractSignInId(attachment.content.buttons[0].value);
29
+ const getTestUrlEndpoint = `https://token.botframework.com/api/sas/gettesturl?signInId=${signInId}`;
30
+ try {
31
+ const response = await window.fetch(getTestUrlEndpoint);
32
+ if (response.status === 200) {
33
+ const responseJson = await response.json();
34
+ sasUrl = responseJson.sasUrl;
35
+ }
36
+ } catch {
37
+ sasUrl = undefined;
38
+ }
39
+ }
40
+ return sasUrl;
41
+ };
42
+ const fetchBotAuthConfig = async retries => {
43
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
44
+ Event: TelemetryEvent.SetBotAuthProviderFetchConfig
45
+ });
46
+ const botAuthConfigRequestEvent = {
47
+ eventName: BroadcastEvent.BotAuthConfigRequest
48
+ };
49
+ BroadcastService.postMessage(botAuthConfigRequestEvent);
50
+ const listener = BroadcastService.getMessageByEventName(BroadcastEvent.BotAuthConfigResponse).subscribe(data => {
51
+ var _data$payload, _data$payload2;
52
+ response = ((_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.response) !== undefined ? (_data$payload2 = data.payload) === null || _data$payload2 === void 0 ? void 0 : _data$payload2.response : response;
53
+ listener.unsubscribe();
54
+ });
55
+ if (response !== undefined) {
56
+ //return response;
57
+ return response;
58
+ }
59
+ if (retries === 1) {
60
+ // Base Case
61
+ throw new Error();
62
+ }
63
+ await delay(fetchBotAuthConfigRetryInterval);
64
+ return await fetchBotAuthConfig(--retries);
65
+ };
66
+ export class BotAuthActivitySubscriber {
67
+ constructor() {
68
+ _defineProperty(this, "observer", void 0);
69
+ _defineProperty(this, "signInCardSeen", void 0);
70
+ this.signInCardSeen = new Set();
71
+ }
72
+ applicable(activity) {
73
+ var _activity$attachments;
74
+ return (activity === null || activity === void 0 ? void 0 : (_activity$attachments = activity.attachments) === null || _activity$attachments === void 0 ? void 0 : _activity$attachments.length) > 0 && activity.attachments[0] && supportedSignInCardContentTypes.indexOf(activity.attachments[0].contentType) >= 0;
75
+ }
76
+ async apply(activity) {
77
+ this.observer.next(false); // Hides card
78
+ const attachment = activity.attachments[0];
79
+ const signInUrl = attachment.content.buttons[0].value;
80
+ const signInId = extractSignInId(signInUrl);
81
+ if (!signInId) {
82
+ return;
83
+ }
84
+ if (this.signInCardSeen.has(signInId)) {
85
+ // Prevents duplicate auth
86
+ return;
87
+ }
88
+ this.signInCardSeen.add(signInId);
89
+ const sasUrl = await extractSasUrl(attachment);
90
+ const event = {
91
+ eventName: BroadcastEvent.SigninCardReceived,
92
+ payload: {
93
+ sasUrl
94
+ }
95
+ };
96
+ if (!sasUrl) {
97
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
98
+ Event: TelemetryEvent.BotAuthActivityEmptySasUrl,
99
+ Description: "SaS Url is empty"
100
+ });
101
+ return activity;
102
+ } else {
103
+ BroadcastService.postMessage(event);
104
+ }
105
+ try {
106
+ const response = await fetchBotAuthConfig(fetchBotAuthConfigRetries);
107
+ if (response === false) {
108
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
109
+ Event: TelemetryEvent.SetBotAuthProviderHideCard
110
+ });
111
+ } else {
112
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
113
+ Event: TelemetryEvent.SetBotAuthProviderDisplayCard
114
+ });
115
+ return activity;
116
+ }
117
+ } catch {
118
+ TelemetryHelper.logLoadingEvent(LogLevel.INFO, {
119
+ Event: TelemetryEvent.SetBotAuthProviderNotFound
120
+ });
121
+ //this is to ensure listener continues waiting for response
122
+ if (this.signInCardSeen.has(signInId)) {
123
+ this.signInCardSeen.delete(signInId);
124
+ }
125
+ return activity;
126
+ }
127
+ }
128
+ async next(activity) {
129
+ if (this.applicable(activity)) {
130
+ return await this.apply(activity);
131
+ }
132
+ return activity;
133
+ }
134
+ }
@@ -4,6 +4,7 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
4
4
  import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
5
5
  import { ChatAdapterShim } from "./ChatAdapterShim";
6
6
  import { PauseActivitySubscriber } from "./ActivitySubscriber/PauseActivitySubscriber";
7
+ import { BotAuthActivitySubscriber } from "./ActivitySubscriber/BotAuthActivitySubscriber";
7
8
 
8
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
10
  export const createAdapter = async chatSDK => {
@@ -29,6 +30,7 @@ export const createAdapter = async chatSDK => {
29
30
  if (chatSDK.isMockModeOn !== true) {
30
31
  adapter = new ChatAdapterShim(adapter);
31
32
  adapter.addSubscriber(new PauseActivitySubscriber());
33
+ adapter.addSubscriber(new BotAuthActivitySubscriber());
32
34
  return adapter.chatAdapter;
33
35
  }
34
36
  return adapter;
@@ -9,9 +9,9 @@ import { createActivityMiddleware } from "../../../webchatcontainerstateful/webc
9
9
  import createAttachmentMiddleware from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
10
10
  import { createAvatarMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware";
11
11
  import { createMarkdown } from "../createMarkdown";
12
+ import { createWebChatTelemetry } from "../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
12
13
  import { groupActivitiesMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/groupActivitiesMiddleware";
13
14
  import { typingIndicatorMiddleware } from "../../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware";
14
- import { createWebChatTelemetry } from "../../../webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger";
15
15
 
16
16
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
17
  export const dummyDefaultProps = {
@@ -407,6 +407,7 @@ export const dummyDefaultProps = {
407
407
  width: "90px",
408
408
  cursor: "pointer",
409
409
  overflow: "hidden",
410
+ padding: "0px",
410
411
  whiteSpace: "nowrap"
411
412
  },
412
413
  subtitleStyleProps: {
@@ -414,12 +415,14 @@ export const dummyDefaultProps = {
414
415
  fontWeight: "200",
415
416
  color: "#666",
416
417
  overflow: "hidden",
418
+ padding: "0px",
417
419
  fontFamily: "'Segoe UI',Arial,sans-serif",
418
420
  display: "block",
419
421
  alignItems: "center",
420
422
  margin: "0px 14px 0px 14px",
421
423
  textOverflow: "ellipsis !important",
422
- width: "max-content",
424
+ width: "90px",
425
+ whiteSpace: "nowrap",
423
426
  cursor: "pointer"
424
427
  },
425
428
  classNames: {
@@ -469,7 +472,6 @@ export const dummyDefaultProps = {
469
472
  cancelButtonText: "Cancel",
470
473
  cancelButtonAriaLabel: "Cancel. Return to Chat",
471
474
  brightnessValueOnDim: "0.2",
472
- disableDimLayer: false,
473
475
  onConfirm: () => {},
474
476
  // Detailed implementation omitted
475
477
  onCancel: () => {} // Detailed implementation omitted
@@ -577,6 +579,7 @@ export const dummyDefaultProps = {
577
579
  hideCallingContainer: false,
578
580
  hideChatButton: false,
579
581
  hideConfirmationPane: false,
582
+ hideErrorUIPane: false,
580
583
  hideFooter: false,
581
584
  hideHeader: false,
582
585
  hideLoadingPane: false,
@@ -627,7 +630,6 @@ export const dummyDefaultProps = {
627
630
  cancelButtonText: "Cancel",
628
631
  cancelButtonAriaLabel: "Cancel",
629
632
  brightnessValueOnDim: "0.2",
630
- disableDimLayer: false,
631
633
  onSend: undefined,
632
634
  onCancel: undefined,
633
635
  checkInput: undefined
@@ -1025,7 +1027,8 @@ export const dummyDefaultProps = {
1025
1027
  margin: "0px 0px 20px 0px",
1026
1028
  display: "flex",
1027
1029
  order: 1,
1028
- alignSelf: "auto"
1030
+ alignSelf: "auto",
1031
+ overflow: "visible"
1029
1032
  },
1030
1033
  iconImageProps: {
1031
1034
  src: "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIwX2lpKSI+DQo8cGF0aCBkPSJNMTUuMTk3MSAxNi4yNzI1VjI1Ljg1MjRDMTUuMTk3MSAyNy4zODExIDE1Ljg0MDEgMjcuNTIwMSAxNi45ODMyIDI3LjUyMDFMMjYuNzA4NCAyNy41NjQ5TDMxLjAwMzkgMzIuMzEyM1YyNy41NjQ5SDMxLjg5N0MzMi4xNzQzIDI3LjU2MzcgMzIuNDQ4NyAyNy41MDc3IDMyLjcwNDUgMjcuNDAwMUMzMi45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aXRzPSJ1c2VyU3BhY2VPblVzZSI+DQo8c3RvcCBzdG9wLWNvbG9yPSIjRUZFRkVGIi8+DQo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IndoaXRlIi8+DQo8L2xpbmVhckdyYWRpZW50Pg0KPC9kZWZzPg0KPC9zdmc+DQo=",
@@ -1117,7 +1120,8 @@ export const dummyDefaultProps = {
1117
1120
  dir: "auto",
1118
1121
  hideOOOHPane: false,
1119
1122
  hideTitle: false,
1120
- titleText: "Thanks for contacting us. You have reached us outside of our operating hours. An agent will respond when we open."
1123
+ titleText: "Thanks for contacting us. You have reached us outside of our operating hours. An agent will respond when we open. Please see link https://microsoft.com",
1124
+ openLinkInNewTab: true
1121
1125
  },
1122
1126
  styleProps: {
1123
1127
  generalStyleProps: {
@@ -1160,7 +1164,7 @@ export const dummyDefaultProps = {
1160
1164
  subtitleText: "Please take a moment to give us feedback about your chat experience. We are loading the survey for you now."
1161
1165
  },
1162
1166
  styleProps: {
1163
- // ...[Existing chat button style props]
1167
+ // ...[Existing loading pane style props]
1164
1168
  generalStyleProps: {
1165
1169
  position: "initial",
1166
1170
  width: "100%",
@@ -1205,7 +1209,7 @@ export const dummyDefaultProps = {
1205
1209
  generalStyleProps: {
1206
1210
  borderStyle: "solid",
1207
1211
  borderRadius: "4px",
1208
- borderWidth: "3px",
1212
+ borderWidth: "0px",
1209
1213
  backgroundColor: "#FFFFFF",
1210
1214
  borderColor: "#F1F1F1",
1211
1215
  overflowY: "auto",
@@ -1610,10 +1614,10 @@ export const dummyDefaultProps = {
1610
1614
  padding: "0px 10px 0 10px"
1611
1615
  },
1612
1616
  userMessageBoxStyles: {
1613
- maxWidth: "75%"
1617
+ maxWidth: "90%"
1614
1618
  },
1615
1619
  systemMessageBoxStyles: {
1616
- maxWidth: "75%"
1620
+ maxWidth: "90%"
1617
1621
  },
1618
1622
  typingIndicatorStyleProps: {
1619
1623
  marginLeft: "10px",
@@ -12,15 +12,15 @@ import { getAuthClientFunction, handleAuthentication } from "./authHelper";
12
12
 
13
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
14
  const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
15
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
16
- const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
17
- const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
15
+ var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2, _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
16
+ const isPostChatEnabled = ((_props$chatConfig = props.chatConfig) === null || _props$chatConfig === void 0 ? void 0 : (_props$chatConfig$Liv = _props$chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.msdyn_postconversationsurveyenable) ?? ((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable);
17
+ const postChatSurveyMode = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode);
18
18
 
19
19
  //Unable to end chat if token has expired
20
20
  if (props.getAuthToken) {
21
21
  const authClientFunction = getAuthClientFunction(props.chatConfig);
22
22
  if (props.getAuthToken && authClientFunction) {
23
- // set auth token to chat sdk before start chat
23
+ // set auth token to chat sdk before end chat
24
24
  const authSuccess = await handleAuthentication(chatSDK, props.chatConfig, props.getAuthToken);
25
25
  if (!authSuccess) {
26
26
  TelemetryHelper.logActionEvent(LogLevel.ERROR, {
@@ -56,15 +56,20 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
56
56
  chatSDK.requestId = chatSession.requestId;
57
57
  }
58
58
  if (postChatSurveyMode === PostChatSurveyMode.Embed) {
59
- dispatch({
60
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
61
- payload: ConversationState.PostchatLoading
62
- });
63
- await addDelayInMs(Constants.PostChatLoadingDurationInMs);
64
- const loadPostChatEvent = {
65
- eventName: BroadcastEvent.LoadPostChatSurvey
66
- };
67
- BroadcastService.postMessage(loadPostChatEvent);
59
+ // Only start embedded Postchat workflow if postchat context is set successfully else close chat
60
+ if (state.domainStates.postChatContext) {
61
+ dispatch({
62
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
63
+ payload: ConversationState.PostchatLoading
64
+ });
65
+ await addDelayInMs(Constants.PostChatLoadingDurationInMs);
66
+ const loadPostChatEvent = {
67
+ eventName: BroadcastEvent.LoadPostChatSurvey
68
+ };
69
+ BroadcastService.postMessage(loadPostChatEvent);
70
+ } else {
71
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, true, false, true);
72
+ }
68
73
  } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
69
74
  var _props$webChatContain, _props$webChatContain2;
70
75
  dispatch({
@@ -150,10 +155,6 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
150
155
  type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
151
156
  payload: null
152
157
  });
153
- dispatch({
154
- type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
155
- payload: 0
156
- });
157
158
  dispatch({
158
159
  type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
159
160
  payload: {
@@ -176,6 +177,11 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
176
177
  exception: `Failed to endChat: ${error}`
177
178
  }
178
179
  });
180
+ } finally {
181
+ dispatch({
182
+ type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
183
+ payload: 0
184
+ });
179
185
  }
180
186
  }
181
187
  };