@microsoft/omnichannel-chat-widget 0.1.0-main.ae27766 → 0.1.0-main.bcfe8a3
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 +32 -0
- package/lib/cjs/common/Constants.js +14 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +20 -3
- package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +17 -16
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +17 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +7 -13
- package/lib/cjs/components/livechatwidget/common/endChat.js +28 -13
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +12 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +49 -10
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +150 -31
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -5
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -0
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +117 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +24 -21
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
- package/lib/cjs/contexts/createReducer.js +16 -0
- package/lib/cjs/controller/componentController.js +1 -1
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
- package/lib/esm/common/Constants.js +14 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +20 -3
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +18 -13
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +8 -0
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +18 -7
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +7 -13
- package/lib/esm/components/livechatwidget/common/endChat.js +26 -14
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +11 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +51 -14
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +139 -31
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +6 -7
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -0
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
- package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.js +107 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +24 -21
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -1
- package/lib/esm/contexts/createReducer.js +16 -0
- package/lib/esm/controller/componentController.js +1 -1
- package/lib/esm/plugins/newMessageEventHandler.js +10 -12
- package/lib/types/common/Constants.d.ts +7 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +20 -5
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/utils.d.ts +2 -0
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
- package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware.d.ts +5 -0
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +24 -21
- package/package.json +2 -2
|
@@ -35,7 +35,11 @@ var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurve
|
|
|
35
35
|
|
|
36
36
|
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
37
37
|
|
|
38
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
39
|
+
|
|
38
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42
|
+
|
|
39
43
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
40
44
|
var _props$reconnectChatP;
|
|
41
45
|
|
|
@@ -74,11 +78,13 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
74
78
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
75
79
|
payload: _ConversationState.ConversationState.Prechat
|
|
76
80
|
});
|
|
81
|
+
setCustomContextParams(props, state);
|
|
77
82
|
} else {
|
|
78
83
|
dispatch({
|
|
79
84
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
80
85
|
payload: _ConversationState.ConversationState.Loading
|
|
81
86
|
});
|
|
87
|
+
setCustomContextParams(props, state);
|
|
82
88
|
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
83
89
|
}
|
|
84
90
|
}
|
|
@@ -91,6 +97,21 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
91
97
|
try {
|
|
92
98
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
93
99
|
|
|
100
|
+
let isStartChatSuccessful = false;
|
|
101
|
+
|
|
102
|
+
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
103
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
104
|
+
|
|
105
|
+
// Broadcasting limited cached chat details
|
|
106
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
107
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatRetrievedFromCache,
|
|
108
|
+
payload: {
|
|
109
|
+
chatId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.liveChatContext) === null || _persistedState$domai2 === void 0 ? void 0 : (_persistedState$domai3 = _persistedState$domai2.chatToken) === null || _persistedState$domai3 === void 0 ? void 0 : _persistedState$domai3.chatId,
|
|
110
|
+
requestId: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai4 = persistedState.domainStates) === null || _persistedState$domai4 === void 0 ? void 0 : (_persistedState$domai5 = _persistedState$domai4.liveChatContext) === null || _persistedState$domai5 === void 0 ? void 0 : _persistedState$domai5.requestId
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
94
115
|
try {
|
|
95
116
|
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
96
117
|
|
|
@@ -98,7 +119,9 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
98
119
|
Event: _TelemetryConstants.TelemetryEvent.StartChatSDKCall
|
|
99
120
|
});
|
|
100
121
|
|
|
101
|
-
|
|
122
|
+
optionalParams = Object.assign({}, params, optionalParams);
|
|
123
|
+
await chatSDK.startChat(optionalParams);
|
|
124
|
+
isStartChatSuccessful = true;
|
|
102
125
|
} catch (error) {
|
|
103
126
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
104
127
|
Event: _TelemetryConstants.TelemetryEvent.StartChatMethodException,
|
|
@@ -106,6 +129,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
106
129
|
exception: `Failed to setup startChat: ${error}`
|
|
107
130
|
}
|
|
108
131
|
});
|
|
132
|
+
|
|
133
|
+
isStartChatSuccessful = false;
|
|
109
134
|
}
|
|
110
135
|
|
|
111
136
|
const newAdapter = await (0, _createAdapter.createAdapter)(chatSDK);
|
|
@@ -133,10 +158,12 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
133
158
|
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
134
159
|
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch); // Set app state to Active
|
|
135
160
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
161
|
+
if (isStartChatSuccessful) {
|
|
162
|
+
dispatch({
|
|
163
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
164
|
+
payload: _ConversationState.ConversationState.Active
|
|
165
|
+
});
|
|
166
|
+
}
|
|
140
167
|
} else {
|
|
141
168
|
dispatch({
|
|
142
169
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
@@ -178,24 +205,36 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
178
205
|
exports.initStartChat = initStartChat;
|
|
179
206
|
|
|
180
207
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
181
|
-
var _DataStoreManager$cli, _persistedState$
|
|
208
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli, _persistedState$domai6;
|
|
182
209
|
|
|
183
|
-
const
|
|
210
|
+
const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
|
|
211
|
+
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateEventName, "localStorage");
|
|
184
212
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
185
213
|
|
|
186
|
-
if (persistedState !== null && persistedState !== void 0 && (_persistedState$
|
|
187
|
-
var _persistedState$
|
|
214
|
+
if (persistedState !== null && persistedState !== void 0 && (_persistedState$domai6 = persistedState.domainStates) !== null && _persistedState$domai6 !== void 0 && _persistedState$domai6.liveChatContext) {
|
|
215
|
+
var _persistedState$domai7;
|
|
188
216
|
|
|
189
217
|
dispatch({
|
|
190
218
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
191
219
|
payload: _ConversationState.ConversationState.Loading
|
|
192
220
|
});
|
|
193
221
|
const optionalParams = {
|
|
194
|
-
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
222
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
195
223
|
};
|
|
196
224
|
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
197
225
|
return true;
|
|
198
226
|
} else {
|
|
199
227
|
return false;
|
|
200
228
|
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const setCustomContextParams = (props, state) => {
|
|
232
|
+
var _props$chatConfig, _state$domainStates;
|
|
233
|
+
|
|
234
|
+
// Add custom context if any only for unauthenticated chat
|
|
235
|
+
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && (_state$domainStates = state.domainStates) !== null && _state$domainStates !== void 0 && _state$domainStates.customContext) {
|
|
236
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
237
|
+
customContext: state.domainStates.customContext
|
|
238
|
+
});
|
|
239
|
+
}
|
|
201
240
|
};
|
|
@@ -107,7 +107,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
107
107
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.webChatStyles)
|
|
108
108
|
}); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
109
109
|
|
|
110
|
-
const chatSDK = (0, _useChatSDKStore.default)();
|
|
110
|
+
const chatSDK = (0, _useChatSDKStore.default)(); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
|
|
111
112
|
const [voiceVideoCallingSDK, setVoiceVideoCallingSDK] = (0, _react2.useState)(undefined);
|
|
112
113
|
const {
|
|
113
114
|
Composer
|
|
@@ -121,6 +122,33 @@ const LiveChatWidgetStateful = props => {
|
|
|
121
122
|
_TelemetryManager.TelemetryTimers.LcwLoadToChatButtonTimer = (0, _utils.createTimer)();
|
|
122
123
|
const widgetElementId = ((_props$controlProps = props.controlProps) === null || _props$controlProps === void 0 ? void 0 : _props$controlProps.id) || "oc-lcw";
|
|
123
124
|
const currentMessageCountRef = (0, _react2.useRef)(0);
|
|
125
|
+
let widgetStateEventName = "";
|
|
126
|
+
|
|
127
|
+
const initiateEndChatOnBrowserUnload = () => {
|
|
128
|
+
var _DataStoreManager$cli;
|
|
129
|
+
|
|
130
|
+
const persistedState = getStateFromCache(); // End chat if the chat is still active and browser closed
|
|
131
|
+
|
|
132
|
+
if (persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
133
|
+
//Browser close scenario/no room for PCS/so just end chat and notify agent immidiately
|
|
134
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
135
|
+
} // Clean local storage
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
(_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.removeData(widgetStateEventName, "localStorage");
|
|
139
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
const getStateFromCache = () => {
|
|
143
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _DataStoreManager$cli2;
|
|
144
|
+
|
|
145
|
+
// Getting updated state from cache
|
|
146
|
+
const widgetStateEventName = (0, _utils.getWidgetCacheId)((chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC === void 0 ? void 0 : _chatSDK$omnichannelC.orgId) ?? "", (chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC2 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC2 === void 0 ? void 0 : _chatSDK$omnichannelC2.widgetId) ?? "");
|
|
147
|
+
const widgetStateFromCache = (_DataStoreManager$cli2 = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli2 === void 0 ? void 0 : _DataStoreManager$cli2.getData(widgetStateEventName, "localStorage");
|
|
148
|
+
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
149
|
+
return persistedState;
|
|
150
|
+
};
|
|
151
|
+
|
|
124
152
|
(0, _react2.useEffect)(() => {
|
|
125
153
|
var _props$controlProps2, _props$controlProps3, _props$reconnectChatP, _props$controlProps4, _props$chatConfig, _props$chatConfig$Cha, _state$domainStates;
|
|
126
154
|
|
|
@@ -135,6 +163,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
135
163
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SKIP_CHAT_BUTTON_RENDERING,
|
|
136
164
|
payload: ((_props$controlProps2 = props.controlProps) === null || _props$controlProps2 === void 0 ? void 0 : _props$controlProps2.skipChatButtonRendering) || false
|
|
137
165
|
});
|
|
166
|
+
dispatch({
|
|
167
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
168
|
+
payload: false
|
|
169
|
+
});
|
|
138
170
|
(0, _initCallingSdk.initCallingSdk)(chatSDK, setVoiceVideoCallingSDK).then(sdkCreated => {
|
|
139
171
|
sdkCreated && dispatch({
|
|
140
172
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_E2VV_ENABLED,
|
|
@@ -163,11 +195,16 @@ const LiveChatWidgetStateful = props => {
|
|
|
163
195
|
};
|
|
164
196
|
(0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams);
|
|
165
197
|
}
|
|
166
|
-
}, []);
|
|
198
|
+
}, []); // useEffect for when skip chat button rendering
|
|
199
|
+
|
|
167
200
|
(0, _react2.useEffect)(() => {
|
|
168
201
|
if (state.appStates.skipChatButtonRendering) {
|
|
169
202
|
var _props$reconnectChatP3;
|
|
170
203
|
|
|
204
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
205
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
206
|
+
});
|
|
207
|
+
|
|
171
208
|
if ((_props$reconnectChatP3 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP3 !== void 0 && _props$reconnectChatP3.reconnectId && !state.appStates.reconnectId) {
|
|
172
209
|
var _props$reconnectChatP4, _props$reconnectChatP5;
|
|
173
210
|
|
|
@@ -199,9 +236,25 @@ const LiveChatWidgetStateful = props => {
|
|
|
199
236
|
});
|
|
200
237
|
}
|
|
201
238
|
}
|
|
202
|
-
}, [state.appStates.skipChatButtonRendering]);
|
|
239
|
+
}, [state.appStates.skipChatButtonRendering]); // useEffect for when skip chat button rendering
|
|
240
|
+
|
|
203
241
|
(0, _react2.useEffect)(() => {
|
|
204
|
-
|
|
242
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4;
|
|
243
|
+
|
|
244
|
+
// Add the custom context on receiving the SetCustomContext event
|
|
245
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.SetCustomContext).subscribe(msg => {
|
|
246
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
247
|
+
Event: _TelemetryConstants.TelemetryEvent.CustomContextReceived,
|
|
248
|
+
Description: "CustomContext received."
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
dispatch({
|
|
252
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
253
|
+
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartProactiveChat).subscribe(msg => {
|
|
205
258
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
206
259
|
Event: _TelemetryConstants.TelemetryEvent.StartProactiveChatEventReceived,
|
|
207
260
|
Description: "Start proactive chat event received."
|
|
@@ -217,32 +270,52 @@ const LiveChatWidgetStateful = props => {
|
|
|
217
270
|
Description: "Start proactive chat method called, when chat was already triggered."
|
|
218
271
|
});
|
|
219
272
|
}
|
|
220
|
-
}); //
|
|
273
|
+
}); // Start chat from SDK Event
|
|
221
274
|
|
|
222
275
|
|
|
223
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(
|
|
276
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartChat).subscribe(() => {
|
|
224
277
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
225
278
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventRecevied,
|
|
226
279
|
Description: "Start chat event received."
|
|
227
280
|
});
|
|
228
281
|
|
|
229
|
-
|
|
282
|
+
const persistedState = getStateFromCache();
|
|
283
|
+
|
|
284
|
+
if (persistedState && (persistedState.appStates.conversationState === _ConversationState.ConversationState.Closed || persistedState.appStates.conversationState === _ConversationState.ConversationState.InActive || persistedState.appStates.conversationState === _ConversationState.ConversationState.Postchat)) {
|
|
285
|
+
// Embedded mode
|
|
286
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
287
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
291
|
+
} else if (!persistedState) {
|
|
292
|
+
// Popout chat
|
|
293
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
294
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatInitiated
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
298
|
+
} else {
|
|
299
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4;
|
|
300
|
+
|
|
301
|
+
// Minimize to Maximize
|
|
230
302
|
dispatch({
|
|
231
303
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_MINIMIZED,
|
|
232
304
|
payload: false
|
|
233
305
|
});
|
|
234
|
-
} else {
|
|
235
|
-
(0, _startChat.prepareStartChat)(props, chatSDK, state, dispatch, setAdapter);
|
|
236
|
-
}
|
|
237
|
-
}); // end chat from SDK Event
|
|
238
306
|
|
|
307
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
308
|
+
eventName: _TelemetryConstants.BroadcastEvent.MaximizeChat,
|
|
309
|
+
payload: {
|
|
310
|
+
height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
|
|
311
|
+
width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
|
|
312
|
+
}
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}); // End chat
|
|
239
316
|
|
|
240
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName("EndChat").subscribe(async () => {
|
|
241
|
-
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
242
|
-
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
243
|
-
Description: "End chat event received."
|
|
244
|
-
});
|
|
245
317
|
|
|
318
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async () => {
|
|
246
319
|
if (canEndChat.current) {
|
|
247
320
|
(0, _endChat.prepareEndChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state);
|
|
248
321
|
} else {
|
|
@@ -250,18 +323,58 @@ const LiveChatWidgetStateful = props => {
|
|
|
250
323
|
const skipCloseChat = false;
|
|
251
324
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
252
325
|
}
|
|
326
|
+
|
|
327
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
328
|
+
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
329
|
+
});
|
|
253
330
|
});
|
|
254
331
|
|
|
332
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChatOnBrowserUnload).subscribe(() => {
|
|
333
|
+
initiateEndChatOnBrowserUnload();
|
|
334
|
+
}); // reset proactive chat params
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.ResetProactiveChatParams).subscribe(async () => {
|
|
338
|
+
dispatch({
|
|
339
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
340
|
+
payload: {
|
|
341
|
+
proactiveChatBodyTitle: "",
|
|
342
|
+
proactiveChatEnablePrechat: false,
|
|
343
|
+
proactiveChatInNewWindow: false
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}); // Listen to end chat event from other tabs
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC3 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC3 === void 0 ? void 0 : _chatSDK$omnichannelC3.orgId, chatSDK === null || chatSDK === void 0 ? void 0 : (_chatSDK$omnichannelC4 = chatSDK.omnichannelConfig) === null || _chatSDK$omnichannelC4 === void 0 ? void 0 : _chatSDK$omnichannelC4.widgetId);
|
|
350
|
+
|
|
351
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(async () => {
|
|
352
|
+
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, false);
|
|
353
|
+
}); // Close popout window
|
|
354
|
+
|
|
355
|
+
|
|
255
356
|
window.addEventListener("beforeunload", () => {
|
|
357
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
358
|
+
Event: _TelemetryConstants.TelemetryEvent.WindowClosed,
|
|
359
|
+
Description: "Closed window."
|
|
360
|
+
});
|
|
361
|
+
|
|
256
362
|
(0, _disposeTelemetryLoggers.disposeTelemetryLoggers)();
|
|
257
363
|
});
|
|
258
364
|
|
|
259
365
|
if (state.appStates.conversationEndedByAgent) {
|
|
260
366
|
(0, _endChat.endChat)(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter);
|
|
261
|
-
}
|
|
367
|
+
} //Listen to WidgetSize
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName("WidgetSize").subscribe(msg => {
|
|
371
|
+
dispatch({
|
|
372
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_SIZE,
|
|
373
|
+
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
374
|
+
});
|
|
375
|
+
});
|
|
262
376
|
}, []);
|
|
263
377
|
(0, _react2.useEffect)(() => {
|
|
264
|
-
canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed;
|
|
265
378
|
canEndChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Active;
|
|
266
379
|
|
|
267
380
|
if (state.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
@@ -282,7 +395,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
282
395
|
});
|
|
283
396
|
});
|
|
284
397
|
}
|
|
285
|
-
}, [state.appStates.conversationState]);
|
|
398
|
+
}, [state.appStates.conversationState]);
|
|
399
|
+
(0, _react2.useEffect)(() => {
|
|
400
|
+
canStartProactiveChat.current = state.appStates.conversationState === _ConversationState.ConversationState.Closed && !state.appStates.proactiveChatStates.proactiveChatInNewWindow;
|
|
401
|
+
}, [state.appStates.conversationState, state.appStates.proactiveChatStates.proactiveChatInNewWindow]); // Reset the UnreadMessageCount when minimized is toggled and broadcast it.
|
|
286
402
|
|
|
287
403
|
(0, _react2.useEffect)(() => {
|
|
288
404
|
currentMessageCountRef.current = -1;
|
|
@@ -316,7 +432,20 @@ const LiveChatWidgetStateful = props => {
|
|
|
316
432
|
setWebChatStyles({ ...webChatStyles,
|
|
317
433
|
...((_props$webChatContain2 = props.webChatContainerProps) === null || _props$webChatContain2 === void 0 ? void 0 : _props$webChatContain2.webChatStyles)
|
|
318
434
|
});
|
|
319
|
-
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]);
|
|
435
|
+
}, [(_props$webChatContain3 = props.webChatContainerProps) === null || _props$webChatContain3 === void 0 ? void 0 : _props$webChatContain3.webChatStyles]); // Publish chat widget state
|
|
436
|
+
|
|
437
|
+
(0, _react2.useEffect)(() => {
|
|
438
|
+
var _props$chatSDK, _props$chatSDK$omnich, _props$chatSDK2, _props$chatSDK2$omnic;
|
|
439
|
+
|
|
440
|
+
widgetStateEventName = (0, _utils.getWidgetCacheId)(props === null || props === void 0 ? void 0 : (_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, props === null || props === void 0 ? void 0 : (_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);
|
|
441
|
+
const chatWidgetStateChangeEvent = {
|
|
442
|
+
eventName: widgetStateEventName,
|
|
443
|
+
payload: { ...state
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
448
|
+
}, [state]);
|
|
320
449
|
const webChatProps = (0, _initWebChatComposer.initWebChatComposer)(props, chatSDK, state, dispatch, setWebChatStyles);
|
|
321
450
|
|
|
322
451
|
const setPostChatContextRelay = () => (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -332,17 +461,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
332
461
|
|
|
333
462
|
const initStartChatRelay = (optionalParams, persistedState) => (0, _startChat.initStartChat)(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
334
463
|
|
|
335
|
-
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
336
|
-
|
|
337
|
-
(0, _react2.useEffect)(() => {
|
|
338
|
-
const chatWidgetStateChangeEvent = {
|
|
339
|
-
eventName: _TelemetryConstants.BroadcastEvent.ChatWidgetStateChanged,
|
|
340
|
-
payload: { ...state
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
_omnichannelChatComponents.BroadcastService.postMessage(chatWidgetStateChangeEvent);
|
|
345
|
-
}, [state]);
|
|
464
|
+
const confirmationPaneProps = (0, _initConfirmationPropsComposer.initConfirmationPropsComposer)(props);
|
|
346
465
|
return /*#__PURE__*/_react2.default.createElement(Composer, _extends({}, webChatProps, {
|
|
347
466
|
styleOptions: webChatStyles,
|
|
348
467
|
directLine: ((_props$webChatContain4 = props.webChatContainerProps) === null || _props$webChatContain4 === void 0 ? void 0 : _props$webChatContain4.directLine) ?? adapter ?? _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.directLine
|
|
@@ -93,9 +93,10 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
try {
|
|
96
|
-
var _DataStoreManager$cli, _persistedState$domai;
|
|
96
|
+
var _state$domainStates, _state$domainStates$t, _state$domainStates$t2, _DataStoreManager$cli, _persistedState$domai;
|
|
97
97
|
|
|
98
|
-
const
|
|
98
|
+
const widgetStateCacheId = (0, _utils.getWidgetCacheId)(((_state$domainStates = state.domainStates) === null || _state$domainStates === void 0 ? void 0 : (_state$domainStates$t = _state$domainStates.telemetryInternalData) === null || _state$domainStates$t === void 0 ? void 0 : _state$domainStates$t.orgId) ?? "", ((_state$domainStates$t2 = state.domainStates.telemetryInternalData) === null || _state$domainStates$t2 === void 0 ? void 0 : _state$domainStates$t2.widgetId) ?? "");
|
|
99
|
+
const widgetStateFromCache = (_DataStoreManager$cli = _DataStoreManager.DataStoreManager.clientDataStore) === null || _DataStoreManager$cli === void 0 ? void 0 : _DataStoreManager$cli.getData(widgetStateCacheId, "localStorage");
|
|
99
100
|
const persistedState = widgetStateFromCache ? JSON.parse(widgetStateFromCache) : undefined;
|
|
100
101
|
let optionalParams = {};
|
|
101
102
|
|
|
@@ -109,9 +110,7 @@ const PreChatSurveyPaneStateful = props => {
|
|
|
109
110
|
} else {
|
|
110
111
|
const prechatResponseValues = (0, _utils.extractPreChatSurveyResponseValues)(state.domainStates.preChatSurveyResponse, values);
|
|
111
112
|
optionalParams = {
|
|
112
|
-
|
|
113
|
-
preChatResponse: prechatResponseValues
|
|
114
|
-
}
|
|
113
|
+
preChatResponse: prechatResponseValues
|
|
115
114
|
};
|
|
116
115
|
setPreChatResponseEmail(values);
|
|
117
116
|
await initStartChat(optionalParams);
|
|
@@ -46,6 +46,14 @@ const ProactiveChatPaneStateful = props => {
|
|
|
46
46
|
const handleProactiveChatInviteTimeout = () => {
|
|
47
47
|
if (!timeoutRemoved) {
|
|
48
48
|
setTimeoutRemoved(true);
|
|
49
|
+
dispatch({
|
|
50
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
51
|
+
payload: {
|
|
52
|
+
proactiveChatBodyTitle: "",
|
|
53
|
+
proactiveChatEnablePrechat: false,
|
|
54
|
+
proactiveChatInNewWindow: false
|
|
55
|
+
}
|
|
56
|
+
});
|
|
49
57
|
dispatch({
|
|
50
58
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
51
59
|
payload: _ConversationState.ConversationState.Closed
|
|
@@ -111,6 +119,14 @@ const ProactiveChatPaneStateful = props => {
|
|
|
111
119
|
Description: "Proactive chat closed."
|
|
112
120
|
});
|
|
113
121
|
|
|
122
|
+
dispatch({
|
|
123
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
124
|
+
payload: {
|
|
125
|
+
proactiveChatBodyTitle: "",
|
|
126
|
+
proactiveChatEnablePrechat: false,
|
|
127
|
+
proactiveChatInNewWindow: false
|
|
128
|
+
}
|
|
129
|
+
});
|
|
114
130
|
dispatch({
|
|
115
131
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
116
132
|
payload: _ConversationState.ConversationState.Closed
|
|
@@ -25,15 +25,53 @@ var _utils = require("../../common/utils");
|
|
|
25
25
|
|
|
26
26
|
var _ = require("../..");
|
|
27
27
|
|
|
28
|
+
var _WebChatActionType = require("./webchatcontroller/enums/WebChatActionType");
|
|
29
|
+
|
|
30
|
+
var _WebChatStoreLoader = require("./webchatcontroller/WebChatStoreLoader");
|
|
31
|
+
|
|
32
|
+
var _Constants = require("../../common/Constants");
|
|
33
|
+
|
|
34
|
+
var _BotMagicCodeStore = require("./webchatcontroller/BotMagicCodeStore");
|
|
35
|
+
|
|
28
36
|
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); }
|
|
29
37
|
|
|
30
38
|
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; }
|
|
31
39
|
|
|
40
|
+
const broadcastChannelMessageEvent = "message";
|
|
41
|
+
|
|
42
|
+
const postActivity = activity => {
|
|
43
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
44
|
+
return {
|
|
45
|
+
type: _WebChatActionType.WebChatActionType.DIRECT_LINE_POST_ACTIVITY,
|
|
46
|
+
meta: {
|
|
47
|
+
method: "keyboard"
|
|
48
|
+
},
|
|
49
|
+
payload: {
|
|
50
|
+
activity: {
|
|
51
|
+
channelData: undefined,
|
|
52
|
+
text: "",
|
|
53
|
+
textFormat: "plain",
|
|
54
|
+
type: _Constants.Constants.message,
|
|
55
|
+
...activity
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const createMagicCodeSuccessResponse = signin => {
|
|
62
|
+
return {
|
|
63
|
+
signin,
|
|
64
|
+
result: "Success"
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
|
|
32
68
|
const WebChatContainerStateful = props => {
|
|
33
69
|
const {
|
|
34
70
|
BasicWebChat
|
|
35
71
|
} = _botframeworkWebchat.Components;
|
|
36
72
|
const [state, dispatch] = (0, _.useChatContextStore)();
|
|
73
|
+
const magicCodeBroadcastChannel = new BroadcastChannel(_Constants.Constants.magicCodeBroadcastChannel);
|
|
74
|
+
const magicCodeResponseBroadcastChannel = new BroadcastChannel(_Constants.Constants.magicCodeResponseBroadcastChannel);
|
|
37
75
|
const containerStyles = {
|
|
38
76
|
root: Object.assign({}, _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.containerStyles, props === null || props === void 0 ? void 0 : props.containerStyles, {
|
|
39
77
|
display: state.appStates.isMinimized ? "none" : ""
|
|
@@ -58,6 +96,48 @@ const WebChatContainerStateful = props => {
|
|
|
58
96
|
Event: _TelemetryConstants.TelemetryEvent.WebChatLoaded
|
|
59
97
|
});
|
|
60
98
|
}, []);
|
|
99
|
+
(0, _react2.useEffect)(() => {
|
|
100
|
+
const eventListener = event => {
|
|
101
|
+
// eslint-disable-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-empty-function
|
|
102
|
+
const {
|
|
103
|
+
data
|
|
104
|
+
} = event;
|
|
105
|
+
|
|
106
|
+
if (_BotMagicCodeStore.BotMagicCodeStore.botOAuthSignInId === data.signin) {
|
|
107
|
+
const {
|
|
108
|
+
signin,
|
|
109
|
+
code
|
|
110
|
+
} = data;
|
|
111
|
+
const text = `${code}`;
|
|
112
|
+
const action = postActivity({
|
|
113
|
+
text,
|
|
114
|
+
channelData: {
|
|
115
|
+
tags: [_Constants.Constants.hiddenTag]
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
_WebChatStoreLoader.WebChatStoreLoader.store.dispatch(action);
|
|
120
|
+
|
|
121
|
+
const response = createMagicCodeSuccessResponse(signin);
|
|
122
|
+
magicCodeResponseBroadcastChannel.postMessage(response);
|
|
123
|
+
|
|
124
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
125
|
+
Event: _TelemetryConstants.TelemetryEvent.SuppressBotMagicCodeSucceeded
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
_BotMagicCodeStore.BotMagicCodeStore.botOAuthSignInId = "";
|
|
129
|
+
magicCodeBroadcastChannel.close();
|
|
130
|
+
magicCodeResponseBroadcastChannel.close();
|
|
131
|
+
} else {
|
|
132
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
133
|
+
Event: _TelemetryConstants.TelemetryEvent.SuppressBotMagicCodeFailed,
|
|
134
|
+
Description: "Signin does not match"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
magicCodeBroadcastChannel.addEventListener(broadcastChannelMessageEvent, eventListener);
|
|
140
|
+
}, []);
|
|
61
141
|
return /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
62
142
|
.ms_lcw_webchat_received_message img.webchat__markdown__external-link-icon {
|
|
63
143
|
background-image : url(data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIzIDMgMTggMTgiICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik03LjI1MDEgNC41MDAxN0gxMC43NDk1QzExLjE2MzcgNC41MDAxNyAxMS40OTk1IDQuODM1OTYgMTEuNDk5NSA1LjI1MDE3QzExLjQ5OTUgNS42Mjk4NiAxMS4yMTczIDUuOTQzNjYgMTAuODUxMyA1Ljk5MzMyTDEwLjc0OTUgNi4wMDAxN0g3LjI0OTc0QzYuMDcwNzkgNS45OTk2MSA1LjEwMzQ5IDYuOTA2NTYgNS4wMDc4NiA4LjA2MTEyTDUuMDAwMjggOC4yMjAwM0w1LjAwMzEyIDE2Ljc1MDdDNS4wMDM0MyAxNy45NDE1IDUuOTI4ODUgMTguOTE2MSA3LjA5OTY2IDE4Ljk5NDlMNy4yNTM3MSAxOS4wMDAxTDE1Ljc1MTggMTguOTg4NEMxNi45NDE1IDE4Ljk4NjggMTcuOTE0NSAxOC4wNjIgMTcuOTkzNSAxNi44OTIzTDE3Ljk5ODcgMTYuNzM4NFYxMy4yMzIxQzE3Ljk5ODcgMTIuODE3OSAxOC4zMzQ1IDEyLjQ4MjEgMTguNzQ4NyAxMi40ODIxQzE5LjEyODQgMTIuNDgyMSAxOS40NDIyIDEyLjc2NDMgMTkuNDkxOCAxMy4xMzAzTDE5LjQ5ODcgMTMuMjMyMVYxNi43Mzg0QzE5LjQ5ODcgMTguNzQwNyAxNy45MjkzIDIwLjM3NjkgMTUuOTUyOCAyMC40ODI5TDE1Ljc1MzggMjAuNDg4NEw3LjI1ODI3IDIwLjUwMDFMNy4wNTQ5NSAyMC40OTQ5QzUuMTQyMzkgMjAuMzk1NCAzLjYwODk1IDE4Ljg2MjcgMy41MDgzNyAxNi45NTAyTDMuNTAzMTIgMTYuNzUxMUwzLjUwMDg5IDguMjUyN0wzLjUwNTI5IDguMDUwMkMzLjYwNTM5IDYuMTM3NDkgNS4xMzg2NyA0LjYwNDQ5IDcuMDUwOTYgNC41MDUyN0w3LjI1MDEgNC41MDAxN0gxMC43NDk1SDcuMjUwMVpNMTMuNzQ4MSAzLjAwMTQ2TDIwLjMwMTggMy4wMDE5N0wyMC40MDE0IDMuMDE1NzVMMjAuNTAyMiAzLjA0MzkzTDIwLjU1OSAzLjA2ODAzQzIwLjYxMjIgMy4wOTEyMiAyMC42NjM0IDMuMTIxNjMgMjAuNzExMSAzLjE1ODg1TDIwLjc4MDQgMy4yMjE1NkwyMC44NjQxIDMuMzIwMTRMMjAuOTE4MyAzLjQxMDI1TDIwLjk1NyAzLjUwMDU3TDIwLjk3NjIgMy41NjQ3NkwyMC45ODk4IDMuNjI4NjJMMjAuOTk5MiAzLjcyMjgyTDIwLjk5OTcgMTAuMjU1NEMyMC45OTk3IDEwLjY2OTYgMjAuNjYzOSAxMS4wMDU0IDIwLjI0OTcgMTEuMDA1NEMxOS44NyAxMS4wMDU0IDE5LjU1NjIgMTAuNzIzMiAxOS41MDY1IDEwLjM1NzFMMTkuNDk5NyAxMC4yNTU0TDE5LjQ5ODkgNS41NjE0N0wxMi4yNzk3IDEyLjc4NDdDMTIuMDEzNCAxMy4wNTEgMTEuNTk2OCAxMy4wNzUzIDExLjMwMzEgMTIuODU3NUwxMS4yMTkgMTIuNzg0OUMxMC45NTI3IDEyLjUxODcgMTAuOTI4NCAxMi4xMDIxIDExLjE0NjIgMTEuODA4NEwxMS4yMTg4IDExLjcyNDNMMTguNDM2OSA0LjUwMTQ2SDEzLjc0ODFDMTMuMzY4NCA0LjUwMTQ2IDEzLjA1NDYgNC4yMTkzMSAxMy4wMDUgMy44NTMyNEwxMi45OTgxIDMuNzUxNDZDMTIuOTk4MSAzLjM3MTc3IDEzLjI4MDMgMy4wNTc5NyAxMy42NDY0IDMuMDA4MzFMMTMuNzQ4MSAzLjAwMTQ2WiIgZmlsbD0iI0ZGRkZGRiIgLz48L3N2Zz4) !important;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BotMagicCodeStore = 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 BotMagicCodeStore {}
|
|
11
|
+
|
|
12
|
+
exports.BotMagicCodeStore = BotMagicCodeStore;
|
|
13
|
+
|
|
14
|
+
_defineProperty(BotMagicCodeStore, "botOAuthSignInId", "");
|
|
@@ -75,6 +75,16 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
|
|
|
75
75
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
76
|
|
|
77
77
|
|
|
78
|
+
const isTagIncluded = (card, tag) => {
|
|
79
|
+
return isDataTagsPresent(card) && card.activity.channelData.tags.includes(tag);
|
|
80
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
const isDataTagsPresent = card => {
|
|
84
|
+
return card && card.activity && card.activity.channelData && card.activity.channelData.tags && card.activity.channelData.tags.length > 0;
|
|
85
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
|
+
|
|
87
|
+
|
|
78
88
|
const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
|
|
79
89
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
80
90
|
args[_key] = arguments[_key];
|
|
@@ -83,7 +93,7 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
83
93
|
const [card] = args;
|
|
84
94
|
|
|
85
95
|
if (card.activity) {
|
|
86
|
-
var _card$activity$from
|
|
96
|
+
var _card$activity$from;
|
|
87
97
|
|
|
88
98
|
if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel) {
|
|
89
99
|
var _card$activity$channe3;
|
|
@@ -98,7 +108,11 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
|
|
|
98
108
|
return () => false;
|
|
99
109
|
}
|
|
100
110
|
|
|
101
|
-
if ((
|
|
111
|
+
if (isTagIncluded(card, _Constants.Constants.hiddenTag)) {
|
|
112
|
+
return () => false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (isTagIncluded(card, _Constants.Constants.systemMessageTag)) {
|
|
102
116
|
return handleSystemMessage(next, args, card, systemMessageStyleProps);
|
|
103
117
|
} else if (card.activity.text && card.activity.type === _DirectLineActivityType.DirectLineActivityType.Message) {
|
|
104
118
|
if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === _Constants.Constants.webchatChannelId) {
|