@microsoft/omnichannel-chat-widget 1.7.2-main.42ab898 → 1.7.2-main.6642960

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.WidgetLoadTelemetryMessage = exports.WidgetLoadCustomErrorString = exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.StartChatErrorPaneConstants = exports.Regex = exports.PrepareEndChatDescriptionConstants = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
6
+ exports.WidgetLoadTelemetryMessage = exports.WidgetLoadCustomErrorString = exports.WebChatMiddlewareConstants = exports.TranscriptConstants = exports.StorageType = exports.StartChatErrorPaneConstants = exports.Regex = exports.PrepareEndChatDescriptionConstants = exports.PostChatSurveyTelemetryMessage = exports.ParticipantType = exports.NotificationPaneConstants = exports.MimeTypes = exports.LocaleConstants = exports.LiveWorkItemState = exports.HtmlIdNames = exports.HtmlElementSelectors = exports.HtmlClassNames = exports.HtmlAttributeNames = exports.EnvironmentVersion = exports.ElementType = exports.E2VVOptions = exports.ConversationMode = exports.ConversationEndEntity = exports.Constants = exports.ConfirmationState = exports.AriaTelemetryConstants = exports.AMSConstants = void 0;
7
7
  var _class;
8
8
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
9
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
@@ -318,4 +318,8 @@ _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceived", "
318
318
  _defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
319
319
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
320
320
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
321
- _defineProperty(PrepareEndChatDescriptionConstants, "BrowserUnload", "Browser unload event received. Ending chat.");
321
+ _defineProperty(PrepareEndChatDescriptionConstants, "BrowserUnload", "Browser unload event received. Ending chat.");
322
+ class PostChatSurveyTelemetryMessage {}
323
+ exports.PostChatSurveyTelemetryMessage = PostChatSurveyTelemetryMessage;
324
+ _defineProperty(PostChatSurveyTelemetryMessage, "PostChatContextCallFailed", "Failed to get post chat context.");
325
+ _defineProperty(PostChatSurveyTelemetryMessage, "PostChatContextCallSucceed", "Postchat context call succeed.");
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isPostChatSurveyEnabled = void 0;
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ const isPostChatSurveyEnabled = async chatSDK => {
9
+ var _chatConfig$LiveWSAnd;
10
+ const chatConfig = await chatSDK.getLiveChatConfig();
11
+ const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
12
+ return postChatEnabled === "true";
13
+ };
14
+ exports.isPostChatSurveyEnabled = isPostChatSurveyEnabled;
@@ -11,6 +11,7 @@ var _utils = require("../../../common/utils");
11
11
  var _ConversationState = require("../../../contexts/common/ConversationState");
12
12
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
13
13
  var _PostChatSurveyMode = require("../../postchatsurveypanestateful/enums/PostChatSurveyMode");
14
+ var _liveChatConfigUtils = require("./liveChatConfigUtils");
14
15
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
16
  let conversationDetails = undefined;
16
17
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -108,24 +109,27 @@ const isPostChatEnabled = (props, state) => {
108
109
  exports.checkPostChatEnabled = isPostChatEnabled;
109
110
  const getPostChatContext = async (chatSDK, state, dispatch) => {
110
111
  try {
111
- var _state$domainStates2;
112
- if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
113
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
- const context = await chatSDK.getPostChatSurveyContext();
115
- _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
116
- Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
117
- Description: "Postchat context call succeed."
118
- });
119
- dispatch({
120
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
121
- payload: context
122
- });
123
- return context;
112
+ const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(chatSDK);
113
+ if (postChatEnabled) {
114
+ var _state$domainStates2;
115
+ if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
116
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
+ const context = await chatSDK.getPostChatSurveyContext();
118
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
119
+ Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
120
+ Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
121
+ });
122
+ dispatch({
123
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
124
+ payload: context
125
+ });
126
+ return context;
127
+ }
124
128
  }
125
129
  } catch (error) {
126
- _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
130
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
127
131
  Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallFailed,
128
- Description: "Failed to get post chat context."
132
+ Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallFailed
129
133
  });
130
134
  }
131
135
  };
@@ -9,20 +9,25 @@ var _omnichannelChatComponents = require("@microsoft/omnichannel-chat-components
9
9
  var _ConversationState = require("../../../contexts/common/ConversationState");
10
10
  var _LiveChatWidgetActionType = require("../../../contexts/common/LiveChatWidgetActionType");
11
11
  var _TelemetryHelper = require("../../../common/telemetry/TelemetryHelper");
12
+ var _Constants = require("../../../common/Constants");
13
+ var _liveChatConfigUtils = require("./liveChatConfigUtils");
12
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
15
  const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
14
16
  try {
15
- if (!persistedChat) {
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- const context = await chatSDK.getPostChatSurveyContext();
18
- _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
19
- Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
20
- Description: "Postchat context call succeed."
21
- });
22
- dispatch({
23
- type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
24
- payload: context
25
- });
17
+ const postChatEnabled = await (0, _liveChatConfigUtils.isPostChatSurveyEnabled)(chatSDK);
18
+ if (postChatEnabled) {
19
+ if (!persistedChat) {
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
+ const context = await chatSDK.getPostChatSurveyContext();
22
+ _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.INFO, {
23
+ Event: _TelemetryConstants.TelemetryEvent.PostChatContextCallSucceed,
24
+ Description: _Constants.PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
25
+ });
26
+ dispatch({
27
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
28
+ payload: context
29
+ });
30
+ }
26
31
  }
27
32
  } catch (ex) {
28
33
  _TelemetryHelper.TelemetryHelper.logSDKEvent(_TelemetryConstants.LogLevel.ERROR, {
@@ -32,7 +37,6 @@ const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat)
32
37
  }
33
38
  });
34
39
  }
35
-
36
40
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
41
  _omnichannelChatComponents.BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
38
42
  dispatch({
@@ -58,6 +58,10 @@ const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSuccessfu
58
58
  case _omnichannelChatSdk.ChatSDKErrorName.UninitializedChatSDK:
59
59
  handleUninitializedChatSDK(ex);
60
60
  break;
61
+ // Handle the case indicating failure to retrieve an authenticated chat conversation
62
+ case _omnichannelChatSdk.ChatSDKErrorName.AuthenticatedChatConversationRetrievalFailure:
63
+ logWidgetLoadCompleteWithError(ex);
64
+ break;
61
65
  case _omnichannelChatSdk.ChatSDKErrorName.InvalidConversation:
62
66
  case _omnichannelChatSdk.ChatSDKErrorName.ClosedConversation:
63
67
  handleInvalidOrClosedConversation(dispatch, chatSDK, props, ex);
@@ -63,5 +63,12 @@ class MockChatSDK {
63
63
  getVoiceVideoCalling() {
64
64
  return null;
65
65
  }
66
+ getLiveChatConfig() {
67
+ return {
68
+ LiveWSAndLiveChatEngJoin: {
69
+ msdyn_postconversationsurveyenable: "true"
70
+ }
71
+ };
72
+ }
66
73
  }
67
74
  exports.MockChatSDK = MockChatSDK;
@@ -286,4 +286,7 @@ _defineProperty(PrepareEndChatDescriptionConstants, "InitiateEndChatReceived", "
286
286
  _defineProperty(PrepareEndChatDescriptionConstants, "EndChatReceivedFromOtherTabs", "Received EndChat BroadcastEvent from other tabs. Closing this chat.");
287
287
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseChatOnFailureOrPostChat", "Customer is trying to close chat widget on start chat failure or post chat pane.");
288
288
  _defineProperty(PrepareEndChatDescriptionConstants, "CustomerCloseInactiveChat", "Chat was Inactive and customer is trying to close chat widget or refreshing the page.");
289
- _defineProperty(PrepareEndChatDescriptionConstants, "BrowserUnload", "Browser unload event received. Ending chat.");
289
+ _defineProperty(PrepareEndChatDescriptionConstants, "BrowserUnload", "Browser unload event received. Ending chat.");
290
+ export class PostChatSurveyTelemetryMessage {}
291
+ _defineProperty(PostChatSurveyTelemetryMessage, "PostChatContextCallFailed", "Failed to get post chat context.");
292
+ _defineProperty(PostChatSurveyTelemetryMessage, "PostChatContextCallSucceed", "Postchat context call succeed.");
@@ -0,0 +1,7 @@
1
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
+ export const isPostChatSurveyEnabled = async chatSDK => {
3
+ var _chatConfig$LiveWSAnd;
4
+ const chatConfig = await chatSDK.getLiveChatConfig();
5
+ const postChatEnabled = (_chatConfig$LiveWSAnd = chatConfig.LiveWSAndLiveChatEngJoin) === null || _chatConfig$LiveWSAnd === void 0 ? void 0 : _chatConfig$LiveWSAnd.msdyn_postconversationsurveyenable.toString().toLowerCase();
6
+ return postChatEnabled === "true";
7
+ };
@@ -1,10 +1,12 @@
1
- import { Constants, ParticipantType } from "../../../common/Constants";
1
+ import { Constants, ParticipantType, PostChatSurveyTelemetryMessage } from "../../../common/Constants";
2
2
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
4
4
  import { addDelayInMs } from "../../../common/utils";
5
5
  import { ConversationState } from "../../../contexts/common/ConversationState";
6
6
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
7
7
  import { PostChatSurveyMode } from "../../postchatsurveypanestateful/enums/PostChatSurveyMode";
8
+ import { isPostChatSurveyEnabled } from "./liveChatConfigUtils";
9
+
8
10
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
11
  let conversationDetails = undefined;
10
12
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -100,24 +102,27 @@ const isPostChatEnabled = (props, state) => {
100
102
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
103
  const getPostChatContext = async (chatSDK, state, dispatch) => {
102
104
  try {
103
- var _state$domainStates2;
104
- if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
105
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
- const context = await chatSDK.getPostChatSurveyContext();
107
- TelemetryHelper.logSDKEvent(LogLevel.INFO, {
108
- Event: TelemetryEvent.PostChatContextCallSucceed,
109
- Description: "Postchat context call succeed."
110
- });
111
- dispatch({
112
- type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
113
- payload: context
114
- });
115
- return context;
105
+ const postChatEnabled = await isPostChatSurveyEnabled(chatSDK);
106
+ if (postChatEnabled) {
107
+ var _state$domainStates2;
108
+ if ((state === null || state === void 0 ? void 0 : (_state$domainStates2 = state.domainStates) === null || _state$domainStates2 === void 0 ? void 0 : _state$domainStates2.postChatContext) === undefined) {
109
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
+ const context = await chatSDK.getPostChatSurveyContext();
111
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
112
+ Event: TelemetryEvent.PostChatContextCallSucceed,
113
+ Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
114
+ });
115
+ dispatch({
116
+ type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
117
+ payload: context
118
+ });
119
+ return context;
120
+ }
116
121
  }
117
122
  } catch (error) {
118
- TelemetryHelper.logSDKEvent(LogLevel.INFO, {
123
+ TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
119
124
  Event: TelemetryEvent.PostChatContextCallFailed,
120
- Description: "Failed to get post chat context."
125
+ Description: PostChatSurveyTelemetryMessage.PostChatContextCallFailed
121
126
  });
122
127
  }
123
128
  };
@@ -3,21 +3,26 @@ import { BroadcastService } from "@microsoft/omnichannel-chat-components";
3
3
  import { ConversationState } from "../../../contexts/common/ConversationState";
4
4
  import { LiveChatWidgetActionType } from "../../../contexts/common/LiveChatWidgetActionType";
5
5
  import { TelemetryHelper } from "../../../common/telemetry/TelemetryHelper";
6
+ import { PostChatSurveyTelemetryMessage } from "../../../common/Constants";
7
+ import { isPostChatSurveyEnabled } from "./liveChatConfigUtils";
6
8
 
7
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
10
  export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persistedChat) => {
9
11
  try {
10
- if (!persistedChat) {
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- const context = await chatSDK.getPostChatSurveyContext();
13
- TelemetryHelper.logSDKEvent(LogLevel.INFO, {
14
- Event: TelemetryEvent.PostChatContextCallSucceed,
15
- Description: "Postchat context call succeed."
16
- });
17
- dispatch({
18
- type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
19
- payload: context
20
- });
12
+ const postChatEnabled = await isPostChatSurveyEnabled(chatSDK);
13
+ if (postChatEnabled) {
14
+ if (!persistedChat) {
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ const context = await chatSDK.getPostChatSurveyContext();
17
+ TelemetryHelper.logSDKEvent(LogLevel.INFO, {
18
+ Event: TelemetryEvent.PostChatContextCallSucceed,
19
+ Description: PostChatSurveyTelemetryMessage.PostChatContextCallSucceed
20
+ });
21
+ dispatch({
22
+ type: LiveChatWidgetActionType.SET_POST_CHAT_CONTEXT,
23
+ payload: context
24
+ });
25
+ }
21
26
  }
22
27
  } catch (ex) {
23
28
  TelemetryHelper.logSDKEvent(LogLevel.ERROR, {
@@ -27,7 +32,6 @@ export const setPostChatContextAndLoadSurvey = async (chatSDK, dispatch, persist
27
32
  }
28
33
  });
29
34
  }
30
-
31
35
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
36
  BroadcastService.getMessageByEventName("LoadPostChatSurvey").subscribe(msg => {
33
37
  dispatch({
@@ -53,6 +53,10 @@ export const handleStartChatError = (dispatch, chatSDK, props, ex, isStartChatSu
53
53
  case ChatSDKErrorName.UninitializedChatSDK:
54
54
  handleUninitializedChatSDK(ex);
55
55
  break;
56
+ // Handle the case indicating failure to retrieve an authenticated chat conversation
57
+ case ChatSDKErrorName.AuthenticatedChatConversationRetrievalFailure:
58
+ logWidgetLoadCompleteWithError(ex);
59
+ break;
56
60
  case ChatSDKErrorName.InvalidConversation:
57
61
  case ChatSDKErrorName.ClosedConversation:
58
62
  handleInvalidOrClosedConversation(dispatch, chatSDK, props, ex);
@@ -56,4 +56,11 @@ export class MockChatSDK {
56
56
  getVoiceVideoCalling() {
57
57
  return null;
58
58
  }
59
+ getLiveChatConfig() {
60
+ return {
61
+ LiveWSAndLiveChatEngJoin: {
62
+ msdyn_postconversationsurveyenable: "true"
63
+ }
64
+ };
65
+ }
59
66
  }
@@ -267,3 +267,7 @@ export declare class PrepareEndChatDescriptionConstants {
267
267
  static readonly CustomerCloseInactiveChat = "Chat was Inactive and customer is trying to close chat widget or refreshing the page.";
268
268
  static readonly BrowserUnload = "Browser unload event received. Ending chat.";
269
269
  }
270
+ export declare class PostChatSurveyTelemetryMessage {
271
+ static readonly PostChatContextCallFailed = "Failed to get post chat context.";
272
+ static readonly PostChatContextCallSucceed = "Postchat context call succeed.";
273
+ }
@@ -0,0 +1 @@
1
+ export declare const isPostChatSurveyEnabled: (chatSDK: any) => Promise<boolean>;
@@ -28,4 +28,9 @@ export declare class MockChatSDK {
28
28
  reconnectId: string;
29
29
  };
30
30
  getVoiceVideoCalling(): null;
31
+ getLiveChatConfig(): {
32
+ LiveWSAndLiveChatEngJoin: {
33
+ msdyn_postconversationsurveyenable: string;
34
+ };
35
+ };
31
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.7.2-main.42ab898",
3
+ "version": "1.7.2-main.6642960",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@microsoft/omnichannel-chat-components": "1.1.5",
78
- "@microsoft/omnichannel-chat-sdk": "^1.9.2",
78
+ "@microsoft/omnichannel-chat-sdk": "^1.9.4",
79
79
  "abort-controller-es5": "^2.0.1",
80
80
  "dompurify": "^2.3.4",
81
81
  "markdown-it": "^12.3.2",