@microsoft/omnichannel-chat-widget 0.1.0-main.63cfb47 → 0.1.0-main.7375e33
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 +48 -4
- package/lib/cjs/common/telemetry/TelemetryConstants.js +24 -3
- package/lib/cjs/common/telemetry/TelemetryManager.js +7 -1
- package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
- package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/cjs/common/utils.js +76 -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/registerTelemetryLoggers.js +3 -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 -87
- 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 +44 -3
- package/lib/esm/common/telemetry/TelemetryConstants.js +24 -3
- package/lib/esm/common/telemetry/TelemetryManager.js +6 -1
- package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
- package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +36 -14
- package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
- package/lib/esm/common/utils.js +55 -1
- 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/registerTelemetryLoggers.js +3 -13
- 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 -89
- 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 +24 -1
- package/lib/types/common/interfaces/IContextDataStore.d.ts +2 -2
- 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/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
- package/lib/types/common/utils.d.ts +6 -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 +3 -1
- 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 +4 -7
|
@@ -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";
|