@microsoft/omnichannel-chat-widget 0.1.0-main.84a7035 → 0.1.0-main.886e5cf
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 +16 -2
- package/lib/cjs/common/telemetry/TelemetryConstants.js +24 -3
- package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +16 -13
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +63 -2
- package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +20 -4
- package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
- package/lib/cjs/components/headerstateful/HeaderStateful.js +2 -2
- package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -14
- package/lib/cjs/components/livechatwidget/common/endChat.js +63 -16
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +20 -3
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +15 -15
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/cjs/components/livechatwidget/common/startChat.js +149 -70
- package/lib/cjs/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +198 -85
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +5 -10
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- 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/ConversationState.js +3 -2
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +24 -21
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
- package/lib/cjs/contexts/createReducer.js +16 -0
- package/lib/cjs/controller/componentController.js +3 -3
- package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
- package/lib/esm/common/Constants.js +16 -2
- package/lib/esm/common/telemetry/TelemetryConstants.js +24 -3
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +17 -11
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +44 -0
- package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +22 -7
- package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +0 -1
- package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
- package/lib/esm/components/headerstateful/HeaderStateful.js +2 -2
- package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +11 -14
- package/lib/esm/components/livechatwidget/common/endChat.js +61 -17
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +19 -5
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +17 -16
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +0 -4
- package/lib/esm/components/livechatwidget/common/startChat.js +149 -73
- package/lib/esm/components/livechatwidget/interfaces/IAuthProps.js +1 -0
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +190 -87
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +7 -11
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +17 -1
- 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/ConversationState.js +3 -2
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +24 -21
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +3 -2
- package/lib/esm/contexts/createReducer.js +16 -0
- package/lib/esm/controller/componentController.js +3 -3
- package/lib/esm/plugins/newMessageEventHandler.js +10 -12
- package/lib/types/common/Constants.d.ts +8 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +23 -5
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -1
- package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
- package/lib/types/common/utils.d.ts +5 -0
- package/lib/types/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/endChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -4
- package/lib/types/components/livechatwidget/common/setPostChatContextAndLoadSurvey.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/startChat.d.ts +4 -2
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +1 -1
- package/lib/types/components/livechatwidget/interfaces/IAuthProps.d.ts +4 -0
- package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +2 -0
- package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +0 -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/activityMiddleware.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/avatarMiddleware.d.ts +1 -1
- 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/ConversationState.d.ts +3 -2
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +24 -21
- package/package.json +2 -2
|
@@ -23,20 +23,39 @@ var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostCh
|
|
|
23
23
|
|
|
24
24
|
var _Constants = require("../../../common/Constants");
|
|
25
25
|
|
|
26
|
+
var _utils = require("../../../common/utils");
|
|
27
|
+
|
|
26
28
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
29
|
const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, state) => {
|
|
28
|
-
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4;
|
|
30
|
+
var _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _conversationDetails;
|
|
29
31
|
|
|
30
32
|
const isPostChatEnabled = (_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.msdyn_postconversationsurveyenable;
|
|
31
|
-
const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode;
|
|
32
|
-
|
|
33
|
+
const postChatSurveyMode = (_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : (_state$domainStates$l4 = _state$domainStates$l3.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l4 === void 0 ? void 0 : _state$domainStates$l4.msdyn_postconversationsurveymode; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
|
|
35
|
+
let conversationDetails = undefined;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
conversationDetails = await chatSDK.getConversationDetails();
|
|
39
|
+
} catch (erorr) {
|
|
40
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
41
|
+
Event: _TelemetryConstants.TelemetryEvent.GetConversationDetailsException,
|
|
42
|
+
ExceptionDetails: {
|
|
43
|
+
exception: `Failed to get conversation details: ${erorr}`
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
33
47
|
|
|
34
|
-
if (isPostChatEnabled === "true" && (conversationDetails === null ||
|
|
48
|
+
if (isPostChatEnabled === "true" && ((_conversationDetails = conversationDetails) === null || _conversationDetails === void 0 ? void 0 : _conversationDetails.canRenderPostChat) === _Constants.Constants.truePascal) {
|
|
35
49
|
const skipEndChatSDK = false;
|
|
36
50
|
const skipCloseChat = true;
|
|
37
|
-
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat);
|
|
51
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, true);
|
|
38
52
|
|
|
39
53
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
54
|
+
dispatch({
|
|
55
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
56
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
57
|
+
});
|
|
58
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
40
59
|
const loadPostChatEvent = {
|
|
41
60
|
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
42
61
|
};
|
|
@@ -48,15 +67,17 @@ const prepareEndChat = async (props, chatSDK, setAdapter, setWebChatStyles, disp
|
|
|
48
67
|
payload: _ConversationState.ConversationState.InActive
|
|
49
68
|
});
|
|
50
69
|
}
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
|
|
71
|
+
return;
|
|
53
72
|
}
|
|
73
|
+
|
|
74
|
+
await endChat(props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, false, false, true);
|
|
54
75
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
76
|
|
|
56
77
|
|
|
57
78
|
exports.prepareEndChat = prepareEndChat;
|
|
58
79
|
|
|
59
|
-
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat) => {
|
|
80
|
+
const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, adapter, skipEndChatSDK, skipCloseChat, postMessageToOtherTab) => {
|
|
60
81
|
if (!skipEndChatSDK) {
|
|
61
82
|
try {
|
|
62
83
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -71,8 +92,24 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
71
92
|
exception: ex
|
|
72
93
|
}
|
|
73
94
|
});
|
|
95
|
+
|
|
96
|
+
postMessageToOtherTab = false;
|
|
74
97
|
}
|
|
75
|
-
}
|
|
98
|
+
} // Need to clear these states immediately when chat ended from OC.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
dispatch({
|
|
102
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT,
|
|
103
|
+
payload: undefined
|
|
104
|
+
});
|
|
105
|
+
dispatch({
|
|
106
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
107
|
+
payload: undefined
|
|
108
|
+
});
|
|
109
|
+
dispatch({
|
|
110
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
111
|
+
payload: undefined
|
|
112
|
+
});
|
|
76
113
|
|
|
77
114
|
if (!skipCloseChat) {
|
|
78
115
|
try {
|
|
@@ -101,17 +138,27 @@ const endChat = async (props, chatSDK, setAdapter, setWebChatStyles, dispatch, a
|
|
|
101
138
|
payload: null
|
|
102
139
|
});
|
|
103
140
|
dispatch({
|
|
104
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
105
|
-
payload:
|
|
141
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_UNREAD_MESSAGE_COUNT,
|
|
142
|
+
payload: 0
|
|
106
143
|
});
|
|
107
144
|
dispatch({
|
|
108
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
109
|
-
payload:
|
|
145
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
146
|
+
payload: {
|
|
147
|
+
proactiveChatBodyTitle: "",
|
|
148
|
+
proactiveChatEnablePrechat: false,
|
|
149
|
+
proactiveChatInNewWindow: false
|
|
150
|
+
}
|
|
110
151
|
});
|
|
111
152
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
153
|
+
if (postMessageToOtherTab) {
|
|
154
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2;
|
|
155
|
+
|
|
156
|
+
const endChatEventName = (0, _utils.getWidgetEndChatEventName)(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);
|
|
157
|
+
|
|
158
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
159
|
+
eventName: endChatEventName
|
|
160
|
+
});
|
|
161
|
+
}
|
|
115
162
|
} catch (error) {
|
|
116
163
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
117
164
|
Event: _TelemetryConstants.TelemetryEvent.CloseChatMethodException,
|
|
@@ -63,11 +63,17 @@ var _preProcessingMiddleware = _interopRequireDefault(require("../../webchatcont
|
|
|
63
63
|
|
|
64
64
|
var _sanitizationMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/sanitizationMiddleware"));
|
|
65
65
|
|
|
66
|
+
var _cardActionMiddleware = require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware");
|
|
67
|
+
|
|
68
|
+
var _messageTimestampMiddleware = _interopRequireDefault(require("../../webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/messageTimestampMiddleware"));
|
|
69
|
+
|
|
70
|
+
var _Constants = require("../../../common/Constants");
|
|
71
|
+
|
|
66
72
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
67
73
|
|
|
68
74
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
69
75
|
const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles) => {
|
|
70
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21;
|
|
76
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _state$domainStates$l, _state$domainStates$l2, _state$domainStates$l3, _state$domainStates$l4, _state$domainStates$l8, _state$domainStates$l9, _props$webChatContain7, _props$webChatContain8, _state$domainStates$r, _state$domainStates$r2, _props$webChatContain9, _props$webChatContain10, _state$domainStates$r3, _state$domainStates$r4, _props$webChatContain11, _props$webChatContain12, _defaultWebChatContai, _props$webChatContain13, _props$webChatContain14, _props$webChatContain15, _props$webChatContain16, _state$domainStates$r5, _state$domainStates$r6, _props$webChatContain17, _props$webChatContain18, _defaultWebChatContai2, _props$webChatContain19, _props$webChatContain20, _defaultWebChatContai3, _props$webChatContain21, _props$webChatContain22;
|
|
71
77
|
|
|
72
78
|
const localizedTexts = { ..._defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts,
|
|
73
79
|
...((_props$webChatContain = props.webChatContainerProps) === null || _props$webChatContain === void 0 ? void 0 : _props$webChatContain.localizedTexts)
|
|
@@ -101,6 +107,12 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
101
107
|
|
|
102
108
|
if (isPostChatEnabled === "true") {
|
|
103
109
|
if (postChatSurveyMode === _PostChatSurveyMode.PostChatSurveyMode.Embed) {
|
|
110
|
+
_WebChatStoreLoader.WebChatStoreLoader.store = null;
|
|
111
|
+
dispatch({
|
|
112
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
113
|
+
payload: _ConversationState.ConversationState.PostchatLoading
|
|
114
|
+
});
|
|
115
|
+
await (0, _utils.addDelayInMs)(_Constants.Constants.PostChatLoadingDurationInMs);
|
|
104
116
|
const loadPostChatEvent = {
|
|
105
117
|
eventName: _TelemetryConstants.BroadcastEvent.LoadPostChatSurvey
|
|
106
118
|
};
|
|
@@ -123,10 +135,14 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
123
135
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
124
136
|
payload: undefined
|
|
125
137
|
});
|
|
138
|
+
dispatch({
|
|
139
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
140
|
+
payload: undefined
|
|
141
|
+
});
|
|
126
142
|
};
|
|
127
143
|
|
|
128
144
|
webChatStore = (0, _botframeworkWebchat.createStore)({}, //initial state
|
|
129
|
-
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
145
|
+
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l5 = state.domainStates.liveChatConfig) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.allowedFileExtensions, (_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : _state$domainStates$l6.maxUploadFileSize, localizedTexts), _channelDataMiddleware.default, (0, _conversationEndMiddleware.default)(conversationEndCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l7 = state.domainStates.liveChatConfig) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.DataMaskingInfo), _messageTimestampMiddleware.default, _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, _htmlTextMiddleware.default, (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
146
|
...(((_props$webChatContain6 = props.webChatContainerProps) === null || _props$webChatContain6 === void 0 ? void 0 : _props$webChatContain6.storeMiddlewares) ?? []));
|
|
131
147
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
132
148
|
} // Initialize the remaining Web Chat props
|
|
@@ -144,7 +160,8 @@ const initWebChatComposer = (props, chatSDK, state, dispatch, setWebChatStyles)
|
|
|
144
160
|
groupActivitiesMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableGroupActivitiesMiddleware ? undefined : (_defaultWebChatContai2 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai2 === void 0 ? void 0 : _defaultWebChatContai2.groupActivitiesMiddleware,
|
|
145
161
|
typingIndicatorMiddleware: (_props$webChatContain19 = props.webChatContainerProps) !== null && _props$webChatContain19 !== void 0 && (_props$webChatContain20 = _props$webChatContain19.renderingMiddlewareProps) !== null && _props$webChatContain20 !== void 0 && _props$webChatContain20.disableTypingIndicatorMiddleware ? undefined : (_defaultWebChatContai3 = _defaultWebChatContainerStatefulProps.defaultWebChatContainerStatefulProps.webChatProps) === null || _defaultWebChatContai3 === void 0 ? void 0 : _defaultWebChatContai3.typingIndicatorMiddleware,
|
|
146
162
|
onTelemetry: (0, _WebChatLogger.createWebChatTelemetry)(),
|
|
147
|
-
|
|
163
|
+
cardActionMiddleware: (0, _cardActionMiddleware.createCardActionMiddleware)(((_props$webChatContain21 = props.webChatContainerProps) === null || _props$webChatContain21 === void 0 ? void 0 : _props$webChatContain21.botMagicCode) || undefined),
|
|
164
|
+
...((_props$webChatContain22 = props.webChatContainerProps) === null || _props$webChatContain22 === void 0 ? void 0 : _props$webChatContain22.webChatProps)
|
|
148
165
|
};
|
|
149
166
|
return webChatProps;
|
|
150
167
|
};
|
|
@@ -44,9 +44,9 @@ const getChatReconnectContext = async (chatSDK, reconnectId) => {
|
|
|
44
44
|
exports.getChatReconnectContext = getChatReconnectContext;
|
|
45
45
|
|
|
46
46
|
const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
47
|
-
var _props$reconnectChatP, _props$
|
|
47
|
+
var _props$reconnectChatP, _props$authProps;
|
|
48
48
|
|
|
49
|
-
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$
|
|
49
|
+
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.isReconnectEnabled && (_props$authProps = props.authProps) !== null && _props$authProps !== void 0 && _props$authProps.authClientFunction // TODO: Implement this after storage is in place
|
|
50
50
|
|
|
51
51
|
/* && !isLoadWithState() */
|
|
52
52
|
) {
|
|
@@ -63,31 +63,31 @@ const getReconnectIdForAuthenticatedChat = async (props, chatSDK) => {
|
|
|
63
63
|
|
|
64
64
|
exports.getReconnectIdForAuthenticatedChat = getReconnectIdForAuthenticatedChat;
|
|
65
65
|
|
|
66
|
-
const handleUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
66
|
+
const handleUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat, redirectInSameWindow) => {
|
|
67
67
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
68
68
|
|
|
69
69
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
70
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
70
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
71
71
|
} else {
|
|
72
|
-
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
72
|
+
await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
|
|
73
73
|
}
|
|
74
74
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
exports.handleUnauthenticatedReconnectChat = handleUnauthenticatedReconnectChat;
|
|
78
78
|
|
|
79
|
-
const startUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
79
|
+
const startUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
80
80
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
81
81
|
|
|
82
82
|
if (!shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
83
|
-
await setReconnectIdAndStartChat(chatSDK, dispatch, setAdapter, reconnectId, initStartChat);
|
|
83
|
+
await setReconnectIdAndStartChat(chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat);
|
|
84
84
|
}
|
|
85
85
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
86
|
|
|
87
87
|
|
|
88
88
|
exports.startUnauthenticatedReconnectChat = startUnauthenticatedReconnectChat;
|
|
89
89
|
|
|
90
|
-
const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
90
|
+
const setReconnectIdAndStartChat = async (chatSDK, authProps, dispatch, setAdapter, reconnectId, initStartChat) => {
|
|
91
91
|
const startUnauthenticatedReconnectChat = {
|
|
92
92
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
93
93
|
};
|
|
@@ -105,7 +105,7 @@ const setReconnectIdAndStartChat = async (chatSDK, dispatch, setAdapter, reconne
|
|
|
105
105
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
106
106
|
payload: _ConversationState.ConversationState.Loading
|
|
107
107
|
});
|
|
108
|
-
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams);
|
|
108
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter, optionalParams);
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
const redirectPage = (redirectURL, redirectInSameWindow) => {
|
|
@@ -128,7 +128,7 @@ const shouldRedirectOrStartNewChat = reconnectAvailabilityResponse => {
|
|
|
128
128
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, initStartChat) => {
|
|
131
|
+
const startNewChatEmptyRedirectionUrl = async (chatSDK, authProps, dispatch, setAdapter, initStartChat) => {
|
|
132
132
|
const startUnauthenticatedReconnectChat = {
|
|
133
133
|
eventName: _TelemetryConstants.BroadcastEvent.StartUnauthenticatedReconnectChat
|
|
134
134
|
};
|
|
@@ -153,26 +153,26 @@ const startNewChatEmptyRedirectionUrl = async (chatSDK, dispatch, setAdapter, in
|
|
|
153
153
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
154
154
|
payload: _ConversationState.ConversationState.Loading
|
|
155
155
|
});
|
|
156
|
-
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
156
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter);
|
|
157
157
|
}
|
|
158
158
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
159
159
|
|
|
160
160
|
|
|
161
|
-
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
161
|
+
const handleRedirectUnauthenticatedReconnectChat = async (chatSDK, authProps, dispatch, setAdapter, initStartChat, reconnectId, redirectInSameWindow) => {
|
|
162
162
|
const reconnectAvailabilityResponse = await getChatReconnectContext(chatSDK, reconnectId);
|
|
163
163
|
|
|
164
164
|
if (shouldRedirectOrStartNewChat(reconnectAvailabilityResponse)) {
|
|
165
|
-
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
165
|
+
await redirectOrStartNewChat(reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow);
|
|
166
166
|
}
|
|
167
167
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
168
168
|
|
|
169
169
|
|
|
170
170
|
exports.handleRedirectUnauthenticatedReconnectChat = handleRedirectUnauthenticatedReconnectChat;
|
|
171
171
|
|
|
172
|
-
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
172
|
+
const redirectOrStartNewChat = async (reconnectAvailabilityResponse, chatSDK, authProps, dispatch, setAdapter, initStartChat, redirectInSameWindow) => {
|
|
173
173
|
if (reconnectAvailabilityResponse.redirectURL) {
|
|
174
174
|
redirectPage(reconnectAvailabilityResponse.redirectURL, redirectInSameWindow);
|
|
175
175
|
} else {
|
|
176
|
-
await startNewChatEmptyRedirectionUrl(chatSDK, dispatch, setAdapter, initStartChat);
|
|
176
|
+
await startNewChatEmptyRedirectionUrl(chatSDK, authProps, dispatch, setAdapter, initStartChat);
|
|
177
177
|
}
|
|
178
178
|
};
|
|
@@ -43,10 +43,6 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat)
|
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
|
|
46
|
-
dispatch({
|
|
47
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
48
|
-
payload: _ConversationState.ConversationState.Loading
|
|
49
|
-
});
|
|
50
46
|
dispatch({
|
|
51
47
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
52
48
|
payload: _ConversationState.ConversationState.Postchat
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.prepareStartChat = exports.initStartChat = void 0;
|
|
6
|
+
exports.setPreChatAndInitiateChat = exports.prepareStartChat = exports.initStartChat = void 0;
|
|
7
7
|
|
|
8
8
|
var _Constants = require("../../../common/Constants");
|
|
9
9
|
|
|
@@ -11,8 +11,6 @@ var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants"
|
|
|
11
11
|
|
|
12
12
|
var _ConversationState = require("../../../contexts/common/ConversationState");
|
|
13
13
|
|
|
14
|
-
var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
|
|
15
|
-
|
|
16
14
|
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
17
15
|
|
|
18
16
|
var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontroller/notification/NotificationHandler");
|
|
@@ -35,10 +33,17 @@ var _setPostChatContextAndLoadSurvey = require("./setPostChatContextAndLoadSurve
|
|
|
35
33
|
|
|
36
34
|
var _updateSessionDataForTelemetry = require("./updateSessionDataForTelemetry");
|
|
37
35
|
|
|
36
|
+
var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components");
|
|
37
|
+
|
|
38
38
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
39
|
+
let optionalParams = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
|
|
39
41
|
const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
40
42
|
var _props$reconnectChatP;
|
|
41
43
|
|
|
44
|
+
optionalParams = {}; //Resetting to ensure no stale values
|
|
45
|
+
// Can connect to existing chat session
|
|
46
|
+
|
|
42
47
|
if (await canConnectToExistingChat(props, chatSDK, state, dispatch, setAdapter)) {
|
|
43
48
|
return;
|
|
44
49
|
} // Redirecting if unauthenticated reconnect chat expired
|
|
@@ -47,58 +52,101 @@ const prepareStartChat = async (props, chatSDK, state, dispatch, setAdapter) =>
|
|
|
47
52
|
if ((_props$reconnectChatP = props.reconnectChatPaneProps) !== null && _props$reconnectChatP !== void 0 && _props$reconnectChatP.reconnectId) {
|
|
48
53
|
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
49
54
|
|
|
50
|
-
await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const parseToJson = false;
|
|
54
|
-
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
55
|
-
const showPrechat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat ? preChatSurveyResponse && state.appStates.proactiveChatStates.proactiveChatEnablePrechat : preChatSurveyResponse; // Getting reconnectId for authenticated chat
|
|
55
|
+
await (0, _reconnectChatHelper.handleRedirectUnauthenticatedReconnectChat)(chatSDK, props.authProps, dispatch, setAdapter, initStartChat, (_props$reconnectChatP2 = props.reconnectChatPaneProps) === null || _props$reconnectChatP2 === void 0 ? void 0 : _props$reconnectChatP2.reconnectId, (_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.redirectInSameWindow);
|
|
56
|
+
return;
|
|
57
|
+
} // Getting reconnectId for authenticated chat
|
|
56
58
|
|
|
57
|
-
const reconnectId = await (0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK);
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
payload: _ConversationState.ConversationState.Loading
|
|
81
|
-
});
|
|
82
|
-
await initStartChat(chatSDK, dispatch, setAdapter);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
60
|
+
const reconnectId = await (0, _reconnectChatHelper.getReconnectIdForAuthenticatedChat)(props, chatSDK);
|
|
61
|
+
|
|
62
|
+
if (reconnectId) {
|
|
63
|
+
dispatch({
|
|
64
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_RECONNECT_ID,
|
|
65
|
+
payload: reconnectId
|
|
66
|
+
});
|
|
67
|
+
dispatch({
|
|
68
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
69
|
+
payload: _ConversationState.ConversationState.ReconnectChat
|
|
70
|
+
});
|
|
71
|
+
return;
|
|
72
|
+
} // Set custom context params
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
setCustomContextParams(props, chatSDK); // Setting Proactive chat settings
|
|
76
|
+
|
|
77
|
+
const isProactiveChat = state.appStates.conversationState === _ConversationState.ConversationState.ProactiveChat;
|
|
78
|
+
const isPreChatEnabledInProactiveChat = state.appStates.proactiveChatStates.proactiveChatEnablePrechat; //Setting PreChat and intiate chat
|
|
79
|
+
|
|
80
|
+
setPreChatAndInitiateChat(chatSDK, props.authProps, dispatch, setAdapter, isProactiveChat, isPreChatEnabledInProactiveChat);
|
|
85
81
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
82
|
|
|
87
83
|
|
|
88
84
|
exports.prepareStartChat = prepareStartChat;
|
|
89
85
|
|
|
90
|
-
const
|
|
86
|
+
const setPreChatAndInitiateChat = async (chatSDK, authProps, dispatch, setAdapter, isProactiveChat, proactiveChatEnablePrechatState) => {
|
|
87
|
+
// Getting prechat Survey Context
|
|
88
|
+
const parseToJson = false;
|
|
89
|
+
const preChatSurveyResponse = await chatSDK.getPreChatSurvey(parseToJson);
|
|
90
|
+
const showPrechat = isProactiveChat ? preChatSurveyResponse && proactiveChatEnablePrechatState : preChatSurveyResponse;
|
|
91
|
+
|
|
92
|
+
if (showPrechat) {
|
|
93
|
+
dispatch({
|
|
94
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PRE_CHAT_SURVEY_RESPONSE,
|
|
95
|
+
payload: preChatSurveyResponse
|
|
96
|
+
});
|
|
97
|
+
dispatch({
|
|
98
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
99
|
+
payload: _ConversationState.ConversationState.Prechat
|
|
100
|
+
});
|
|
101
|
+
return;
|
|
102
|
+
} //Initiate start chat
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
dispatch({
|
|
106
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
107
|
+
payload: _ConversationState.ConversationState.Loading
|
|
108
|
+
});
|
|
109
|
+
await initStartChat(chatSDK, authProps, dispatch, setAdapter);
|
|
110
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
exports.setPreChatAndInitiateChat = setPreChatAndInitiateChat;
|
|
114
|
+
|
|
115
|
+
const initStartChat = async (chatSDK, authProps, dispatch, setAdapter, params, persistedState) => {
|
|
91
116
|
try {
|
|
92
117
|
var _newAdapter$activity$, _TelemetryTimers$Widg;
|
|
93
118
|
|
|
119
|
+
let isStartChatSuccessful = false; //Check if chat retrieved from cache
|
|
120
|
+
|
|
121
|
+
if (persistedState || params !== null && params !== void 0 && params.liveChatContext) {
|
|
122
|
+
var _persistedState$domai, _persistedState$domai2, _persistedState$domai3, _persistedState$domai4, _persistedState$domai5;
|
|
123
|
+
|
|
124
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
125
|
+
eventName: _TelemetryConstants.BroadcastEvent.ChatRetrievedFromCache,
|
|
126
|
+
payload: {
|
|
127
|
+
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,
|
|
128
|
+
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
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
94
133
|
try {
|
|
134
|
+
//Start widget load timer
|
|
95
135
|
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
96
136
|
|
|
97
137
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
98
138
|
Event: _TelemetryConstants.TelemetryEvent.StartChatSDKCall
|
|
99
|
-
});
|
|
139
|
+
}); // Set optional params
|
|
100
140
|
|
|
101
|
-
|
|
141
|
+
|
|
142
|
+
optionalParams = Object.assign({}, params, optionalParams); // set auth token to chat sdk before start chat
|
|
143
|
+
|
|
144
|
+
if (authProps && authProps.setAuthTokenProviderToChatSdk) {
|
|
145
|
+
await authProps.setAuthTokenProviderToChatSdk(chatSDK, authProps.authClientFunction);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
await chatSDK.startChat(optionalParams);
|
|
149
|
+
isStartChatSuccessful = true;
|
|
102
150
|
} catch (error) {
|
|
103
151
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
104
152
|
Event: _TelemetryConstants.TelemetryEvent.StartChatMethodException,
|
|
@@ -106,43 +154,52 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
106
154
|
exception: `Failed to setup startChat: ${error}`
|
|
107
155
|
}
|
|
108
156
|
});
|
|
109
|
-
|
|
157
|
+
|
|
158
|
+
isStartChatSuccessful = false; // Resetting the widget state to Closed, for recent introduction of OC rate limiting(429 Error)
|
|
159
|
+
// TODO : How to diplay a proper UI message to customer to try after sometime at this point - cool down scenario
|
|
160
|
+
|
|
161
|
+
dispatch({
|
|
162
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
163
|
+
payload: _ConversationState.ConversationState.Closed
|
|
164
|
+
});
|
|
165
|
+
return;
|
|
166
|
+
} // New adapter creation
|
|
167
|
+
|
|
110
168
|
|
|
111
169
|
const newAdapter = await (0, _createAdapter.createAdapter)(chatSDK);
|
|
112
170
|
setAdapter(newAdapter);
|
|
113
171
|
const chatToken = await chatSDK.getChatToken();
|
|
172
|
+
dispatch({
|
|
173
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
174
|
+
payload: chatToken
|
|
175
|
+
});
|
|
114
176
|
newAdapter === null || newAdapter === void 0 ? void 0 : (_newAdapter$activity$ = newAdapter.activity$) === null || _newAdapter$activity$ === void 0 ? void 0 : _newAdapter$activity$.subscribe((0, _newMessageEventHandler.createOnNewAdapterActivityHandler)(chatToken === null || chatToken === void 0 ? void 0 : chatToken.chatId, chatToken === null || chatToken === void 0 ? void 0 : chatToken.visitorId));
|
|
115
177
|
|
|
116
|
-
if (
|
|
117
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
-
if (chatSDK !== null && chatSDK !== void 0 && chatSDK.getVoiceVideoCalling) {
|
|
119
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
120
|
-
const chatToken = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getChatToken());
|
|
121
|
-
dispatch({
|
|
122
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CHAT_TOKEN,
|
|
123
|
-
payload: chatToken
|
|
124
|
-
});
|
|
125
|
-
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
178
|
+
if (persistedState) {
|
|
129
179
|
dispatch({
|
|
130
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
131
|
-
payload:
|
|
180
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
181
|
+
payload: persistedState
|
|
132
182
|
});
|
|
133
|
-
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch);
|
|
134
|
-
|
|
183
|
+
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
|
|
184
|
+
return;
|
|
185
|
+
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
const liveChatContext = await (chatSDK === null || chatSDK === void 0 ? void 0 : chatSDK.getCurrentLiveChatContext());
|
|
189
|
+
dispatch({
|
|
190
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_LIVE_CHAT_CONTEXT,
|
|
191
|
+
payload: liveChatContext
|
|
192
|
+
}); // Set post chat context in state, no survey load
|
|
193
|
+
|
|
194
|
+
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch); // Updating chat session detail for telemetry
|
|
195
|
+
|
|
196
|
+
await (0, _updateSessionDataForTelemetry.updateSessionDataForTelemetry)(chatSDK, dispatch); // Set app state to Active
|
|
135
197
|
|
|
198
|
+
if (isStartChatSuccessful) {
|
|
136
199
|
dispatch({
|
|
137
200
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
138
201
|
payload: _ConversationState.ConversationState.Active
|
|
139
202
|
});
|
|
140
|
-
} else {
|
|
141
|
-
dispatch({
|
|
142
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_WIDGET_STATE,
|
|
143
|
-
payload: persistedState
|
|
144
|
-
});
|
|
145
|
-
await (0, _setPostChatContextAndLoadSurvey.setPostChatContextAndLoadSurvey)(chatSDK, dispatch, true);
|
|
146
203
|
}
|
|
147
204
|
|
|
148
205
|
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
@@ -171,6 +228,8 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
171
228
|
payload: _ConversationState.ConversationState.OutOfOffice
|
|
172
229
|
});
|
|
173
230
|
}
|
|
231
|
+
} finally {
|
|
232
|
+
optionalParams = {};
|
|
174
233
|
}
|
|
175
234
|
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
176
235
|
|
|
@@ -178,24 +237,44 @@ const initStartChat = async (chatSDK, dispatch, setAdapter, params, persistedSta
|
|
|
178
237
|
exports.initStartChat = initStartChat;
|
|
179
238
|
|
|
180
239
|
const canConnectToExistingChat = async (props, chatSDK, state, dispatch, setAdapter) => {
|
|
181
|
-
var
|
|
240
|
+
var _chatSDK$omnichannelC, _chatSDK$omnichannelC2, _persistedState$domai6, _persistedState$appSt;
|
|
182
241
|
|
|
183
|
-
|
|
184
|
-
|
|
242
|
+
// By pass this function in case of popout chat
|
|
243
|
+
if (state.appStates.skipChatButtonRendering === true) {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const persistedState = (0, _utils.getStateFromCache)(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); //Connect to only active chat session
|
|
185
248
|
|
|
186
|
-
if (persistedState
|
|
187
|
-
var _persistedState$
|
|
249
|
+
if (persistedState && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai6 = persistedState.domainStates) === null || _persistedState$domai6 === void 0 ? void 0 : _persistedState$domai6.liveChatContext) && (persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$appSt = persistedState.appStates) === null || _persistedState$appSt === void 0 ? void 0 : _persistedState$appSt.conversationState) === _ConversationState.ConversationState.Active) {
|
|
250
|
+
var _persistedState$domai7;
|
|
188
251
|
|
|
189
252
|
dispatch({
|
|
190
253
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
191
254
|
payload: _ConversationState.ConversationState.Loading
|
|
192
255
|
});
|
|
193
256
|
const optionalParams = {
|
|
194
|
-
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$
|
|
257
|
+
liveChatContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai7 = persistedState.domainStates) === null || _persistedState$domai7 === void 0 ? void 0 : _persistedState$domai7.liveChatContext
|
|
195
258
|
};
|
|
196
|
-
await initStartChat(chatSDK, dispatch, setAdapter, optionalParams, persistedState);
|
|
259
|
+
await initStartChat(chatSDK, props.authProps, dispatch, setAdapter, optionalParams, persistedState);
|
|
197
260
|
return true;
|
|
198
261
|
} else {
|
|
199
262
|
return false;
|
|
200
263
|
}
|
|
264
|
+
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
const setCustomContextParams = (props, chatSDK) => {
|
|
268
|
+
var _chatSDK$omnichannelC3, _chatSDK$omnichannelC4, _props$chatConfig, _persistedState$domai8;
|
|
269
|
+
|
|
270
|
+
// Add custom context only for unauthenticated chat
|
|
271
|
+
const persistedState = (0, _utils.getStateFromCache)(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);
|
|
272
|
+
|
|
273
|
+
if (!((_props$chatConfig = props.chatConfig) !== null && _props$chatConfig !== void 0 && _props$chatConfig.LiveChatConfigAuthSettings) && !(0, _utils.isUndefinedOrEmpty)(persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai8 = persistedState.domainStates) === null || _persistedState$domai8 === void 0 ? void 0 : _persistedState$domai8.customContext)) {
|
|
274
|
+
var _persistedState$domai9;
|
|
275
|
+
|
|
276
|
+
optionalParams = Object.assign({}, optionalParams, {
|
|
277
|
+
customContext: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai9 = persistedState.domainStates) === null || _persistedState$domai9 === void 0 ? void 0 : _persistedState$domai9.customContext
|
|
278
|
+
});
|
|
279
|
+
}
|
|
201
280
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|