@microsoft/omnichannel-chat-widget 1.3.1-main.c1cf6d6 → 1.3.1-main.cb0a057

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.
@@ -34,6 +34,14 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
34
34
  return;
35
35
  }
36
36
 
37
+ // Register post chat participant type
38
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.ParticipantType.Bot || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.ParticipantType.User) {
39
+ dispatch({
40
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE,
41
+ payload: conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType
42
+ });
43
+ }
44
+
37
45
  // Use Case: Can render post chat scenarios
38
46
  await (0, _renderSurveyHelpers.getPostChatContext)(chatSDK, state, dispatch);
39
47
 
@@ -69,6 +69,12 @@ const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) => {
69
69
  payload: _Constants.ConversationEndEntity.Agent
70
70
  });
71
71
  }
72
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.ParticipantType.Bot || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === _Constants.ParticipantType.User) {
73
+ dispatch({
74
+ type: _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE,
75
+ payload: conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType
76
+ });
77
+ }
72
78
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
73
79
  Event: _TelemetryConstants.TelemetryEvent.ConversationEndedThreadEventReceived,
74
80
  Description: "Conversation end by agent side or by timeout event received."
@@ -27,14 +27,17 @@ const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, co
27
27
  return surveyLink;
28
28
  };
29
29
  const PostChatSurveyPaneStateful = props => {
30
- var _props$styleProps, _state$appStates, _state$appStates2, _props$controlProps;
30
+ var _props$styleProps, _state$appStates, _props$controlProps;
31
31
  const [state] = (0, _useChatContextStore.default)();
32
32
  const generalStyleProps = Object.assign({}, _defaultgeneralPostChatSurveyPaneStyleProps.defaultGeneralPostChatSurveyPaneStyleProps, (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps, {
33
33
  display: state.appStates.isMinimized ? "none" : "contents"
34
34
  });
35
35
  let surveyInviteLink = "";
36
36
  const surveyMode = (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.selectedSurveyMode) === _PostChatSurveyMode.PostChatSurveyMode.Embed;
37
- if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === _Constants.ConversationEndEntity.Bot && state.domainStates.postChatContext.botSurveyInviteLink) {
37
+ if (state.domainStates.postChatContext.botSurveyInviteLink &&
38
+ // Bot survey enabled
39
+ state.appStates.postChatParticipantType === _Constants.ParticipantType.Bot) {
40
+ // Only Bot has engaged
38
41
  surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
39
42
  } else {
40
43
  surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
@@ -50,4 +50,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
50
50
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_DISCONNECT_EVENT_RECEIVED"] = 40] = "SET_CHAT_DISCONNECT_EVENT_RECEIVED";
51
51
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 41] = "SET_SURVEY_MODE";
52
52
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 42] = "SET_CONFIRMATION_STATE";
53
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 43] = "SET_POST_CHAT_PARTICIPANT_TYPE";
53
54
  })(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
@@ -59,7 +59,8 @@ const getLiveChatWidgetContextInitialState = props => {
59
59
  unreadMessageCount: 0,
60
60
  conversationEndedBy: _Constants.ConversationEndEntity.NotSet,
61
61
  chatDisconnectEventReceived: false,
62
- selectedSurveyMode: null
62
+ selectedSurveyMode: null,
63
+ postChatParticipantType: undefined
63
64
  },
64
65
  uiStates: {
65
66
  showConfirmationPane: false,
@@ -331,6 +331,14 @@ const createReducer = () => {
331
331
  confirmationState: action.payload
332
332
  }
333
333
  };
334
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE:
335
+ return {
336
+ ...state,
337
+ appStates: {
338
+ ...state.appStates,
339
+ postChatParticipantType: action.payload
340
+ }
341
+ };
334
342
  default:
335
343
  return state;
336
344
  }
@@ -1,4 +1,4 @@
1
- import { ConfirmationState, Constants, ConversationEndEntity } from "../../../common/Constants";
1
+ import { ConfirmationState, Constants, ConversationEndEntity, ParticipantType } from "../../../common/Constants";
2
2
  import { LogLevel, TelemetryEvent } from "../../../common/telemetry/TelemetryConstants";
3
3
  import { getAuthClientFunction, handleAuthentication } from "./authHelper";
4
4
  import { getConversationDetailsCall, getWidgetEndChatEventName, isNullOrEmptyString } from "../../../common/utils";
@@ -29,6 +29,14 @@ const prepareEndChat = async (props, chatSDK, state, dispatch, setAdapter, setWe
29
29
  return;
30
30
  }
31
31
 
32
+ // Register post chat participant type
33
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.User) {
34
+ dispatch({
35
+ type: LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE,
36
+ payload: conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType
37
+ });
38
+ }
39
+
32
40
  // Use Case: Can render post chat scenarios
33
41
  await getPostChatContext(chatSDK, state, dispatch);
34
42
 
@@ -63,6 +63,12 @@ export const initWebChatComposer = (props, state, dispatch, chatSDK, endChat) =>
63
63
  payload: ConversationEndEntity.Agent
64
64
  });
65
65
  }
66
+ if ((conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.Bot || (conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType) === ParticipantType.User) {
67
+ dispatch({
68
+ type: LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE,
69
+ payload: conversationDetails === null || conversationDetails === void 0 ? void 0 : conversationDetails.participantType
70
+ });
71
+ }
66
72
  TelemetryHelper.logActionEvent(LogLevel.INFO, {
67
73
  Event: TelemetryEvent.ConversationEndedThreadEventReceived,
68
74
  Description: "Conversation end by agent side or by timeout event received."
@@ -1,6 +1,6 @@
1
1
  import { LogLevel, TelemetryEvent } from "../../common/telemetry/TelemetryConstants";
2
2
  import React, { useEffect } from "react";
3
- import { ConversationEndEntity } from "../../common/Constants";
3
+ import { ParticipantType } from "../../common/Constants";
4
4
  import { CustomerVoiceEvents } from "./enums/CustomerVoiceEvents";
5
5
  import { PostChatSurveyMode } from "./enums/PostChatSurveyMode";
6
6
  import { PostChatSurveyPane } from "@microsoft/omnichannel-chat-components";
@@ -18,14 +18,17 @@ const generateSurveyInviteLink = function (surveyInviteLink, isEmbed, locale, co
18
18
  return surveyLink;
19
19
  };
20
20
  export const PostChatSurveyPaneStateful = props => {
21
- var _props$styleProps, _state$appStates, _state$appStates2, _props$controlProps;
21
+ var _props$styleProps, _state$appStates, _props$controlProps;
22
22
  const [state] = useChatContextStore();
23
23
  const generalStyleProps = Object.assign({}, defaultGeneralPostChatSurveyPaneStyleProps, (_props$styleProps = props.styleProps) === null || _props$styleProps === void 0 ? void 0 : _props$styleProps.generalStyleProps, {
24
24
  display: state.appStates.isMinimized ? "none" : "contents"
25
25
  });
26
26
  let surveyInviteLink = "";
27
27
  const surveyMode = (state === null || state === void 0 ? void 0 : (_state$appStates = state.appStates) === null || _state$appStates === void 0 ? void 0 : _state$appStates.selectedSurveyMode) === PostChatSurveyMode.Embed;
28
- if ((state === null || state === void 0 ? void 0 : (_state$appStates2 = state.appStates) === null || _state$appStates2 === void 0 ? void 0 : _state$appStates2.conversationEndedBy) === ConversationEndEntity.Bot && state.domainStates.postChatContext.botSurveyInviteLink) {
28
+ if (state.domainStates.postChatContext.botSurveyInviteLink &&
29
+ // Bot survey enabled
30
+ state.appStates.postChatParticipantType === ParticipantType.Bot) {
31
+ // Only Bot has engaged
29
32
  surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.botSurveyInviteLink, surveyMode, state.domainStates.postChatContext.botFormsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
30
33
  } else {
31
34
  surveyInviteLink = generateSurveyInviteLink(state.domainStates.postChatContext.surveyInviteLink, surveyMode, state.domainStates.postChatContext.formsProLocale, props.isCustomerVoiceSurveyCompact ?? true);
@@ -43,4 +43,5 @@ export let LiveChatWidgetActionType;
43
43
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CHAT_DISCONNECT_EVENT_RECEIVED"] = 40] = "SET_CHAT_DISCONNECT_EVENT_RECEIVED";
44
44
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SURVEY_MODE"] = 41] = "SET_SURVEY_MODE";
45
45
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONFIRMATION_STATE"] = 42] = "SET_CONFIRMATION_STATE";
46
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_PARTICIPANT_TYPE"] = 43] = "SET_POST_CHAT_PARTICIPANT_TYPE";
46
47
  })(LiveChatWidgetActionType || (LiveChatWidgetActionType = {}));
@@ -53,7 +53,8 @@ export const getLiveChatWidgetContextInitialState = props => {
53
53
  unreadMessageCount: 0,
54
54
  conversationEndedBy: ConversationEndEntity.NotSet,
55
55
  chatDisconnectEventReceived: false,
56
- selectedSurveyMode: null
56
+ selectedSurveyMode: null,
57
+ postChatParticipantType: undefined
57
58
  },
58
59
  uiStates: {
59
60
  showConfirmationPane: false,
@@ -325,6 +325,14 @@ export const createReducer = () => {
325
325
  confirmationState: action.payload
326
326
  }
327
327
  };
328
+ case LiveChatWidgetActionType.SET_POST_CHAT_PARTICIPANT_TYPE:
329
+ return {
330
+ ...state,
331
+ appStates: {
332
+ ...state.appStates,
333
+ postChatParticipantType: action.payload
334
+ }
335
+ };
328
336
  default:
329
337
  return state;
330
338
  }
@@ -3,7 +3,7 @@ import { ConversationState } from "./ConversationState";
3
3
  import { IInternalTelemetryData } from "../../common/telemetry/interfaces/IInternalTelemetryData";
4
4
  import { ILiveChatWidgetLocalizedTexts } from "./ILiveChatWidgetLocalizedTexts";
5
5
  import { IRenderingMiddlewareProps } from "../../components/webchatcontainerstateful/interfaces/IRenderingMiddlewareProps";
6
- import { ConfirmationState, ConversationEndEntity } from "../../common/Constants";
6
+ import { ConfirmationState, ConversationEndEntity, ParticipantType } from "../../common/Constants";
7
7
  export interface ILiveChatWidgetContext {
8
8
  domainStates: {
9
9
  liveChatConfig: ChatConfig | undefined;
@@ -45,6 +45,7 @@ export interface ILiveChatWidgetContext {
45
45
  conversationEndedBy: ConversationEndEntity;
46
46
  chatDisconnectEventReceived: boolean;
47
47
  selectedSurveyMode: string | null;
48
+ postChatParticipantType: undefined | ParticipantType;
48
49
  };
49
50
  uiStates: {
50
51
  showConfirmationPane: boolean;
@@ -41,5 +41,6 @@ export declare enum LiveChatWidgetActionType {
41
41
  SET_SHOULD_USE_BOT_SURVEY = 39,
42
42
  SET_CHAT_DISCONNECT_EVENT_RECEIVED = 40,
43
43
  SET_SURVEY_MODE = 41,
44
- SET_CONFIRMATION_STATE = 42
44
+ SET_CONFIRMATION_STATE = 42,
45
+ SET_POST_CHAT_PARTICIPANT_TYPE = 43
45
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/omnichannel-chat-widget",
3
- "version": "1.3.1-main.c1cf6d6",
3
+ "version": "1.3.1-main.cb0a057",
4
4
  "description": "Microsoft Omnichannel Chat Widget",
5
5
  "main": "lib/cjs/index.js",
6
6
  "types": "lib/types/index.d.ts",