@microsoft/omnichannel-chat-widget 0.1.0-main.07f52ee → 0.1.0-main.0ec5410

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 (92) hide show
  1. package/lib/cjs/assets/Audios.js +8 -0
  2. package/lib/cjs/assets/Icons.js +28 -0
  3. package/lib/cjs/common/Constants.js +2 -0
  4. package/lib/cjs/common/telemetry/TelemetryConstants.js +24 -3
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +1 -1
  6. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +22 -20
  7. package/lib/cjs/components/footerstateful/FooterStateful.js +3 -3
  8. package/lib/cjs/components/headerstateful/HeaderStateful.js +12 -3
  9. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +3 -4
  10. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -7
  11. package/lib/cjs/components/livechatwidget/common/endChat.js +63 -55
  12. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +25 -7
  13. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
  14. package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
  15. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
  16. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -14
  17. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -3
  18. package/lib/cjs/{assets/assets.d.js → components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js} +0 -0
  19. package/lib/cjs/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  20. package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +51 -73
  21. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +9 -46
  22. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +3 -1
  23. package/lib/cjs/contexts/common/ConversationState.js +3 -2
  24. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +5 -1
  25. package/lib/cjs/controller/componentController.js +2 -2
  26. package/lib/cjs/plugins/newMessageEventHandler.js +102 -0
  27. package/lib/esm/assets/Audios.js +1 -0
  28. package/lib/esm/assets/Icons.js +11 -0
  29. package/lib/esm/common/Constants.js +2 -0
  30. package/lib/esm/common/telemetry/TelemetryConstants.js +20 -2
  31. package/lib/esm/common/telemetry/TelemetryManager.js +1 -1
  32. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +21 -20
  33. package/lib/esm/components/footerstateful/FooterStateful.js +3 -3
  34. package/lib/esm/components/headerstateful/HeaderStateful.js +13 -4
  35. package/lib/esm/components/livechatwidget/common/createMarkdown.js +3 -3
  36. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -9
  37. package/lib/esm/components/livechatwidget/common/endChat.js +62 -51
  38. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +23 -8
  39. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +6 -5
  40. package/lib/esm/components/livechatwidget/common/startChat.js +4 -1
  41. package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
  42. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +23 -11
  43. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +8 -4
  44. package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  45. package/lib/esm/components/webchatcontainerstateful/common/mockchatsdk.js +4 -0
  46. package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -12
  47. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -44
  48. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
  49. package/lib/esm/contexts/common/ConversationState.js +3 -2
  50. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +5 -1
  51. package/lib/esm/controller/componentController.js +2 -2
  52. package/lib/esm/plugins/newMessageEventHandler.js +84 -0
  53. package/lib/types/assets/Audios.d.ts +1 -0
  54. package/lib/types/assets/Icons.d.ts +11 -0
  55. package/lib/types/common/Constants.d.ts +1 -0
  56. package/lib/types/common/telemetry/TelemetryConstants.d.ts +16 -1
  57. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +4 -1
  58. package/lib/types/components/headerstateful/interfaces/IHeaderStatefulParams.d.ts +4 -1
  59. package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
  60. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
  61. package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
  62. package/lib/types/components/webchatcontainerstateful/common/mockchatsdk.d.ts +1 -0
  63. package/lib/types/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.d.ts +1 -1
  64. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +0 -1
  65. package/lib/types/contexts/common/ConversationState.d.ts +3 -2
  66. package/lib/types/plugins/newMessageEventHandler.d.ts +2 -0
  67. package/package.json +5 -6
  68. package/lib/cjs/assets/audios/newMessageNotification.mp3 +0 -0
  69. package/lib/cjs/assets/icons/archiveIcon.svg +0 -3
  70. package/lib/cjs/assets/icons/audioIcon.svg +0 -6
  71. package/lib/cjs/assets/icons/blankIcon.svg +0 -6
  72. package/lib/cjs/assets/icons/excelIcon.svg +0 -6
  73. package/lib/cjs/assets/icons/imageIcon.svg +0 -6
  74. package/lib/cjs/assets/icons/oneNoteIcon.svg +0 -6
  75. package/lib/cjs/assets/icons/pdfIcon.svg +0 -6
  76. package/lib/cjs/assets/icons/powerpointIcon.svg +0 -6
  77. package/lib/cjs/assets/icons/videoIcon.svg +0 -6
  78. package/lib/cjs/assets/icons/visioIcon.svg +0 -6
  79. package/lib/cjs/assets/icons/wordIcon.svg +0 -6
  80. package/lib/esm/assets/assets.d.js +0 -0
  81. package/lib/esm/assets/audios/newMessageNotification.mp3 +0 -0
  82. package/lib/esm/assets/icons/archiveIcon.svg +0 -3
  83. package/lib/esm/assets/icons/audioIcon.svg +0 -6
  84. package/lib/esm/assets/icons/blankIcon.svg +0 -6
  85. package/lib/esm/assets/icons/excelIcon.svg +0 -6
  86. package/lib/esm/assets/icons/imageIcon.svg +0 -6
  87. package/lib/esm/assets/icons/oneNoteIcon.svg +0 -6
  88. package/lib/esm/assets/icons/pdfIcon.svg +0 -6
  89. package/lib/esm/assets/icons/powerpointIcon.svg +0 -6
  90. package/lib/esm/assets/icons/videoIcon.svg +0 -6
  91. package/lib/esm/assets/icons/visioIcon.svg +0 -6
  92. package/lib/esm/assets/icons/wordIcon.svg +0 -6
@@ -1,61 +1,72 @@
1
- import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
2
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
3
3
  import { ConversationState } from "../../../contexts/common/ConversationState";
4
4
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
- import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler";
6
- import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
7
5
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
8
6
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
9
7
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
8
 
11
- export const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter) => {
12
- try {
13
- var _props$webChatContain;
9
+ export const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
10
+ if (!skipEndChatSDK) {
11
+ try {
12
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
13
+ Event: TelemetryEvent.EndChatSDKCall
14
+ });
15
+ await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
16
+ } catch (ex) {
17
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
18
+ Event: TelemetryEvent.EndChatSDKCallFailed,
19
+ ExceptionDetails: {
20
+ exception: ex
21
+ }
22
+ });
23
+ }
24
+ }
25
+
26
+ if (!skipCloseChat) {
27
+ try {
28
+ var _props$webChatContain;
14
29
 
15
- TelemetryHelper.logSDKEvent(LogLevel.INFO, {
16
- Event: TelemetryEvent.EndChatSDKCall
17
- });
18
- await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.endChat());
19
- adapter === null || adapter === void 0 ? void 0 : adapter.end();
20
- setAdapter(undefined);
21
- setWebChatStyles({ ...defaultWebChatContainerStatefulProps.webChatStyles,
22
- ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
23
- });
24
- WebChatStoreLoader.store = null;
25
- dispatch({
26
- type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
27
- payload: ConversationState.Closed
28
- });
29
- dispatch({
30
- type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
31
- payload: false
32
- });
33
- dispatch({
34
- type: LiveChatWidgetActionType.SET_RECONNECT_ID,
35
- payload: undefined
36
- });
37
- dispatch({
38
- type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
39
- payload: null
40
- });
41
- dispatch({
42
- type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
43
- payload: undefined
44
- });
45
- dispatch({
46
- type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
47
- payload: undefined
48
- });
49
- BroadcastService.postMessage({
50
- eventName: "EndChat"
51
- });
52
- } catch (ex) {
53
- TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
54
- Event: TelemetryEvent.EndChatSDKCallFailed,
55
- ExceptionDetails: {
56
- exception: ex
57
- }
58
- });
59
- NotificationHandler.notifyError(NotificationScenarios.Connection, "End Chat Call Failed: " + ex);
30
+ adapter === null || adapter === void 0 ? void 0 : adapter.end();
31
+ setAdapter(undefined);
32
+ setWebChatStyles({ ...defaultWebChatContainerStatefulProps.webChatStyles,
33
+ ...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
34
+ });
35
+ WebChatStoreLoader.store = null;
36
+ dispatch({
37
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
38
+ payload: ConversationState.Closed
39
+ });
40
+ dispatch({
41
+ type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
42
+ payload: false
43
+ });
44
+ dispatch({
45
+ type: LiveChatWidgetActionType.SET_RECONNECT_ID,
46
+ payload: undefined
47
+ });
48
+ dispatch({
49
+ type: LiveChatWidgetActionType.SET_AUDIO_NOTIFICATION,
50
+ payload: null
51
+ });
52
+ dispatch({
53
+ type: LiveChatWidgetActionType.SET_CHAT_TOKEN,
54
+ payload: undefined
55
+ });
56
+ dispatch({
57
+ type: LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
58
+ payload: undefined
59
+ });
60
+ BroadcastService.postMessage({
61
+ eventName: BroadcastEvent.EndChat
62
+ });
63
+ } catch (error) {
64
+ TelemetryHelper.logActionEvent(LogLevel.ERROR, {
65
+ Event: TelemetryEvent.CloseChatMethodException,
66
+ ExceptionDetails: {
67
+ exception: `Failed to endChat: ${error}`
68
+ }
69
+ });
70
+ }
60
71
  }
61
72
  };
@@ -1,6 +1,10 @@
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
1
2
  import { createStore } from "botframework-webchat";
3
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
4
+ import { ConversationState } from "../../../contexts/common/ConversationState";
2
5
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
6
  import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
7
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
8
  import { WebChatStoreLoader } from "../../webchatcontainerstateful/webchatcontroller/WebChatStoreLoader";
5
9
  import attachmentProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentProcessingMiddleware";
6
10
  import { changeLanguageCodeFormatForWebChat } from "../../../common/utils";
@@ -21,9 +25,8 @@ import gifUploadMiddleware from "../../webchatcontainerstateful/webchatcontrolle
21
25
  import htmlPlayerMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlPlayerMiddleware";
22
26
  import htmlTextMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/htmlTextMiddleware";
23
27
  import preProcessingMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/preProcessingMiddleware";
24
- import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware";
25
- import { BroadcastService } from "@microsoft/omnichannel-chat-components";
26
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ import sanitizationMiddleware from "../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+
27
30
  export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
28
31
  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;
29
32
 
@@ -44,6 +47,11 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
44
47
  const conversationEndCallback = async () => {
45
48
  var _props$webChatContain4, _props$webChatContain5;
46
49
 
50
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
51
+ Event: TelemetryEvent.ConversationEndedThreadEventReceived,
52
+ Description: "Conversation is ended by agent side or by timeout."
53
+ });
54
+
47
55
  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) {
48
56
  setWebChatStyles(styles => {
49
57
  return { ...styles,
@@ -52,11 +60,18 @@ export const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatS
52
60
  });
53
61
  }
54
62
 
55
- if (isPostChatEnabled === "true" && postChatSurveyMode === PostChatSurveyMode.Embed) {
56
- const loadPostChatEvent = {
57
- eventName: "LoadPostChatSurvey"
58
- };
59
- BroadcastService.postMessage(loadPostChatEvent);
63
+ if (isPostChatEnabled === "true") {
64
+ if (postChatSurveyMode === PostChatSurveyMode.Embed) {
65
+ const loadPostChatEvent = {
66
+ eventName: BroadcastEvent.LoadPostChatSurvey
67
+ };
68
+ BroadcastService.postMessage(loadPostChatEvent);
69
+ } else if (postChatSurveyMode === PostChatSurveyMode.Link) {
70
+ dispatch({
71
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
72
+ payload: ConversationState.InActive
73
+ });
74
+ }
60
75
  } else {
61
76
  dispatch({
62
77
  type: LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
@@ -1,9 +1,9 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
2
- import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
3
- import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
- import { ConversationState } from "../../../contexts/common/ConversationState";
5
2
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
6
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ import { ConversationState } from "../../../contexts/common/ConversationState";
4
+ import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper"; // eslint-disable-next-line @typescript-eslint/no-explicit-any
6
+
7
7
  export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
8
8
  try {
9
9
  if (!persistedChat) {
@@ -25,7 +25,8 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
25
25
  exception: ex
26
26
  }
27
27
  });
28
- }
28
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
29
+
29
30
 
30
31
  BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
31
32
  dispatch({
@@ -8,6 +8,7 @@ import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcon
8
8
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
9
9
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
10
10
  import { createAdapter } from "./createAdapter";
11
+ import { createOnNewAdapterActivityHandler } from "../../../plugins/newMessageEventHandler";
11
12
  import { createTimer } from "../../../common/utils";
12
13
  import { getReconnectIdForAuthenticatedChat } from "./reconnectChatHelper";
13
14
  import { setPostChatContextAndLoadSurvey } from "./setPostChatContextAndLoadSurvey";
@@ -55,7 +56,7 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
55
56
 
56
57
  const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedState) => {
57
58
  try {
58
- var _TelemetryTimers$Widg;
59
+ var _newAdapter$activity$, _TelemetryTimers$Widg;
59
60
 
60
61
  try {
61
62
  TelemetryTimers.WidgetLoadTimer = createTimer();
@@ -74,6 +75,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
74
75
 
75
76
  const newAdapter = await createAdapter(chatSDK);
76
77
  setAdapter(newAdapter);
78
+ const chatToken = await chatSDK.getChatToken();
79
+ newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe(createOnNewAdapterActivityHandler(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
77
80
 
78
81
  if (!persistedState) {
79
82
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -2,14 +2,14 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
2
2
  import { ConversationState } from "../../../contexts/common/ConversationState";
3
3
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
4
4
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
5
- import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager"; // Defines startProactiveChat callback
6
-
7
- export const startProactiveChat = (dispatch, bodyTitle, showPrechat, inNewWindow) => {
5
+ import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
6
+ // Defines startProactiveChat callback
7
+ export const startProactiveChat = (dispatch, notificationConfig, enablePreChat, inNewWindow) => {
8
8
  dispatch({
9
9
  type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
10
10
  payload: {
11
- proactiveChatBodyTitle: bodyTitle ?? "",
12
- proactiveChatEnablePrechat: showPrechat ?? false,
11
+ proactiveChatBodyTitle: notificationConfig && notificationConfig.message ? notificationConfig.message : "",
12
+ proactiveChatEnablePrechat: enablePreChat ?? false,
13
13
  proactiveChatInNewWindow: inNewWindow ?? false
14
14
  }
15
15
  });
@@ -1,5 +1,6 @@
1
1
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
2
 
3
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
4
  import { BroadcastService, decodeComponentString } from "@microsoft/omnichannel-chat-components";
4
5
  import { Stack } from "@fluentui/react";
5
6
  import React, { useEffect, useRef, useState } from "react";
@@ -12,6 +13,7 @@ import ChatButtonStateful from "../../chatbuttonstateful/ChatButtonStateful";
12
13
  import { Components } from "botframework-webchat";
13
14
  import ConfirmationPaneStateful from "../../confirmationpanestateful/ConfirmationPaneStateful";
14
15
  import { ConversationState } from "../../../contexts/common/ConversationState";
16
+ import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
15
17
  import { ElementType } from "@microsoft/omnichannel-chat-components";
16
18
  import EmailTranscriptPaneStateful from "../../emailtranscriptpanestateful/EmailTranscriptPaneStateful";
17
19
  import HeaderStateful from "../../headerstateful/HeaderStateful";
@@ -23,11 +25,13 @@ import PostChatSurveyPaneStateful from "../../postchatsurveypanestateful/PostCha
23
25
  import PreChatSurveyPaneStateful from "../../prechatsurveypanestateful/PreChatSurveyPaneStateful";
24
26
  import ProactiveChatPaneStateful from "../../proactivechatpanestateful/ProactiveChatPaneStateful";
25
27
  import ReconnectChatPaneStateful from "../../reconnectchatpanestateful/ReconnectChatPaneStateful";
28
+ import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
26
29
  import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
27
30
  import WebChatContainerStateful from "../../webchatcontainerstateful/WebChatContainerStateful";
28
31
  import { createFooter } from "../common/createFooter";
29
32
  import { createInternetConnectionChangeHandler } from "../common/createInternetConnectionChangeHandler";
30
33
  import { defaultWebChatContainerStatefulProps } from "../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps";
34
+ import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
31
35
  import { endChat } from "../common/endChat";
32
36
  import { getGeneralStylesForButton } from "../common/getGeneralStylesForButton";
33
37
  import { initCallingSdk } from "../common/initCallingSdk";
@@ -39,9 +43,6 @@ import { startProactiveChat } from "../common/startProactiveChat";
39
43
  import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
40
44
  import useChatContextStore from "../../../hooks/useChatContextStore";
41
45
  import useChatSDKStore from "../../../hooks/useChatSDKStore";
42
- import { TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
43
- import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
44
- import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
45
46
  export const LiveChatWidgetStateful = props => {
46
47
  var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$controlProps12, _props$controlProps13, _props$componentOverr7, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$componentOverr10, _props$componentOverr11;
47
48
 
@@ -142,13 +143,23 @@ export const LiveChatWidgetStateful = props => {
142
143
  }, [state.appStates.skipChatButtonRendering]);
143
144
  useEffect(() => {
144
145
  BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
146
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
147
+ Event: TelemetryEvent.StartProactiveChatEventReceived,
148
+ Description: "Start proactive chat event received."
149
+ });
150
+
145
151
  if (canStartProactiveChat.current) {
146
152
  var _msg$payload, _msg$payload2, _msg$payload3;
147
153
 
148
- startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.bodyTitle, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.showPrechat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
154
+ startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.notificationConfig, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.enablePreChat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
155
+ } else {
156
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
157
+ Event: TelemetryEvent.ChatAlreadyTriggered,
158
+ Description: "Start proactive chat method called, when chat was already triggered."
159
+ });
149
160
  }
150
161
  });
151
- window.addEventListener("beforeunload", event => {
162
+ window.addEventListener("beforeunload", () => {
152
163
  disposeTelemetryLoggers();
153
164
  });
154
165
 
@@ -162,7 +173,7 @@ export const LiveChatWidgetStateful = props => {
162
173
  if (state.appStates.conversationState === ConversationState.Active) {
163
174
  chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.onNewMessage(() => {
164
175
  BroadcastService.postMessage({
165
- eventName: "NewMessageNotification"
176
+ eventName: BroadcastEvent.NewMessageNotification
166
177
  });
167
178
  });
168
179
  } // Track the message count
@@ -187,7 +198,7 @@ export const LiveChatWidgetStateful = props => {
187
198
  });
188
199
  const customEvent = {
189
200
  elementType: ElementType.Custom,
190
- eventName: "UnreadMessageCount",
201
+ eventName: BroadcastEvent.UnreadMessageCount,
191
202
  payload: 0
192
203
  };
193
204
  BroadcastService.postMessage(customEvent);
@@ -197,7 +208,7 @@ export const LiveChatWidgetStateful = props => {
197
208
  if (state.appStates.isMinimized && state.appStates.unreadMessageCount > 0) {
198
209
  const customEvent = {
199
210
  elementType: ElementType.Custom,
200
- eventName: "UnreadMessageCount",
211
+ eventName: BroadcastEvent.UnreadMessageCount,
201
212
  payload: `${state.appStates.unreadMessageCount}`
202
213
  };
203
214
  BroadcastService.postMessage(customEvent);
@@ -212,9 +223,10 @@ export const LiveChatWidgetStateful = props => {
212
223
  }, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
213
224
  const webChatProps = initWebChatComposer(props, chatSDK, state, dispatch, setWebChatStyles);
214
225
 
215
- const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch);
226
+ const setPostChatContextRelay = () => setPostChatContextAndLoadSurvey(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
227
+
216
228
 
217
- const endChatRelay = () => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
229
+ const endChatRelay = (adapter, skipEndChatSDK, skipCloseChat) => endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
218
230
 
219
231
  const prepareStartChatRelay = () => prepareStartChat(props, chatSDK, state, dispatch, setAdapter); // eslint-disable-next-line @typescript-eslint/no-explicit-any
220
232
 
@@ -225,7 +237,7 @@ export const LiveChatWidgetStateful = props => {
225
237
 
226
238
  useEffect(() => {
227
239
  const chatWidgetStateChangeEvent = {
228
- eventName: TelemetryEvent.ChatWidgetStateChanged,
240
+ eventName: BroadcastEvent.ChatWidgetStateChanged,
229
241
  payload: { ...state
230
242
  }
231
243
  };
@@ -1,4 +1,4 @@
1
- import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
1
+ import { BroadcastEvent, LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect, useState } from "react";
3
3
  import { createTimer, setFocusOnElement } from "../../common/utils";
4
4
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
@@ -51,12 +51,12 @@ export const ProactiveChatPaneStateful = props => {
51
51
  if (state.appStates.proactiveChatStates.proactiveChatInNewWindow) {
52
52
  // TODO: BroadcastService: replace with the sdk broadcast service, when in place
53
53
  const startPopoutChatEvent = {
54
- eventName: "StartPopoutChat"
54
+ eventName: BroadcastEvent.ProactiveChatStartPopoutChat
55
55
  };
56
56
  BroadcastService.postMessage(startPopoutChatEvent);
57
57
  dispatch({
58
- type: LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
59
- payload: true
58
+ type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
59
+ payload: ConversationState.Closed
60
60
  });
61
61
  } else if (((_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") {
62
62
  dispatch({
@@ -68,6 +68,10 @@ export const ProactiveChatPaneStateful = props => {
68
68
  payload: ConversationState.OutOfOffice
69
69
  });
70
70
  } else {
71
+ const proactiveChatStarted = {
72
+ eventName: BroadcastEvent.ProactiveChatStartChat
73
+ };
74
+ BroadcastService.postMessage(proactiveChatStarted);
71
75
  await startChat();
72
76
  }
73
77
  },
@@ -14,6 +14,10 @@ export class MockChatSDK {
14
14
  return null;
15
15
  }
16
16
 
17
+ getChatToken() {
18
+ return null;
19
+ }
20
+
17
21
  createChatAdapter() {
18
22
  return new MockAdapter();
19
23
  } // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1,16 +1,6 @@
1
- import { BrowserVendor } from "../../webchatcontroller/enums/BrowserVendor";
1
+ import { ArchiveIcon, AudioIcon, BlankIcon, ExcelIcon, ImageIcon, OneNoteIcon, PDFIcon, PowerpointIcon, VideoIcon, VisioIcon, WordIcon } from "../../../../assets/Icons";
2
2
  import { getBrowserName, isChromiumEdge } from "./BrowserInfo";
3
- import ArchiveIcon from "../../../../assets/icons/archiveIcon.svg";
4
- import AudioIcon from "../../../../assets/icons/audioIcon.svg";
5
- import BlankIcon from "../../../../assets/icons/blankIcon.svg";
6
- import VideoIcon from "../../../../assets/icons/videoIcon.svg";
7
- import ImageIcon from "../../../../assets/icons/imageIcon.svg";
8
- import WordIcon from "../../../../assets/icons/wordIcon.svg";
9
- import OneNoteIcon from "../../../../assets/icons/oneNoteIcon.svg";
10
- import PowerpointIcon from "../../../../assets/icons/powerpointIcon.svg";
11
- import VisioIcon from "../../../../assets/icons/visioIcon.svg";
12
- import PDFIcon from "../../../../assets/icons/pdfIcon.svg";
13
- import ExcelIcon from "../../../../assets/icons/excelIcon.svg";
3
+ import { BrowserVendor } from "../../webchatcontroller/enums/BrowserVendor";
14
4
  import { Constants } from "../../../../common/Constants";
15
5
  const FileAttachmentIconMap = {
16
6
  "aac": AudioIcon,
@@ -5,59 +5,19 @@
5
5
  * 1. Renders system messages differently, according to Microsoft LiveChatWidget styles
6
6
  * 2. Changes the font size of user messages
7
7
  * 3. Decodes certain html characters that came through from chat services
8
- * 4. Triggers end conversation sequence when the chat thread is deleted
9
8
  ******/
10
- import React from "react";
9
+ import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
11
10
  import { Constants } from "../../../../../common/Constants";
12
11
  import { DirectLineActivityType } from "../../enums/DirectLineActivityType";
13
12
  import { DirectLineSenderRole } from "../../enums/DirectLineSenderRole";
14
13
  import { MessageTypes } from "../../enums/MessageType";
14
+ import React from "react";
15
+ import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
15
16
  import { defaultSystemMessageStyles } from "./defaultStyles/defaultSystemMessageStyles";
16
17
  import { defaultUserMessageStyles } from "./defaultStyles/defaultUserMessageStyles";
17
18
  import { escapeHtml } from "../../../../../common/utils";
18
- import { TelemetryHelper } from "../../../../../common/telemetry/TelemetryHelper";
19
- import { LogLevel, TelemetryEvent } from "../../../../../common/telemetry/TelemetryConstants";
20
19
  const loggedSystemMessages = new Array(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
20
 
22
- const handleThreadUpdate = channelData => {
23
- var _channelData$properti, _channelData$properti2;
24
-
25
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
26
- Event: TelemetryEvent.IC3ThreadUpdateEventReceived,
27
- Description: "IC3 ThreadUpdateEvent Received"
28
- });
29
-
30
- const postConversationEndedAction = () => {
31
- TelemetryHelper.logActionEvent(LogLevel.INFO, {
32
- Event: TelemetryEvent.ConversationEndedThreadEventReceived,
33
- Description: "Conversation is ended by agent side or by timeout."
34
- });
35
- }; // If the Thread is deleted, then display post conversation survey if enabled.
36
-
37
-
38
- const isThreadDeleted = (channelData === null || channelData === void 0 ? void 0 : (_channelData$properti = channelData.properties) === null || _channelData$properti === void 0 ? void 0 : (_channelData$properti2 = _channelData$properti.isdeleted) === null || _channelData$properti2 === void 0 ? void 0 : _channelData$properti2.toLowerCase()) === Constants.true;
39
-
40
- if (isThreadDeleted) {
41
- postConversationEndedAction();
42
- return;
43
- } //check if customer is still in the thread
44
-
45
-
46
- if (channelData.members && channelData.members.length > 0) {
47
- for (let i = 0; i < channelData.members.length; i++) {
48
- const id = channelData.members[i].id;
49
- const tag = channelData.members[i].tag; // In case of ACS customer is not removed from thread and has "left" tag
50
-
51
- if (id.startsWith(Constants.visitorIdPrefix) && tag !== Constants.left) {
52
- return;
53
- }
54
- }
55
- }
56
-
57
- postConversationEndedAction();
58
- }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
-
60
-
61
21
  const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
62
22
  var _card$activity, _card$activity$channe, _card$activity$channe2, _card$activity2, _card$activity2$chann, _card$activity3, _card$activity3$chann, _card$activity3$chann2, _card$activity4, _card$activity4$chann, _card$activity5, _card$activity5$chann, _card$nextVisibleActi, _card$nextVisibleActi2, _card$activity6, _card$activity6$chann, _card$activity7, _card$nextVisibleActi3, _card$activity8;
63
23
 
@@ -108,7 +68,10 @@ export const createActivityMiddleware = (systemMessageStyleProps, userMessageSty
108
68
  var _card$activity$channe3;
109
69
 
110
70
  if (((_card$activity$channe3 = card.activity.channelData) === null || _card$activity$channe3 === void 0 ? void 0 : _card$activity$channe3.type) === MessageTypes.Thread) {
111
- handleThreadUpdate(card.activity.channelData);
71
+ TelemetryHelper.logActionEvent(LogLevel.INFO, {
72
+ Event: TelemetryEvent.IC3ThreadUpdateEventReceived,
73
+ Description: "IC3 ThreadUpdateEvent Received"
74
+ });
112
75
  }
113
76
 
114
77
  return () => false;
@@ -8,6 +8,7 @@
8
8
  import { Constants, MimeTypes, WebChatMiddlewareConstants } from "../../../../../common/Constants";
9
9
  import React from "react";
10
10
  import { getFileAttachmentIconData, isInlineMediaSupported } from "../../../common/utils/FileAttachmentIconManager";
11
+ import { BroadcastEvent } from "../../../../../common/telemetry/TelemetryConstants";
11
12
  import { BroadcastService } from "@microsoft/omnichannel-chat-components";
12
13
  import { WebChatActionType } from "../../enums/WebChatActionType";
13
14
  import { defaultAttachmentAdaptiveCardStyles } from "./defaultStyles/defaultAtttachmentAdaptiveCardStyles";
@@ -187,7 +188,7 @@ const createAttachmentMiddleware = enableInlinePlaying => {
187
188
  } catch (e) {
188
189
  const errorData = "Unable to parse the adaptive card format";
189
190
  BroadcastService.postMessage({
190
- eventName: "InvalidAdaptiveCardFormat",
191
+ eventName: BroadcastEvent.InvalidAdaptiveCardFormat,
191
192
  payload: {
192
193
  Message: errorData,
193
194
  ExceptionDetails: e
@@ -7,6 +7,7 @@ export let ConversationState;
7
7
  ConversationState[ConversationState["OutOfOffice"] = 3] = "OutOfOffice";
8
8
  ConversationState[ConversationState["ProactiveChat"] = 4] = "ProactiveChat";
9
9
  ConversationState[ConversationState["Active"] = 5] = "Active";
10
- ConversationState[ConversationState["Postchat"] = 6] = "Postchat";
11
- ConversationState[ConversationState["Closed"] = 7] = "Closed";
10
+ ConversationState[ConversationState["InActive"] = 6] = "InActive";
11
+ ConversationState[ConversationState["Postchat"] = 7] = "Postchat";
12
+ ConversationState[ConversationState["Closed"] = 8] = "Closed";
12
13
  })(ConversationState || (ConversationState = {}));
@@ -3,6 +3,10 @@ import { defaultMiddlewareLocalizedTexts } from "../../components/webchatcontain
3
3
  export const getLiveChatWidgetContextInitialState = props => {
4
4
  var _props$webChatContain;
5
5
 
6
+ if (props !== null && props !== void 0 && props.liveChatContextFromCache) {
7
+ return props === null || props === void 0 ? void 0 : props.liveChatContextFromCache;
8
+ }
9
+
6
10
  const LiveChatWidgetContextInitialState = {
7
11
  domainStates: {
8
12
  liveChatConfig: props.chatConfig,
@@ -47,5 +51,5 @@ export const getLiveChatWidgetContextInitialState = props => {
47
51
  focusChatButton: false
48
52
  }
49
53
  };
50
- return props.liveChatContextFromCache ?? LiveChatWidgetContextInitialState;
54
+ return LiveChatWidgetContextInitialState;
51
55
  };
@@ -9,13 +9,13 @@ export const shouldShowHeader = state => {
9
9
  return !state.appStates.isMinimized && state.appStates.conversationState !== ConversationState.Closed && state.appStates.conversationState !== ConversationState.ProactiveChat;
10
10
  };
11
11
  export const shouldShowFooter = state => {
12
- return !state.appStates.isMinimized && state.appStates.conversationState === ConversationState.Active;
12
+ return !state.appStates.isMinimized && (state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive);
13
13
  };
14
14
  export const shouldShowEmailTranscriptPane = state => {
15
15
  return state.uiStates.showEmailTranscriptPane;
16
16
  };
17
17
  export const shouldShowWebChatContainer = state => {
18
- return state.appStates.conversationState === ConversationState.Active;
18
+ return state.appStates.conversationState === ConversationState.Active || state.appStates.conversationState === ConversationState.InActive;
19
19
  };
20
20
  export const shouldShowLoadingPane = state => {
21
21
  return !state.appStates.isMinimized && !state.appStates.shouldShowPostChat && state.appStates.conversationState === ConversationState.Loading;