@microsoft/omnichannel-chat-widget 0.1.0-main.3d1c026 → 0.1.0-main.7338c17

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 (58) hide show
  1. package/README.md +235 -0
  2. package/lib/cjs/common/Constants.js +2 -0
  3. package/lib/cjs/common/contextDataStore/DataStoreManager.js +14 -0
  4. package/lib/cjs/common/interfaces/IContextDataStore.js +1 -0
  5. package/lib/cjs/common/telemetry/TelemetryConstants.js +5 -1
  6. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +15 -28
  7. package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
  8. package/lib/cjs/components/livechatwidget/common/endChat.js +7 -3
  9. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +5 -0
  10. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +6 -12
  11. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +20 -3
  12. package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +23 -22
  13. package/lib/cjs/components/livechatwidget/common/startChat.js +72 -26
  14. package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
  15. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +27 -11
  16. package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  17. package/lib/cjs/components/ooohpanestateful/OOOHPaneStateful.js +8 -0
  18. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +28 -11
  19. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +10 -4
  20. package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  21. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +2 -0
  22. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
  23. package/lib/cjs/contexts/createReducer.js +13 -0
  24. package/lib/esm/common/Constants.js +2 -0
  25. package/lib/esm/common/contextDataStore/DataStoreManager.js +5 -0
  26. package/lib/esm/common/interfaces/IContextDataStore.js +1 -0
  27. package/lib/esm/common/telemetry/TelemetryConstants.js +5 -1
  28. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +15 -28
  29. package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +2 -2
  30. package/lib/esm/components/livechatwidget/common/endChat.js +7 -3
  31. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +3 -0
  32. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +6 -12
  33. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +18 -3
  34. package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +22 -22
  35. package/lib/esm/components/livechatwidget/common/startChat.js +67 -22
  36. package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
  37. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +26 -11
  38. package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +1 -1
  39. package/lib/esm/components/ooohpanestateful/OOOHPaneStateful.js +6 -0
  40. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +26 -10
  41. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +8 -4
  42. package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
  43. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +2 -0
  44. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
  45. package/lib/esm/contexts/createReducer.js +13 -0
  46. package/lib/types/common/Constants.d.ts +1 -0
  47. package/lib/types/common/contextDataStore/DataStoreManager.d.ts +4 -0
  48. package/lib/types/common/interfaces/IContextDataStore.d.ts +14 -0
  49. package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -0
  50. package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
  51. package/lib/types/components/livechatwidget/common/startChat.d.ts +1 -1
  52. package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
  53. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +3 -1
  54. package/lib/types/components/prechatsurveypanestateful/interfaces/IPreChatSurveyPaneStatefulParams.d.ts +1 -1
  55. package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
  56. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  57. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +3 -1
  58. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,235 @@
1
+ # Omnichannel Live Chat Widget UI Components
2
+
3
+ ![Release CI](https://github.com/microsoft/omnichannel-chat-widget/workflows/chat-components-release/badge.svg) [![npm version](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-components.svg)](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-components.svg) ![npm](https://img.shields.io/npm/dm/@microsoft/omnichannel-chat-components)\
4
+ ![Release CI](https://github.com/microsoft/omnichannel-chat-widget/workflows/chat-widget-release/badge.svg) [![npm version](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-widget.svg)](https://badge.fury.io/js/%40microsoft%2Fomnichannel-chat-widget.svg) ![npm](https://img.shields.io/npm/dm/@microsoft/omnichannel-chat-widget)
5
+
6
+ [@microsoft/omnichannel-chat-widget](https://www.npmjs.com/package/@microsoft/omnichannel-chat-widget) is a React-based UI component library which allows you to build your own live chat widget experience using [@microsoft/omnichannel-chat-sdk](https://www.npmjs.com/package/@microsoft/omnichannel-chat-sdk).
7
+
8
+ ## Table of Contents
9
+
10
+ 1. [Introduction](#introduction)
11
+ 1. [Installation](#installation)
12
+ 1. [Example Usage](#example-usage)
13
+ 1. [Components](#components)
14
+ 1. [Telemetry](#telemetry)
15
+ 1. [Features](#features)
16
+
17
+ ## Introduction
18
+
19
+ Omnichannel Live Chat Widget UI Components offers a re-usable component-based library to help create a custom chat widget that can be connected to the Dynamics 365 Customer Service experience.
20
+
21
+ For more information about Live Chat Widget, see [here](https://docs.microsoft.com/en-us/dynamics365/customer-service/set-up-chat-widget).
22
+
23
+ ## Installation
24
+
25
+ ```powershell
26
+ npm i @microsoft/omnichannel-chat-sdk
27
+ npm i @microsoft/omnichannel-chat-widget
28
+ ```
29
+
30
+ or
31
+
32
+ ```powershell
33
+ yarn add @microsoft/omnichannel-chat-sdk
34
+ yarn add @microsoft/omnichannel-chat-widget
35
+ ```
36
+
37
+ The repo also contains the ```@microsoft/omnichannel-chat-components``` package, which is a collection of UI components. The ```@microsoft/omnichannel-chat-widget``` package is an integration of the Chat SDK and the UI components. To install the UI components separately, do
38
+
39
+ ```powershell
40
+ npm i @microsoft/omnichannel-chat-components
41
+ ```
42
+
43
+ or
44
+
45
+ ```powershell
46
+ yarn add @microsoft/omnichannel-chat-components
47
+ ```
48
+
49
+ ## Example Usage
50
+
51
+ The basic example below takes in the ```<LiveChatWidget/>``` component along with the Chat SDK to create a customized Omnichannel chat widget.
52
+ > :warning: The Chat SDK has to be **_initialized_** before being passed in.
53
+
54
+ ```js
55
+ import * as React from "react";
56
+
57
+ import { LiveChatWidget } from "@microsoft/omnichannel-chat-widget";
58
+ import { OmnichannelChatSDK } from "@microsoft/omnichannel-chat-sdk";
59
+ import ReactDOM from "react-dom";
60
+ //Below version numbers will help us to troubleshoot issues with specific package
61
+ import { version as chatSdkVersion } from "@microsoft/omnichannel-chat-sdk/package.json";
62
+ import { version as chatWidgetVersion } from "../package.json";
63
+ import { version as chatComponentVersion } from "@microsoft/omnichannel-chat-components/package.json";
64
+
65
+ const render = async () => {
66
+ const omnichannelConfig = {
67
+ orgId: "00000000-0000-0000-0000-000000000000", // dummy config
68
+ orgUrl: "https://www.org-url.com", // dummy config
69
+ widgetId: "00000000-0000-0000-0000-000000000000" // dummy config
70
+ };
71
+ const chatSDK = new OmnichannelChatSDK(omnichannelConfig);
72
+ await chatSDK.initialize(); // mandatory
73
+ const chatConfig = await chatSDK.getLiveChatConfig();
74
+ const liveChatWidgetProps = {
75
+ styleProps: {
76
+ generalStyles: {
77
+ width: "700px",
78
+ height: "800px"
79
+ }
80
+ },
81
+ headerProps: {
82
+ controlProps: {
83
+ hideMinimizeButton: true
84
+ }
85
+ },
86
+ chatSDK: chatSDK, // mandatory
87
+ chatConfig: chatConfig, // mandatory
88
+ telemetryConfig: { //mandatory
89
+ orgId: omnichannelConfig.orgId,
90
+ orgUrl: omnichannelConfig.orgUrl,
91
+ appId: omnichannelConfig.widgetId,
92
+ OCChatSDKVersion: chatSdkVersion,
93
+ chatComponentVersion: chatComponentVersion,
94
+ chatWidgetVersion: chatWidgetVersion
95
+ }
96
+ };
97
+
98
+ ReactDOM.render(
99
+ <LiveChatWidget {...liveChatWidgetProps}/>,
100
+ document.getElementById("my-container")
101
+ );
102
+ };
103
+
104
+ render();
105
+ ```
106
+
107
+ A sample widget can be found in this repo [here](https://github.com/microsoft/omnichannel-chat-widget/tree/main/chat-widget/sample). To build it, do ```yarn build-sample``` or ```yarn build-sample:dev``` from project root.
108
+
109
+ ## Components
110
+
111
+ ### Stateless UI Components
112
+
113
+ These are components that are included in the ```@microsoft/omnichannel-chat-components``` package.
114
+
115
+ | Component | Usage | Interface |
116
+ | ----- | -------- | ----- |
117
+ | CallingContainerPane | The container for voice and video feature in the chat widget | [ICallingContainerProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/callingcontainer/interfaces/ICallingContainerProps.ts) |
118
+ | ChatButton | The button that appears on the user's portal that is designed to be the entry point for the user to initate chat | [IChatButtonProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/chatbutton/interfaces/IChatButtonProps.ts) |
119
+ | CommandButton | A customizable button component that can be injected to the header and/or footer | [ICommandButtonProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/common/interfaces/ICommandButtonProps.ts)|
120
+ | ConfirmationPane | The default pane used when the Header close button is launched | [IConfirmationPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/confirmationpane/interfaces/IConfirmationPaneProps.ts) |
121
+ | Footer | The bottom container of the chat containing the download transcript, notification sound and email transcript buttons by default. | [IFooterProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/footer/interfaces/IFooterProps.ts) |
122
+ | Header | The top container of the chat containing the default minimize, close and title of the chat widget | [IHeaderProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/header/interfaces/IHeaderProps.ts) |
123
+ | InputValidationPane | A pop-up input pane with validation. In the default widget this is used as part of [EmailTranscriptPane](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-widget/src/components/emailtranscriptpanestateful/interfaces/IEmailTranscriptPaneProps.ts) | [IInputValidationPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/inputvalidationpane/interfaces/IInputValidationPaneProps.ts) |
124
+ | LoadingPane | The default pane used after the chat button is clicked and before the chat loads completely | [ILoadingPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/loadingpane/interfaces/ILoadingPaneProps.ts) |
125
+ | OutOfOfficeHoursPane | The pane that is displayed when the chat is outside of operating hours set on admin side | [IOOOHPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/outofofficehourspane/interfaces/IOOOHPaneProps.ts) |
126
+ | PostChatSurveyPane | The pane that holds the [Customer Voice](https://dynamics.microsoft.com/en-us/customer-voice/overview/) survey which would be used by the customer to input their chat experience, provide user ratings etc. It uses an IFrame to render the survey URL fetched from `getPostChatSurveyContext` call from [OmniChannel ChatSDK](https://github.com/microsoft/omnichannel-chat-sdk#get-postchat-survey). | [IPostChatSurveyPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/postchatsurveypane/interfaces/IPostChatSurveyPaneProps.ts) |
127
+ | PreChatSurveyPane | The pane that holds the form which would be used by the customer to input helpful information for using the Support Chat before starting up the Chat Process. Makes use of [AdaptiveCards](https://adaptivecards.io/) | [IPreChatSurveyPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/prechatsurveypane/interfaces/IPreChatSurveyPaneProps.ts) |
128
+ | ProactiveChatSurveyPane | A pane that holds more information than a normal chat button and can be configured to proactively pop up | [IProactiveChatPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/proactivechatpane/interfaces/IProactiveChatPaneProps.ts) |
129
+ | ReconnectChatPane | The pane that shows up when the customer is re-connecting to the chat to add additional conversation | [IReconnectChatPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/reconnectchatpane/interfaces/IReconnectChatPaneProps.ts) |
130
+
131
+ > :warning: Because the components extend Microsoft's [Fluent UI](https://developer.microsoft.com/en-us/fluentui#/) components, the base interface for all the ```styleProps``` in the above table is [IStyle](https://github.com/microsoft/fluentui/blob/master/packages/merge-styles/src/IStyle.ts), which extends the [IRawStyleBase](https://docs.microsoft.com/en-us/javascript/api/merge-styles/irawstylebase?view=office-ui-fabric-react-latest) interface, which is the most useful reference.
132
+
133
+ ### Stateful Components
134
+
135
+ | Component | Default Usage | Interface |
136
+ | ----- | -------- | ----- |
137
+ | LiveChatWidget | The default widget that stitches the UI components with Chat SDK | [ILiveChatWidgetProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-widget/src/components/livechatwidget/interfaces/ILiveChatWidgetProps.ts) |
138
+
139
+ Some of the interfaces listed in the Stateless table have Stateful counterparts defined in the ```@microsoft/omnichannel-chat-widget``` package. For example, [IConfirmationPaneStatefulProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-widget/src/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulProps.ts) extends [IConfirmationPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/confirmationpane/interfaces/IConfirmationPaneProps.ts) with additional attributes that only makes sense in the stateful context.
140
+
141
+ ### Default Props
142
+
143
+ For a list of all default props used in the default stateful widget, please see [here](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-widget/src/components/livechatwidget/common/defaultProps/dummyDefaultProps.ts). If you want to change a default prop, you need to explicitly set it and parse the object as the argument to ```<LiveChatWidget/>```
144
+
145
+ ### Custom Components
146
+
147
+ There are two ways to custom the components provided in the library - 1) Replacing components using ComponentOverrides, and 2) Adding custom components in header and footer.
148
+
149
+ #### ComponentOverrides
150
+
151
+ Most sub-components and the default panes provided can be overriden. Components have "componentOverrides" as part of props interface, which consists of ReactNodes or strings for each part of the component. For example, the "ProactiveChatPane" component has a close button, and the close button can be overriden by creating a custom react node and setting it to the "closeButton" attribute of "componentOverrides" interface that is part of the props.
152
+
153
+ ```js
154
+ const customButton = (
155
+ <button style={{
156
+ background: "green",
157
+ height: "80px",
158
+ margin: "30px 15px 0 0",
159
+ padding: "10px",
160
+ width: "160px"
161
+ }}>
162
+ This is a custom button
163
+ </button>
164
+ );
165
+
166
+ const liveChatWidgetProps = {
167
+ proactiveChatPaneProps: {
168
+ componentOverrides: {
169
+ closeButton: customButton
170
+ };
171
+ };
172
+ }
173
+ ```
174
+
175
+ #### Custom Components in Header and Footer
176
+
177
+ Header's and Footer's child components consist of three parts:
178
+
179
+ 1. "leftGroup" - adding child components at the left of the Header/Footer
180
+ 1. "middleGroup" - adding child components in the middle of the Header/Footer
181
+ 1. "rightGroup" - adding child components at the right of the Header/Footer
182
+
183
+ By default Header has the header icon and title on the left and minimize and close buttons on the right, and Footer has Download Transcript and Email Transcript buttons on the left and audio notification button on the right. These components can be overriden with [ComponentOverrides](#ComponentOverrides). In addition, other custom child components can be added to both Header and Footer by creating custom react nodes and adding them to attributes "leftGroup", "middleGroup" or "rightGroup" of "controlProps".
184
+
185
+ ```js
186
+ const buttonStyleProps: IButtonStyles = {
187
+ root: {
188
+ color: "blue",
189
+ height: 25,
190
+ width: 25,
191
+ }
192
+ };
193
+
194
+ const calendarIcon: IIconProps = { iconName: "Calendar" };
195
+ const calendarIconButton = <IconButton
196
+ key="calendarIconButton"
197
+ iconProps={calendarIcon}
198
+ styles={buttonStyleProps}
199
+ title="Calendar">
200
+ </IconButton>;
201
+
202
+ const emojiIcon: IIconProps = { iconName: "Emoji2" };
203
+ const emojiIconButton = <IconButton
204
+ key="emojiIconButton"
205
+ iconProps={emojiIcon}
206
+ styles={buttonStyleProps}
207
+ title="Sentiment">
208
+ </IconButton>;
209
+
210
+ const uploadIcon: IIconProps = { iconName: "Upload" };
211
+ const uploadIconButton = <IconButton
212
+ key="uploadIconButton"
213
+ iconProps={uploadIcon}
214
+ styles={buttonStyleProps}
215
+ title="Upload">
216
+ </IconButton>;
217
+
218
+ const customizedFooterProp: IFooterProps = {
219
+ controlProps: {
220
+ leftGroup: { children: [uploadIconButton] },
221
+ middleGroup: { children: [calendarIconButton] },
222
+ rightGroup: { children: [emojiIconButton] }
223
+ }
224
+ };
225
+ ```
226
+
227
+ > :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
228
+
229
+ ## See Also
230
+
231
+ [Telemetry](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Telemetry.md)\
232
+ [Create LCW widget with Webpack5 and TypeScript](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/BuildingUsingWebpack5.md)\
233
+ [Omnichannel Features](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Features.md)\
234
+ [How to Add Visual Regression Tests](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/VisualRegressionTestingGuide.md)\
235
+ [Security](https://github.com/microsoft/omnichannel-chat-widget/blob/main/SECURITY.md)
@@ -41,6 +41,8 @@ _defineProperty(Constants, "false", "false");
41
41
 
42
42
  _defineProperty(Constants, "maximumUnreadMessageCount", 99);
43
43
 
44
+ _defineProperty(Constants, "widgetStateDataKey", "LcwChatWidgetState");
45
+
44
46
  _defineProperty(Constants, "channelIdKey", "ChannelId-");
45
47
 
46
48
  _defineProperty(Constants, "ChannelId", "lcw");
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DataStoreManager = void 0;
7
+
8
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+
10
+ class DataStoreManager {}
11
+
12
+ exports.DataStoreManager = DataStoreManager;
13
+
14
+ _defineProperty(DataStoreManager, "clientDataStore", void 0);
@@ -0,0 +1 @@
1
+ "use strict";
@@ -115,11 +115,15 @@ exports.TelemetryEvent = TelemetryEvent;
115
115
  TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
116
116
  TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
117
117
  TelemetryEvent["PreChatSurveyStartChatMethodFailed"] = "PreChatSurveyStartChatMethodFailed";
118
+ TelemetryEvent["ChatAlreadyTriggered"] = "ChatAlreadyTriggered";
119
+ TelemetryEvent["StartProactiveChatEventReceived"] = "StartProactiveChatEventReceived";
118
120
  TelemetryEvent["StartProactiveChatMethodFailed"] = "StartProactiveChatMethodFailed";
119
121
  TelemetryEvent["ProactiveChatAccepted"] = "ProactiveChatAccepted";
120
122
  TelemetryEvent["ProactiveChatRejected"] = "ProactiveChatRejected";
121
123
  TelemetryEvent["IncomingProactiveChatScreenLoaded"] = "IncomingProactiveChatScreenLoaded";
122
124
  TelemetryEvent["ProactiveChatClosed"] = "ProactiveChatClosed";
125
+ TelemetryEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
126
+ TelemetryEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
123
127
  TelemetryEvent["ReconnectChatContinueConversation"] = "ReconnectChatContinueConversation";
124
128
  TelemetryEvent["ReconnectChatStartNewConversation"] = "ReconnectChatStartNewConversation";
125
129
  TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
@@ -129,7 +133,6 @@ exports.TelemetryEvent = TelemetryEvent;
129
133
  class TelemetryConstants {
130
134
  static map(eventTypeOrScenarioType) {
131
135
  switch (eventTypeOrScenarioType) {
132
- case TelemetryEvent.StartChatSDKCall:
133
136
  case TelemetryEvent.ParseAdaptiveCardFailed:
134
137
  return ScenarioType.CONFIG_VALIDATION;
135
138
 
@@ -168,6 +171,7 @@ class TelemetryConstants {
168
171
  case TelemetryEvent.HeaderMinimizeButtonClicked:
169
172
  return ScenarioType.ACTIONS;
170
173
 
174
+ case TelemetryEvent.StartChatSDKCall:
171
175
  case TelemetryEvent.StartChatMethodException:
172
176
  case TelemetryEvent.CloseChatMethodException:
173
177
  case TelemetryEvent.StartProactiveChatMethodFailed:
@@ -13,10 +13,6 @@ var _utils = require("../../common/utils");
13
13
 
14
14
  var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
15
15
 
16
- var _Constants = require("../../common/Constants");
17
-
18
- var _ConversationState = require("../../contexts/common/ConversationState");
19
-
20
16
  var _DimLayer = require("../dimlayer/DimLayer");
21
17
 
22
18
  var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
@@ -35,6 +31,8 @@ var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatCo
35
31
 
36
32
  var _useChatSDKStore = _interopRequireDefault(require("../../hooks/useChatSDKStore"));
37
33
 
34
+ var _Constants = require("../../common/Constants");
35
+
38
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
37
 
40
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -46,14 +44,14 @@ const ConfirmationPaneStateful = props => {
46
44
  var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
47
45
 
48
46
  const initialTabIndexMap = new Map();
49
- let elements = [];
47
+ let elements = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+
49
+ const chatSDK = (0, _useChatSDKStore.default)();
50
50
  const [state, dispatch] = (0, _useChatContextStore.default)();
51
51
  const {
52
- setPostChatContext,
53
52
  endChat
54
53
  } = props; // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
-
56
- const chatSDK = (0, _useChatSDKStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
57
55
 
58
56
  const [adapter] = (0, _useChatAdapterStore.default)();
59
57
  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;
@@ -62,7 +60,7 @@ const ConfirmationPaneStateful = props => {
62
60
  id: "oc-lcw-confirmation-pane",
63
61
  dir: state.domainStates.globalDir,
64
62
  onConfirm: async () => {
65
- _TelemetryHelper.TelemetryHelper.logConfigDataEvent(_TelemetryConstants.LogLevel.INFO, {
63
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
66
64
  Event: _TelemetryConstants.TelemetryEvent.ConfirmationConfirmButtonClicked,
67
65
  Description: "Confirmation pane Confirm button clicked"
68
66
  });
@@ -73,26 +71,15 @@ const ConfirmationPaneStateful = props => {
73
71
  });
74
72
 
75
73
  try {
76
- //ToDo: End Chat before PostChat Context and conversation Details is set once the getPostChatContext request ID fetch issue is fixed
77
- const conversationDetails = await chatSDK.getConversationDetails(); // ToDo: Replace with CanRenderPostChat once available in conversationDetails API response
74
+ // check agent has joined conversation
75
+ const conversationDetails = await chatSDK.getConversationDetails();
78
76
 
79
77
  if (isPostChatEnabled === "true" && postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed && conversationDetails.canRenderPostChat === _Constants.Constants.truePascal) {
80
- dispatch({
81
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT,
82
- payload: true
83
- });
84
- dispatch({
85
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
86
- payload: _ConversationState.ConversationState.Loading
87
- });
88
- await setPostChatContext();
89
-
90
- if (state.domainStates.postChatContext) {
91
- dispatch({
92
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
93
- payload: _ConversationState.ConversationState.Postchat
94
- });
95
- }
78
+ const loadPostChatEvent = {
79
+ eventName: "LoadPostChatSurvey"
80
+ };
81
+
82
+ _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
96
83
  } else {
97
84
  (0, _utils.setTabIndices)(elements, initialTabIndexMap, true);
98
85
 
@@ -119,7 +106,7 @@ const ConfirmationPaneStateful = props => {
119
106
  }
120
107
  },
121
108
  onCancel: () => {
122
- _TelemetryHelper.TelemetryHelper.logConfigDataEvent(_TelemetryConstants.LogLevel.INFO, {
109
+ _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
123
110
  Event: _TelemetryConstants.TelemetryEvent.ConfirmationCancelButtonClicked,
124
111
  Description: "Confirmation pane Cancel button clicked."
125
112
  });
@@ -95,8 +95,8 @@ const EmailTranscriptPaneStateful = props => {
95
95
  },
96
96
  onCancel: () => {
97
97
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
98
- Event: _TelemetryConstants.TelemetryEvent.EmailTranscriptButtonClicked,
99
- Description: "Email Transcript button clicked."
98
+ Event: _TelemetryConstants.TelemetryEvent.EmailTranscriptCancelButtonClicked,
99
+ Description: "Email Transcript cancel button clicked."
100
100
  });
101
101
 
102
102
  closeEmailTranscriptPane();
@@ -7,6 +7,8 @@ exports.endChat = void 0;
7
7
 
8
8
  var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
9
9
 
10
+ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
11
+
10
12
  var _ConversationState = require("../../../contexts/common/ConversationState");
11
13
 
12
14
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
@@ -21,14 +23,12 @@ var _WebChatStoreLoader = require("../../webchatcontainerstateful/webchatcontrol
21
23
 
22
24
  var _defaultWebChatContainerStatefulProps = require("../../webchatcontainerstateful/common/defaultProps/defaultWebChatContainerStatefulProps");
23
25
 
24
- var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
25
-
26
26
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
27
27
  const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter) => {
28
28
  try {
29
29
  var _props$webChatContain;
30
30
 
31
- _TelemetryHelper.TelemetryHelper.logConfigDataEvent(_TelemetryConstants.LogLevel.INFO, {
31
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
32
32
  Event: _TelemetryConstants.TelemetryEvent.EndChatSDKCall
33
33
  });
34
34
 
@@ -59,6 +59,10 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
59
59
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
60
60
  payload: undefined
61
61
  });
62
+ dispatch({
63
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
64
+ payload: undefined
65
+ });
62
66
 
63
67
  _omnichannelChatComponents.BroadcastService.postMessage({
64
68
  eventName: "EndChat"
@@ -17,6 +17,11 @@ const initCallingSdk = async (chatSDK, setVoiceVideoCallingSDK) => {
17
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
18
  const callingSDK = await chatSDK.getVoiceVideoCalling();
19
19
  setVoiceVideoCallingSDK(callingSDK);
20
+
21
+ _TelemetryHelper.TelemetryHelper.logCallingEvent(_TelemetryConstants.LogLevel.ERROR, {
22
+ Event: _TelemetryConstants.TelemetryEvent.CallingSDKLoadSuccess
23
+ });
24
+
20
25
  return true;
21
26
  }
22
27
 
@@ -7,8 +7,6 @@ exports.initWebChatComposer = void 0;
7
7
 
8
8
  var _botframeworkWebchat = require("botframework-webchat");
9
9
 
10
- var _ConversationState = require("../../../contexts/common/ConversationState");
11
-
12
10
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
13
11
 
14
12
  var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
@@ -55,7 +53,7 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
55
53
 
56
54
  var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
57
55
 
58
- var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurvey");
56
+ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
59
57
 
60
58
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
61
59
 
@@ -89,15 +87,11 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
89
87
  }
90
88
 
91
89
  if (isPostChatEnabled === "true" && postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
92
- dispatch({
93
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT,
94
- payload: true
95
- });
96
- dispatch({
97
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
98
- payload: _ConversationState.ConversationState.Loading
99
- });
100
- await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
90
+ const loadPostChatEvent = {
91
+ eventName: "LoadPostChatSurvey"
92
+ };
93
+
94
+ _omnichannelChatComponents.BroadcastService.postMessage(loadPostChatEvent);
101
95
  } else {
102
96
  dispatch({
103
97
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY_AGENT,
@@ -17,9 +17,21 @@ var _defaultTelemetryInternalData = require("../../../common/telemetry/defaultCo
17
17
 
18
18
  var _defaultTelemetryConfiguration = require("../../../common/telemetry/defaultConfigs/defaultTelemetryConfiguration");
19
19
 
20
+ var _package = require("@microsoft/omnichannel-chat-components/package.json");
21
+
22
+ var _package2 = require("@microsoft/omnichannel-chat-sdk/package.json");
23
+
20
24
  const registerTelemetryLoggers = (props, dispatch) => {
21
25
  var _props$liveChatContex, _props$liveChatContex2;
22
26
 
27
+ let widgetPackageInfo;
28
+
29
+ try {
30
+ widgetPackageInfo = require("@microsoft/omnichannel-chat-widget/package.json");
31
+ } catch (error) {
32
+ widgetPackageInfo = "0.0.0-0";
33
+ }
34
+
23
35
  const telemetryConfig = { ..._defaultTelemetryConfiguration.defaultTelemetryConfiguration,
24
36
  ...props.telemetryConfig
25
37
  };
@@ -29,6 +41,8 @@ const registerTelemetryLoggers = (props, dispatch) => {
29
41
 
30
42
  _TelemetryManager.TelemetryManager.InternalTelemetryData = (_props$liveChatContex3 = props.liveChatContextFromCache) === null || _props$liveChatContex3 === void 0 ? void 0 : (_props$liveChatContex4 = _props$liveChatContex3.domainStates) === null || _props$liveChatContex4 === void 0 ? void 0 : _props$liveChatContex4.telemetryInternalData;
31
43
  } else {
44
+ var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic, _props$chatSDK3, _props$chatSDK3$omnic;
45
+
32
46
  let telemetryData = { ..._defaultTelemetryInternalData.defaultInternalTelemetryData,
33
47
  telemetryConfig: Object.assign({}, _defaultTelemetryConfiguration.defaultTelemetryConfiguration, telemetryConfig),
34
48
  ariaConfig: Object.assign({}, _defaultAriaConfig.defaultAriaConfig, telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.ariaConfigurations)
@@ -39,9 +53,12 @@ const registerTelemetryLoggers = (props, dispatch) => {
39
53
  }
40
54
 
41
55
  telemetryData = _TelemetryHelper.TelemetryHelper.addWidgetDataToTelemetry(telemetryConfig, telemetryData);
42
- telemetryData.OCChatSDKVersion = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.OCChatSDKVersion;
43
- telemetryData.chatComponentVersion = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.chatComponentVersion;
44
- telemetryData.chatWidgetVersion = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.chatWidgetVersion;
56
+ telemetryData.OCChatSDKVersion = _package2.version;
57
+ telemetryData.chatComponentVersion = _package.version;
58
+ telemetryData.chatWidgetVersion = widgetPackageInfo;
59
+ telemetryData.orgId = (_props$chatSDK = props.chatSDK) === null || _props$chatSDK === void 0 ? void 0 : (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) === null || _props$chatSDK$omnich === void 0 ? void 0 : _props$chatSDK$omnich.orgId;
60
+ telemetryData.widgetId = (_props$chatSDK2 = props.chatSDK) === null || _props$chatSDK2 === void 0 ? void 0 : (_props$chatSDK2$omnic = _props$chatSDK2.omnichannelConfig) === null || _props$chatSDK2$omnic === void 0 ? void 0 : _props$chatSDK2$omnic.widgetId;
61
+ telemetryData.orgUrl = (_props$chatSDK3 = props.chatSDK) === null || _props$chatSDK3 === void 0 ? void 0 : (_props$chatSDK3$omnic = _props$chatSDK3.omnichannelConfig) === null || _props$chatSDK3$omnic === void 0 ? void 0 : _props$chatSDK3$omnic.orgUrl;
45
62
  dispatch({
46
63
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_TELEMETRY_DATA,
47
64
  payload: telemetryData
@@ -13,21 +13,25 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
13
13
 
14
14
  var _ConversationState = require("../../../contexts/common/ConversationState");
15
15
 
16
+ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
17
+
16
18
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, loadSurvey) => {
19
+ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
18
20
  try {
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- const context = await chatSDK.getPostChatSurveyContext();
21
-
22
- _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
23
- Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
24
- Description: "Postchat context call succeed."
25
- });
26
-
27
- dispatch({
28
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
29
- payload: context
30
- });
21
+ if (!persistedChat) {
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ const context = await chatSDK.getPostChatSurveyContext();
24
+
25
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
26
+ Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
27
+ Description: "Postchat context call succeed."
28
+ });
29
+
30
+ dispatch({
31
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
32
+ payload: context
33
+ });
34
+ }
31
35
  } catch (ex) {
32
36
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
33
37
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallFailed,
@@ -36,20 +40,17 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, loadSurvey) =>
36
40
  }
37
41
  });
38
42
  }
39
- /* -true: setPostChatContextAndLoadSurvey is called after passing all checks from ConfirmationPane and endChatMiddleware in usual scenario.
40
- -false: Below if condition is needed for multi-tab scenarios. So when agent ends a chat and customer has opened chat in multiple tabs,
41
- all tabs should show post chat survey as per existing functionality. But when an agent end a conversation, Omnichannel SDK
42
- getPostChatSurveyContext returns as invalid conversation. To avoid that, caching the survey url is needed after chat starts and
43
- in this case loadSurvey is false
44
- */
45
43
 
46
-
47
- if (loadSurvey) {
44
+ _omnichannelChatComponents.BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
45
+ dispatch({
46
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
47
+ payload: _ConversationState.ConversationState.Loading
48
+ });
48
49
  dispatch({
49
50
  type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
50
51
  payload: _ConversationState.ConversationState.Postchat
51
52
  });
52
- }
53
+ });
53
54
  };
54
55
 
55
56
  exports.setPostChatContextAndLoadSurvey = setPostChatContextAndLoadSurvey;