@microsoft/omnichannel-chat-widget 0.1.0-main.07f52ee → 0.1.0-main.7338c17
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/lib/cjs/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/cjs/components/livechatwidget/common/startProactiveChat.js +3 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +13 -1
- package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +9 -3
- package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
- package/lib/esm/common/telemetry/TelemetryConstants.js +4 -0
- package/lib/esm/components/livechatwidget/common/startProactiveChat.js +5 -5
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +13 -2
- package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +7 -3
- package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js +1 -0
- package/lib/types/common/telemetry/TelemetryConstants.d.ts +4 -0
- package/lib/types/components/livechatwidget/common/startProactiveChat.d.ts +2 -1
- package/lib/types/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.d.ts +3 -0
- package/package.json +1 -1
|
@@ -115,11 +115,15 @@ exports.TelemetryEvent = TelemetryEvent;
|
|
|
115
115
|
TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
|
|
116
116
|
TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
|
|
117
117
|
TelemetryEvent["PreChatSurveyStartChatMethodFailed"] = "PreChatSurveyStartChatMethodFailed";
|
|
118
|
+
TelemetryEvent["ChatAlreadyTriggered"] = "ChatAlreadyTriggered";
|
|
119
|
+
TelemetryEvent["StartProactiveChatEventReceived"] = "StartProactiveChatEventReceived";
|
|
118
120
|
TelemetryEvent["StartProactiveChatMethodFailed"] = "StartProactiveChatMethodFailed";
|
|
119
121
|
TelemetryEvent["ProactiveChatAccepted"] = "ProactiveChatAccepted";
|
|
120
122
|
TelemetryEvent["ProactiveChatRejected"] = "ProactiveChatRejected";
|
|
121
123
|
TelemetryEvent["IncomingProactiveChatScreenLoaded"] = "IncomingProactiveChatScreenLoaded";
|
|
122
124
|
TelemetryEvent["ProactiveChatClosed"] = "ProactiveChatClosed";
|
|
125
|
+
TelemetryEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
|
|
126
|
+
TelemetryEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
|
|
123
127
|
TelemetryEvent["ReconnectChatContinueConversation"] = "ReconnectChatContinueConversation";
|
|
124
128
|
TelemetryEvent["ReconnectChatStartNewConversation"] = "ReconnectChatStartNewConversation";
|
|
125
129
|
TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
|
|
@@ -16,12 +16,12 @@ var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
|
16
16
|
var _TelemetryManager = require("../../../common/telemetry/TelemetryManager");
|
|
17
17
|
|
|
18
18
|
// Defines startProactiveChat callback
|
|
19
|
-
const startProactiveChat = (dispatch,
|
|
19
|
+
const startProactiveChat = (dispatch, notificationConfig, enablePreChat, inNewWindow) => {
|
|
20
20
|
dispatch({
|
|
21
21
|
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
22
22
|
payload: {
|
|
23
|
-
proactiveChatBodyTitle:
|
|
24
|
-
proactiveChatEnablePrechat:
|
|
23
|
+
proactiveChatBodyTitle: notificationConfig && notificationConfig.message ? notificationConfig.message : "",
|
|
24
|
+
proactiveChatEnablePrechat: enablePreChat ?? false,
|
|
25
25
|
proactiveChatInNewWindow: inNewWindow ?? false
|
|
26
26
|
}
|
|
27
27
|
});
|
|
@@ -87,6 +87,8 @@ var _disposeTelemetryLoggers = require("../common/disposeTelemetryLoggers");
|
|
|
87
87
|
|
|
88
88
|
var _DataStoreManager = require("../../../common/contextDataStore/DataStoreManager");
|
|
89
89
|
|
|
90
|
+
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
91
|
+
|
|
90
92
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
91
93
|
|
|
92
94
|
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); }
|
|
@@ -195,10 +197,20 @@ const LiveChatWidgetStateful = props => {
|
|
|
195
197
|
}, [state.appStates.skipChatButtonRendering]);
|
|
196
198
|
(0, _react2.useEffect)(() => {
|
|
197
199
|
_omnichannelChatComponents.BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
|
|
200
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
201
|
+
Event: _TelemetryConstants.TelemetryEvent.StartProactiveChatEventReceived,
|
|
202
|
+
Description: "Start proactive chat event received."
|
|
203
|
+
});
|
|
204
|
+
|
|
198
205
|
if (canStartProactiveChat.current) {
|
|
199
206
|
var _msg$payload, _msg$payload2, _msg$payload3;
|
|
200
207
|
|
|
201
|
-
(0, _startProactiveChat.startProactiveChat)(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.
|
|
208
|
+
(0, _startProactiveChat.startProactiveChat)(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.notificationConfig, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.enablePreChat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
|
|
209
|
+
} else {
|
|
210
|
+
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
211
|
+
Event: _TelemetryConstants.TelemetryEvent.ChatAlreadyTriggered,
|
|
212
|
+
Description: "Start proactive chat method called, when chat was already triggered."
|
|
213
|
+
});
|
|
202
214
|
}
|
|
203
215
|
});
|
|
204
216
|
|
|
@@ -75,14 +75,14 @@ const ProactiveChatPaneStateful = props => {
|
|
|
75
75
|
if (state.appStates.proactiveChatStates.proactiveChatInNewWindow) {
|
|
76
76
|
// TODO: BroadcastService: replace with the sdk broadcast service, when in place
|
|
77
77
|
const startPopoutChatEvent = {
|
|
78
|
-
eventName:
|
|
78
|
+
eventName: _TelemetryConstants.TelemetryEvent.ProactiveChatStartPopoutChat
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
_omnichannelChatComponents.BroadcastService.postMessage(startPopoutChatEvent);
|
|
82
82
|
|
|
83
83
|
dispatch({
|
|
84
|
-
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.
|
|
85
|
-
payload:
|
|
84
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
85
|
+
payload: _ConversationState.ConversationState.Closed
|
|
86
86
|
});
|
|
87
87
|
} else if (((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True") {
|
|
88
88
|
dispatch({
|
|
@@ -94,6 +94,12 @@ const ProactiveChatPaneStateful = props => {
|
|
|
94
94
|
payload: _ConversationState.ConversationState.OutOfOffice
|
|
95
95
|
});
|
|
96
96
|
} else {
|
|
97
|
+
const proactiveChatStarted = {
|
|
98
|
+
eventName: _TelemetryConstants.TelemetryEvent.ProactiveChatStartChat
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
_omnichannelChatComponents.BroadcastService.postMessage(proactiveChatStarted);
|
|
102
|
+
|
|
97
103
|
await startChat();
|
|
98
104
|
}
|
|
99
105
|
},
|
package/lib/cjs/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -106,11 +106,15 @@ export let TelemetryEvent;
|
|
|
106
106
|
TelemetryEvent["SendTypingIndicatorSucceeded"] = "SendTypingIndicatorSucceeded";
|
|
107
107
|
TelemetryEvent["SendTypingIndicatorFailed"] = "SendTypingIndicatorFailed";
|
|
108
108
|
TelemetryEvent["PreChatSurveyStartChatMethodFailed"] = "PreChatSurveyStartChatMethodFailed";
|
|
109
|
+
TelemetryEvent["ChatAlreadyTriggered"] = "ChatAlreadyTriggered";
|
|
110
|
+
TelemetryEvent["StartProactiveChatEventReceived"] = "StartProactiveChatEventReceived";
|
|
109
111
|
TelemetryEvent["StartProactiveChatMethodFailed"] = "StartProactiveChatMethodFailed";
|
|
110
112
|
TelemetryEvent["ProactiveChatAccepted"] = "ProactiveChatAccepted";
|
|
111
113
|
TelemetryEvent["ProactiveChatRejected"] = "ProactiveChatRejected";
|
|
112
114
|
TelemetryEvent["IncomingProactiveChatScreenLoaded"] = "IncomingProactiveChatScreenLoaded";
|
|
113
115
|
TelemetryEvent["ProactiveChatClosed"] = "ProactiveChatClosed";
|
|
116
|
+
TelemetryEvent["ProactiveChatStartChat"] = "ProactiveChatStartChat";
|
|
117
|
+
TelemetryEvent["ProactiveChatStartPopoutChat"] = "ProactiveChatStartPopoutChat";
|
|
114
118
|
TelemetryEvent["ReconnectChatContinueConversation"] = "ReconnectChatContinueConversation";
|
|
115
119
|
TelemetryEvent["ReconnectChatStartNewConversation"] = "ReconnectChatStartNewConversation";
|
|
116
120
|
TelemetryEvent["ReconnectChatMinimize"] = "ReconnectChatMinimize";
|
|
@@ -2,14 +2,14 @@ import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryCon
|
|
|
2
2
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
3
3
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
4
4
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
5
|
-
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
6
|
-
|
|
7
|
-
export const startProactiveChat = (dispatch,
|
|
5
|
+
import { TelemetryTimers } from "../../../common/telemetry/TelemetryManager";
|
|
6
|
+
// Defines startProactiveChat callback
|
|
7
|
+
export const startProactiveChat = (dispatch, notificationConfig, enablePreChat, inNewWindow) => {
|
|
8
8
|
dispatch({
|
|
9
9
|
type: LiveChatWidgetActionType.SET_PROACTIVE_CHAT_PARAMS,
|
|
10
10
|
payload: {
|
|
11
|
-
proactiveChatBodyTitle:
|
|
12
|
-
proactiveChatEnablePrechat:
|
|
11
|
+
proactiveChatBodyTitle: notificationConfig && notificationConfig.message ? notificationConfig.message : "",
|
|
12
|
+
proactiveChatEnablePrechat: enablePreChat ?? false,
|
|
13
13
|
proactiveChatInNewWindow: inNewWindow ?? false
|
|
14
14
|
}
|
|
15
15
|
});
|
|
@@ -39,9 +39,10 @@ import { startProactiveChat } from "../common/startProactiveChat";
|
|
|
39
39
|
import useChatAdapterStore from "../../../hooks/useChatAdapterStore";
|
|
40
40
|
import useChatContextStore from "../../../hooks/useChatContextStore";
|
|
41
41
|
import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
42
|
-
import { TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
42
|
+
import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
|
|
43
43
|
import { disposeTelemetryLoggers } from "../common/disposeTelemetryLoggers";
|
|
44
44
|
import { DataStoreManager } from "../../../common/contextDataStore/DataStoreManager";
|
|
45
|
+
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
45
46
|
export const LiveChatWidgetStateful = props => {
|
|
46
47
|
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$webChatContain3, _props$webChatContain4, _props$styleProps2, _props$controlProps5, _props$componentOverr, _props$controlProps6, _props$componentOverr2, _props$controlProps7, _props$componentOverr3, _props$controlProps8, _props$componentOverr4, _props$controlProps9, _props$componentOverr5, _props$controlProps10, _props$componentOverr6, _props$controlProps11, _props$controlProps12, _props$controlProps13, _props$componentOverr7, _props$controlProps14, _props$componentOverr8, _props$controlProps15, _props$componentOverr9, _props$componentOverr10, _props$componentOverr11;
|
|
47
48
|
|
|
@@ -142,10 +143,20 @@ export const LiveChatWidgetStateful = props => {
|
|
|
142
143
|
}, [state.appStates.skipChatButtonRendering]);
|
|
143
144
|
useEffect(() => {
|
|
144
145
|
BroadcastService.getMessageByEventName("StartProactiveChat").subscribe(msg => {
|
|
146
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
147
|
+
Event: TelemetryEvent.StartProactiveChatEventReceived,
|
|
148
|
+
Description: "Start proactive chat event received."
|
|
149
|
+
});
|
|
150
|
+
|
|
145
151
|
if (canStartProactiveChat.current) {
|
|
146
152
|
var _msg$payload, _msg$payload2, _msg$payload3;
|
|
147
153
|
|
|
148
|
-
startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.
|
|
154
|
+
startProactiveChat(dispatch, msg === null || msg === void 0 ? void 0 : (_msg$payload = msg.payload) === null || _msg$payload === void 0 ? void 0 : _msg$payload.notificationConfig, msg === null || msg === void 0 ? void 0 : (_msg$payload2 = msg.payload) === null || _msg$payload2 === void 0 ? void 0 : _msg$payload2.enablePreChat, msg === null || msg === void 0 ? void 0 : (_msg$payload3 = msg.payload) === null || _msg$payload3 === void 0 ? void 0 : _msg$payload3.inNewWindow);
|
|
155
|
+
} else {
|
|
156
|
+
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
157
|
+
Event: TelemetryEvent.ChatAlreadyTriggered,
|
|
158
|
+
Description: "Start proactive chat method called, when chat was already triggered."
|
|
159
|
+
});
|
|
149
160
|
}
|
|
150
161
|
});
|
|
151
162
|
window.addEventListener("beforeunload", event => {
|
|
@@ -51,12 +51,12 @@ export const ProactiveChatPaneStateful = props => {
|
|
|
51
51
|
if (state.appStates.proactiveChatStates.proactiveChatInNewWindow) {
|
|
52
52
|
// TODO: BroadcastService: replace with the sdk broadcast service, when in place
|
|
53
53
|
const startPopoutChatEvent = {
|
|
54
|
-
eventName:
|
|
54
|
+
eventName: TelemetryEvent.ProactiveChatStartPopoutChat
|
|
55
55
|
};
|
|
56
56
|
BroadcastService.postMessage(startPopoutChatEvent);
|
|
57
57
|
dispatch({
|
|
58
|
-
type: LiveChatWidgetActionType.
|
|
59
|
-
payload:
|
|
58
|
+
type: LiveChatWidgetActionType.SET_CONVERSATION_STATE,
|
|
59
|
+
payload: ConversationState.Closed
|
|
60
60
|
});
|
|
61
61
|
} else if (((_state$domainStates$l = state.domainStates.liveChatConfig) === null || _state$domainStates$l === void 0 ? void 0 : (_state$domainStates$l2 = _state$domainStates$l.LiveWSAndLiveChatEngJoin) === null || _state$domainStates$l2 === void 0 ? void 0 : _state$domainStates$l2.OutOfOperatingHours) === "True") {
|
|
62
62
|
dispatch({
|
|
@@ -68,6 +68,10 @@ export const ProactiveChatPaneStateful = props => {
|
|
|
68
68
|
payload: ConversationState.OutOfOffice
|
|
69
69
|
});
|
|
70
70
|
} else {
|
|
71
|
+
const proactiveChatStarted = {
|
|
72
|
+
eventName: TelemetryEvent.ProactiveChatStartChat
|
|
73
|
+
};
|
|
74
|
+
BroadcastService.postMessage(proactiveChatStarted);
|
|
71
75
|
await startChat();
|
|
72
76
|
}
|
|
73
77
|
},
|
package/lib/esm/components/proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -99,11 +99,15 @@ export declare enum TelemetryEvent {
|
|
|
99
99
|
SendTypingIndicatorSucceeded = "SendTypingIndicatorSucceeded",
|
|
100
100
|
SendTypingIndicatorFailed = "SendTypingIndicatorFailed",
|
|
101
101
|
PreChatSurveyStartChatMethodFailed = "PreChatSurveyStartChatMethodFailed",
|
|
102
|
+
ChatAlreadyTriggered = "ChatAlreadyTriggered",
|
|
103
|
+
StartProactiveChatEventReceived = "StartProactiveChatEventReceived",
|
|
102
104
|
StartProactiveChatMethodFailed = "StartProactiveChatMethodFailed",
|
|
103
105
|
ProactiveChatAccepted = "ProactiveChatAccepted",
|
|
104
106
|
ProactiveChatRejected = "ProactiveChatRejected",
|
|
105
107
|
IncomingProactiveChatScreenLoaded = "IncomingProactiveChatScreenLoaded",
|
|
106
108
|
ProactiveChatClosed = "ProactiveChatClosed",
|
|
109
|
+
ProactiveChatStartChat = "ProactiveChatStartChat",
|
|
110
|
+
ProactiveChatStartPopoutChat = "ProactiveChatStartPopoutChat",
|
|
107
111
|
ReconnectChatContinueConversation = "ReconnectChatContinueConversation",
|
|
108
112
|
ReconnectChatStartNewConversation = "ReconnectChatStartNewConversation",
|
|
109
113
|
ReconnectChatMinimize = "ReconnectChatMinimize",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { Dispatch } from "react";
|
|
2
2
|
import { ILiveChatWidgetAction } from "../../../contexts/common/ILiveChatWidgetAction";
|
|
3
|
-
|
|
3
|
+
import { IProactiveChatNotificationConfig } from "../../proactivechatpanestateful/interfaces/IProactiveChatNotificationConfig";
|
|
4
|
+
export declare const startProactiveChat: (dispatch: Dispatch<ILiveChatWidgetAction>, notificationConfig?: IProactiveChatNotificationConfig | undefined, enablePreChat?: boolean | undefined, inNewWindow?: boolean | undefined) => void;
|