@microsoft/omnichannel-chat-widget 1.8.2-main.5199342 → 1.8.2-main.b882454

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 (78) hide show
  1. package/README.md +48 -1
  2. package/lib/cjs/common/Constants.js +17 -3
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +2 -0
  4. package/lib/cjs/common/utils.js +27 -2
  5. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
  6. package/lib/cjs/components/draggable/DraggableChatWidget.js +16 -1
  7. package/lib/cjs/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
  8. package/lib/cjs/components/livechatwidget/common/createMarkdown.js +54 -1
  9. package/lib/cjs/components/livechatwidget/common/customEventHandler.js +53 -0
  10. package/lib/cjs/components/livechatwidget/common/endChat.js +19 -7
  11. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +33 -1
  12. package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +18 -1
  13. package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +54 -7
  14. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +15 -2
  15. package/lib/cjs/components/livechatwidget/common/startChat.js +6 -4
  16. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -12
  17. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +18 -14
  18. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +42 -0
  19. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -3
  20. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
  21. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +41 -0
  22. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +45 -0
  23. package/lib/cjs/contexts/common/CustomEventType.js +1 -0
  24. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +3 -1
  25. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
  26. package/lib/cjs/contexts/createReducer.js +30 -0
  27. package/lib/cjs/controller/componentController.js +2 -2
  28. package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
  29. package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
  30. package/lib/cjs/firstresponselatency/util.js +60 -31
  31. package/lib/cjs/plugins/newMessageEventHandler.js +12 -6
  32. package/lib/esm/common/Constants.js +15 -2
  33. package/lib/esm/common/telemetry/TelemetryConstants.js +2 -0
  34. package/lib/esm/common/utils.js +21 -0
  35. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +4 -4
  36. package/lib/esm/components/draggable/DraggableChatWidget.js +16 -1
  37. package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +22 -9
  38. package/lib/esm/components/livechatwidget/common/createMarkdown.js +54 -1
  39. package/lib/esm/components/livechatwidget/common/customEventHandler.js +45 -0
  40. package/lib/esm/components/livechatwidget/common/endChat.js +19 -7
  41. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +33 -1
  42. package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +16 -0
  43. package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +56 -9
  44. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +16 -3
  45. package/lib/esm/components/livechatwidget/common/startChat.js +6 -4
  46. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -12
  47. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +18 -14
  48. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.js +36 -0
  49. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +4 -4
  50. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.js +12 -6
  51. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.js +33 -0
  52. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.js +38 -0
  53. package/lib/esm/contexts/common/CustomEventType.js +1 -0
  54. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +3 -1
  55. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
  56. package/lib/esm/contexts/createReducer.js +30 -0
  57. package/lib/esm/controller/componentController.js +2 -2
  58. package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +101 -36
  59. package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +39 -21
  60. package/lib/esm/firstresponselatency/util.js +57 -29
  61. package/lib/esm/plugins/newMessageEventHandler.js +12 -6
  62. package/lib/types/common/Constants.d.ts +14 -2
  63. package/lib/types/common/telemetry/TelemetryConstants.d.ts +2 -0
  64. package/lib/types/common/utils.d.ts +8 -0
  65. package/lib/types/components/livechatwidget/common/customEventHandler.d.ts +4 -0
  66. package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +1 -0
  67. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/callActionMiddleware.d.ts +8 -0
  68. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.d.ts +1 -1
  69. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/conversationEndMiddleware.d.ts +1 -1
  70. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/customEventMiddleware.d.ts +22 -0
  71. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/queueOverflowHandlerMiddleware.d.ts +5 -0
  72. package/lib/types/contexts/common/CustomEventType.d.ts +6 -0
  73. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
  74. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  75. package/lib/types/firstresponselatency/FirstResponseLatencyTracker.d.ts +2 -2
  76. package/lib/types/firstresponselatency/util.d.ts +17 -0
  77. package/lib/types/plugins/newMessageEventHandler.d.ts +1 -1
  78. package/package.json +5 -5
@@ -7,12 +7,16 @@ export declare class Constants {
7
7
  static readonly historyMessageTag = "history";
8
8
  static readonly agentEndConversationMessageTag = "agentendconversation";
9
9
  static readonly supervisorForceCloseMessageTag = "supervisorforceclosedconversation";
10
+ static readonly endConversationalSurveyMessageTag = "endconversationalsurvey";
11
+ static readonly startConversationalSurveyMessageTag = "startconversationalsurvey";
12
+ static readonly c2ConversationalSurveyMessageTag = "c2conversationalsurvey";
10
13
  static readonly receivedMessageClassName = "ms_lcw_webchat_received_message";
11
14
  static readonly sentMessageClassName = "ms_lcw_webchat_sent_message";
12
15
  static readonly webchatChannelId = "webchat";
13
16
  static readonly markdown = "markdown";
14
17
  static readonly actionType = "actionType";
15
18
  static readonly markDownSystemMessageClass = "webchat__basic-transcript__activity-markdown-body";
19
+ static readonly MARKDOWN_LIST_INDENTATION = " ";
16
20
  static readonly String = "string";
17
21
  static readonly ChatMessagesJson = "chatMessagesJson";
18
22
  static readonly truePascal = "True";
@@ -80,8 +84,7 @@ export declare class Constants {
80
84
  static readonly TargetRelationship = "rel";
81
85
  static readonly TargetRelationshipAttributes = "noopener noreferrer";
82
86
  static readonly OpenLinkIconCssClass = "webchat__render-markdown__external-link-icon";
83
- static readonly internetConnectionTestUrl = "https://ocsdk-prod.azureedge.net/public/connecttest.txt";
84
- static readonly internetConnectionTestUrlText = "Omnichannel Connect Test";
87
+ static readonly internetConnectionTestPath = "/livechatwidget/version.txt";
85
88
  static readonly ChatWidgetStateChangedPrefix = "ChatWidgetStateChanged";
86
89
  static readonly PostChatLoadingDurationInMs = 2000;
87
90
  static readonly BrowserUnloadConfirmationMessage = "Do you want to leave chat?";
@@ -94,6 +97,12 @@ export declare class Constants {
94
97
  static readonly OCOriginalMessageId = "OriginalMessageId";
95
98
  static readonly WebchatSequenceIdAttribute = "webchat:sequence-id";
96
99
  static readonly MessageSequenceIdOverride = "MessageSequenceIdOverride";
100
+ static readonly sendCustomEvent = "sendCustomEvent";
101
+ static readonly onCustomEvent = "onCustomEvent";
102
+ static readonly customEventName = "customEventName";
103
+ static readonly customEventValue = "customEventValue";
104
+ static readonly Hidden = "Hidden";
105
+ static readonly EndConversationDueToOverflow = "endconversationduetooverflow";
97
106
  }
98
107
  export declare const Regex: {
99
108
  new (): {};
@@ -180,6 +189,9 @@ export declare enum ConversationMode {
180
189
  Regular = "192350000",
181
190
  Persistent = "192350001"
182
191
  }
192
+ export declare enum SurveyProvider {
193
+ MicrosoftCopilotStudio = "600990001"
194
+ }
183
195
  export declare enum LiveWorkItemState {
184
196
  Active = "Active",
185
197
  Closed = "Closed",
@@ -172,6 +172,7 @@ export declare enum TelemetryEvent {
172
172
  BotAuthActivityUndefinedSignInId = "BotAuthActivityUndefinedSignInId",
173
173
  ThirdPartyCookiesBlocked = "ThirdPartyCookiesBlocked",
174
174
  ParticipantsRemovedEvent = "ParticipantsRemovedEvent",
175
+ QueueOverflowEvent = "QueueOverflowEvent",
175
176
  ProcessingHTMLTextMiddlewareFailed = "ProcessingHTMLTextMiddlewareFailed",
176
177
  ProcessingSanitizationMiddlewareFailed = "ProcessingSanitizationMiddlewareFailed",
177
178
  FormatTagsMiddlewareJSONStringifyFailed = "FormatTagsMiddlewareJSONStringifyFailed",
@@ -210,6 +211,7 @@ export declare enum TelemetryEvent {
210
211
  SystemMessageReceived = "SystemMessageReceived",
211
212
  RehydrateMessageReceived = "RehydrateMessageReceived",
212
213
  CustomContextReceived = "CustomContextReceived",
214
+ CustomEventAction = "CustomEventAction",
213
215
  NetworkDisconnected = "NetworkDisconnected",
214
216
  NetworkReconnected = "NetworkReconnected",
215
217
  LinkModePostChatWorkflowStarted = "LinkModePostChatWorkflowStarted",
@@ -1,5 +1,6 @@
1
1
  import { FacadeChatSDK } from "./facades/FacadeChatSDK";
2
2
  import { ITimer } from "./interfaces/ITimer";
3
+ import * as CustomEventType from "../contexts/common/CustomEventType";
3
4
  export declare const setTabIndices: (elements: HTMLElement[] | null, tabIndexMap: Map<string, number>, shouldBeFocusable: boolean) => void;
4
5
  export declare const findParentFocusableElementsWithoutChildContainer: (elementId: string) => HTMLElement[] | null;
5
6
  export declare const findAllFocusableElement: (parent: string | HTMLElement) => any[] | null;
@@ -47,3 +48,10 @@ export declare const formatTemplateString: (templateMessage: string, values: any
47
48
  export declare const parseLowerCaseString: (property: string | boolean | undefined) => string;
48
49
  export declare const setOcUserAgent: (chatSDK: any) => void;
49
50
  export declare function getDeviceType(): string;
51
+ export declare const isValidCustomEvent: (payload: object) => boolean;
52
+ export declare const getCustomEventValue: (customEventPayload: CustomEventType.ICustomEvent) => string;
53
+ export declare function isEndConversationDueToOverflowActivity(activity: {
54
+ channelData?: {
55
+ tags?: string[];
56
+ };
57
+ }): boolean | undefined;
@@ -0,0 +1,4 @@
1
+ import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
3
+ export declare const customEventCallback: (facadeChatSDK: FacadeChatSDK) => (event: object) => void;
4
+ export declare const subscribeToSendCustomEvent: (broadcastService: typeof BroadcastService, facadeChatSDK: FacadeChatSDK, customEventCallback: (fackageSdK: FacadeChatSDK) => (event: object) => void) => void;
@@ -1,3 +1,4 @@
1
1
  import { FacadeChatSDK } from "../../../common/facades/FacadeChatSDK";
2
2
  export declare const isPostChatSurveyEnabled: (facadeChatSDK: FacadeChatSDK) => Promise<boolean>;
3
+ export declare const getPostChatSurveyConfig: (facadeChatSDK: FacadeChatSDK) => Promise<any>;
3
4
  export declare const isPersistentChatEnabled: (conversationMode: string | undefined) => boolean;
@@ -0,0 +1,8 @@
1
+ /******
2
+ * CallActionMiddleware
3
+ *
4
+ * Intercepts custom call actions and handles tel: URL navigation
5
+ ******/
6
+ import { IWebChatAction } from "../../../interfaces/IWebChatAction";
7
+ declare const createCallActionMiddleware: () => () => (next: any) => (action: IWebChatAction) => any;
8
+ export default createCallActionMiddleware;
@@ -4,7 +4,7 @@
4
4
  * Adds necessary tags if not present so that the rendering middlewares can process them later.
5
5
  ******/
6
6
  import { IWebChatAction } from "../../../interfaces/IWebChatAction";
7
- declare const channelDataMiddleware: ({ dispatch }: {
7
+ declare const channelDataMiddleware: (addConversationalSurveyTagsCallback: any) => ({ dispatch }: {
8
8
  dispatch: any;
9
9
  }) => (next: any) => (action: IWebChatAction) => any;
10
10
  export default channelDataMiddleware;
@@ -5,7 +5,7 @@
5
5
  * The callback is then invoked to hide the send box (by default).
6
6
  ******/
7
7
  import { IWebChatAction } from "../../../interfaces/IWebChatAction";
8
- declare const createConversationEndMiddleware: (conversationEndCallback: any) => ({ dispatch }: {
8
+ declare const createConversationEndMiddleware: (conversationEndCallback: any, startConversationalSurveyCallback: any, endConversationalSurveyCallback: any) => ({ dispatch }: {
9
9
  dispatch: any;
10
10
  }) => (next: any) => (action: IWebChatAction) => any;
11
11
  export default createConversationEndMiddleware;
@@ -0,0 +1,22 @@
1
+ /******
2
+ * CustomEventMiddleware
3
+ *
4
+ * This middleware is invoked when a custom event is received.
5
+ * The callback is then invoked to handle the custom event.
6
+ ******/
7
+ import { IWebChatAction } from "../../../interfaces/IWebChatAction";
8
+ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
9
+ export declare const isValidCustomEvent: (activity: {
10
+ channelData?: {
11
+ metadata?: {
12
+ customEvent?: string;
13
+ customEventName?: string;
14
+ customEventValue?: unknown;
15
+ };
16
+ };
17
+ from?: {
18
+ role: string;
19
+ };
20
+ }) => boolean;
21
+ declare const createCustomEventMiddleware: (broadcastservice: typeof BroadcastService) => () => (next: (action: IWebChatAction) => void) => (action: IWebChatAction) => void;
22
+ export default createCustomEventMiddleware;
@@ -0,0 +1,5 @@
1
+ import { IWebChatAction } from "../../../interfaces/IWebChatAction";
2
+ import { ILiveChatWidgetContext } from "../../../../../contexts/common/ILiveChatWidgetContext";
3
+ import { Dispatch } from "react";
4
+ import { ILiveChatWidgetAction } from "../../../../../contexts/common/ILiveChatWidgetAction";
5
+ export declare const createQueueOverflowMiddleware: (state: ILiveChatWidgetContext, dispatch: Dispatch<ILiveChatWidgetAction>) => () => (next: (action: IWebChatAction) => void) => (action: IWebChatAction) => void;
@@ -0,0 +1,6 @@
1
+ export interface ICustomEvent {
2
+ messageId?: string;
3
+ customEvent?: string;
4
+ customEventName: string;
5
+ customEventValue: unknown;
6
+ }
@@ -48,6 +48,8 @@ export interface ILiveChatWidgetContext {
48
48
  chatDisconnectEventReceived: boolean;
49
49
  selectedSurveyMode: string | null;
50
50
  postChatParticipantType: undefined | ParticipantType;
51
+ isConversationalSurvey: boolean;
52
+ isConversationalSurveyEnabled: boolean;
51
53
  };
52
54
  uiStates: {
53
55
  showConfirmationPane: boolean;
@@ -44,5 +44,7 @@ export declare enum LiveChatWidgetActionType {
44
44
  SET_SURVEY_MODE = 42,
45
45
  SET_CONFIRMATION_STATE = 43,
46
46
  SET_POST_CHAT_PARTICIPANT_TYPE = 44,
47
- GET_IN_MEMORY_STATE = 45
47
+ SET_CONVERSATIONAL_SURVEY_ENABLED = 45,
48
+ SET_CONVERSATIONAL_SURVEY_DISPLAY = 46,
49
+ GET_IN_MEMORY_STATE = 47
48
50
  }
@@ -1,11 +1,11 @@
1
1
  import { MessagePayload } from "./Constants";
2
2
  export declare class FirstResponseLatencyTracker {
3
3
  private isABotConversation;
4
- private isStarted;
5
- private isEnded;
4
+ private isTracking;
6
5
  private startTrackingMessage?;
7
6
  private stopTrackingMessage?;
8
7
  private isReady;
8
+ private trackingTimeoutId?;
9
9
  constructor();
10
10
  private createTrackingMessage;
11
11
  private startTracking;
@@ -1,6 +1,23 @@
1
1
  import { MessagePayload, ScenarioType, TrackingMessage } from "./Constants";
2
2
  import { IActivity } from "botframework-directlinejs";
3
+ /**
4
+ * Determines whether a given activity is a historical message.
5
+ *
6
+ * This function checks if the activity is a message type and uses a combination
7
+ * of legacy tags and timestamp-based logic to determine if the message is historical.
8
+ *
9
+ * @param {IActivity} activity - The activity object to evaluate.
10
+ * @param {number} startTime - The start time (in milliseconds since epoch) to compare against.
11
+ * @returns {boolean} - Returns true if the activity is a historical message, false otherwise.
12
+ *
13
+ * Logic:
14
+ * - If the activity type is not a message, it is not historical.
15
+ * - If the activity contains a legacy history message tag, it is considered historical.
16
+ * - Otherwise, the function extracts a timestamp from the activity ID using `extractTimestampFromId`.
17
+ * - If the ID is valid and the timestamp is older than the start time, the message is historical.
18
+ */
3
19
  export declare const isHistoryMessage: (activity: IActivity, startTime: number) => boolean;
20
+ export declare const extractTimestampFromId: (activity: IActivity) => number;
4
21
  export declare const buildMessagePayload: (activity: IActivity, userId: string) => MessagePayload;
5
22
  export declare const polyfillMessagePayloadForEvent: (activity: IActivity, payload: MessagePayload, conversationId?: string) => MessagePayload;
6
23
  export declare const getScenarioType: (activity: IActivity) => ScenarioType;
@@ -1,2 +1,2 @@
1
1
  import { IActivity } from "botframework-directlinejs";
2
- export declare const createOnNewAdapterActivityHandler: (chatId: string, userId: string) => (activity: IActivity) => void;
2
+ export declare const createOnNewAdapterActivityHandler: (chatId: string, userId: string, startTime: number) => (activity: IActivity) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.8.2-main.5199342",
3
+ "version": "1.8.2-main.b882454",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -86,8 +86,8 @@
86
86
  "dependencies": {
87
87
  "@azure/core-tracing": "^1.2.0",
88
88
  "@microsoft/applicationinsights-web": "^3.3.6",
89
- "@microsoft/omnichannel-chat-components": "1.1.12",
90
- "@microsoft/omnichannel-chat-sdk": "^1.11.4",
89
+ "@microsoft/omnichannel-chat-components": "1.1.13",
90
+ "@microsoft/omnichannel-chat-sdk": "^1.11.6",
91
91
  "@opentelemetry/api": "^1.9.0",
92
92
  "abort-controller": "^3",
93
93
  "abort-controller-es5": "^2.0.1",
@@ -121,8 +121,8 @@
121
121
  "build:umd": "webpack --config ./webpack.umd.config.cjs",
122
122
  "verify": "yarn install && yarn build-storybook && yarn test:all && yarn build && yarn storybook",
123
123
  "testpack": "yarn build && yarn pack",
124
- "build-sample": "yarn build && webpack --config ./webpack.config.cjs",
125
- "build-sample:dev": "yarn build && webpack --config ./webpack.dev.config.cjs",
124
+ "build-sample": "yarn build && cross-env NODE_OPTIONS=--openssl-legacy-provider webpack --config ./webpack.config.cjs",
125
+ "build-sample:dev": "yarn build && cross-env NODE_OPTIONS=--openssl-legacy-provider webpack --config ./webpack.dev.config.cjs",
126
126
  "test:visual:build": "yarn build-storybook && yarn test:visual",
127
127
  "lint": "yarn eslint . --max-warnings=0",
128
128
  "prepush": "yarn lint && yarn danger:prepush",