@microsoft/omnichannel-chat-widget 1.7.7-main.a833758 → 1.7.7
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/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -4
- package/lib/cjs/plugins/newMessageEventHandler.js +2 -2
- package/lib/esm/components/livechatwidget/common/createInternetConnectionChangeHandler.js +10 -4
- package/lib/esm/plugins/newMessageEventHandler.js +2 -2
- package/lib/types/common/telemetry/TelemetryHelper.d.ts +1 -0
- package/package.json +1 -1
|
@@ -11,6 +11,8 @@ var _NotificationHandler = require("../../webchatcontainerstateful/webchatcontro
|
|
|
11
11
|
var _NotificationScenarios = require("../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios");
|
|
12
12
|
var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
|
|
13
13
|
var _defaultMiddlewareLocalizedTexts = require("../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts");
|
|
14
|
+
var _createReducer = require("../../../contexts/createReducer");
|
|
15
|
+
var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
|
|
14
16
|
const isInternetConnected = async () => {
|
|
15
17
|
try {
|
|
16
18
|
const response = await fetch(_Constants.Constants.internetConnectionTestUrl);
|
|
@@ -23,18 +25,22 @@ const isInternetConnected = async () => {
|
|
|
23
25
|
const createInternetConnectionChangeHandler = async state => {
|
|
24
26
|
const handler = async () => {
|
|
25
27
|
const connected = await isInternetConnected();
|
|
28
|
+
const inMemoryState = (0, _createReducer.executeReducer)(state, {
|
|
29
|
+
type: _LiveChatWidgetActionType.LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
30
|
+
payload: null
|
|
31
|
+
});
|
|
26
32
|
if (!connected) {
|
|
27
|
-
var
|
|
33
|
+
var _inMemoryState$domain, _inMemoryState$domain2;
|
|
28
34
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
29
35
|
Event: _TelemetryConstants.TelemetryEvent.NetworkDisconnected
|
|
30
36
|
});
|
|
31
|
-
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, (
|
|
37
|
+
_NotificationHandler.NotificationHandler.notifyError(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.middlewareLocalizedTexts) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
|
|
32
38
|
} else {
|
|
33
|
-
var
|
|
39
|
+
var _inMemoryState$domain3, _inMemoryState$domain4;
|
|
34
40
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.WARN, {
|
|
35
41
|
Event: _TelemetryConstants.TelemetryEvent.NetworkReconnected
|
|
36
42
|
});
|
|
37
|
-
_NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, (
|
|
43
|
+
_NotificationHandler.NotificationHandler.notifySuccess(_NotificationScenarios.NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.middlewareLocalizedTexts) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE) ?? _defaultMiddlewareLocalizedTexts.defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
38
44
|
_omnichannelChatComponents.BroadcastService.postMessage({
|
|
39
45
|
eventName: _TelemetryConstants.BroadcastEvent.NetworkReconnected
|
|
40
46
|
});
|
|
@@ -89,7 +89,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
89
89
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
90
90
|
Event: _TelemetryConstants.TelemetryEvent.MessageReceived,
|
|
91
91
|
Description: "New message received",
|
|
92
|
-
|
|
92
|
+
CustomProperties: payload
|
|
93
93
|
});
|
|
94
94
|
} else {
|
|
95
95
|
if (!isHistoryMessageReceivedEventRasied) {
|
|
@@ -97,7 +97,7 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
97
97
|
_TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
|
|
98
98
|
Event: _TelemetryConstants.TelemetryEvent.RehydrateMessageReceived,
|
|
99
99
|
Description: "History message received",
|
|
100
|
-
|
|
100
|
+
CustomProperties: payload
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
}
|
|
@@ -5,6 +5,8 @@ import { NotificationHandler } from "../../webchatcontainerstateful/webchatcontr
|
|
|
5
5
|
import { NotificationScenarios } from "../../webchatcontainerstateful/webchatcontroller/enums/NotificationScenarios";
|
|
6
6
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
7
7
|
import { defaultMiddlewareLocalizedTexts } from "../../webchatcontainerstateful/common/defaultProps/defaultMiddlewareLocalizedTexts";
|
|
8
|
+
import { executeReducer } from "../../../contexts/createReducer";
|
|
9
|
+
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
8
10
|
const isInternetConnected = async () => {
|
|
9
11
|
try {
|
|
10
12
|
const response = await fetch(Constants.internetConnectionTestUrl);
|
|
@@ -17,18 +19,22 @@ const isInternetConnected = async () => {
|
|
|
17
19
|
export const createInternetConnectionChangeHandler = async state => {
|
|
18
20
|
const handler = async () => {
|
|
19
21
|
const connected = await isInternetConnected();
|
|
22
|
+
const inMemoryState = executeReducer(state, {
|
|
23
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
24
|
+
payload: null
|
|
25
|
+
});
|
|
20
26
|
if (!connected) {
|
|
21
|
-
var
|
|
27
|
+
var _inMemoryState$domain, _inMemoryState$domain2;
|
|
22
28
|
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
23
29
|
Event: TelemetryEvent.NetworkDisconnected
|
|
24
30
|
});
|
|
25
|
-
NotificationHandler.notifyError(NotificationScenarios.InternetConnection, (
|
|
31
|
+
NotificationHandler.notifyError(NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.middlewareLocalizedTexts) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_NO_INTERNET_CONNECTION);
|
|
26
32
|
} else {
|
|
27
|
-
var
|
|
33
|
+
var _inMemoryState$domain3, _inMemoryState$domain4;
|
|
28
34
|
TelemetryHelper.logActionEvent(LogLevel.WARN, {
|
|
29
35
|
Event: TelemetryEvent.NetworkReconnected
|
|
30
36
|
});
|
|
31
|
-
NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, (
|
|
37
|
+
NotificationHandler.notifySuccess(NotificationScenarios.InternetConnection, (inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.middlewareLocalizedTexts) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE) ?? defaultMiddlewareLocalizedTexts.MIDDLEWARE_BANNER_INTERNET_BACK_ONLINE);
|
|
32
38
|
BroadcastService.postMessage({
|
|
33
39
|
eventName: BroadcastEvent.NetworkReconnected
|
|
34
40
|
});
|
|
@@ -83,7 +83,7 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
83
83
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
84
84
|
Event: TelemetryEvent.MessageReceived,
|
|
85
85
|
Description: "New message received",
|
|
86
|
-
|
|
86
|
+
CustomProperties: payload
|
|
87
87
|
});
|
|
88
88
|
} else {
|
|
89
89
|
if (!isHistoryMessageReceivedEventRasied) {
|
|
@@ -91,7 +91,7 @@ export const createOnNewAdapterActivityHandler = (chatId, userId) => {
|
|
|
91
91
|
TelemetryHelper.logActionEvent(LogLevel.INFO, {
|
|
92
92
|
Event: TelemetryEvent.RehydrateMessageReceived,
|
|
93
93
|
Description: "History message received",
|
|
94
|
-
|
|
94
|
+
CustomProperties: payload
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|