@microsoft/omnichannel-chat-widget 0.1.0-main.52da005 → 0.1.0-main.52fa2fc
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.
- package/README.md +7 -34
- package/lib/cjs/common/Constants.js +12 -3
- package/lib/cjs/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/cjs/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/cjs/common/telemetry/TelemetryConstants.js +35 -4
- package/lib/cjs/common/telemetry/TelemetryHelper.js +2 -1
- package/lib/cjs/common/utils.js +23 -2
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
- package/lib/cjs/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +5 -2
- package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +139 -0
- package/lib/cjs/components/livechatwidget/common/agentEndConversationHelper.js +36 -0
- package/lib/cjs/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
- package/lib/cjs/components/livechatwidget/common/endChat.js +43 -63
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +11 -49
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +11 -7
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -2
- package/lib/cjs/components/livechatwidget/common/startChat.js +83 -64
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +91 -45
- package/lib/cjs/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/cjs/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/cjs/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +7 -3
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
- package/lib/cjs/contexts/common/ConversationEndEntity.js +12 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +11 -7
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +10 -4
- package/lib/cjs/contexts/createReducer.js +36 -2
- package/lib/cjs/hooks/useDebounce.js +28 -0
- package/lib/cjs/hooks/useWindowDimensions.js +30 -0
- package/lib/cjs/plugins/newMessageEventHandler.js +14 -0
- package/lib/esm/common/Constants.js +10 -2
- package/lib/esm/common/storage/default/defaultCacheManager.js +2 -2
- package/lib/esm/common/storage/default/defaultClientDataStoreProvider.js +15 -6
- package/lib/esm/common/telemetry/TelemetryConstants.js +35 -4
- package/lib/esm/common/telemetry/TelemetryHelper.js +2 -1
- package/lib/esm/common/utils.js +20 -0
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +12 -19
- package/lib/esm/components/emailtranscriptpanestateful/EmailTranscriptPaneStateful.js +1 -1
- package/lib/esm/components/headerstateful/HeaderStateful.js +5 -2
- package/lib/esm/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js +134 -0
- package/lib/esm/components/livechatwidget/common/agentEndConversationHelper.js +30 -0
- package/lib/esm/components/livechatwidget/common/createAdapter.js +2 -0
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +66 -14
- package/lib/esm/components/livechatwidget/common/endChat.js +45 -65
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -51
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +12 -7
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +255 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +83 -64
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +92 -46
- package/lib/esm/components/loadingpanestateful/LoadingPaneStateful.js +8 -1
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +3 -1
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +1 -1
- package/lib/esm/components/prechatsurveypanestateful/common/defaultStyles/defaultGeneralPreChatSurveyPaneStyleProps.js +1 -1
- package/lib/esm/components/reconnectchatpanestateful/ReconnectChatPaneStateful.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/common/utils/FileAttachmentIconManager.js +2 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityStatusMiddleware.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/attachmentMiddleware.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultSystemMessageBoxStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/defaultStyles/defaultUserMessageBoxStyles.js +1 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +2 -14
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.js +2 -11
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/typingIndicatorMiddleware.js +5 -3
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.js +75 -11
- package/lib/esm/contexts/common/ConversationEndEntity.js +5 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +11 -7
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +10 -4
- package/lib/esm/contexts/createReducer.js +36 -2
- package/lib/esm/hooks/useDebounce.js +22 -0
- package/lib/esm/hooks/useWindowDimensions.js +23 -0
- package/lib/esm/plugins/newMessageEventHandler.js +14 -0
- package/lib/types/common/Constants.d.ts +9 -0
- package/lib/types/common/storage/default/defaultCacheManager.d.ts +1 -1
- package/lib/types/common/storage/default/defaultClientDataStoreProvider.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +31 -6
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +2 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +1 -0
- package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +4 -0
- package/lib/types/common/utils.d.ts +1 -0
- package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +0 -7
- package/lib/types/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.d.ts +9 -0
- package/lib/types/components/livechatwidget/common/agentEndConversationHelper.d.ts +6 -0
- package/lib/types/components/livechatwidget/common/initWebChatComposer.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +6 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +3 -3
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetControlProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/SendingTimestamp.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/attachmentUploadValidatorMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ConversationEndEntity.d.ts +4 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +6 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +11 -7
- package/lib/types/hooks/useDebounce.d.ts +3 -0
- package/lib/types/hooks/useWindowDimensions.d.ts +4 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,8 +11,6 @@
|
|
|
11
11
|
1. [Installation](#installation)
|
|
12
12
|
1. [Example Usage](#example-usage)
|
|
13
13
|
1. [Components](#components)
|
|
14
|
-
1. [Common Scenarios](#common-scenarios)
|
|
15
|
-
- [Disable Bot Magic Code](#disable-bot-magic-code)
|
|
16
14
|
1. [See Also](#see-also)
|
|
17
15
|
|
|
18
16
|
## Introduction
|
|
@@ -97,7 +95,9 @@ const render = async () => {
|
|
|
97
95
|
render();
|
|
98
96
|
```
|
|
99
97
|
|
|
100
|
-
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.
|
|
98
|
+
A javascript sample widget can be found in this repo [here](https://github.com/microsoft/omnichannel-chat-widget/tree/main/chat-widget/samples/javascript-sample). To build it, do ```yarn build-sample``` or ```yarn build-sample:dev``` from project root.
|
|
99
|
+
|
|
100
|
+
A typescript sample widget can be found [here](https://github.com/microsoft/omnichannel-chat-widget/tree/main/chat-widget/samples/typescript-sample)
|
|
101
101
|
|
|
102
102
|
## Components
|
|
103
103
|
|
|
@@ -129,6 +129,7 @@ These are components that are included in the ```@microsoft/omnichannel-chat-com
|
|
|
129
129
|
| ----- | -------- | ----- |
|
|
130
130
|
| WebChatContainer | The default wrapper around BotFramework's [WebChat](https://github.com/microsoft/BotFramework-WebChat), which is the message container we are using | [IWebChatContainerStatefulProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-widget/src/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.ts) |
|
|
131
131
|
| 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) |
|
|
132
|
+
| PostChatLoadingPane | The default loading pane used after the chat is ended and before the post chat pane loads completely | [ILoadingPaneProps](https://github.com/microsoft/omnichannel-chat-widget/blob/main/chat-components/src/components/loadingpane/interfaces/ILoadingPaneProps.ts) |
|
|
132
133
|
|
|
133
134
|
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.
|
|
134
135
|
|
|
@@ -220,40 +221,12 @@ const customizedFooterProp: IFooterProps = {
|
|
|
220
221
|
|
|
221
222
|
> :pushpin: Note that [WebChat hooks](https://github.com/microsoft/BotFramework-WebChat/blob/main/docs/HOOKS.md) can also be used in any custom components.
|
|
222
223
|
|
|
223
|
-
## Common Scenarios
|
|
224
|
-
|
|
225
|
-
### Disable Bot Magic Code
|
|
226
|
-
|
|
227
|
-
Configuration to disable the default behaviour of having to type the magic code in the conversation to complete the sign-in proccess with a bot. Instead, the magic code will be sent to the bot behind the scenes.
|
|
228
|
-
|
|
229
|
-
1. Add [MagicCodeForwarder.html](sample/MagicCodeForwarder.html) in the same location as the chat widget
|
|
230
|
-
|
|
231
|
-
2. Add `botMagicCode` configuration to disable default magic code feature
|
|
232
|
-
|
|
233
|
-
> :exclamation: `fwdUrl` **MUST** have the same `origin` as the chat widget URL
|
|
234
|
-
|
|
235
|
-
```js
|
|
236
|
-
const liveChatWidgetProps = {
|
|
237
|
-
chatSDK: chatSDK, // mandatory
|
|
238
|
-
chatConfig: chatConfig, // mandatory
|
|
239
|
-
webChatContainerProps: {
|
|
240
|
-
botMagicCode: {
|
|
241
|
-
disabled: true,
|
|
242
|
-
fwdUrl: 'http://localhost:8000/sample/MagicCodeForwarder.html'
|
|
243
|
-
}
|
|
244
|
-
},
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
ReactDOM.render(
|
|
248
|
-
<LiveChatWidget {...liveChatWidgetProps}/>,
|
|
249
|
-
document.getElementById("my-container")
|
|
250
|
-
);
|
|
251
|
-
```
|
|
252
|
-
|
|
253
224
|
## See Also
|
|
254
225
|
|
|
255
226
|
[Telemetry](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Telemetry.md)\
|
|
256
227
|
[Create LCW widget with Webpack5 and TypeScript](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/BuildingUsingWebpack5.md)\
|
|
257
228
|
[Omnichannel Features](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Features.md)\
|
|
258
229
|
[How to Add Visual Regression Tests](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/VisualRegressionTestingGuide.md)\
|
|
259
|
-
[Security](https://github.com/microsoft/omnichannel-chat-widget/blob/main/SECURITY.md)
|
|
230
|
+
[Security](https://github.com/microsoft/omnichannel-chat-widget/blob/main/SECURITY.md)\
|
|
231
|
+
[Third Party Cookie Support](https://github.com/microsoft/omnichannel-chat-widget/blob/main/docs/Tpc.md)\
|
|
232
|
+
[Storybook](https://microsoft.github.io/omnichannel-chat-widget/docs/storybook/)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.Regex = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.Constants = exports.ChatSDKError = exports.AriaTelemetryConstants = void 0;
|
|
6
|
+
exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.Regex = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.Constants = exports.ChatSDKError = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
|
|
7
7
|
var _class;
|
|
8
8
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
9
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
@@ -28,6 +28,8 @@ _defineProperty(Constants, "truePascal", "True");
|
|
|
28
28
|
_defineProperty(Constants, "true", "true");
|
|
29
29
|
_defineProperty(Constants, "false", "false");
|
|
30
30
|
_defineProperty(Constants, "maximumUnreadMessageCount", 99);
|
|
31
|
+
_defineProperty(Constants, "userParticipantTypeTag", "User");
|
|
32
|
+
_defineProperty(Constants, "botParticipantTypeTag", "Bot");
|
|
31
33
|
_defineProperty(Constants, "channelIdKey", "ChannelId-");
|
|
32
34
|
_defineProperty(Constants, "ChannelId", "lcw");
|
|
33
35
|
_defineProperty(Constants, "CustomerTag", "FromCustomer");
|
|
@@ -51,8 +53,8 @@ _defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
|
|
|
51
53
|
_defineProperty(Constants, "publicMessageTag", "public");
|
|
52
54
|
_defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
|
|
53
55
|
_defineProperty(Constants, "maxUploadFileSize", "500000");
|
|
54
|
-
_defineProperty(Constants, "imageRegex", /(\.)(jpeg|jpg|jiff|png|gif|bmp)$/i);
|
|
55
|
-
_defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|flac|mp2|mp3|pcm|wav|wma)$/i);
|
|
56
|
+
_defineProperty(Constants, "imageRegex", /(\.)(jpeg|jpg|jiff|png|gif|bmp|webp)$/i);
|
|
57
|
+
_defineProperty(Constants, "audioMediaRegex", /(\.)(aac|aiff|alac|amr|flac|mp2|mp3|pcm|wav|wma)$/i);
|
|
56
58
|
_defineProperty(Constants, "videoMediaRegex", /(\.)(avchd|avi|flv|mpe|mpeg|mpg|mpv|mp4|m4p|m4v|mov|qt|swf|webm|wmv)$/i);
|
|
57
59
|
_defineProperty(Constants, "chromeSupportedInlineMediaRegex", /(\.)(aac|mp3|wav|mp4)$/i);
|
|
58
60
|
_defineProperty(Constants, "firefoxSupportedInlineMediaRegex", /(\.)(aac|flac|mp3|wav|mp4|mov)$/i);
|
|
@@ -89,6 +91,7 @@ _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect
|
|
|
89
91
|
_defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
|
|
90
92
|
_defineProperty(Constants, "PostChatLoadingDurationInMs", 2000);
|
|
91
93
|
_defineProperty(Constants, "BrowserUnloadConfirmationMessage", "Do you want to leave chat?");
|
|
94
|
+
_defineProperty(Constants, "CacheTtlInMinutes", 15);
|
|
92
95
|
const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
|
|
93
96
|
exports.Regex = Regex;
|
|
94
97
|
class HtmlIdNames {}
|
|
@@ -134,12 +137,18 @@ _defineProperty(HtmlAttributeNames, "noreferrerTag", "noreferrer");
|
|
|
134
137
|
_defineProperty(HtmlAttributeNames, "adaptiveCardClassName", "ac-adaptiveCard");
|
|
135
138
|
_defineProperty(HtmlAttributeNames, "adaptiveCardTextBlockClassName", "ac-textBlock");
|
|
136
139
|
_defineProperty(HtmlAttributeNames, "adaptiveCardToggleInputClassName", "ac-toggleInput");
|
|
140
|
+
_defineProperty(HtmlAttributeNames, "adaptiveCardActionSetClassName", "ac-actionSet");
|
|
137
141
|
class WebChatMiddlewareConstants {}
|
|
138
142
|
exports.WebChatMiddlewareConstants = WebChatMiddlewareConstants;
|
|
139
143
|
_defineProperty(WebChatMiddlewareConstants, "nextVisibleActivity", "nextVisibleActivity");
|
|
140
144
|
_defineProperty(WebChatMiddlewareConstants, "timeBetweenTimestampGroups", 300000);
|
|
141
145
|
_defineProperty(WebChatMiddlewareConstants, "maxTextLength", 6000);
|
|
142
146
|
_defineProperty(WebChatMiddlewareConstants, "adaptiveCard", "AdaptiveCard");
|
|
147
|
+
class AMSConstants {}
|
|
148
|
+
exports.AMSConstants = AMSConstants;
|
|
149
|
+
_defineProperty(AMSConstants, "supportedImagesMimeTypes", ["image/jpeg", "image/png", "image/gif", "image/heic", "image/webp"]);
|
|
150
|
+
_defineProperty(AMSConstants, "maxSupportedImageSize", 20);
|
|
151
|
+
_defineProperty(AMSConstants, "maxSupportedFileSize", 300);
|
|
143
152
|
class MimeTypes {}
|
|
144
153
|
exports.MimeTypes = MimeTypes;
|
|
145
154
|
_defineProperty(MimeTypes, "UnknownFileType", "application/octet-stream");
|
|
@@ -13,11 +13,11 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
13
13
|
class defaultCacheManager {}
|
|
14
14
|
exports.defaultCacheManager = defaultCacheManager;
|
|
15
15
|
_defineProperty(defaultCacheManager, "InternalCache", {});
|
|
16
|
-
const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId) => {
|
|
16
|
+
const registerBroadcastServiceForLocalStorage = (orgid, widgetId, widgetInstanceId, ttlInMins) => {
|
|
17
17
|
const widgetCacheId = (0, _utils.getWidgetCacheId)(orgid, widgetId, widgetInstanceId);
|
|
18
18
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(widgetCacheId).subscribe(msg => {
|
|
19
19
|
try {
|
|
20
|
-
(0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)().setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
20
|
+
(0, _defaultClientDataStoreProvider.defaultClientDataStoreProvider)(ttlInMins).setData(widgetCacheId, JSON.stringify(msg.payload), "localStorage");
|
|
21
21
|
} catch (error) {
|
|
22
22
|
console.error("Error in setting data to localstorage", error);
|
|
23
23
|
}
|
|
@@ -4,21 +4,30 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.defaultClientDataStoreProvider = void 0;
|
|
7
|
-
var _defaultInMemoryDataStore = require("./defaultInMemoryDataStore");
|
|
8
|
-
var _TelemetryHelper = require("../../telemetry/TelemetryHelper");
|
|
9
7
|
var _TelemetryConstants = require("../../telemetry/TelemetryConstants");
|
|
10
|
-
|
|
8
|
+
var _TelemetryHelper = require("../../telemetry/TelemetryHelper");
|
|
9
|
+
var _defaultInMemoryDataStore = require("./defaultInMemoryDataStore");
|
|
10
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
11
|
+
|
|
12
|
+
const defaultClientDataStoreProvider = function () {
|
|
13
|
+
let cacheTtlinMins = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
14
|
+
let ttlInMs = 0;
|
|
11
15
|
const isCookieAllowed = () => {
|
|
12
16
|
try {
|
|
13
17
|
localStorage;
|
|
14
18
|
sessionStorage;
|
|
15
19
|
return true;
|
|
16
20
|
} catch (error) {
|
|
17
|
-
|
|
21
|
+
if (!window.TPCWarningShown) {
|
|
22
|
+
console.warn("Third party cookies blocked.");
|
|
23
|
+
window.TPCWarningShown = true;
|
|
24
|
+
}
|
|
18
25
|
return false;
|
|
19
26
|
}
|
|
20
27
|
};
|
|
21
|
-
|
|
28
|
+
if (ttlInMs == 0) {
|
|
29
|
+
ttlInMs = cacheTtlinMins * 60 * 1000;
|
|
30
|
+
}
|
|
22
31
|
const dataStoreProvider = {
|
|
23
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
33
|
setData: (key, data, type) => {
|
|
@@ -28,7 +37,7 @@ const defaultClientDataStoreProvider = () => {
|
|
|
28
37
|
const now = new Date();
|
|
29
38
|
const item = {
|
|
30
39
|
data: data,
|
|
31
|
-
expiry: now.getTime() +
|
|
40
|
+
expiry: now.getTime() + ttlInMs
|
|
32
41
|
};
|
|
33
42
|
const strItem = JSON.stringify(item);
|
|
34
43
|
if (type === "localStorage") {
|
|
@@ -54,6 +54,12 @@ exports.BroadcastEvent = BroadcastEvent;
|
|
|
54
54
|
BroadcastEvent["InitiateEndChatOnBrowserUnload"] = "InitiateEndChatOnBrowserUnload";
|
|
55
55
|
BroadcastEvent["ClosePopoutWindow"] = "ClosePopoutWindow";
|
|
56
56
|
BroadcastEvent["RaiseErrorEvent"] = "RaiseErrorEvent";
|
|
57
|
+
BroadcastEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
58
|
+
BroadcastEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
59
|
+
BroadcastEvent["SigninCardReceived"] = "SignInCardReceived";
|
|
60
|
+
BroadcastEvent["BotAuthConfigRequest"] = "BotAuthConfigRequest";
|
|
61
|
+
BroadcastEvent["BotAuthConfigResponse"] = "BotAuthConfigResponse";
|
|
62
|
+
BroadcastEvent["HideChatVisibilityChangeEvent"] = "hideChatVisibilityChangeEvent";
|
|
57
63
|
})(BroadcastEvent || (exports.BroadcastEvent = BroadcastEvent = {}));
|
|
58
64
|
let TelemetryEvent;
|
|
59
65
|
exports.TelemetryEvent = TelemetryEvent;
|
|
@@ -90,11 +96,10 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
90
96
|
TelemetryEvent["GetConversationDetailsCallFailed"] = "GetConversationDetailsCallFailed";
|
|
91
97
|
TelemetryEvent["EndChatSDKCallFailed"] = "EndChatSDKCallFailed";
|
|
92
98
|
TelemetryEvent["GetChatReconnectContextSDKCallFailed"] = "GetChatReconnectContextSDKCallFailed";
|
|
93
|
-
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
94
|
-
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
95
99
|
TelemetryEvent["ParseAdaptiveCardFailed"] = "ParseAdaptiveCardFailed";
|
|
96
100
|
TelemetryEvent["ClientDataStoreProviderFailed"] = "ClientDataStoreProviderFailed";
|
|
97
101
|
TelemetryEvent["InMemoryDataStoreFailed"] = "InMemoryDataStoreFailed";
|
|
102
|
+
TelemetryEvent["ChatVisibilityChanged"] = "ChatVisibilityChanged";
|
|
98
103
|
TelemetryEvent["WebChatLoaded"] = "WebChatLoaded";
|
|
99
104
|
TelemetryEvent["LCWChatButtonClicked"] = "LCWChatButtonClicked";
|
|
100
105
|
TelemetryEvent["LCWChatButtonShow"] = "LCWChatButtonShow";
|
|
@@ -102,6 +107,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
102
107
|
TelemetryEvent["WidgetLoadComplete"] = "WidgetLoadComplete";
|
|
103
108
|
TelemetryEvent["WidgetLoadFailed"] = "WidgetLoadFailed";
|
|
104
109
|
TelemetryEvent["StartChatMethodException"] = "StartChatMethodException";
|
|
110
|
+
TelemetryEvent["CloseChatCall"] = "CloseChatCall";
|
|
105
111
|
TelemetryEvent["CloseChatMethodException"] = "CloseChatMethodException";
|
|
106
112
|
TelemetryEvent["PrechatSurveyLoaded"] = "PrechatSurveyLoaded";
|
|
107
113
|
TelemetryEvent["PrechatSubmitted"] = "PrechatSubmitted";
|
|
@@ -115,6 +121,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
115
121
|
TelemetryEvent["DownloadTranscriptResponseNullOrUndefined"] = "DownloadTranscriptResponseNullOrUndefined";
|
|
116
122
|
TelemetryEvent["EmailTranscriptSent"] = "EmailTranscriptSent";
|
|
117
123
|
TelemetryEvent["EmailTranscriptFailed"] = "EmailTranscriptFailed";
|
|
124
|
+
TelemetryEvent["ErrorUIPaneLoaded"] = "ErrorUIPaneLoaded";
|
|
118
125
|
TelemetryEvent["DownloadTranscriptFailed"] = "DownloadTranscriptFailed";
|
|
119
126
|
TelemetryEvent["StartChatFailed"] = "StartChatFailed";
|
|
120
127
|
TelemetryEvent["IC3ThreadUpdateEventReceived"] = "IC3ThreadUpdateEventReceived";
|
|
@@ -123,8 +130,6 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
123
130
|
TelemetryEvent["LoadingPaneLoaded"] = "LoadingPaneLoaded";
|
|
124
131
|
TelemetryEvent["EmailTranscriptLoaded"] = "EmailTranscriptLoaded";
|
|
125
132
|
TelemetryEvent["OutOfOfficePaneLoaded"] = "OutOfOfficePaneLoaded";
|
|
126
|
-
TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
|
|
127
|
-
TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
|
|
128
133
|
TelemetryEvent["ConfirmationPaneLoaded"] = "ConfirmationPaneLoaded";
|
|
129
134
|
TelemetryEvent["ProactiveChatPaneLoaded"] = "ProactiveChatPaneLoaded";
|
|
130
135
|
TelemetryEvent["ReconnectChatPaneLoaded"] = "ReconnectChatPaneLoaded";
|
|
@@ -137,6 +142,7 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
137
142
|
TelemetryEvent["SuppressBotMagicCodeSucceeded"] = "SuppressBotMagicCodeSucceeded";
|
|
138
143
|
TelemetryEvent["SuppressBotMagicCodeFailed"] = "SuppressBotMagicCodeFailed";
|
|
139
144
|
TelemetryEvent["GetConversationDetailsException"] = "GetConversationDetailsException";
|
|
145
|
+
TelemetryEvent["AppStatesException"] = "AppStatesException";
|
|
140
146
|
TelemetryEvent["BrowserUnloadEventStarted"] = "BrowserUnloadEventStarted";
|
|
141
147
|
TelemetryEvent["GetAuthTokenCalled"] = "GetAuthTokenCalled";
|
|
142
148
|
TelemetryEvent["GetAuthTokenFailed"] = "GetAuthTokenFailed";
|
|
@@ -144,15 +150,23 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
144
150
|
TelemetryEvent["CustomerVoiceResponsePageLoaded"] = "CustomerVoiceResponsePageLoaded";
|
|
145
151
|
TelemetryEvent["CustomerVoiceFormResponseSubmitted"] = "CustomerVoiceFormResponseSubmitted";
|
|
146
152
|
TelemetryEvent["CustomerVoiceFormResponseError"] = "CustomerVoiceFormResponseError";
|
|
153
|
+
TelemetryEvent["BotAuthActivityEmptySasUrl"] = "BotAuthActivityEmptySasUrl";
|
|
154
|
+
TelemetryEvent["SetBotAuthProviderFetchConfig"] = "SetBotAuthProviderFetchConfig";
|
|
155
|
+
TelemetryEvent["SetBotAuthProviderHideCard"] = "SetBotAuthProviderHideCard";
|
|
156
|
+
TelemetryEvent["SetBotAuthProviderDisplayCard"] = "SetBotAuthProviderDisplayCard";
|
|
157
|
+
TelemetryEvent["SetBotAuthProviderNotFound"] = "SetBotAuthProviderNotFound";
|
|
147
158
|
TelemetryEvent["ProcessingHTMLTextMiddlewareFailed"] = "ProcessingHTMLTextMiddlewareFailed";
|
|
148
159
|
TelemetryEvent["ProcessingSanitizationMiddlewareFailed"] = "ProcessingSanitizationMiddlewareFailed";
|
|
149
160
|
TelemetryEvent["FormatTagsMiddlewareJSONStringifyFailed"] = "FormatTagsMiddlewareJSONStringifyFailed";
|
|
161
|
+
TelemetryEvent["AttachmentUploadValidatorMiddlewareFailed"] = "AttachmentUploadValidatorMiddlewareFailed";
|
|
150
162
|
TelemetryEvent["QueuePositionMessageRecieved"] = "QueuePositionMessageRecieved";
|
|
151
163
|
TelemetryEvent["AverageWaitTimeMessageRecieved"] = "AverageWaitTimeMessageRecieved";
|
|
152
164
|
TelemetryEvent["DataMaskingRuleApplied"] = "DataMaskingRuleApplied";
|
|
153
165
|
TelemetryEvent["DataMaskingRuleApplyFailed"] = "DataMaskingRuleApplyFailed";
|
|
154
166
|
TelemetryEvent["IC3ClientEvent"] = "IC3ClientEvent";
|
|
155
167
|
TelemetryEvent["ConversationEndedThreadEventReceived"] = "ConversationEndedThreadEventReceived";
|
|
168
|
+
TelemetryEvent["ConversationEndedByCustomer"] = "ConversationEndedByCustomer";
|
|
169
|
+
TelemetryEvent["ConversationEndedByAgent"] = "ConversationEndedByAgent";
|
|
156
170
|
TelemetryEvent["InvalidConfiguration"] = "InvalidConfiguration";
|
|
157
171
|
TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
|
|
158
172
|
TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
|
|
@@ -170,9 +184,20 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
170
184
|
TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
|
|
171
185
|
TelemetryEvent["MessageSent"] = "MessageSent";
|
|
172
186
|
TelemetryEvent["MessageReceived"] = "MessageReceived";
|
|
187
|
+
TelemetryEvent["SystemMessageReceived"] = "SystemMessageReceived";
|
|
188
|
+
TelemetryEvent["HistoryMessageReceived"] = "HistoryMessageReceived";
|
|
173
189
|
TelemetryEvent["CustomContextReceived"] = "CustomContextReceived";
|
|
174
190
|
TelemetryEvent["NetworkDisconnected"] = "NetworkDisconnected";
|
|
175
191
|
TelemetryEvent["NetworkReconnected"] = "NetworkReconnected";
|
|
192
|
+
TelemetryEvent["LinkModePostChatWorkflowStarted"] = "LinkModePostChatWorkflowStarted";
|
|
193
|
+
TelemetryEvent["EmbedModePostChatWorkflowStarted"] = "EmbedModePostChatWorkflowStarted";
|
|
194
|
+
TelemetryEvent["PostChatWorkflowFromCustomer"] = "PostChatWorkflowFromCustomer";
|
|
195
|
+
TelemetryEvent["PostChatWorkflowFromAgent"] = "PostChatWorkflowFromAgent";
|
|
196
|
+
TelemetryEvent["PostChatWorkflowFromBot"] = "PostChatWorkflowFromBot";
|
|
197
|
+
TelemetryEvent["PostChatContextCallSucceed"] = "PostChatContextCallSucceed";
|
|
198
|
+
TelemetryEvent["PostChatContextCallFailed"] = "PostChatContextCallFailed";
|
|
199
|
+
TelemetryEvent["PostChatSurveyLoadingPaneLoaded"] = "PostChatSurveyLoadingPaneLoaded";
|
|
200
|
+
TelemetryEvent["PostChatSurveyLoaded"] = "PostChatSurveyLoaded";
|
|
176
201
|
})(TelemetryEvent || (exports.TelemetryEvent = TelemetryEvent = {}));
|
|
177
202
|
class TelemetryConstants {
|
|
178
203
|
static map(eventTypeOrScenarioType) {
|
|
@@ -227,6 +252,12 @@ class TelemetryConstants {
|
|
|
227
252
|
case TelemetryEvent.CustomerVoiceResponsePageLoaded:
|
|
228
253
|
case TelemetryEvent.CustomerVoiceFormResponseSubmitted:
|
|
229
254
|
case TelemetryEvent.CustomerVoiceFormResponseError:
|
|
255
|
+
case TelemetryEvent.LinkModePostChatWorkflowStarted:
|
|
256
|
+
case TelemetryEvent.EmbedModePostChatWorkflowStarted:
|
|
257
|
+
case TelemetryEvent.PostChatWorkflowFromCustomer:
|
|
258
|
+
case TelemetryEvent.PostChatWorkflowFromAgent:
|
|
259
|
+
case TelemetryEvent.PostChatWorkflowFromBot:
|
|
260
|
+
case TelemetryEvent.AppStatesException:
|
|
230
261
|
return ScenarioType.ACTIONS;
|
|
231
262
|
case TelemetryEvent.StartChatSDKCall:
|
|
232
263
|
case TelemetryEvent.StartChatEventRecevied:
|
|
@@ -62,6 +62,7 @@ class TelemetryHelper {
|
|
|
62
62
|
event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
|
|
63
63
|
event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
|
|
64
64
|
event.Description = payload.Description;
|
|
65
|
+
event.CustomProperties = JSON.stringify(payload.CustomProperties);
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
static conformToWebChatContract(level, input) {
|
|
@@ -167,7 +168,7 @@ class TelemetryHelper {
|
|
|
167
168
|
telemetryDataLocal.widgetId = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.appId;
|
|
168
169
|
telemetryDataLocal.orgId = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgId;
|
|
169
170
|
telemetryDataLocal.orgUrl = telemetryConfig === null || telemetryConfig === void 0 ? void 0 : telemetryConfig.orgUrl;
|
|
170
|
-
telemetryDataLocal.lcwRuntimeId = (0, _utils.newGuid)();
|
|
171
|
+
telemetryDataLocal.lcwRuntimeId = telemetryConfig.LCWRuntimeId ?? (0, _utils.newGuid)();
|
|
171
172
|
return telemetryDataLocal;
|
|
172
173
|
}
|
|
173
174
|
static addSessionDataToTelemetry(chatSession, telemetryInternalData) {
|
package/lib/cjs/common/utils.js
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
6
|
+
exports.setTabIndices = exports.setFocusOnSendBox = exports.setFocusOnElement = exports.preventFocusToMoveOutOfElement = exports.parseAdaptiveCardPayload = exports.newGuid = exports.isUndefinedOrEmpty = exports.isNullOrUndefined = exports.isNullOrEmptyString = exports.getWidgetEndChatEventName = exports.getWidgetCacheId = exports.getTimestampHourMinute = exports.getStateFromCache = exports.getLocaleDirection = exports.getIconText = exports.getDomain = exports.getBroadcastChannelName = exports.findParentFocusableElementsWithoutChildContainer = exports.findAllFocusableElement = exports.extractPreChatSurveyResponseValues = exports.escapeHtml = exports.debounceLeading = exports.createTimer = exports.changeLanguageCodeFormatForWebChat = exports.addDelayInMs = void 0;
|
|
7
7
|
var _Constants = require("./Constants");
|
|
8
8
|
var _DataStoreManager = require("./contextDataStore/DataStoreManager");
|
|
9
9
|
var _KeyCodes = require("./KeyCodes");
|
|
10
10
|
var _TelemetryConstants = require("./telemetry/TelemetryConstants");
|
|
11
11
|
var _md5Typescript = require("md5-typescript");
|
|
12
|
+
var _this = void 0;
|
|
12
13
|
const getElementBySelector = selector => {
|
|
13
14
|
let element;
|
|
14
15
|
if (typeof selector === "string") {
|
|
@@ -334,4 +335,24 @@ exports.addDelayInMs = addDelayInMs;
|
|
|
334
335
|
const getBroadcastChannelName = (widgetId, widgetInstanceId) => {
|
|
335
336
|
return widgetInstanceId && !isNullOrEmptyString(widgetInstanceId) ? `${widgetInstanceId}_${widgetId}` : widgetId;
|
|
336
337
|
};
|
|
337
|
-
|
|
338
|
+
|
|
339
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
340
|
+
exports.getBroadcastChannelName = getBroadcastChannelName;
|
|
341
|
+
const debounceLeading = function (fn) {
|
|
342
|
+
let ms = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3000;
|
|
343
|
+
let timeoutId;
|
|
344
|
+
return function () {
|
|
345
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
346
|
+
|
|
347
|
+
if (!timeoutId) {
|
|
348
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
349
|
+
args[_key] = arguments[_key];
|
|
350
|
+
}
|
|
351
|
+
fn.apply(_this, args);
|
|
352
|
+
}
|
|
353
|
+
timeoutId = setTimeout(() => {
|
|
354
|
+
timeoutId = null;
|
|
355
|
+
}, ms);
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
exports.debounceLeading = debounceLeading;
|
|
@@ -10,11 +10,10 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
var _utils = require("../../common/utils");
|
|
11
11
|
var _DimLayer = require("../dimlayer/DimLayer");
|
|
12
12
|
var _LiveChatWidgetActionType = require("../../contexts/common/LiveChatWidgetActionType");
|
|
13
|
-
var _NotificationHandler = require("../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
14
|
-
var _NotificationScenarios = require("../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
|
|
15
13
|
var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
16
14
|
var _useChatAdapterStore = _interopRequireDefault(require("../../hooks/useChatAdapterStore"));
|
|
17
15
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
16
|
+
var _ConversationEndEntity = require("../../contexts/common/ConversationEndEntity");
|
|
18
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
18
|
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); }
|
|
20
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -23,10 +22,7 @@ const ConfirmationPaneStateful = props => {
|
|
|
23
22
|
const initialTabIndexMap = new Map();
|
|
24
23
|
let elements = [];
|
|
25
24
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
26
|
-
|
|
27
|
-
prepareEndChat
|
|
28
|
-
} = props;
|
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
|
|
30
26
|
const [adapter] = (0, _useChatAdapterStore.default)();
|
|
31
27
|
const controlProps = {
|
|
32
28
|
id: "oc-lcw-confirmation-pane",
|
|
@@ -40,18 +36,15 @@ const ConfirmationPaneStateful = props => {
|
|
|
40
36
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
|
|
41
37
|
payload: false
|
|
42
38
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.Connection, "Get Conversation Details Call Failed: " + ex);
|
|
54
|
-
}
|
|
39
|
+
(0, _utils.setTabIndices)(elements, initialTabIndexMap, true);
|
|
40
|
+
dispatch({
|
|
41
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_ENDED_BY,
|
|
42
|
+
payload: _ConversationEndEntity.ConversationEndEntity.Customer
|
|
43
|
+
});
|
|
44
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
45
|
+
Event: _TelemetryConstants.TelemetryEvent.ConversationEndedByCustomer,
|
|
46
|
+
Description: "Conversation is ended by customer."
|
|
47
|
+
});
|
|
55
48
|
},
|
|
56
49
|
onCancel: () => {
|
|
57
50
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -90,7 +83,7 @@ const ConfirmationPaneStateful = props => {
|
|
|
90
83
|
Event: _TelemetryConstants.TelemetryEvent.ConfirmationPaneLoaded
|
|
91
84
|
});
|
|
92
85
|
}, []);
|
|
93
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
86
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_DimLayer.DimLayer, {
|
|
94
87
|
brightness: (controlProps === null || controlProps === void 0 ? void 0 : controlProps.brightnessValueOnDim) ?? "0.2"
|
|
95
88
|
}), /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.ConfirmationPane, {
|
|
96
89
|
componentOverrides: props === null || props === void 0 ? void 0 : props.componentOverrides,
|
|
@@ -97,7 +97,7 @@ const EmailTranscriptPaneStateful = props => {
|
|
|
97
97
|
Event: _TelemetryConstants.TelemetryEvent.EmailTranscriptLoaded
|
|
98
98
|
});
|
|
99
99
|
}, [initialEmail]);
|
|
100
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
100
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_DimLayer.DimLayer, {
|
|
101
101
|
brightness: (controlProps === null || controlProps === void 0 ? void 0 : controlProps.brightnessValueOnDim) ?? "0.2"
|
|
102
102
|
}), /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.InputValidationPane, {
|
|
103
103
|
componentOverrides: props.componentOverrides,
|
|
@@ -13,6 +13,7 @@ var _TelemetryHelper = require("../../common/telemetry/TelemetryHelper");
|
|
|
13
13
|
var _defaultOutOfOfficeHeaderStyleProps = require("./common/styleProps/defaultOutOfOfficeHeaderStyleProps");
|
|
14
14
|
var _useChatAdapterStore = _interopRequireDefault(require("../../hooks/useChatAdapterStore"));
|
|
15
15
|
var _useChatContextStore = _interopRequireDefault(require("../../hooks/useChatContextStore"));
|
|
16
|
+
var _ConversationEndEntity = require("../../contexts/common/ConversationEndEntity");
|
|
16
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
18
|
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); }
|
|
18
19
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -30,6 +31,7 @@ const HeaderStateful = props => {
|
|
|
30
31
|
const [outOfOperatingHours, setOutOfOperatingHours] = (0, _react.useState)(((_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");
|
|
31
32
|
const outOfOfficeStyleProps = Object.assign({}, _defaultOutOfOfficeHeaderStyleProps.defaultOutOfOfficeHeaderStyleProps, outOfOfficeHeaderProps === null || outOfOfficeHeaderProps === void 0 ? void 0 : outOfOfficeHeaderProps.styleProps);
|
|
32
33
|
const conversationState = (0, _react.useRef)(state.appStates.conversationState);
|
|
34
|
+
const conversationEndedBy = (0, _react.useRef)(state.appStates.conversationEndedBy);
|
|
33
35
|
const controlProps = {
|
|
34
36
|
id: "oc-lcw-header",
|
|
35
37
|
dir: state.domainStates.globalDir,
|
|
@@ -49,7 +51,7 @@ const HeaderStateful = props => {
|
|
|
49
51
|
Event: _TelemetryConstants.TelemetryEvent.HeaderCloseButtonClicked,
|
|
50
52
|
Description: "Header Close button clicked."
|
|
51
53
|
});
|
|
52
|
-
if (conversationState.current === _ConversationState.ConversationState.Active) {
|
|
54
|
+
if (conversationState.current === _ConversationState.ConversationState.Active || conversationEndedBy.current === _ConversationEndEntity.ConversationEndEntity.Agent) {
|
|
53
55
|
dispatch({
|
|
54
56
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOW_CONFIRMATION,
|
|
55
57
|
payload: true
|
|
@@ -71,7 +73,7 @@ const HeaderStateful = props => {
|
|
|
71
73
|
...(headerProps === null || headerProps === void 0 ? void 0 : headerProps.controlProps),
|
|
72
74
|
hideTitle: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP = headerProps.controlProps) === null || _headerProps$controlP === void 0 ? void 0 : _headerProps$controlP.hideTitle),
|
|
73
75
|
hideIcon: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP2 = headerProps.controlProps) === null || _headerProps$controlP2 === void 0 ? void 0 : _headerProps$controlP2.hideIcon),
|
|
74
|
-
hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
76
|
+
hideCloseButton: state.appStates.conversationState === _ConversationState.ConversationState.Loading && !state.appStates.isStartChatFailing || state.appStates.conversationState === _ConversationState.ConversationState.PostchatLoading || state.appStates.conversationState === _ConversationState.ConversationState.Prechat || state.appStates.conversationState === _ConversationState.ConversationState.ReconnectChat || (headerProps === null || headerProps === void 0 ? void 0 : (_headerProps$controlP3 = headerProps.controlProps) === null || _headerProps$controlP3 === void 0 ? void 0 : _headerProps$controlP3.hideCloseButton)
|
|
75
77
|
};
|
|
76
78
|
const outOfOfficeControlProps = {
|
|
77
79
|
id: "oc-lcw-header",
|
|
@@ -95,6 +97,7 @@ const HeaderStateful = props => {
|
|
|
95
97
|
if (state.appStates.conversationState) {
|
|
96
98
|
conversationState.current = state.appStates.conversationState;
|
|
97
99
|
}
|
|
100
|
+
conversationEndedBy.current = state.appStates.conversationEndedBy;
|
|
98
101
|
}, [state.appStates]);
|
|
99
102
|
return /*#__PURE__*/_react.default.createElement(_omnichannelChatComponents.Header, {
|
|
100
103
|
componentOverrides: headerProps === null || headerProps === void 0 ? void 0 : headerProps.componentOverrides,
|
package/lib/cjs/components/livechatwidget/common/ActivitySubscriber/BotAuthActivitySubscriber.js
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BotAuthActivitySubscriber = void 0;
|
|
7
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
8
|
+
var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstants");
|
|
9
|
+
var _TelemetryHelper = require("../../../../common/telemetry/TelemetryHelper");
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
const supportedSignInCardContentTypes = ["application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"];
|
|
14
|
+
const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
|
|
15
|
+
const delay = t => new Promise(resolve => setTimeout(resolve, t));
|
|
16
|
+
const fetchBotAuthConfigRetries = 3;
|
|
17
|
+
const fetchBotAuthConfigRetryInterval = 1000;
|
|
18
|
+
let response;
|
|
19
|
+
const extractSignInId = signInUrl => {
|
|
20
|
+
const result = botOauthUrlRegex.exec(signInUrl);
|
|
21
|
+
if (result && result[1]) {
|
|
22
|
+
return result[1];
|
|
23
|
+
}
|
|
24
|
+
return "";
|
|
25
|
+
};
|
|
26
|
+
const extractSasUrl = async attachment => {
|
|
27
|
+
let sasUrl = undefined;
|
|
28
|
+
if (attachment && attachment.content && attachment.content.tokenPostResource && attachment.content.tokenPostResource.sasUrl) {
|
|
29
|
+
sasUrl = attachment.content.tokenPostResource.sasUrl;
|
|
30
|
+
}
|
|
31
|
+
if (!sasUrl) {
|
|
32
|
+
const signInId = extractSignInId(attachment.content.buttons[0].value);
|
|
33
|
+
const getTestUrlEndpoint = `https://token.botframework.com/api/sas/gettesturl?signInId=${signInId}`;
|
|
34
|
+
try {
|
|
35
|
+
const response = await window.fetch(getTestUrlEndpoint);
|
|
36
|
+
if (response.status === 200) {
|
|
37
|
+
const responseJson = await response.json();
|
|
38
|
+
sasUrl = responseJson.sasUrl;
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
sasUrl = undefined;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return sasUrl;
|
|
45
|
+
};
|
|
46
|
+
const fetchBotAuthConfig = async retries => {
|
|
47
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
48
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderFetchConfig
|
|
49
|
+
});
|
|
50
|
+
const botAuthConfigRequestEvent = {
|
|
51
|
+
eventName: _TelemetryConstants.BroadcastEvent.BotAuthConfigRequest
|
|
52
|
+
};
|
|
53
|
+
_omnichannelChatComponents.BroadcastService.postMessage(botAuthConfigRequestEvent);
|
|
54
|
+
const listener = _omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.BotAuthConfigResponse).subscribe(data => {
|
|
55
|
+
var _data$payload, _data$payload2;
|
|
56
|
+
response = ((_data$payload = data.payload) === null || _data$payload === void 0 ? void 0 : _data$payload.response) !== undefined ? (_data$payload2 = data.payload) === null || _data$payload2 === void 0 ? void 0 : _data$payload2.response : response;
|
|
57
|
+
listener.unsubscribe();
|
|
58
|
+
});
|
|
59
|
+
if (response !== undefined) {
|
|
60
|
+
//return response;
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
if (retries === 1) {
|
|
64
|
+
// Base Case
|
|
65
|
+
throw new Error();
|
|
66
|
+
}
|
|
67
|
+
await delay(fetchBotAuthConfigRetryInterval);
|
|
68
|
+
return await fetchBotAuthConfig(--retries);
|
|
69
|
+
};
|
|
70
|
+
class BotAuthActivitySubscriber {
|
|
71
|
+
constructor() {
|
|
72
|
+
_defineProperty(this, "observer", void 0);
|
|
73
|
+
_defineProperty(this, "signInCardSeen", void 0);
|
|
74
|
+
this.signInCardSeen = new Set();
|
|
75
|
+
}
|
|
76
|
+
applicable(activity) {
|
|
77
|
+
var _activity$attachments;
|
|
78
|
+
return (activity === null || activity === void 0 ? void 0 : (_activity$attachments = activity.attachments) === null || _activity$attachments === void 0 ? void 0 : _activity$attachments.length) > 0 && activity.attachments[0] && supportedSignInCardContentTypes.indexOf(activity.attachments[0].contentType) >= 0;
|
|
79
|
+
}
|
|
80
|
+
async apply(activity) {
|
|
81
|
+
this.observer.next(false); // Hides card
|
|
82
|
+
const attachment = activity.attachments[0];
|
|
83
|
+
const signInUrl = attachment.content.buttons[0].value;
|
|
84
|
+
const signInId = extractSignInId(signInUrl);
|
|
85
|
+
if (!signInId) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (this.signInCardSeen.has(signInId)) {
|
|
89
|
+
// Prevents duplicate auth
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.signInCardSeen.add(signInId);
|
|
93
|
+
const sasUrl = await extractSasUrl(attachment);
|
|
94
|
+
const event = {
|
|
95
|
+
eventName: _TelemetryConstants.BroadcastEvent.SigninCardReceived,
|
|
96
|
+
payload: {
|
|
97
|
+
sasUrl
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
if (!sasUrl) {
|
|
101
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
102
|
+
Event: _TelemetryConstants.TelemetryEvent.BotAuthActivityEmptySasUrl,
|
|
103
|
+
Description: "SaS Url is empty"
|
|
104
|
+
});
|
|
105
|
+
return activity;
|
|
106
|
+
} else {
|
|
107
|
+
_omnichannelChatComponents.BroadcastService.postMessage(event);
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const response = await fetchBotAuthConfig(fetchBotAuthConfigRetries);
|
|
111
|
+
if (response === false) {
|
|
112
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
113
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderHideCard
|
|
114
|
+
});
|
|
115
|
+
} else {
|
|
116
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
117
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderDisplayCard
|
|
118
|
+
});
|
|
119
|
+
return activity;
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
122
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
123
|
+
Event: _TelemetryConstants.TelemetryEvent.SetBotAuthProviderNotFound
|
|
124
|
+
});
|
|
125
|
+
//this is to ensure listener continues waiting for response
|
|
126
|
+
if (this.signInCardSeen.has(signInId)) {
|
|
127
|
+
this.signInCardSeen.delete(signInId);
|
|
128
|
+
}
|
|
129
|
+
return activity;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async next(activity) {
|
|
133
|
+
if (this.applicable(activity)) {
|
|
134
|
+
return await this.apply(activity);
|
|
135
|
+
}
|
|
136
|
+
return activity;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.BotAuthActivitySubscriber = BotAuthActivitySubscriber;
|