@microsoft/omnichannel-chat-widget 0.1.0-main.170e416 → 0.1.0-main.18d1166

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 (131) hide show
  1. package/README.md +7 -34
  2. package/lib/cjs/assets/Icons.js +4 -2
  3. package/lib/cjs/common/Constants.js +9 -3
  4. package/lib/cjs/common/KeyCodes.js +3 -1
  5. package/lib/cjs/common/contextDataStore/DataStoreManager.js +3 -1
  6. package/lib/cjs/common/storage/default/defaultCacheManager.js +5 -3
  7. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  8. package/lib/cjs/common/telemetry/TelemetryConstants.js +34 -4
  9. package/lib/cjs/common/telemetry/TelemetryHelper.js +5 -2
  10. package/lib/cjs/common/telemetry/TelemetryManager.js +3 -1
  11. package/lib/cjs/common/utils.js +23 -2
  12. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
  13. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  14. package/lib/cjs/components/headerstateful/HeaderStateful.js +7 -4
  15. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +3 -1
  16. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
  17. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +3 -1
  18. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +3 -1
  19. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +3 -1
  20. package/lib/cjs/components/livechatwidget/common/Deferred.js +3 -1
  21. package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
  22. package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
  23. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
  24. package/lib/cjs/components/livechatwidget/common/endChat.js +41 -49
  25. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +11 -49
  26. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +6 -9
  27. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +254 -2
  28. package/lib/cjs/components/livechatwidget/common/startChat.js +76 -53
  29. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +82 -44
  30. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +22 -2
  31. package/lib/cjs/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +57 -0
  32. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  33. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  34. package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  35. package/lib/cjs/components/webchatcontainerstateful/common/mockadapter.js +3 -1
  36. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +3 -1
  37. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  38. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -1
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -1
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  41. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  42. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  43. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  44. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +5 -6
  45. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  46. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  47. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -3
  48. package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
  49. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +32 -28
  50. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +9 -3
  51. package/lib/cjs/contexts/createReducer.js +36 -2
  52. package/lib/cjs/hooks/useDebounce.js +28 -0
  53. package/lib/cjs/hooks/useWindowDimensions.js +30 -0
  54. package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
  55. package/lib/esm/assets/Icons.js +2 -1
  56. package/lib/esm/common/Constants.js +9 -3
  57. package/lib/esm/common/KeyCodes.js +3 -1
  58. package/lib/esm/common/contextDataStore/DataStoreManager.js +3 -1
  59. package/lib/esm/common/storage/default/defaultCacheManager.js +5 -3
  60. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
  61. package/lib/esm/common/telemetry/TelemetryConstants.js +34 -4
  62. package/lib/esm/common/telemetry/TelemetryHelper.js +5 -2
  63. package/lib/esm/common/telemetry/TelemetryManager.js +3 -1
  64. package/lib/esm/common/utils.js +20 -0
  65. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
  66. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
  67. package/lib/esm/components/headerstateful/HeaderStateful.js +7 -4
  68. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +3 -1
  69. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
  70. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +3 -1
  71. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +3 -1
  72. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +3 -1
  73. package/lib/esm/components/livechatwidget/common/Deferred.js +3 -1
  74. package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
  75. package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
  76. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
  77. package/lib/esm/components/livechatwidget/common/endChat.js +43 -51
  78. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -51
  79. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +7 -9
  80. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +254 -3
  81. package/lib/esm/components/livechatwidget/common/startChat.js +76 -53
  82. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +83 -45
  83. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +22 -2
  84. package/lib/esm/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.js +50 -0
  85. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
  86. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
  87. package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
  88. package/lib/esm/components/webchatcontainerstateful/common/mockadapter.js +3 -1
  89. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +3 -1
  90. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
  91. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +3 -1
  92. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatStoreLoader.js +3 -1
  93. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
  94. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  95. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
  96. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
  97. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/DeliveredTimestamp.js +5 -6
  98. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
  99. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
  100. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -3
  101. package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
  102. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +32 -28
  103. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +9 -3
  104. package/lib/esm/contexts/createReducer.js +36 -2
  105. package/lib/esm/hooks/useDebounce.js +22 -0
  106. package/lib/esm/hooks/useWindowDimensions.js +23 -0
  107. package/lib/esm/plugins/newMessageEventHandler.js +14 -0
  108. package/lib/types/assets/Icons.d.ts +1 -0
  109. package/lib/types/common/Constants.d.ts +4 -0
  110. package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
  111. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
  112. package/lib/types/common/telemetry/TelemetryConstants.d.ts +30 -6
  113. package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
  114. package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
  115. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
  116. package/lib/types/common/utils.d.ts +1 -0
  117. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
  118. package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
  119. package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
  120. package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
  121. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
  122. package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
  123. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
  124. package/lib/types/components/loadingpanestateful/common/errorUIStyleProps/errorUILoadingPaneStyleProps.d.ts +2 -0
  125. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
  126. package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
  127. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
  128. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +32 -28
  129. package/lib/types/hooks/useDebounce.d.ts +3 -0
  130. package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
  131. package/package.json +3 -3
@@ -6,10 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.initWebChatComposer = void 0;
7
7
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
8
8
  var _botframeworkWebchat = require("botframework-webchat");
9
- var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
10
- var _ConversationState = require("../../../contexts/common/ConversationState");
11
9
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
12
- var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
13
10
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
14
11
  var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader");
15
12
  var _attachmentProcessingMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware"));
@@ -35,11 +32,10 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
35
32
  var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
36
33
  var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
37
34
  var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
38
- var _Constants = require("../../../common/Constants");
39
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
- const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
42
- var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
37
+ const initWebChatComposer = (props, chatSDK, setAdapter, state, dispatch, adapter, setWebChatStyles) => {
38
+ var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l4, _state$domainStates$l5, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
43
39
  const localizedTexts = {
44
40
  ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
45
41
  ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
@@ -47,19 +43,12 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
47
43
  const disableNewLineMarkdownSupport = ((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.disableNewLineMarkdownSupport) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableNewLineMarkdownSupport;
48
44
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
49
45
  const markdown = (0, _createMarkdown.createMarkdown)(((_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.disableMarkdownMessageFormatting) ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.disableMarkdownMessageFormatting, disableNewLineMarkdownSupport);
50
- 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;
51
- 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;
52
-
53
46
  // Initialize Web Chat's redux store
54
47
  let webChatStore = _WebChatStoreLoader.WebChatStoreLoader.store;
55
48
  if (!webChatStore) {
56
- var _state$domainStates$l5, _state$domainStates$l6, _state$domainStates$l7, _props$webChatContain6;
49
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _props$webChatContain6;
57
50
  const conversationEndCallback = async () => {
58
51
  var _props$webChatContain4, _props$webChatContain5;
59
- _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
60
- Event: _TelemetryConstants.TelemetryEvent.ConversationEndedThreadEventReceived,
61
- Description: "Conversation is ended by agent side or by timeout."
62
- });
63
52
  if ((props === null || props === void 0 ? void 0 : (_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : (_props$webChatContain5 = _props$webChatContain4.renderingMiddlewareProps) === null || _props$webChatContain5 === void 0 ? void 0 : _props$webChatContain5.hideSendboxOnConversationEnd) !== false) {
64
53
  setWebChatStyles(styles => {
65
54
  return {
@@ -68,46 +57,18 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
68
57
  };
69
58
  });
70
59
  }
71
- if (isPostChatEnabled === "true") {
72
- if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
73
- _WebChatStoreLoader.WebChatStoreLoader.store = null;
74
- dispatch({
75
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
76
- payload: _ConversationState.ConversationState.PostchatLoading
77
- });
78
- await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
79
- const loadPostChatEvent = {
80
- eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
81
- };
82
- _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
83
- } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
84
- dispatch({
85
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
86
- payload: _ConversationState.ConversationState.InActive
87
- });
88
- }
89
- } else {
90
- dispatch({
91
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
92
- payload: _ConversationState.ConversationState.InActive
93
- });
94
- dispatch({
95
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
96
- payload: true
97
- });
98
- }
99
60
  dispatch({
100
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
101
- payload: undefined
61
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT_EVENT_RECEIVED,
62
+ payload: true
102
63
  });
103
- dispatch({
104
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
105
- payload: undefined
64
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
65
+ Event: _TelemetryConstants.TelemetryEvent.ConversationEndedThreadEventReceived,
66
+ Description: "Conversation end by agent side or by timeout event received."
106
67
  });
107
68
  };
108
69
  webChatStore = (0, _botframeworkWebchat.createStore)({},
109
70
  //initial state
110
- _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _messageTimestampMiddleware.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
71
+ _preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default,
111
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
73
  ...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
113
74
  _WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
@@ -117,7 +78,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
117
78
  const webChatProps = {
118
79
  ..._defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps,
119
80
  dir: state.domainStates.globalDir,
120
- locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l8 = state.domainStates.liveChatConfig) === null || _state$domainStates$l8 === void 0 ? void 0 : (_state$domainStates$l9 = _state$domainStates$l8.ChatWidgetLanguage) === null || _state$domainStates$l9 === void 0 ? void 0 : _state$domainStates$l9.msdyn_localeid)),
81
+ locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
121
82
  store: webChatStore,
122
83
  activityMiddleware: (_props$webChatContain7 = props.webChatContainerProps) !== null && _props$webChatContain7 !== void 0 && (_props$webChatContain8 = _props$webChatContain7.renderingMiddlewareProps) !== null && _props$webChatContain8 !== void 0 && _props$webChatContain8.disableActivityMiddleware ? undefined : (0, _activityMiddleware.createActivityMiddleware)((_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
123
84
  attachmentMiddleware: (_props$webChatContain9 = props.webChatContainerProps) !== null && _props$webChatContain9 !== void 0 && (_props$webChatContain10 = _props$webChatContain9.renderingMiddlewareProps) !== null && _props$webChatContain10 !== void 0 && _props$webChatContain10.disableAttachmentMiddleware ? undefined : (0, _attachmentMiddleware.default)(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? _defaultAttachmentProps.defaultAttachmentProps.enableInlinePlaying),
@@ -128,6 +89,7 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
128
89
  typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
129
90
  onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
130
91
  cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
92
+ sendTypingIndicator: true,
131
93
  ...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
132
94
  };
133
95
  return webChatProps;
@@ -6,12 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isReconnectEnabled = exports.handleChatReconnect = exports.getChatReconnectContext = void 0;
7
7
  require("regenerator-runtime/runtime");
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
+ var _authHelper = require("./authHelper");
10
+ var _utils = require("../../../common/utils");
9
11
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
10
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
11
13
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
12
14
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
13
- var _authHelper = require("./authHelper");
14
- var _utils = require("../../../common/utils");
15
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
16
  const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
17
17
  var _props$chatConfig, _props$chatConfig$Liv;
@@ -60,14 +60,14 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
60
60
  const chatReconnectOptionalParams = {
61
61
  reconnectId: (_props$reconnectChatP4 = props.reconnectChatPaneProps) === null || _props$reconnectChatP4 === void 0 ? void 0 : _props$reconnectChatP4.reconnectId
62
62
  };
63
+ // Get auth token for getting chat reconnect context
63
64
  if (isAuthenticatedChat) {
64
- // Get auth token for for getting chat reconnect context
65
65
  await (0, _authHelper.handleAuthentication)(chatSDK, chatConfig, props.getAuthToken);
66
66
  }
67
67
  const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
68
68
  if (isAuthenticatedChat) {
69
69
  // remove auth token after reconnectId is fetched
70
- // this will be reset later at start chat
70
+ // AuthToken will be reset later at start chat
71
71
  (0, _authHelper.removeAuthTokenProvider)(chatSDK);
72
72
  }
73
73
  return reconnectChatContext;
@@ -84,10 +84,7 @@ const getChatReconnectContext = async (chatSDK, chatConfig, props, isAuthenticat
84
84
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
85
85
  exports.getChatReconnectContext = getChatReconnectContext;
86
86
  const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, dispatch, setAdapter, reconnectId, initStartChat) => {
87
- if (isAuthenticatedChat) {
88
- // Get auth token for for getting chat reconnect context
89
- await (0, _authHelper.handleAuthentication)(chatSDK, props.chatConfig, props.getAuthToken);
90
- } else {
87
+ if (!isAuthenticatedChat) {
91
88
  const startUnauthenticatedReconnectChat = {
92
89
  eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
93
90
  };
@@ -104,7 +101,7 @@ const setReconnectIdAndStartChat = async (isAuthenticatedChat, chatSDK, props, d
104
101
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
105
102
  payload: _ConversationState.ConversationState.Loading
106
103
  });
107
- await initStartChat(chatSDK, props.chatConfig, props.getAuthToken, dispatch, setAdapter, optionalParams);
104
+ await initStartChat(chatSDK, dispatch, setAdapter, props, optionalParams);
108
105
  };
109
106
  const redirectPage = (redirectURL, redirectInSameWindow) => {
110
107
  const redirectPageRequest = {
@@ -3,12 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setPostChatContextAndLoadSurvey = void 0;
6
+ exports.setPostChatContextAndLoadSurvey = exports.initiatePostChat = exports.checkPostChatEnabled = void 0;
7
7
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
8
8
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
9
9
  var _ConversationState = require("../../../contexts/common/ConversationState");
10
10
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
11
11
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
12
+ var _Constants = require("../../../common/Constants");
13
+ var _endChat = require("./endChat");
14
+ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
15
+ var _utils = require("../../../common/utils");
16
+ var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
17
+ var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
18
+ var _ConversationEndEntity = require("../../../contexts/common/ConversationEndEntity");
12
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
20
  const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
14
21
  try {
@@ -41,4 +48,249 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat)
41
48
  });
42
49
  });
43
50
  };
44
- exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;
51
+
52
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
53
+ exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;
54
+ const checkPostChatEnabled = (props, state) => {
55
+ var _props$chatConfig, _props$chatConfig$Liv, _state$domainStates$l, _state$domainStates$l2;
56
+ 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);
57
+ return isPostChatEnabled === _Constants.Constants.true;
58
+ };
59
+
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ exports.checkPostChatEnabled = checkPostChatEnabled;
62
+ const initiatePostChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
63
+ // Check if Postchat already in progress and handle case where chat is ended by customer
64
+ if (state.appStates.postChatWorkflowInProgress && state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
65
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
66
+ return;
67
+ }
68
+
69
+ // Conversation Details call required by customer as well as agent
70
+ const conversationDetails = await getConversationDetailsCall(chatSDK);
71
+ // Start Postchat workflow
72
+ dispatch({
73
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_WORKFLOW_IN_PROGRESS,
74
+ payload: true
75
+ });
76
+
77
+ // Below logic checks if agent or bot or noone joins conversation and handles them separately
78
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.Constants.userParticipantTypeTag) {
79
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
80
+ // Set use bot settings to false
81
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
82
+ } else if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
83
+ await postChatInitiatedByAgent(props, setWebChatStyles, dispatch, state);
84
+ } else {
85
+ const error = `Conversation was Ended after agent joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
86
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
87
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
88
+ ExceptionDetails: {
89
+ exception: error
90
+ }
91
+ });
92
+ throw new Error(error);
93
+ }
94
+ } else if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.Constants.botParticipantTypeTag) {
95
+ // Set Use bot survey to true
96
+ dispatch({
97
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_USE_BOT_SURVEY,
98
+ payload: true
99
+ });
100
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
101
+ // Set use bot settings to true
102
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, true);
103
+ } else if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Agent) {
104
+ await postChatInitiatedByBot(props, setWebChatStyles, dispatch, state);
105
+ } else {
106
+ const error = `Conversation was Ended after bot joined but App State was not set correctly: conversationEndedBy = ${state.appStates.conversationEndedBy}`;
107
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
108
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
109
+ ExceptionDetails: {
110
+ exception: error
111
+ }
112
+ });
113
+ throw new Error(error);
114
+ }
115
+ } else {
116
+ if (state.appStates.conversationEndedBy === _ConversationEndEntity.ConversationEndEntity.Customer) {
117
+ // No one has joined chat will be handled by postChat customer
118
+ await postChatInitiatedByCustomer(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, false);
119
+ } else {
120
+ const error = `ConversationDetails and App state was not set correctly: conversationDetails = ${JSON.stringify(conversationDetails)} , conversationEndedBy = ${state.appStates.conversationEndedBy}`;
121
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
122
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
123
+ ExceptionDetails: {
124
+ exception: error
125
+ }
126
+ });
127
+ throw new Error(error);
128
+ }
129
+ }
130
+ };
131
+
132
+ // Function for link mode postchat workflow which is essentially same for both customer and agent
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
+ exports.initiatePostChat = initiatePostChat;
135
+ const linkModePostChatWorkflow = (props, dispatch, setWebChatStyles) => {
136
+ var _props$webChatContain, _props$webChatContain2;
137
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
138
+ Event: _TelemetryConstants.TelemetryEvent.LinkModePostChatWorkflowStarted
139
+ });
140
+ dispatch({
141
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
142
+ payload: _ConversationState.ConversationState.InActive
143
+ });
144
+
145
+ // Disable SendBox
146
+ if ((props === null || props === void 0 ? void 0 : (_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : (_props$webChatContain2 = _props$webChatContain.renderingMiddlewareProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.hideSendboxOnConversationEnd) !== false) {
147
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
+ setWebChatStyles(styles => {
149
+ return {
150
+ ...styles,
151
+ hideSendBox: true
152
+ };
153
+ });
154
+ }
155
+ };
156
+
157
+ // Function for embed mode postchat workflow which is essentially same for both customer and agent
158
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
159
+ const embedModePostChatWorkflow = async (dispatch, state) => {
160
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
161
+ Event: _TelemetryConstants.TelemetryEvent.EmbedModePostChatWorkflowStarted
162
+ });
163
+ if (state.domainStates.postChatContext) {
164
+ dispatch({
165
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
166
+ payload: _ConversationState.ConversationState.PostchatLoading
167
+ });
168
+ await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
169
+ const loadPostChatEvent = {
170
+ eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
171
+ };
172
+ _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
173
+ } else {
174
+ const error = `Conversation was Ended but App State was not set correctly: postChatContext = ${state.domainStates.postChatContext}`;
175
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
176
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
177
+ ExceptionDetails: {
178
+ exception: error
179
+ }
180
+ });
181
+ throw new Error(error);
182
+ }
183
+ };
184
+
185
+ // Function will handle only postchat cases initiated by customer
186
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
187
+ const postChatInitiatedByCustomer = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state, conversationDetails, shouldUseBotSetting) => {
188
+ let postChatSurveyMode = "";
189
+ if (shouldUseBotSetting) {
190
+ var _props$chatConfig2, _props$chatConfig2$Li, _state$domainStates$l3, _state$domainStates$l4;
191
+ 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_postconversationsurveybotsurveymode) ?? ((_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_postconversationsurveybotsurveymode);
192
+ } else {
193
+ var _props$chatConfig3, _props$chatConfig3$Li, _state$domainStates$l5, _state$domainStates$l6;
194
+ postChatSurveyMode = ((_props$chatConfig3 = props.chatConfig) === null || _props$chatConfig3 === void 0 ? void 0 : (_props$chatConfig3$Li = _props$chatConfig3.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig3$Li === void 0 ? void 0 : _props$chatConfig3$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : (_state$domainStates$l6 = _state$domainStates$l5.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.msdyn_postconversationsurveymode);
195
+ }
196
+ // Check if agent or bot has joined conversation
197
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
198
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
199
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromCustomer,
200
+ Description: shouldUseBotSetting ? "PostChat Workflow was started by customer using bot settings" : "PostChat Workflow was started by customer using agent settings"
201
+ });
202
+ const chatSession = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
203
+ if (chatSession) {
204
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
205
+ chatSDK.chatToken = chatSession.chatToken ?? {};
206
+ chatSDK.requestId = chatSession.requestId;
207
+ }
208
+ // End chat call to end chatsdk but not close chat, only if chat ended by customer
209
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, true, false);
210
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
211
+ await embedModePostChatWorkflow(dispatch, state);
212
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
213
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
214
+ } else {
215
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
216
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
217
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
218
+ ExceptionDetails: {
219
+ exception: error
220
+ }
221
+ });
222
+ throw new Error(error);
223
+ }
224
+ } else {
225
+ // Agent did not join chat so end chat normally
226
+ await (0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
227
+ }
228
+ };
229
+
230
+ // Function will handle only postchat cases initiated by agent
231
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
232
+ const postChatInitiatedByAgent = async (props, setWebChatStyles, dispatch, state) => {
233
+ var _props$chatConfig4, _props$chatConfig4$Li, _state$domainStates$l7, _state$domainStates$l8;
234
+ const postChatSurveyMode = ((_props$chatConfig4 = props.chatConfig) === null || _props$chatConfig4 === void 0 ? void 0 : (_props$chatConfig4$Li = _props$chatConfig4.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig4$Li === void 0 ? void 0 : _props$chatConfig4$Li.msdyn_postconversationsurveymode) ?? ((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : (_state$domainStates$l8 = _state$domainStates$l7.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l8 === void 0 ? void 0 : _state$domainStates$l8.msdyn_postconversationsurveymode);
235
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
236
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromAgent,
237
+ Description: "PostChat Workflow was started by agent"
238
+ });
239
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
240
+ await embedModePostChatWorkflow(dispatch, state);
241
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
242
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
243
+ } else {
244
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveymode = ${postChatSurveyMode}`;
245
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
246
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
247
+ ExceptionDetails: {
248
+ exception: error
249
+ }
250
+ });
251
+ throw new Error(error);
252
+ }
253
+ };
254
+
255
+ // Function will handle only postchat cases initiated by bot
256
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
257
+ const postChatInitiatedByBot = async (props, setWebChatStyles, dispatch, state) => {
258
+ var _props$chatConfig5, _props$chatConfig5$Li, _state$domainStates$l9, _state$domainStates$l10;
259
+ const postChatSurveyMode = ((_props$chatConfig5 = props.chatConfig) === null || _props$chatConfig5 === void 0 ? void 0 : (_props$chatConfig5$Li = _props$chatConfig5.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig5$Li === void 0 ? void 0 : _props$chatConfig5$Li.msdyn_postconversationsurveybotsurveymode) ?? ((_state$domainStates$l9 = state.domainStates.liveChatConfig) === null || _state$domainStates$l9 === void 0 ? void 0 : (_state$domainStates$l10 = _state$domainStates$l9.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l10 === void 0 ? void 0 : _state$domainStates$l10.msdyn_postconversationsurveybotsurveymode);
260
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
261
+ Event: _TelemetryConstants.TelemetryEvent.PostChatWorkflowFromBot,
262
+ Description: "PostChat Workflow was started by bot"
263
+ });
264
+ if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
265
+ await embedModePostChatWorkflow(dispatch, state);
266
+ } else if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Link) {
267
+ linkModePostChatWorkflow(props, dispatch, setWebChatStyles);
268
+ } else {
269
+ const error = `Conversation was Ended but App State was not set correctly: msdyn_postconversationsurveybotsurveymode = ${postChatSurveyMode}`;
270
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
271
+ Event: _TelemetryConstants.TelemetryEvent.AppStatesException,
272
+ ExceptionDetails: {
273
+ exception: error
274
+ }
275
+ });
276
+ throw new Error(error);
277
+ }
278
+ };
279
+
280
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
281
+ const getConversationDetailsCall = async chatSDK => {
282
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
283
+ let conversationDetails = undefined;
284
+ try {
285
+ conversationDetails = await chatSDK.getConversationDetails();
286
+ } catch (error) {
287
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
288
+ Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsCallFailed,
289
+ ExceptionDetails: {
290
+ exception: `Get Conversation Details Call Failed : ${error}`
291
+ }
292
+ });
293
+ _NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Get Conversation Details Call Failed: " + error);
294
+ }
295
+ return conversationDetails;
296
+ };