@microsoft/omnichannel-chat-widget 1.6.2-main.c7d45e8 → 1.6.3-main.18ee949
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/TelemetryHelper.js +9 -10
- package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +3 -3
- package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -34
- package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/cjs/contexts/createReducer.js +653 -345
- package/lib/esm/common/telemetry/TelemetryHelper.js +9 -10
- package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +3 -4
- package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +28 -34
- package/lib/esm/contexts/common/LiveChatWidgetActionType.js +1 -0
- package/lib/esm/contexts/createReducer.js +650 -343
- package/lib/types/common/telemetry/definitions/Contracts.d.ts +3 -0
- package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +2 -1
- package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +2 -1
- package/lib/types/contexts/createReducer.d.ts +1 -0
- package/package.json +1 -1
|
@@ -30,7 +30,7 @@ export class TelemetryHelper {
|
|
|
30
30
|
static populateBasicProperties(level,
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
32
|
telemetryData) {
|
|
33
|
-
var _TelemetryManager$Int, _TelemetryManager$Int2, _TelemetryManager$Int3, _TelemetryManager$Int4, _TelemetryManager$Int5, _TelemetryManager$Int6, _TelemetryManager$Int7, _TelemetryManager$Int8;
|
|
33
|
+
var _TelemetryManager$Int, _TelemetryManager$Int2, _TelemetryManager$Int3, _TelemetryManager$Int4, _TelemetryManager$Int5, _TelemetryManager$Int6, _TelemetryManager$Int7, _TelemetryManager$Int8, _TelemetryManager$Int9, _TelemetryManager$Int10, _TelemetryManager$Int11;
|
|
34
34
|
return {
|
|
35
35
|
WidgetId: ((_TelemetryManager$Int = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.widgetId) ?? "",
|
|
36
36
|
ChatId: ((_TelemetryManager$Int2 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int2 === void 0 ? void 0 : _TelemetryManager$Int2.chatId) ?? "",
|
|
@@ -40,7 +40,10 @@ export class TelemetryHelper {
|
|
|
40
40
|
OrganizationUrl: ((_TelemetryManager$Int6 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int6 === void 0 ? void 0 : _TelemetryManager$Int6.orgUrl) ?? "",
|
|
41
41
|
LCWRuntimeId: ((_TelemetryManager$Int7 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int7 === void 0 ? void 0 : _TelemetryManager$Int7.lcwRuntimeId) ?? "",
|
|
42
42
|
CurrentRequestId: ((_TelemetryManager$Int8 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int8 === void 0 ? void 0 : _TelemetryManager$Int8.currentRequestId) ?? "",
|
|
43
|
-
LogLevel: level
|
|
43
|
+
LogLevel: level,
|
|
44
|
+
OCChatSDKVersion: ((_TelemetryManager$Int9 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int9 === void 0 ? void 0 : _TelemetryManager$Int9.OCChatSDKVersion) ?? "",
|
|
45
|
+
OCChatWidgetVersion: ((_TelemetryManager$Int10 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int10 === void 0 ? void 0 : _TelemetryManager$Int10.chatWidgetVersion) ?? "",
|
|
46
|
+
OCChatComponentsVersion: ((_TelemetryManager$Int11 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int11 === void 0 ? void 0 : _TelemetryManager$Int11.chatComponentVersion) ?? ""
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
static populate(level, telemetryData, configure) {
|
|
@@ -74,22 +77,21 @@ export class TelemetryHelper {
|
|
|
74
77
|
static conformToConfigValidationContract(level, input) {
|
|
75
78
|
const payload = input.payload;
|
|
76
79
|
return TelemetryHelper.populate(level, payload, event => {
|
|
77
|
-
var _TelemetryManager$
|
|
80
|
+
var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14;
|
|
78
81
|
event.Event = payload.Event;
|
|
79
82
|
event.RequestId = payload.RequestId;
|
|
80
|
-
event.LCWVersion = (_TelemetryManager$
|
|
83
|
+
event.LCWVersion = (_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : _TelemetryManager$Int12.environmentVersion;
|
|
81
84
|
event.CloudType = payload.CloudType;
|
|
82
|
-
event.Domain = (_TelemetryManager$
|
|
85
|
+
event.Domain = (_TelemetryManager$Int13 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.hostName;
|
|
83
86
|
event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
|
|
84
87
|
event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
|
|
85
|
-
event.Language = ((_TelemetryManager$
|
|
88
|
+
event.Language = ((_TelemetryManager$Int14 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : _TelemetryManager$Int14.chatWidgetLocaleLCID) || "";
|
|
86
89
|
event.Description = payload.Data;
|
|
87
90
|
});
|
|
88
91
|
}
|
|
89
92
|
static conformToLoadContract(level, input) {
|
|
90
93
|
const payload = input.payload;
|
|
91
94
|
return TelemetryHelper.populate(level, payload, event => {
|
|
92
|
-
var _TelemetryManager$Int12, _TelemetryManager$Int13, _TelemetryManager$Int14;
|
|
93
95
|
event.Event = payload.Event;
|
|
94
96
|
event.Description = payload.Description;
|
|
95
97
|
event.ResourcePath = payload.ResourcePath;
|
|
@@ -98,9 +100,6 @@ export class TelemetryHelper {
|
|
|
98
100
|
event.ChatType = payload.ChatType;
|
|
99
101
|
event.ElapsedTimeInMilliseconds = payload.ElapsedTimeInMilliseconds;
|
|
100
102
|
event.ExceptionDetails = JSON.stringify(payload.ExceptionDetails);
|
|
101
|
-
event.OCChatSDKVersion = ((_TelemetryManager$Int12 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int12 === void 0 ? void 0 : _TelemetryManager$Int12.OCChatSDKVersion) ?? "";
|
|
102
|
-
event.OCChatWidgetVersion = ((_TelemetryManager$Int13 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int13 === void 0 ? void 0 : _TelemetryManager$Int13.chatWidgetVersion) ?? "";
|
|
103
|
-
event.OCChatComponentsVersion = ((_TelemetryManager$Int14 = TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int14 === void 0 ? void 0 : _TelemetryManager$Int14.chatComponentVersion) ?? "";
|
|
104
103
|
});
|
|
105
104
|
}
|
|
106
105
|
static conformToIC3ClientContract(level, input) {
|
|
@@ -7,7 +7,6 @@ import { ConversationMode } from "../../../common/Constants";
|
|
|
7
7
|
import { ConversationState } from "../../../contexts/common/ConversationState";
|
|
8
8
|
import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
|
|
9
9
|
import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
|
|
10
|
-
|
|
11
10
|
// Return value: should start normal chat flow when reconnect is enabled
|
|
12
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
12
|
const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initStartChat, state) => {
|
|
@@ -25,9 +24,9 @@ const handleChatReconnect = async (chatSDK, props, dispatch, setAdapter, initSta
|
|
|
25
24
|
return false;
|
|
26
25
|
}
|
|
27
26
|
if (hasReconnectId(reconnectChatContext)) {
|
|
28
|
-
var _props$reconnectChatP2, _props$reconnectChatP3;
|
|
29
|
-
//if reconnect id is provided in props, don't show reconnect pane
|
|
30
|
-
if ((_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.reconnectId && !isNullOrEmptyString((_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId)) {
|
|
27
|
+
var _props$reconnectChatP2, _props$reconnectChatP3, _props$controlProps;
|
|
28
|
+
//if reconnect id is provided in props, or hideReconnectChatPane is true, don't show reconnect pane
|
|
29
|
+
if ((_props$reconnectChatP2 = props.reconnectChatPaneProps) !== null && _props$reconnectChatP2 !== void 0 && _props$reconnectChatP2.reconnectId && !isNullOrEmptyString((_props$reconnectChatP3 = props.reconnectChatPaneProps) === null || _props$reconnectChatP3 === void 0 ? void 0 : _props$reconnectChatP3.reconnectId) || (_props$controlProps = props.controlProps) !== null && _props$controlProps !== void 0 && _props$controlProps.hideReconnectChatPane) {
|
|
31
30
|
await setReconnectIdAndStartChat(isAuthenticatedChat, chatSDK, state, props, dispatch, setAdapter, reconnectChatContext.reconnectId ?? "", initStartChat);
|
|
32
31
|
return false;
|
|
33
32
|
}
|
|
@@ -53,6 +53,7 @@ import useChatSDKStore from "../../../hooks/useChatSDKStore";
|
|
|
53
53
|
import { defaultAdaptiveCardStyles } from "../../webchatcontainerstateful/common/defaultStyles/defaultAdaptiveCardStyles";
|
|
54
54
|
import StartChatErrorPaneStateful from "../../startchaterrorpanestateful/StartChatErrorPaneStateful";
|
|
55
55
|
import { StartChatFailureType } from "../../../contexts/common/StartChatFailureType";
|
|
56
|
+
import { executeReducer } from "../../../contexts/createReducer";
|
|
56
57
|
export const LiveChatWidgetStateful = props => {
|
|
57
58
|
var _props$webChatContain, _props$styleProps, _props$controlProps, _props$controlProps3, _state$appStates7, _props$webChatContain5, _state$appStates14, _props$webChatContain6, _props$controlProps12, _props$draggableChatW, _props$draggableChatW2, _props$draggableChatW3, _props$draggableChatW4, _props$draggableChatW5, _props$webChatContain7, _props$webChatContain8, _props$webChatContain9, _props$webChatContain10, _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;
|
|
58
59
|
const [state, dispatch] = useChatContextStore();
|
|
@@ -117,8 +118,12 @@ export const LiveChatWidgetStateful = props => {
|
|
|
117
118
|
const isReconnectTriggered = async () => {
|
|
118
119
|
if (isReconnectEnabled(props.chatConfig) === true && !isPersistentEnabled(props.chatConfig)) {
|
|
119
120
|
const noValidReconnectId = await handleChatReconnect(chatSDK, props, dispatch, setAdapter, initStartChat, state);
|
|
121
|
+
const inMemoryState = executeReducer(state, {
|
|
122
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
123
|
+
payload: null
|
|
124
|
+
});
|
|
120
125
|
// If chat reconnect has kicked in chat state will become Active or Reconnect. So just exit, else go next
|
|
121
|
-
if (!noValidReconnectId && (
|
|
126
|
+
if (!noValidReconnectId && (inMemoryState.appStates.conversationState === ConversationState.Active || inMemoryState.appStates.conversationState === ConversationState.ReconnectChat)) {
|
|
122
127
|
return true;
|
|
123
128
|
}
|
|
124
129
|
}
|
|
@@ -332,7 +337,7 @@ export const LiveChatWidgetStateful = props => {
|
|
|
332
337
|
|
|
333
338
|
// Start chat from SDK Event
|
|
334
339
|
BroadcastService.getMessageByEventName(BroadcastEvent.StartChat).subscribe(msg => {
|
|
335
|
-
var _msg$payload4, _msg$payload5, _msg$payload6;
|
|
340
|
+
var _msg$payload4, _msg$payload5, _msg$payload6, _inMemoryState$appSta, _inMemoryState$appSta2, _inMemoryState$appSta3, _inMemoryState$appSta4;
|
|
336
341
|
// If the startChat event is not initiated by the same tab. Ignore the call
|
|
337
342
|
if (!isNullOrUndefined(msg === null || msg === void 0 ? void 0 : (_msg$payload4 = msg.payload) === null || _msg$payload4 === void 0 ? void 0 : _msg$payload4.runtimeId) && (msg === null || msg === void 0 ? void 0 : (_msg$payload5 = msg.payload) === null || _msg$payload5 === void 0 ? void 0 : _msg$payload5.runtimeId) !== TelemetryManager.InternalTelemetryData.lcwRuntimeId) {
|
|
338
343
|
return;
|
|
@@ -360,12 +365,13 @@ export const LiveChatWidgetStateful = props => {
|
|
|
360
365
|
Event: TelemetryEvent.StartChatEventRecevied,
|
|
361
366
|
Description: "Start chat event received."
|
|
362
367
|
});
|
|
368
|
+
const inMemoryState = executeReducer(state, {
|
|
369
|
+
type: LiveChatWidgetActionType.GET_IN_MEMORY_STATE,
|
|
370
|
+
payload: null
|
|
371
|
+
});
|
|
363
372
|
|
|
364
|
-
//
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
// Chat not found in cache - scenario: explicitly clearing cache and calling startChat SDK method
|
|
368
|
-
if (persistedState === undefined) {
|
|
373
|
+
// Only initiate new chat if widget runtime state is one of the followings
|
|
374
|
+
if (((_inMemoryState$appSta = inMemoryState.appStates) === null || _inMemoryState$appSta === void 0 ? void 0 : _inMemoryState$appSta.conversationState) === ConversationState.Closed || ((_inMemoryState$appSta2 = inMemoryState.appStates) === null || _inMemoryState$appSta2 === void 0 ? void 0 : _inMemoryState$appSta2.conversationState) === ConversationState.InActive || ((_inMemoryState$appSta3 = inMemoryState.appStates) === null || _inMemoryState$appSta3 === void 0 ? void 0 : _inMemoryState$appSta3.conversationState) === ConversationState.Postchat) {
|
|
369
375
|
BroadcastService.postMessage({
|
|
370
376
|
eventName: BroadcastEvent.ChatInitiated
|
|
371
377
|
});
|
|
@@ -373,33 +379,21 @@ export const LiveChatWidgetStateful = props => {
|
|
|
373
379
|
return;
|
|
374
380
|
}
|
|
375
381
|
|
|
376
|
-
//
|
|
377
|
-
if (
|
|
378
|
-
var
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
dispatch({
|
|
392
|
-
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
393
|
-
payload: false
|
|
394
|
-
});
|
|
395
|
-
BroadcastService.postMessage({
|
|
396
|
-
eventName: BroadcastEvent.MaximizeChat,
|
|
397
|
-
payload: {
|
|
398
|
-
height: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai = persistedState.domainStates) === null || _persistedState$domai === void 0 ? void 0 : (_persistedState$domai2 = _persistedState$domai.widgetSize) === null || _persistedState$domai2 === void 0 ? void 0 : _persistedState$domai2.height,
|
|
399
|
-
width: persistedState === null || persistedState === void 0 ? void 0 : (_persistedState$domai3 = persistedState.domainStates) === null || _persistedState$domai3 === void 0 ? void 0 : (_persistedState$domai4 = _persistedState$domai3.widgetSize) === null || _persistedState$domai4 === void 0 ? void 0 : _persistedState$domai4.width
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}
|
|
382
|
+
// If minimized, maximize the chat
|
|
383
|
+
if ((inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$appSta4 = inMemoryState.appStates) === null || _inMemoryState$appSta4 === void 0 ? void 0 : _inMemoryState$appSta4.isMinimized) === true) {
|
|
384
|
+
var _inMemoryState$domain, _inMemoryState$domain2, _inMemoryState$domain3, _inMemoryState$domain4;
|
|
385
|
+
dispatch({
|
|
386
|
+
type: LiveChatWidgetActionType.SET_MINIMIZED,
|
|
387
|
+
payload: false
|
|
388
|
+
});
|
|
389
|
+
BroadcastService.postMessage({
|
|
390
|
+
eventName: BroadcastEvent.MaximizeChat,
|
|
391
|
+
payload: {
|
|
392
|
+
height: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain = inMemoryState.domainStates) === null || _inMemoryState$domain === void 0 ? void 0 : (_inMemoryState$domain2 = _inMemoryState$domain.widgetSize) === null || _inMemoryState$domain2 === void 0 ? void 0 : _inMemoryState$domain2.height,
|
|
393
|
+
width: inMemoryState === null || inMemoryState === void 0 ? void 0 : (_inMemoryState$domain3 = inMemoryState.domainStates) === null || _inMemoryState$domain3 === void 0 ? void 0 : (_inMemoryState$domain4 = _inMemoryState$domain3.widgetSize) === null || _inMemoryState$domain4 === void 0 ? void 0 : _inMemoryState$domain4.width
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
return;
|
|
403
397
|
}
|
|
404
398
|
});
|
|
405
399
|
|
|
@@ -45,4 +45,5 @@ export let LiveChatWidgetActionType;
|
|
|
45
45
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 42] = "SET_SURVEY_MODE";
|
|
46
46
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 43] = "SET_CONFIRMATION_STATE";
|
|
47
47
|
LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 44] = "SET_POST_CHAT_PARTICIPANT_TYPE";
|
|
48
|
+
LiveChatWidgetActionType[LiveChatWidgetActionType["GET_IN_MEMORY_STATE"] = 45] = "GET_IN_MEMORY_STATE";
|
|
48
49
|
})(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
|