@microsoft/omnichannel-chat-widget 1.8.4-main.7bdb634 → 1.8.4-main.c687f88
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 +27 -0
- package/lib/cjs/common/Constants.js +3 -0
- package/lib/cjs/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/cjs/common/telemetry/TelemetryConstants.js +15 -2
- package/lib/cjs/common/telemetry/TelemetryManager.js +10 -7
- package/lib/cjs/common/telemetry/loggers/appInsightsLogger.js +29 -13
- package/lib/cjs/common/utils.js +14 -1
- package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
- package/lib/cjs/components/citationpanestateful/CitationPaneStateful.js +20 -1
- package/lib/cjs/components/errorboundary/ErrorBoundary.js +2 -1
- package/lib/cjs/components/headerstateful/HeaderStateful.js +8 -2
- package/lib/cjs/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
- package/lib/cjs/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
- package/lib/cjs/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
- package/lib/cjs/components/livechatwidget/common/endChat.js +26 -9
- package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +9 -2
- package/lib/cjs/components/livechatwidget/common/liveChatConfigUtils.js +36 -4
- package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/cjs/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/cjs/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/cjs/components/livechatwidget/common/startChat.js +5 -1
- package/lib/cjs/components/livechatwidget/common/startChatErrorHandler.js +24 -4
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +124 -28
- package/lib/cjs/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +37 -8
- package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +12 -3
- package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +28 -30
- package/lib/cjs/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +12 -12
- package/lib/cjs/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/cjs/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
- package/lib/cjs/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -0
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
- package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/cjs/contexts/createReducer.js +15 -0
- package/lib/cjs/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/cjs/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/cjs/plugins/newMessageEventHandler.js +4 -1
- package/lib/esm/common/Constants.js +3 -0
- package/lib/esm/common/telemetry/AppInsightsEvents.js +14 -9
- package/lib/esm/common/telemetry/TelemetryConstants.js +13 -1
- package/lib/esm/common/telemetry/TelemetryManager.js +10 -7
- package/lib/esm/common/telemetry/loggers/appInsightsLogger.js +30 -14
- package/lib/esm/common/utils.js +11 -0
- package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +17 -5
- package/lib/esm/components/citationpanestateful/CitationPaneStateful.js +20 -1
- package/lib/esm/components/errorboundary/ErrorBoundary.js +4 -2
- package/lib/esm/components/headerstateful/HeaderStateful.js +9 -3
- package/lib/esm/components/livechatwidget/common/ChatWidgetEvents.js +1 -1
- package/lib/esm/components/livechatwidget/common/PersistentConversationHandler.js +26 -20
- package/lib/esm/components/livechatwidget/common/defaultProps/defaultPersistentChatHistoryProps.js +1 -2
- package/lib/esm/components/livechatwidget/common/endChat.js +26 -9
- package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +9 -2
- package/lib/esm/components/livechatwidget/common/liveChatConfigUtils.js +33 -2
- package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +3 -0
- package/lib/esm/components/livechatwidget/common/renderSurveyHelpers.js +2 -2
- package/lib/esm/components/livechatwidget/common/setPostChatContextAndLoadSurvey.js +3 -3
- package/lib/esm/components/livechatwidget/common/startChat.js +7 -3
- package/lib/esm/components/livechatwidget/common/startChatErrorHandler.js +23 -4
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +125 -29
- package/lib/esm/components/postchatsurveypanestateful/PostChatSurveyPaneStateful.js +39 -10
- package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +13 -4
- package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +29 -34
- package/lib/esm/components/webchatcontainerstateful/common/activityConverters/convertPersistentChatHistoryMessageToActivity.js +12 -12
- package/lib/esm/components/webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts.js +2 -1
- package/lib/esm/components/webchatcontainerstateful/hooks/usePersistentChatHistory.js +1 -3
- package/lib/esm/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.js +6 -7
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/ConversationDividerActivity.js +30 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.js +21 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +7 -2
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/timestamps/NotDeliveredTimestamp.js +3 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/channelDataMiddleware.js +1 -0
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/citationsMiddleware.js +6 -1
- package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.js +29 -7
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +7 -1
- package/lib/esm/contexts/createReducer.js +15 -0
- package/lib/esm/firstresponselatency/FirstMessageTrackerFromBot.js +3 -2
- package/lib/esm/firstresponselatency/FirstResponseLatencyTracker.js +6 -2
- package/lib/esm/plugins/newMessageEventHandler.js +4 -1
- package/lib/types/common/Constants.d.ts +3 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +12 -1
- package/lib/types/common/telemetry/interfaces/IInternalTelemetryData.d.ts +1 -0
- package/lib/types/common/utils.d.ts +9 -1
- package/lib/types/components/errorboundary/ErrorBoundary.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/ChatWidgetEvents.d.ts +1 -1
- package/lib/types/components/livechatwidget/common/liveChatConfigUtils.d.ts +11 -0
- package/lib/types/components/livechatwidget/common/startChatErrorHandler.d.ts +1 -0
- package/lib/types/components/livechatwidget/interfaces/IPersistentChatHistoryProps.d.ts +5 -1
- package/lib/types/components/webchatcontainerstateful/interfaces/IExtendedChatConffig.d.ts +15 -0
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/WebChatEventSubscribers.d.ts +1 -2
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activities/LazyLoadActivity.d.ts +1 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.d.ts +2 -1
- package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/storemiddlewares/localizedStringsBotInitialsMiddleware.d.ts +1 -1
- package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
- package/lib/types/contexts/common/ILiveChatWidgetLocalizedTexts.d.ts +5 -0
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/package.json +3 -3
|
@@ -125,7 +125,14 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
125
125
|
};
|
|
126
126
|
webChatStore = (0, _botframeworkWebchat.createStore)({},
|
|
127
127
|
//initial state
|
|
128
|
-
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, (0, _citationsMiddleware.createCitationsMiddleware)(state, dispatch), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.default)(),
|
|
128
|
+
_preProcessingMiddleware.default, _attachmentProcessingMiddleware.default, (0, _attachmentUploadValidatorMiddleware.default)((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : _state$domainStates$l.allowedFileExtensions, (_state$domainStates$l2 = state.domainStates.liveChatConfig) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.maxUploadFileSize, localizedTexts), (0, _customEventMiddleware.default)(_omnichannelChatComponents.BroadcastService), (0, _queueOverflowHandlerMiddleware.createQueueOverflowMiddleware)(state, dispatch), (0, _channelDataMiddleware.default)(addConversationalSurveyTagsCallback), (0, _conversationEndMiddleware.default)(conversationEndCallback, startConversationalSurveyCallback, endConversationalSurveyCallback), (0, _dataMaskingMiddleware.default)((_state$domainStates$l3 = state.domainStates.liveChatConfig) === null || _state$domainStates$l3 === void 0 ? void 0 : _state$domainStates$l3.DataMaskingInfo), _messageTimestampMiddleware.createMessageTimeStampMiddleware, _messageSequenceIdOverrideMiddleware.createMessageSequenceIdOverrideMiddleware, (0, _citationsMiddleware.createCitationsMiddleware)(state, dispatch), _gifUploadMiddleware.default, _htmlPlayerMiddleware.default, (0, _htmlTextMiddleware.default)(honorsTargetInHTMLLinks), (0, _maxMessageSizeValidator.default)(localizedTexts), _sanitizationMiddleware.default, (0, _callActionMiddleware.default)(),
|
|
129
|
+
// Pass a callback so middleware can push initials into React context for reactivity
|
|
130
|
+
(0, _localizedStringsBotInitialsMiddleware.localizedStringsBotInitialsMiddleware)(initials => {
|
|
131
|
+
dispatch({
|
|
132
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_BOT_AVATAR_INITIALS,
|
|
133
|
+
payload: initials
|
|
134
|
+
});
|
|
135
|
+
}),
|
|
129
136
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
130
137
|
...(((_props$webChatContain7 = props.webChatContainerProps) === null || _props$webChatContain7 === void 0 ? void 0 : _props$webChatContain7.storeMiddlewares) ?? []));
|
|
131
138
|
_WebChatStoreLoader.WebChatStoreLoader.store = webChatStore;
|
|
@@ -168,7 +175,7 @@ const initWebChatComposer = (props, state, dispatch, facadeChatSDK, endChat) =>
|
|
|
168
175
|
dir: state.domainStates.globalDir,
|
|
169
176
|
locale: (0, _utils.changeLanguageCodeFormatForWebChat)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l4 = state.domainStates.liveChatConfig) === null || _state$domainStates$l4 === void 0 ? void 0 : (_state$domainStates$l5 = _state$domainStates$l4.ChatWidgetLanguage) === null || _state$domainStates$l5 === void 0 ? void 0 : _state$domainStates$l5.msdyn_localeid)),
|
|
170
177
|
store: webChatStore,
|
|
171
|
-
activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : (0, _activityMiddleware.createActivityMiddleware)(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps),
|
|
178
|
+
activityMiddleware: (_props$webChatContain11 = props.webChatContainerProps) !== null && _props$webChatContain11 !== void 0 && (_props$webChatContain12 = _props$webChatContain11.renderingMiddlewareProps) !== null && _props$webChatContain12 !== void 0 && _props$webChatContain12.disableActivityMiddleware ? undefined : (0, _activityMiddleware.createActivityMiddleware)(renderMarkdown, (_state$domainStates$r = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r === void 0 ? void 0 : _state$domainStates$r.systemMessageStyleProps, (_state$domainStates$r2 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r2 === void 0 ? void 0 : _state$domainStates$r2.userMessageStyleProps, localizedTexts),
|
|
172
179
|
attachmentMiddleware: (_props$webChatContain13 = props.webChatContainerProps) !== null && _props$webChatContain13 !== void 0 && (_props$webChatContain14 = _props$webChatContain13.renderingMiddlewareProps) !== null && _props$webChatContain14 !== void 0 && _props$webChatContain14.disableAttachmentMiddleware ? undefined : (0, _attachmentMiddleware.createAttachmentMiddleware)(((_state$domainStates$r3 = state.domainStates.renderingMiddlewareProps) === null || _state$domainStates$r3 === void 0 ? void 0 : (_state$domainStates$r4 = _state$domainStates$r3.attachmentProps) === null || _state$domainStates$r4 === void 0 ? void 0 : _state$domainStates$r4.enableInlinePlaying) ?? _defaultAttachmentProps.defaultAttachmentProps.enableInlinePlaying),
|
|
173
180
|
activityStatusMiddleware: (_props$webChatContain15 = props.webChatContainerProps) !== null && _props$webChatContain15 !== void 0 && (_props$webChatContain16 = _props$webChatContain15.renderingMiddlewareProps) !== null && _props$webChatContain16 !== void 0 && _props$webChatContain16.disableActivityStatusMiddleware ? undefined : (0, _activityStatusMiddleware.createActivityStatusMiddleware)((0, _omnichannelChatSdk.getLocaleStringFromId)((_state$domainStates$l6 = state.domainStates.liveChatConfig) === null || _state$domainStates$l6 === void 0 ? void 0 : (_state$domainStates$l7 = _state$domainStates$l6.ChatWidgetLanguage) === null || _state$domainStates$l7 === void 0 ? void 0 : _state$domainStates$l7.msdyn_localeid)),
|
|
174
181
|
toastMiddleware: (_props$webChatContain17 = props.webChatContainerProps) !== null && _props$webChatContain17 !== void 0 && (_props$webChatContain18 = _props$webChatContain17.renderingMiddlewareProps) !== null && _props$webChatContain18 !== void 0 && _props$webChatContain18.disableToastMiddleware ? undefined : (0, _toastMiddleware.createToastMiddleware)(props.notificationPaneProps, endChat),
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = exports.getPostChatSurveyConfig = void 0;
|
|
7
|
-
var _Constants = require("../../../common/Constants");
|
|
6
|
+
exports.shouldLoadPersistentChatHistory = exports.isPostChatSurveyEnabled = exports.isPersistentChatEnabled = exports.getPostChatSurveyConfig = void 0;
|
|
8
7
|
var _utils = require("../../../common/utils");
|
|
8
|
+
var _Constants = require("../../../common/Constants");
|
|
9
9
|
const isPostChatSurveyEnabled = async facadeChatSDK => {
|
|
10
10
|
var _chatConfig$LiveWSAnd;
|
|
11
11
|
const chatConfig = await facadeChatSDK.getLiveChatConfig();
|
|
12
12
|
const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
|
|
13
13
|
return postChatEnabled === "true";
|
|
14
14
|
};
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
17
|
exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
|
|
16
18
|
const getPostChatSurveyConfig = async facadeChatSDK => {
|
|
17
19
|
var _chatConfig$LiveWSAnd2, _chatConfig$LiveWSAnd3, _chatConfig$LiveWSAnd4, _chatConfig$LiveWSAnd5, _chatConfig$LiveWSAnd6, _chatConfig$LiveWSAnd7, _chatConfig$LiveWSAnd8, _chatConfig$LiveWSAnd9, _chatConfig$LiveWSAnd10;
|
|
@@ -34,6 +36,36 @@ const isPersistentChatEnabled = conversationMode => {
|
|
|
34
36
|
if ((0, _utils.isNullOrUndefined)(conversationMode)) {
|
|
35
37
|
return false;
|
|
36
38
|
}
|
|
37
|
-
return (conversationMode === null || conversationMode === void 0 ? void 0 : conversationMode.toString()
|
|
39
|
+
return (conversationMode === null || conversationMode === void 0 ? void 0 : conversationMode.toString()) === _Constants.ConversationMode.Persistent;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Determines if persistent chat history should be loaded based on all required conditions.
|
|
44
|
+
*
|
|
45
|
+
* @param extendedChatConfig - The extended chat configuration object
|
|
46
|
+
* @returns true if ALL conditions are met:
|
|
47
|
+
* 1. Conversation mode must be Persistent ("192350001")
|
|
48
|
+
* 2. History is enabled in admin config (msdyn_enablepersistentchatpreviousconversations)
|
|
49
|
+
* 3. History is enabled via feature flag (lcwPersistentChatHistoryEnabled)
|
|
50
|
+
*/
|
|
51
|
+
exports.isPersistentChatEnabled = isPersistentChatEnabled;
|
|
52
|
+
const shouldLoadPersistentChatHistory = extendedChatConfig => {
|
|
53
|
+
var _extendedChatConfig$L, _extendedChatConfig$L2, _extendedChatConfig$L3;
|
|
54
|
+
// CRITICAL: First check if conversation mode is persistent
|
|
55
|
+
// Only persistent mode ("192350001") should allow history loading
|
|
56
|
+
const isPersistentChatEnabledForWidget = isPersistentChatEnabled(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L === void 0 ? void 0 : _extendedChatConfig$L.msdyn_conversationmode);
|
|
57
|
+
if (!isPersistentChatEnabledForWidget) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Check if history is enabled in admin config (handles both boolean and string "true"/"false")
|
|
62
|
+
const isHistoryEnabledInConfig = (0, _utils.parseBooleanFromConfig)(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L2 = extendedChatConfig.LiveWSAndLiveChatEngJoin) === null || _extendedChatConfig$L2 === void 0 ? void 0 : _extendedChatConfig$L2.msdyn_enablepersistentchatpreviousconversations);
|
|
63
|
+
if (!isHistoryEnabledInConfig) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Check if history is enabled via feature flag (handles both boolean and string "true"/"false")
|
|
68
|
+
const isHistoryEnabledViaFCB = (0, _utils.parseBooleanFromConfig)(extendedChatConfig === null || extendedChatConfig === void 0 ? void 0 : (_extendedChatConfig$L3 = extendedChatConfig.LcwFcbConfiguration) === null || _extendedChatConfig$L3 === void 0 ? void 0 : _extendedChatConfig$L3.lcwPersistentChatHistoryEnabled);
|
|
69
|
+
return isHistoryEnabledViaFCB;
|
|
38
70
|
};
|
|
39
|
-
exports.
|
|
71
|
+
exports.shouldLoadPersistentChatHistory = shouldLoadPersistentChatHistory;
|
|
@@ -30,7 +30,10 @@ const registerTelemetryLoggers = (props, dispatch) => {
|
|
|
30
30
|
appInsightsConfig: Object.assign({}, _defaultAppInsightsConfig.defaultAppInsightsConfig, props.appInsightsConfig)
|
|
31
31
|
};
|
|
32
32
|
if (props.chatConfig) {
|
|
33
|
+
var _props$chatConfig$Liv;
|
|
33
34
|
telemetryData = _TelemetryHelper.TelemetryHelper.addChatConfigDataToTelemetry(props === null || props === void 0 ? void 0 : props.chatConfig, telemetryData);
|
|
35
|
+
//store AppInsights instrumentation key from chatConfig if present
|
|
36
|
+
telemetryData.chatConfigAppInsightsKey = (_props$chatConfig$Liv = props.chatConfig.LiveWSAndLiveChatEngJoin) === null || _props$chatConfig$Liv === void 0 ? void 0 : _props$chatConfig$Liv.AppInsightsInstrumentationKey;
|
|
34
37
|
}
|
|
35
38
|
if (!((_props$chatSDK = props.chatSDK) !== null && _props$chatSDK !== void 0 && (_props$chatSDK$omnich = _props$chatSDK.omnichannelConfig) !== null && _props$chatSDK$omnich !== void 0 && _props$chatSDK$omnich.orgId) || ((_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.orgId.trim().length) === 0) {
|
|
36
39
|
throw new Error("orgId is undefined in ChatSDK");
|
|
@@ -156,7 +156,7 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
|
|
|
156
156
|
if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
|
|
157
157
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
158
|
const context = await facadeChatSDK.getPostChatSurveyContext();
|
|
159
|
-
_TelemetryHelper.TelemetryHelper.
|
|
159
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
160
160
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
|
|
161
161
|
Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
|
|
162
162
|
});
|
|
@@ -174,7 +174,7 @@ const getPostChatContext = async (facadeChatSDK, state, dispatch) => {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
} catch (error) {
|
|
177
|
-
_TelemetryHelper.TelemetryHelper.
|
|
177
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
178
178
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallFailed,
|
|
179
179
|
Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallFailed,
|
|
180
180
|
ExceptionDetails: {
|
|
@@ -24,13 +24,13 @@ const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persiste
|
|
|
24
24
|
const postChatEnabled = postChatConfig.postChatEnabled;
|
|
25
25
|
if (postChatEnabled) {
|
|
26
26
|
if (!persistedChat) {
|
|
27
|
-
_TelemetryHelper.TelemetryHelper.
|
|
27
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
28
28
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallStarted,
|
|
29
29
|
Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallStarted
|
|
30
30
|
});
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
32
|
const context = await facadeChatSDK.getPostChatSurveyContext();
|
|
33
|
-
_TelemetryHelper.TelemetryHelper.
|
|
33
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
34
34
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
|
|
35
35
|
Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
|
|
36
36
|
});
|
|
@@ -47,7 +47,7 @@ const setPostChatContextAndLoadSurvey = async (facadeChatSDK, dispatch, persiste
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
} catch (ex) {
|
|
50
|
-
_TelemetryHelper.TelemetryHelper.
|
|
50
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
|
|
51
51
|
Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallFailed,
|
|
52
52
|
Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallFailed,
|
|
53
53
|
ExceptionDetails: {
|
|
@@ -181,7 +181,10 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
|
|
|
181
181
|
_TelemetryManager.TelemetryTimers.WidgetLoadTimer = (0, _utils.createTimer)();
|
|
182
182
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
183
183
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadStarted,
|
|
184
|
-
Description: "Widget start chat started."
|
|
184
|
+
Description: "Widget start chat started.",
|
|
185
|
+
CustomProperties: {
|
|
186
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
187
|
+
}
|
|
185
188
|
});
|
|
186
189
|
|
|
187
190
|
//Check if chat retrieved from cache
|
|
@@ -209,6 +212,7 @@ const initStartChat = async (facadeChatSDK, dispatch, setAdapter, state, props,
|
|
|
209
212
|
const startTime = new Date().getTime();
|
|
210
213
|
(0, _FirstMessageTrackerFromBot.createTrackingForFirstMessage)();
|
|
211
214
|
await facadeChatSDK.startChat(startChatOptionalParams);
|
|
215
|
+
(0, _startChatErrorHandler.logStartChatComplete)();
|
|
212
216
|
isStartChatSuccessful = true;
|
|
213
217
|
await createAdapterAndSubscribe(facadeChatSDK, dispatch, setAdapter, startTime, props);
|
|
214
218
|
} catch (error) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.logWidgetLoadWithUnexpectedError = exports.logWidgetLoadComplete = exports.handleStartChatError = void 0;
|
|
6
|
+
exports.logWidgetLoadWithUnexpectedError = exports.logWidgetLoadComplete = exports.logStartChatComplete = exports.handleStartChatError = void 0;
|
|
7
7
|
var _omnichannelChatSdk = require("@microsoft/omnichannel-chat-sdk");
|
|
8
8
|
var _TelemetryConstants = require("../../../common/telemetry/TelemetryConstants");
|
|
9
9
|
var _Constants = require("../../../common/Constants");
|
|
@@ -124,7 +124,10 @@ const logWidgetLoadFailed = ex => {
|
|
|
124
124
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
125
125
|
Description: "Widget load complete with error",
|
|
126
126
|
ExceptionDetails: exDetails,
|
|
127
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed
|
|
127
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg === void 0 ? void 0 : _TelemetryTimers$Widg.milliSecondsElapsed,
|
|
128
|
+
CustomProperties: {
|
|
129
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
130
|
+
}
|
|
128
131
|
});
|
|
129
132
|
};
|
|
130
133
|
const logWidgetLoadComplete = additionalMessage => {
|
|
@@ -140,6 +143,17 @@ const logWidgetLoadComplete = additionalMessage => {
|
|
|
140
143
|
});
|
|
141
144
|
};
|
|
142
145
|
exports.logWidgetLoadComplete = logWidgetLoadComplete;
|
|
146
|
+
const logStartChatComplete = additionalMessage => {
|
|
147
|
+
let descriptionString = "Start chat complete";
|
|
148
|
+
if (additionalMessage) {
|
|
149
|
+
descriptionString += `. ${additionalMessage}`;
|
|
150
|
+
}
|
|
151
|
+
_TelemetryHelper.TelemetryHelper.logLoadingEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
152
|
+
Event: _TelemetryConstants.TelemetryEvent.StartChatComplete,
|
|
153
|
+
Description: descriptionString
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
exports.logStartChatComplete = logStartChatComplete;
|
|
143
157
|
const logWidgetLoadCompleteWithError = ex => {
|
|
144
158
|
var _TelemetryTimers$Widg3;
|
|
145
159
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -156,7 +170,10 @@ const logWidgetLoadCompleteWithError = ex => {
|
|
|
156
170
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
157
171
|
Description: "Widget load complete with error",
|
|
158
172
|
ExceptionDetails: exDetails,
|
|
159
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed
|
|
173
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg3 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg3 === void 0 ? void 0 : _TelemetryTimers$Widg3.milliSecondsElapsed,
|
|
174
|
+
CustomProperties: {
|
|
175
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
176
|
+
}
|
|
160
177
|
});
|
|
161
178
|
};
|
|
162
179
|
const logWidgetLoadWithUnexpectedError = ex => {
|
|
@@ -184,7 +201,10 @@ const logWidgetLoadWithUnexpectedError = ex => {
|
|
|
184
201
|
Event: _TelemetryConstants.TelemetryEvent.WidgetLoadFailed,
|
|
185
202
|
Description: "Widget load with unexpected error",
|
|
186
203
|
ExceptionDetails: exDetails,
|
|
187
|
-
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed
|
|
204
|
+
ElapsedTimeInMilliseconds: _TelemetryManager.TelemetryTimers === null || _TelemetryManager.TelemetryTimers === void 0 ? void 0 : (_TelemetryTimers$Widg4 = _TelemetryManager.TelemetryTimers.WidgetLoadTimer) === null || _TelemetryTimers$Widg4 === void 0 ? void 0 : _TelemetryTimers$Widg4.milliSecondsElapsed,
|
|
205
|
+
CustomProperties: {
|
|
206
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
207
|
+
}
|
|
188
208
|
});
|
|
189
209
|
};
|
|
190
210
|
|
|
@@ -58,18 +58,22 @@ var _startProactiveChat = require("../common/startProactiveChat");
|
|
|
58
58
|
var _useChatAdapterStore = _interopRequireDefault(require("../../../hooks/useChatAdapterStore"));
|
|
59
59
|
var _useChatContextStore = _interopRequireDefault(require("../../../hooks/useChatContextStore"));
|
|
60
60
|
var _useFacadeChatSDKStore = _interopRequireDefault(require("../../../hooks/useFacadeChatSDKStore"));
|
|
61
|
+
var _renderSurveyHelpers = require("../common/renderSurveyHelpers");
|
|
61
62
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
62
63
|
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); }
|
|
63
64
|
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; }
|
|
64
65
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
65
66
|
let uiTimer;
|
|
66
67
|
const LiveChatWidgetStateful = props => {
|
|
67
|
-
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$styleProps, _props$webChatContain10, _props$webChatContain11, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain15, _state$
|
|
68
|
+
var _props$webChatContain, _props$webChatContain2, _props$webChatContain3, _props$webChatContain4, _props$webChatContain5, _props$webChatContain6, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$styleProps, _props$webChatContain10, _props$webChatContain11, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain15, _state$appStates8, _props$webChatContain17, _props$webChatContain18, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _livechatProps$webCha, _livechatProps$styleP, _livechatProps$contro, _livechatProps$contro2, _livechatProps$compon, _livechatProps$contro3, _livechatProps$compon2, _livechatProps$contro4, _livechatProps$compon3, _livechatProps$contro5, _livechatProps$compon4, _livechatProps$contro6, _livechatProps$compon5, _livechatProps$contro7, _livechatProps$compon6, _livechatProps$contro8, _livechatProps$compon7, _livechatProps$contro9, _livechatProps$compon8, _livechatProps$contro10, _livechatProps$contro11, _livechatProps$compon9, _livechatProps$contro12, _livechatProps$compon10, _livechatProps$contro13, _livechatProps$compon11, _livechatProps$compon12, _livechatProps$compon13;
|
|
68
69
|
(0, _react2.useEffect)(() => {
|
|
69
70
|
uiTimer = (0, _utils.createTimer)();
|
|
70
71
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
71
72
|
Event: _TelemetryConstants.TelemetryEvent.UXLiveChatWidgetStart,
|
|
72
|
-
Description: "Live chat widget loading started."
|
|
73
|
+
Description: "Live chat widget loading started.",
|
|
74
|
+
CustomProperties: {
|
|
75
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
76
|
+
}
|
|
73
77
|
});
|
|
74
78
|
}, []);
|
|
75
79
|
const [state, dispatch] = (0, _useChatContextStore.default)();
|
|
@@ -322,7 +326,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
322
326
|
});
|
|
323
327
|
});
|
|
324
328
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.StartProactiveChat).subscribe(msg => {
|
|
325
|
-
_TelemetryHelper.TelemetryHelper.
|
|
329
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
326
330
|
Event: _TelemetryConstants.TelemetryEvent.StartProactiveChatEventReceived,
|
|
327
331
|
Description: "Start proactive chat event received."
|
|
328
332
|
});
|
|
@@ -448,7 +452,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
448
452
|
payload: msg === null || msg === void 0 ? void 0 : (_msg$payload8 = msg.payload) === null || _msg$payload8 === void 0 ? void 0 : _msg$payload8.customContext
|
|
449
453
|
});
|
|
450
454
|
}
|
|
451
|
-
_TelemetryHelper.TelemetryHelper.
|
|
455
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
452
456
|
Event: _TelemetryConstants.TelemetryEvent.StartChatEventReceived,
|
|
453
457
|
Description: "Start chat event received."
|
|
454
458
|
});
|
|
@@ -495,18 +499,91 @@ const LiveChatWidgetStateful = props => {
|
|
|
495
499
|
return;
|
|
496
500
|
}
|
|
497
501
|
});
|
|
502
|
+
const handleInitiateEndChatForPersistentChat = async (msg, conversationDetails) => {
|
|
503
|
+
var _msg$payload10, _msg$payload11, _msg$payload12;
|
|
504
|
+
//If the payload does NOT include the skipSessionCloseForPersistentChat flag, default is false. Upon receiving the customer event, always ending session from C2.
|
|
505
|
+
const skipSessionCloseForPersistentChat = typeof (msg === null || msg === void 0 ? void 0 : (_msg$payload10 = msg.payload) === null || _msg$payload10 === void 0 ? void 0 : _msg$payload10[_Constants.Constants.SkipSessionCloseForPersistentChatFlag]) === _Constants.Constants.String && (msg === null || msg === void 0 ? void 0 : (_msg$payload11 = msg.payload) === null || _msg$payload11 === void 0 ? void 0 : _msg$payload11[_Constants.Constants.SkipSessionCloseForPersistentChatFlag]).toLowerCase() === _Constants.Constants.true || (msg === null || msg === void 0 ? void 0 : (_msg$payload12 = msg.payload) === null || _msg$payload12 === void 0 ? void 0 : _msg$payload12[_Constants.Constants.SkipSessionCloseForPersistentChatFlag]) === true;
|
|
506
|
+
_TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
507
|
+
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
508
|
+
Description: "Processing initiateEndChat for persistent chat",
|
|
509
|
+
CustomProperties: {
|
|
510
|
+
conversationDetails
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
const conversationState = conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.state;
|
|
514
|
+
if (conversationState !== _Constants.LiveWorkItemState.Closed && conversationState !== _Constants.LiveWorkItemState.WrapUp) {
|
|
515
|
+
if (skipSessionCloseForPersistentChat) {
|
|
516
|
+
var _conversationDetails$;
|
|
517
|
+
if (((_conversationDetails$ = conversationDetails.canRenderPostChat) === null || _conversationDetails$ === void 0 ? void 0 : _conversationDetails$.toLowerCase()) === "true") {
|
|
518
|
+
var _state$domainStates3;
|
|
519
|
+
_TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
520
|
+
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
521
|
+
Description: "Processing initiateEndChat, fetching postChatContext"
|
|
522
|
+
});
|
|
523
|
+
const postchatContext = (await (0, _renderSurveyHelpers.getPostChatContext)(facadeChatSDK, state, dispatch)) ?? (state === null || state === void 0 ? void 0 : (_state$domainStates3 = state.domainStates) === null || _state$domainStates3 === void 0 ? void 0 : _state$domainStates3.postChatContext);
|
|
524
|
+
if (postchatContext) {
|
|
525
|
+
_TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
526
|
+
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
527
|
+
Description: "Processing initiateEndChat, initiatePostChat",
|
|
528
|
+
CustomProperties: {
|
|
529
|
+
postchatContext
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
await (0, _renderSurveyHelpers.initiatePostChat)(props, conversationDetails, state, dispatch, postchatContext);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
} else {
|
|
536
|
+
const skipEndChatSDK = false;
|
|
537
|
+
const skipCloseChat = false;
|
|
538
|
+
_TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
539
|
+
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
540
|
+
Description: "Processing initiateEndChat, trigger endChat"
|
|
541
|
+
});
|
|
542
|
+
await (0, _endChat.endChat)(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
//if conversation already closed, it is safe to unmount it upon receiving the closeChat event
|
|
546
|
+
else {
|
|
547
|
+
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
548
|
+
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
};
|
|
498
552
|
|
|
499
553
|
// End chat
|
|
500
|
-
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async
|
|
554
|
+
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.InitiateEndChat).subscribe(async msg => {
|
|
501
555
|
_TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
502
556
|
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
503
|
-
Description: "Received InitiateEndChat BroadcastEvent."
|
|
557
|
+
Description: "Received InitiateEndChat BroadcastEvent.",
|
|
558
|
+
CustomProperties: {
|
|
559
|
+
ConversationStage: _TelemetryConstants.ConversationStage.ConversationEnd,
|
|
560
|
+
payload: msg === null || msg === void 0 ? void 0 : msg.payload
|
|
561
|
+
}
|
|
504
562
|
});
|
|
505
|
-
|
|
506
|
-
|
|
563
|
+
const conversationDetails = await (0, _utils.getConversationDetailsCall)(facadeChatSDK);
|
|
564
|
+
const {
|
|
565
|
+
chatConfig
|
|
566
|
+
} = props;
|
|
567
|
+
const isPersistent = (0, _reconnectChatHelper.isPersistentEnabled)(chatConfig);
|
|
568
|
+
_TelemetryHelper.TelemetryHelper.logSDKEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
569
|
+
Event: _TelemetryConstants.TelemetryEvent.EndChatEventReceived,
|
|
570
|
+
Description: "Processing initiateEndChat, fetched conversation details",
|
|
571
|
+
CustomProperties: {
|
|
572
|
+
conversationDetails,
|
|
573
|
+
isPersistent
|
|
574
|
+
}
|
|
575
|
+
});
|
|
576
|
+
if (isPersistent && conversationDetails) {
|
|
577
|
+
await handleInitiateEndChatForPersistentChat(msg, conversationDetails);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
507
580
|
const persistedState = (0, _utils.getStateFromCache)((0, _utils.getWidgetCacheIdfromProps)(props));
|
|
508
581
|
if (persistedState && persistedState.appStates.conversationState === _ConversationState.ConversationState.Active) {
|
|
509
|
-
|
|
582
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
583
|
+
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
584
|
+
Description: _Constants.PrepareEndChatDescriptionConstants.InitiateEndChatReceivedActiveChat
|
|
585
|
+
});
|
|
586
|
+
//We need to simulate states for closing chat, in order to messup with close confirmation pane.
|
|
510
587
|
dispatch({
|
|
511
588
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONFIRMATION_STATE,
|
|
512
589
|
payload: _Constants.ConfirmationState.Ok
|
|
@@ -526,11 +603,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
526
603
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
527
604
|
Description: _Constants.PrepareEndChatDescriptionConstants.InitiateEndChatReceived
|
|
528
605
|
});
|
|
529
|
-
(0, _endChat.endChat)(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
606
|
+
await (0, _endChat.endChat)(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, skipEndChatSDK, skipCloseChat);
|
|
530
607
|
}
|
|
531
|
-
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
532
|
-
eventName: _TelemetryConstants.BroadcastEvent.CloseChat
|
|
533
|
-
});
|
|
534
608
|
});
|
|
535
609
|
|
|
536
610
|
// End chat on browser unload
|
|
@@ -541,8 +615,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
541
615
|
// Listen to end chat event from other tabs
|
|
542
616
|
const endChatEventName = (0, _utils.getWidgetEndChatEventName)((_facadeChatSDK$getCha3 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha3 === void 0 ? void 0 : (_facadeChatSDK$getCha4 = _facadeChatSDK$getCha3.omnichannelConfig) === null || _facadeChatSDK$getCha4 === void 0 ? void 0 : _facadeChatSDK$getCha4.orgId, (_facadeChatSDK$getCha5 = facadeChatSDK.getChatSDK()) === null || _facadeChatSDK$getCha5 === void 0 ? void 0 : (_facadeChatSDK$getCha6 = _facadeChatSDK$getCha5.omnichannelConfig) === null || _facadeChatSDK$getCha6 === void 0 ? void 0 : _facadeChatSDK$getCha6.widgetId, ((_props$controlProps11 = props.controlProps) === null || _props$controlProps11 === void 0 ? void 0 : _props$controlProps11.widgetInstanceId) ?? "");
|
|
543
617
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(endChatEventName).subscribe(msg => {
|
|
544
|
-
var _msg$
|
|
545
|
-
if ((msg === null || msg === void 0 ? void 0 : (_msg$
|
|
618
|
+
var _msg$payload13;
|
|
619
|
+
if ((msg === null || msg === void 0 ? void 0 : (_msg$payload13 = msg.payload) === null || _msg$payload13 === void 0 ? void 0 : _msg$payload13.runtimeId) !== _TelemetryManager.TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
546
620
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
547
621
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
548
622
|
Description: "Received EndChat BroadcastEvent from other tabs. Closing this chat."
|
|
@@ -584,8 +658,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
584
658
|
|
|
585
659
|
// Retrieve convId
|
|
586
660
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName(_TelemetryConstants.BroadcastEvent.UpdateConversationDataForTelemetry).subscribe(msg => {
|
|
587
|
-
var _msg$
|
|
588
|
-
if ((_msg$
|
|
661
|
+
var _msg$payload14, _msg$payload14$liveWo;
|
|
662
|
+
if ((_msg$payload14 = msg.payload) !== null && _msg$payload14 !== void 0 && (_msg$payload14$liveWo = _msg$payload14.liveWorkItem) !== null && _msg$payload14$liveWo !== void 0 && _msg$payload14$liveWo.conversationId) {
|
|
589
663
|
setConversationId(msg.payload.liveWorkItem.conversationId);
|
|
590
664
|
}
|
|
591
665
|
});
|
|
@@ -703,14 +777,22 @@ const LiveChatWidgetStateful = props => {
|
|
|
703
777
|
}
|
|
704
778
|
}, [state.domainStates.confirmationState]);
|
|
705
779
|
(0, _react2.useEffect)(() => {
|
|
706
|
-
var
|
|
780
|
+
var _inMemoryState$appSta7, _inMemoryState$appSta8, _inMemoryState$appSta9, _inMemoryState$appSta10, _inMemoryState$appSta11, _inMemoryState$appSta12, _inMemoryState$appSta13;
|
|
781
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
782
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
783
|
+
payload: null
|
|
784
|
+
});
|
|
707
785
|
// Do not process anything during initialization
|
|
708
|
-
if ((
|
|
786
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta7 = inMemoryState.appStates) === null || _inMemoryState$appSta7 === void 0 ? void 0 : _inMemoryState$appSta7.conversationEndedBy) === _Constants.ConversationEndEntity.NotSet) {
|
|
787
|
+
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
788
|
+
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
789
|
+
Description: "conversationEndedBy is not set"
|
|
790
|
+
});
|
|
709
791
|
return;
|
|
710
792
|
}
|
|
711
793
|
|
|
712
794
|
// If start chat failed, and C2 is trying to close chat widget
|
|
713
|
-
if (
|
|
795
|
+
if (inMemoryState !== null && inMemoryState !== void 0 && (_inMemoryState$appSta8 = inMemoryState.appStates) !== null && _inMemoryState$appSta8 !== void 0 && _inMemoryState$appSta8.startChatFailed || (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta9 = inMemoryState.appStates) === null || _inMemoryState$appSta9 === void 0 ? void 0 : _inMemoryState$appSta9.conversationState) === _ConversationState.ConversationState.Postchat) {
|
|
714
796
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
715
797
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
716
798
|
Description: _Constants.PrepareEndChatDescriptionConstants.CustomerCloseChatOnFailureOrPostChat
|
|
@@ -720,7 +802,7 @@ const LiveChatWidgetStateful = props => {
|
|
|
720
802
|
}
|
|
721
803
|
|
|
722
804
|
// Scenario -> Chat was InActive and closing the chat (Refresh scenario on post chat)
|
|
723
|
-
if ((
|
|
805
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta10 = inMemoryState.appStates) === null || _inMemoryState$appSta10 === void 0 ? void 0 : _inMemoryState$appSta10.conversationState) === _ConversationState.ConversationState.InActive) {
|
|
724
806
|
_TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
725
807
|
Event: _TelemetryConstants.TelemetryEvent.PrepareEndChat,
|
|
726
808
|
Description: _Constants.PrepareEndChatDescriptionConstants.CustomerCloseInactiveChat
|
|
@@ -728,11 +810,11 @@ const LiveChatWidgetStateful = props => {
|
|
|
728
810
|
(0, _endChat.endChat)(props, facadeChatSDK, state, dispatch, setAdapter, setWebChatStyles, adapter, false, false, true);
|
|
729
811
|
return;
|
|
730
812
|
}
|
|
731
|
-
const isConversationalSurveyEnabled =
|
|
813
|
+
const isConversationalSurveyEnabled = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta11 = inMemoryState.appStates) === null || _inMemoryState$appSta11 === void 0 ? void 0 : _inMemoryState$appSta11.isConversationalSurveyEnabled;
|
|
732
814
|
|
|
733
815
|
// In conversational survey, we need to check post chat survey logics before we set ConversationState to InActive
|
|
734
816
|
// Hence setting ConversationState to InActive will be done later in the post chat flows
|
|
735
|
-
if (!isConversationalSurveyEnabled && ((
|
|
817
|
+
if (!isConversationalSurveyEnabled && ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta12 = inMemoryState.appStates) === null || _inMemoryState$appSta12 === void 0 ? void 0 : _inMemoryState$appSta12.conversationEndedBy) === _Constants.ConversationEndEntity.Agent || (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta13 = inMemoryState.appStates) === null || _inMemoryState$appSta13 === void 0 ? void 0 : _inMemoryState$appSta13.conversationEndedBy) === _Constants.ConversationEndEntity.Bot)) {
|
|
736
818
|
dispatch({
|
|
737
819
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
738
820
|
payload: _ConversationState.ConversationState.InActive
|
|
@@ -740,8 +822,8 @@ const LiveChatWidgetStateful = props => {
|
|
|
740
822
|
}
|
|
741
823
|
|
|
742
824
|
// All other cases
|
|
743
|
-
(0, _endChat.prepareEndChat)(props, facadeChatSDK,
|
|
744
|
-
}, [state === null || state === void 0 ? void 0 : (_state$
|
|
825
|
+
(0, _endChat.prepareEndChat)(props, facadeChatSDK, inMemoryState, dispatch, setAdapter, setWebChatStyles, adapter);
|
|
826
|
+
}, [state === null || state === void 0 ? void 0 : (_state$appStates8 = state.appStates) === null || _state$appStates8 === void 0 ? void 0 : _state$appStates8.conversationEndedBy]);
|
|
745
827
|
|
|
746
828
|
// Publish chat widget state
|
|
747
829
|
(0, _react2.useEffect)(() => {
|
|
@@ -773,13 +855,13 @@ const LiveChatWidgetStateful = props => {
|
|
|
773
855
|
|
|
774
856
|
// Handle Chat disconnect cases
|
|
775
857
|
(0, _react2.useEffect)(() => {
|
|
776
|
-
var _inMemoryState$
|
|
858
|
+
var _inMemoryState$appSta14;
|
|
777
859
|
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
778
860
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
779
861
|
payload: null
|
|
780
862
|
});
|
|
781
863
|
(0, _chatDisconnectHelper.handleChatDisconnect)(props, inMemoryState, setWebChatStyles);
|
|
782
|
-
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$
|
|
864
|
+
const chatDisconnectState = inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta14 = inMemoryState.appStates) === null || _inMemoryState$appSta14 === void 0 ? void 0 : _inMemoryState$appSta14.chatDisconnectEventReceived;
|
|
783
865
|
if (chatDisconnectState && adapter) {
|
|
784
866
|
try {
|
|
785
867
|
adapter.end();
|
|
@@ -805,7 +887,10 @@ const LiveChatWidgetStateful = props => {
|
|
|
805
887
|
_TelemetryHelper.TelemetryHelper.logLoadingEventToAllTelemetry(_TelemetryConstants.LogLevel.INFO, {
|
|
806
888
|
Event: _TelemetryConstants.TelemetryEvent.UXLiveChatWidgetCompleted,
|
|
807
889
|
Description: "Live chat widget loading completed.",
|
|
808
|
-
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed
|
|
890
|
+
ElapsedTimeInMilliseconds: uiTimer.milliSecondsElapsed,
|
|
891
|
+
CustomProperties: {
|
|
892
|
+
ConversationStage: _TelemetryConstants.ConversationStage.Initialization
|
|
893
|
+
}
|
|
809
894
|
});
|
|
810
895
|
}, []);
|
|
811
896
|
const initiateEndChatOnBrowserUnload = () => {
|
|
@@ -875,6 +960,17 @@ const LiveChatWidgetStateful = props => {
|
|
|
875
960
|
bubbleTextColor
|
|
876
961
|
}), [webChatStyles, bubbleBackground, bubbleTextColor]);
|
|
877
962
|
|
|
963
|
+
// React to dynamic bot avatar initials updates from context
|
|
964
|
+
(0, _react2.useEffect)(() => {
|
|
965
|
+
if (state.domainStates.botAvatarInitials && state.domainStates.botAvatarInitials !== webChatStyles.botAvatarInitials) {
|
|
966
|
+
/* eslint-disable-next-line @typescript-eslint/no-non-null-assertion */
|
|
967
|
+
setWebChatStyles(styles => ({
|
|
968
|
+
...styles,
|
|
969
|
+
botAvatarInitials: state.domainStates.botAvatarInitials
|
|
970
|
+
}));
|
|
971
|
+
}
|
|
972
|
+
}, [state.domainStates.botAvatarInitials]);
|
|
973
|
+
|
|
878
974
|
// WebChat's Composer can only be rendered if a directLine object is defined
|
|
879
975
|
return directLine && /*#__PURE__*/_react2.default.createElement(_react2.default.Fragment, null, /*#__PURE__*/_react2.default.createElement("style", null, `
|
|
880
976
|
#oc-lcw .webchat__basic-transcript__scrollable::-webkit-scrollbar {
|