@microsoft/omnichannel-chat-widget 0.1.0-main.592da7b → 0.1.0-main.60c3e17

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 (124) hide show
  1. package/lib/cjs/common/Constants.js +4 -0
  2. package/lib/cjs/common/storage/default/defaultCacheManager.js +34 -0
  3. package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +114 -0
  4. package/lib/cjs/common/storage/default/defaultInMemoryDataStore.js +86 -0
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +19 -0
  6. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +31 -18
  7. package/lib/cjs/common/utils.js +64 -5
  8. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -5
  9. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
  10. package/lib/cjs/components/footerstateful/FooterStateful.js +5 -13
  11. package/lib/cjs/components/headerstateful/HeaderStateful.js +14 -7
  12. package/lib/cjs/components/livechatwidget/common/ActivityStreamHandler.js +44 -0
  13. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +23 -0
  14. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  15. package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +39 -0
  16. package/lib/cjs/components/livechatwidget/common/ChatAdapterShim.js +70 -0
  17. package/lib/cjs/components/livechatwidget/common/Deferred.js +42 -0
  18. package/lib/cjs/components/livechatwidget/common/authHelper.js +65 -0
  19. package/lib/cjs/components/livechatwidget/common/createAdapter.js +13 -1
  20. package/lib/cjs/components/livechatwidget/common/createFooter.js +7 -16
  21. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +12 -0
  22. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +31 -30
  23. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +51 -19
  24. package/lib/cjs/components/livechatwidget/common/endChat.js +52 -24
  25. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -0
  26. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +55 -35
  27. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  28. package/lib/cjs/components/livechatwidget/common/shareObservable.js +45 -0
  29. package/lib/cjs/components/livechatwidget/common/startChat.js +135 -83
  30. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -108
  31. package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +6 -4
  32. package/lib/cjs/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  33. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -8
  34. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +20 -4
  35. package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +4 -1
  36. package/lib/cjs/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +11 -0
  37. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  38. package/lib/cjs/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  39. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
  40. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +10 -0
  41. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  42. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -1
  43. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +13 -6
  44. package/lib/cjs/contexts/createReducer.js +10 -2
  45. package/lib/cjs/controller/componentController.js +2 -2
  46. package/lib/esm/common/Constants.js +4 -0
  47. package/lib/esm/common/storage/default/defaultCacheManager.js +19 -0
  48. package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +102 -0
  49. package/lib/esm/common/storage/default/defaultInMemoryDataStore.js +71 -0
  50. package/lib/esm/common/telemetry/TelemetryConstants.js +19 -0
  51. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +29 -13
  52. package/lib/esm/common/utils.js +48 -3
  53. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -5
  54. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +4 -4
  55. package/lib/esm/components/footerstateful/FooterStateful.js +5 -13
  56. package/lib/esm/components/headerstateful/HeaderStateful.js +14 -7
  57. package/lib/esm/components/livechatwidget/common/ActivityStreamHandler.js +34 -0
  58. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.js +14 -0
  59. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.js +1 -0
  60. package/lib/esm/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.js +29 -0
  61. package/lib/esm/components/livechatwidget/common/ChatAdapterShim.js +59 -0
  62. package/lib/esm/components/livechatwidget/common/Deferred.js +33 -0
  63. package/lib/esm/components/livechatwidget/common/authHelper.js +50 -0
  64. package/lib/esm/components/livechatwidget/common/createAdapter.js +12 -2
  65. package/lib/esm/components/livechatwidget/common/createFooter.js +4 -15
  66. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +8 -0
  67. package/lib/esm/components/livechatwidget/common/createMarkdown.js +31 -30
  68. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +51 -19
  69. package/lib/esm/components/livechatwidget/common/endChat.js +53 -25
  70. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -2
  71. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +56 -37
  72. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
  73. package/lib/esm/components/livechatwidget/common/shareObservable.js +38 -0
  74. package/lib/esm/components/livechatwidget/common/startChat.js +131 -83
  75. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +188 -110
  76. package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +5 -4
  77. package/lib/esm/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.js +1 -0
  78. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -8
  79. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +15 -2
  80. package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps.js +3 -1
  81. package/lib/esm/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.js +4 -0
  82. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +2 -0
  83. package/lib/esm/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.js +1 -0
  84. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +2 -1
  85. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.js +3 -0
  86. package/lib/esm/contexts/common/ConversationState.js +3 -2
  87. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -1
  88. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +11 -6
  89. package/lib/esm/contexts/createReducer.js +10 -2
  90. package/lib/esm/controller/componentController.js +2 -2
  91. package/lib/types/common/Constants.d.ts +2 -0
  92. package/lib/types/common/storage/default/defaultCacheManager.d.ts +4 -0
  93. package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +2 -0
  94. package/lib/types/common/storage/default/defaultInMemoryDataStore.d.ts +6 -0
  95. package/lib/types/common/telemetry/TelemetryConstants.d.ts +11 -2
  96. package/lib/types/common/utils.d.ts +7 -3
  97. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +2 -1
  98. package/lib/types/components/livechatwidget/common/ActivityStreamHandler.d.ts +14 -0
  99. package/lib/types/components/livechatwidget/common/ActivitySubscriber/DefaultActivitySubscriber.d.ts +5 -0
  100. package/lib/types/components/livechatwidget/common/ActivitySubscriber/IActivitySubscriber.d.ts +6 -0
  101. package/lib/types/components/livechatwidget/common/ActivitySubscriber/PauseActivitySubscriber.d.ts +7 -0
  102. package/lib/types/components/livechatwidget/common/ChatAdapterShim.d.ts +7 -0
  103. package/lib/types/components/livechatwidget/common/Deferred.d.ts +9 -0
  104. package/lib/types/components/livechatwidget/common/authHelper.d.ts +5 -0
  105. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
  106. package/lib/types/components/livechatwidget/common/shareObservable.d.ts +1 -0
  107. package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -3
  108. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +1 -0
  109. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -2
  110. package/lib/types/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.d.ts +2 -2
  111. package/lib/types/components/postchatsurveypanestateful/interfaces/IPostChatSurveyPaneStatefulProps.d.ts +4 -0
  112. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -1
  113. package/lib/types/components/webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles.d.ts +2 -0
  114. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  115. package/lib/types/components/webchatcontainerstateful/interfaces/IAdaptiveCardStyles.d.ts +4 -0
  116. package/lib/types/components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps.d.ts +2 -1
  117. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  118. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.d.ts +1 -1
  119. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultReceivedMessageAnchorStyles.d.ts +2 -0
  120. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  121. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -2
  122. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -2
  123. package/lib/types/contexts/common/LiveChatWidgetContextInitialState.d.ts +1 -2
  124. package/package.json +5 -4
@@ -166,24 +166,28 @@ export const dummyDefaultProps = {
166
166
  },
167
167
  audioCallButtonStyleProps: {
168
168
  borderRadius: "50%",
169
- color: "#FFFFFF",
170
169
  backgroundColor: "#008000",
171
170
  lineHeight: "40px",
172
171
  height: "40px",
173
172
  width: "40px",
174
- fontSize: 18
173
+ icon: {
174
+ fontSize: 18,
175
+ color: "#FFFFFF"
176
+ }
175
177
  },
176
178
  audioCallButtonHoverStyleProps: {
177
179
  filter: "brightness(0.8)"
178
180
  },
179
181
  videoCallButtonStyleProps: {
180
182
  borderRadius: "50%",
181
- color: "#FFFFFF",
182
183
  backgroundColor: "#008000",
183
184
  lineHeight: "40px",
184
185
  height: "40px",
185
186
  width: "40px",
186
- fontSize: 18
187
+ icon: {
188
+ fontSize: 18,
189
+ color: "#FFFFFF"
190
+ }
187
191
  },
188
192
  videoCallButtonHoverStyleProps: {
189
193
  filter: "brightness(0.8)"
@@ -194,13 +198,15 @@ export const dummyDefaultProps = {
194
198
  },
195
199
  declineCallButtonStyleProps: {
196
200
  borderRadius: "50%",
197
- color: "#FFFFFF",
198
201
  backgroundColor: "#DC0000",
199
202
  lineHeight: "40px",
200
203
  height: "40px",
201
204
  width: "40px",
202
- fontSize: 18,
203
- marginLeft: "5px"
205
+ marginLeft: "5px",
206
+ icon: {
207
+ fontSize: 18,
208
+ color: "#FFFFFF"
209
+ }
204
210
  },
205
211
  incomingCallTitleStyleProps: {
206
212
  margin: "0 5px",
@@ -318,7 +324,8 @@ export const dummyDefaultProps = {
318
324
  hideChatTitle: false,
319
325
  hideNotificationBubble: true,
320
326
  unreadMessageString: "new messages",
321
- largeUnreadMessageString: "99+"
327
+ largeUnreadMessageString: "99+",
328
+ ariaLabelUnreadMessageString: "you have new messages"
322
329
  },
323
330
  styleProps: {
324
331
  generalStyleProps: {
@@ -770,6 +777,7 @@ export const dummyDefaultProps = {
770
777
  },
771
778
  audioNotificationButtonProps: {
772
779
  id: "oc-lcw-footer-audionotification-button",
780
+ type: "icon",
773
781
  ariaLabel: "Turn sound off",
774
782
  toggleAriaLabel: "Turn sound on",
775
783
  iconName: "Volume3",
@@ -795,8 +803,10 @@ export const dummyDefaultProps = {
795
803
  padding: "0 10px 5px 10px"
796
804
  },
797
805
  downloadTranscriptButtonStyleProps: {
798
- color: "blue",
799
- fontSize: 16,
806
+ icon: {
807
+ color: "blue",
808
+ fontSize: 16
809
+ },
800
810
  height: "25px",
801
811
  lineHeight: "25px",
802
812
  width: "25px"
@@ -806,8 +816,10 @@ export const dummyDefaultProps = {
806
816
  backgroundColor: "#C8C8C8"
807
817
  },
808
818
  emailTranscriptButtonStyleProps: {
809
- color: "blue",
810
- fontSize: 16,
819
+ cicon: {
820
+ color: "blue",
821
+ fontSize: 16
822
+ },
811
823
  height: "25px",
812
824
  lineHeight: "25px",
813
825
  width: "25px"
@@ -817,8 +829,10 @@ export const dummyDefaultProps = {
817
829
  backgroundColor: "#C8C8C8"
818
830
  },
819
831
  audioNotificationButtonStyleProps: {
820
- color: "blue",
821
- fontSize: 16,
832
+ icon: {
833
+ color: "blue",
834
+ fontSize: 16
835
+ },
822
836
  height: "25px",
823
837
  lineHeight: "25px",
824
838
  width: "25px"
@@ -869,7 +883,7 @@ export const dummyDefaultProps = {
869
883
  className: undefined
870
884
  },
871
885
  closeButtonProps: {
872
- id: "oc-lcw-header-minimize-button",
886
+ id: "oc-lcw-header-close-button",
873
887
  type: "icon",
874
888
  iconName: "ChromeClose",
875
889
  ariaLabel: "Close",
@@ -1165,7 +1179,8 @@ export const dummyDefaultProps = {
1165
1179
  backgroundColor: "#FFFFFF",
1166
1180
  borderColor: "#F1F1F1"
1167
1181
  }
1168
- }
1182
+ },
1183
+ isCustomerVoiceSurveyCompact: undefined
1169
1184
  },
1170
1185
  proactiveChatPaneProps: {
1171
1186
  componentOverrides: {
@@ -1185,7 +1200,17 @@ export const dummyDefaultProps = {
1185
1200
  hideSubtitle: false,
1186
1201
  subtitleText: "Live chat support!",
1187
1202
  hideCloseButton: false,
1188
- closeButtonAriaLabel: "Close Button",
1203
+ closeButtonProps: {
1204
+ id: "oc-lcw-proactivechat-closebutton",
1205
+ type: "icon",
1206
+ iconName: "ChromeClose",
1207
+ ariaLabel: "Close",
1208
+ imageIconProps: undefined,
1209
+ text: "Close",
1210
+ onClick: undefined,
1211
+ className: undefined,
1212
+ hideButtonTitle: true
1213
+ },
1189
1214
  isBodyContainerHorizantal: false,
1190
1215
  hideBodyTitle: false,
1191
1216
  bodyTitleText: "Hi! Have any questions? I am here to help.",
@@ -1413,7 +1438,6 @@ export const dummyDefaultProps = {
1413
1438
  startNewChatButtonClassName: undefined
1414
1439
  }
1415
1440
  },
1416
- authClientFunction: undefined,
1417
1441
  isReconnectEnabled: undefined,
1418
1442
  reconnectId: undefined,
1419
1443
  redirectInSameWindow: undefined
@@ -1655,6 +1679,9 @@ export const dummyDefaultProps = {
1655
1679
  },
1656
1680
  attachmentSizeStyles: {
1657
1681
  display: "none"
1682
+ },
1683
+ receivedMessageAnchorStyles: {
1684
+ color: "white"
1658
1685
  }
1659
1686
  },
1660
1687
  localizedTexts: {
@@ -1682,7 +1709,12 @@ export const dummyDefaultProps = {
1682
1709
  botMagicCode: {
1683
1710
  disabled: false,
1684
1711
  fwdUrl: ""
1712
+ },
1713
+ adaptiveCardStyles: {
1714
+ background: "white",
1715
+ color: "black"
1685
1716
  }
1686
1717
  },
1687
- telemetryConfig: undefined
1718
+ telemetryConfig: undefined,
1719
+ getAuthToken: undefined
1688
1720
  };
@@ -7,21 +7,38 @@ import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontro
7
7
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
8
8
  import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
9
9
  import { Constants } from "../../../common/Constants";
10
- import { getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ import { addDelayInMs, getWidgetEndChatEventName } from "../../../common/utils"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
11
 
12
12
  const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
13
- var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
13
+ var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
14
14
 
15
15
  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;
16
- 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;
17
- const conversationDetails = await chatSDK.getConversationDetails();
16
+ 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; // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
17
 
19
- if (isPostChatEnabled === "true" && (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.canRenderPostChat) === Constants.truePascal) {
18
+ let conversationDetails = undefined;
19
+
20
+ try {
21
+ conversationDetails = await chatSDK.getConversationDetails();
22
+ } catch (erorr) {
23
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
24
+ Event: TelemetryEvent.GetConversationDetailsException,
25
+ ExceptionDetails: {
26
+ exception: `Failed to get conversation details: ${erorr}`
27
+ }
28
+ });
29
+ }
30
+
31
+ if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === Constants.truePascal) {
20
32
  const skipEndChatSDK = false;
21
33
  const skipCloseChat = true;
22
- await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
34
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, false);
23
35
 
24
36
  if (postChatSurveyMode === PostChatSurveyMode.Embed) {
37
+ dispatch({
38
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
39
+ payload: ConversationState.PostchatLoading
40
+ });
41
+ await addDelayInMs(Constants.PostChatLoadingDurationInMs);
25
42
  const loadPostChatEvent = {
26
43
  eventName: BroadcastEvent.LoadPostChatSurvey
27
44
  };
@@ -32,9 +49,11 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
32
49
  payload: ConversationState.InActive
33
50
  });
34
51
  }
35
- } else {
36
- await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
52
+
53
+ return;
37
54
  }
55
+
56
+ await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
38
57
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
58
 
40
59
 
@@ -44,20 +63,7 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
44
63
  TelemetryHelper.logSDKEvent(LogLevel.INFO, {
45
64
  Event: TelemetryEvent.EndChatSDKCall
46
65
  });
47
- await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat()); // Need to clear these states immediately when chat ended from OC.
48
-
49
- dispatch({
50
- type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
51
- payload: undefined
52
- });
53
- dispatch({
54
- type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
55
- payload: undefined
56
- });
57
- dispatch({
58
- type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
59
- payload: undefined
60
- });
66
+ await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
61
67
  } catch (ex) {
62
68
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
63
69
  Event: TelemetryEvent.EndChatSDKCallFailed,
@@ -67,7 +73,21 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
67
73
  });
68
74
  postMessageToOtherTab = false;
69
75
  }
70
- }
76
+ } // Need to clear these states immediately when chat ended from OC.
77
+
78
+
79
+ dispatch({
80
+ type: LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
81
+ payload: undefined
82
+ });
83
+ dispatch({
84
+ type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
85
+ payload: undefined
86
+ });
87
+ dispatch({
88
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
89
+ payload: undefined
90
+ });
71
91
 
72
92
  if (!skipCloseChat) {
73
93
  try {
@@ -99,11 +119,19 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
99
119
  type: LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
100
120
  payload: 0
101
121
  });
122
+ dispatch({
123
+ type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
124
+ payload: {
125
+ proactiveChatBodyTitle: "",
126
+ proactiveChatEnablePrechat: false,
127
+ proactiveChatInNewWindow: false
128
+ }
129
+ });
102
130
 
103
131
  if (postMessageToOtherTab) {
104
- var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
132
+ var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _props$controlProps;
105
133
 
106
- const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId);
134
+ const endChatEventName = getWidgetEndChatEventName(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId, (props === null || props === void 0 ? void 0 : (_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.widgetInstanceId) ?? "");
107
135
  BroadcastService.postMessage({
108
136
  eventName: endChatEventName
109
137
  });
@@ -7,7 +7,7 @@ import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostC
7
7
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
8
8
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
9
9
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
10
- import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
10
+ import { addDelayInMs, changeLanguageCodeFormatForWebChat } from "../../../common/utils";
11
11
  import channelDataMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware";
12
12
  import { createActivityMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware";
13
13
  import createAttachmentMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware";
@@ -28,7 +28,8 @@ import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller
28
28
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
29
29
  import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
30
30
  import { createCardActionMiddleware } from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware";
31
- import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ import createMessageTimeStampMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware";
32
+ import { Constants } from "../../../common/Constants"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
32
33
 
33
34
  export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
34
35
  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;
@@ -65,6 +66,12 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
65
66
 
66
67
  if (isPostChatEnabled === "true") {
67
68
  if (postChatSurveyMode === PostChatSurveyMode.Embed) {
69
+ WebChatStoreLoader.store = null;
70
+ dispatch({
71
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
72
+ payload: ConversationState.PostchatLoading
73
+ });
74
+ await addDelayInMs(Constants.PostChatLoadingDurationInMs);
68
75
  const loadPostChatEvent = {
69
76
  eventName: BroadcastEvent.LoadPostChatSurvey
70
77
  };
@@ -76,6 +83,10 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
76
83
  });
77
84
  }
78
85
  } else {
86
+ dispatch({
87
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
88
+ payload: ConversationState.InActive
89
+ });
79
90
  dispatch({
80
91
  type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
81
92
  payload: true
@@ -3,25 +3,34 @@ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/teleme
3
3
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
4
  import { ConversationState } from "../../../contexts/common/ConversationState";
5
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
6
- import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
-
8
- const getChatReconnectContext = async (chatSDK, reconnectId) => {
9
- try {
10
- if (reconnectId) {
11
- const chatReconnectOptionalParams = {
12
- reconnectId: reconnectId
13
- };
14
- return await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
15
- } else {
16
- return await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext());
17
- }
18
- } catch (ex) {
19
- TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
20
- Event: TelemetryEvent.GetChatReconnectContextSDKCallFailed,
21
- ExceptionDetails: {
22
- exception: ex
6
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
7
+ import { handleAuthentication, removeAuthTokenProvider } from "./authHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+
9
+ const getChatReconnectContext = async (chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId) => {
10
+ if (isReconnectEnabled) {
11
+ try {
12
+ if (reconnectId) {
13
+ const chatReconnectOptionalParams = {
14
+ reconnectId: reconnectId
15
+ };
16
+ return await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext(chatReconnectOptionalParams));
17
+ } else {
18
+ // set auth token to chat sdk to get reconnectId for auth chat
19
+ await handleAuthentication(chatSDK, chatConfig, getAuthToken);
20
+ const reconnectChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatReconnectContext()); // remove auth token after reconnectId is fetched
21
+ // this will be reset later at start chat
22
+
23
+ removeAuthTokenProvider(chatSDK);
24
+ return reconnectChatContext;
23
25
  }
24
- });
26
+ } catch (ex) {
27
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
28
+ Event: TelemetryEvent.GetChatReconnectContextSDKCallFailed,
29
+ ExceptionDetails: {
30
+ exception: ex
31
+ }
32
+ });
33
+ }
25
34
  }
26
35
 
27
36
  return null;
@@ -29,13 +38,23 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
29
38
 
30
39
 
31
40
  const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
32
- var _props$reconnectChatP, _props$reconnectChatP2;
41
+ var _props$chatConfig, _props$reconnectChatP;
42
+
43
+ let authClientFunction = undefined;
33
44
 
34
- if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.authClientFunction // TODO: Implement this after storage is in place
45
+ if ((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) {
46
+ var _props$chatConfig2, _props$chatConfig2$Li;
47
+
48
+ authClientFunction = ((_props$chatConfig2 = props.chatConfig) === null || _props$chatConfig2 === void 0 ? void 0 : (_props$chatConfig2$Li = _props$chatConfig2.LiveChatConfigAuthSettings) === null || _props$chatConfig2$Li === void 0 ? void 0 : _props$chatConfig2$Li.msdyn_javascriptclientfunction) ?? undefined;
49
+ }
50
+
51
+ if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && authClientFunction // TODO: Implement this after storage is in place
35
52
 
36
53
  /* && !isLoadWithState() */
37
54
  ) {
38
- const previousActiveSessionResponse = await getChatReconnectContext(chatSDK);
55
+ var _props$reconnectChatP2;
56
+
57
+ const previousActiveSessionResponse = await getChatReconnectContext(chatSDK, props.chatConfig, props.getAuthToken, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.isReconnectEnabled);
39
58
 
40
59
  if (previousActiveSessionResponse && previousActiveSessionResponse.reconnectId) {
41
60
  return previousActiveSessionResponse.reconnectId;
@@ -46,27 +65,27 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
46
65
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
66
 
48
67
 
49
- const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
50
- const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
68
+ const handleUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, isReconnectEnabled, reconnectId, initStartChat, redirectInSameWindow) => {
69
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
51
70
 
52
71
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
53
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
72
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
54
73
  } else {
55
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
74
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
56
75
  }
57
76
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
77
 
59
78
 
60
- const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
61
- const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
79
+ const startUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, isReconnectEnabled, reconnectId, initStartChat) => {
80
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
62
81
 
63
82
  if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
64
- await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
83
+ await setReconnectIdAndStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat);
65
84
  }
66
85
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
67
86
 
68
87
 
69
- const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
88
+ const setReconnectIdAndStartChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, reconnectId, initStartChat) => {
70
89
  const startUnauthenticatedReconnectChat = {
71
90
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
72
91
  };
@@ -82,7 +101,7 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
82
101
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
83
102
  payload: ConversationState.Loading
84
103
  });
85
- await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
104
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, optionalParams);
86
105
  };
87
106
 
88
107
  const redirectPage = (redirectURL, redirectInSameWindow) => {
@@ -104,7 +123,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
104
123
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
105
124
 
106
125
 
107
- const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
126
+ const startNewChatEmptyRedirectionUrl = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat) => {
108
127
  const startUnauthenticatedReconnectChat = {
109
128
  eventName: BroadcastEvent.StartUnauthenticatedReconnectChat
110
129
  };
@@ -127,25 +146,25 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, in
127
146
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
128
147
  payload: ConversationState.Loading
129
148
  });
130
- await initStartChat(chatSDK, dispatch, setAdapter);
149
+ await initStartChat(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter);
131
150
  }
132
151
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
152
 
134
153
 
135
- const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
136
- const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
154
+ const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, isReconnectEnabled, reconnectId, redirectInSameWindow) => {
155
+ const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, chatConfig, getAuthToken, isReconnectEnabled, reconnectId);
137
156
 
138
157
  if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
139
- await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
158
+ await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow);
140
159
  }
141
160
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
142
161
 
143
162
 
144
- const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
163
+ const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
145
164
  if (reconnectAvailabilityResponse.redirectURL) {
146
165
  redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
147
166
  } else {
148
- await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
167
+ await startNewChatEmptyRedirectionUrl(chatSDK, chatConfig, getAuthToken, dispatch, setAdapter, initStartChat);
149
168
  }
150
169
  };
151
170
 
@@ -29,10 +29,6 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
29
29
 
30
30
 
31
31
  BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
32
- dispatch({
33
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
34
- payload: ConversationState.Loading
35
- });
36
32
  dispatch({
37
33
  type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
38
34
  payload: ConversationState.Postchat
@@ -0,0 +1,38 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ export function shareObservable(observable) {
3
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
+ let observers = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+
6
+ let subscription; // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
+
8
+ return new window.Observable(observer => {
9
+ if (!subscription) {
10
+ subscription = observable.subscribe({
11
+ complete() {
12
+ observers.forEach(observer => observer.complete());
13
+ },
14
+
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ error(err) {
17
+ observers.forEach(observer => observer.error(err));
18
+ },
19
+
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ next(value) {
22
+ observers.forEach(observer => observer.next(value));
23
+ }
24
+
25
+ });
26
+ }
27
+
28
+ observers.push(observer);
29
+ return () => {
30
+ observers = observers.filter(o => o !== observer);
31
+
32
+ if (!observers.length) {
33
+ subscription.unsubscribe();
34
+ subscription = null;
35
+ }
36
+ };
37
+ });
38
+ }