@microsoft/omnichannel-chat-widget 0.1.0-main.c461296 → 0.1.0-main.d80ebb6

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.
Files changed (101) hide show
  1. package/README.md +35 -11
  2. package/lib/cjs/common/Constants.js +46 -6
  3. package/lib/cjs/common/telemetry/TelemetryConstants.js +27 -2
  4. package/lib/cjs/common/telemetry/TelemetryHelper.js +13 -0
  5. package/lib/cjs/common/telemetry/TelemetryManager.js +16 -5
  6. package/lib/cjs/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  7. package/lib/cjs/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  8. package/lib/cjs/common/telemetry/loggers/ariaTelemetryLogger.js +33 -13
  9. package/lib/cjs/common/telemetry/loggers/consoleLogger.js +6 -5
  10. package/lib/cjs/common/utils.js +30 -2
  11. package/lib/cjs/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  12. package/lib/cjs/components/chatbuttonstateful/ChatButtonStateful.js +16 -4
  13. package/lib/cjs/components/confirmationpanestateful/ConfirmationPaneStateful.js +4 -39
  14. package/lib/cjs/components/footerstateful/FooterStateful.js +1 -2
  15. package/lib/cjs/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +11 -2
  16. package/lib/cjs/components/headerstateful/HeaderStateful.js +1 -7
  17. package/lib/cjs/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +12 -15
  18. package/lib/cjs/components/livechatwidget/common/endChat.js +63 -12
  19. package/lib/cjs/components/livechatwidget/common/initCallingSdk.js +1 -1
  20. package/lib/cjs/components/livechatwidget/common/initWebChatComposer.js +15 -3
  21. package/lib/cjs/components/livechatwidget/common/reconnectChatHelper.js +105 -20
  22. package/lib/cjs/components/livechatwidget/common/registerTelemetryLoggers.js +6 -17
  23. package/lib/cjs/components/livechatwidget/common/startChat.js +87 -39
  24. package/lib/cjs/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +113 -21
  25. package/lib/cjs/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +8 -0
  26. package/lib/cjs/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +4 -5
  27. package/lib/cjs/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -0
  28. package/lib/cjs/components/webchatcontainerstateful/WebChatContainerStateful.js +80 -0
  29. package/lib/cjs/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  30. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +14 -0
  31. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  32. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +52 -0
  33. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +98 -0
  34. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/mesageTimestampMiddleware.js +116 -0
  35. package/lib/cjs/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +45 -0
  36. package/lib/cjs/contexts/common/LiveChatWidgetActionType.js +8 -7
  37. package/lib/cjs/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
  38. package/lib/cjs/contexts/createReducer.js +8 -10
  39. package/lib/cjs/plugins/newMessageEventHandler.js +10 -13
  40. package/lib/esm/common/Constants.js +42 -5
  41. package/lib/esm/common/telemetry/TelemetryConstants.js +27 -2
  42. package/lib/esm/common/telemetry/TelemetryHelper.js +13 -1
  43. package/lib/esm/common/telemetry/TelemetryManager.js +14 -5
  44. package/lib/esm/common/telemetry/defaultConfigs/defaultAriaConfig.js +1 -1
  45. package/lib/esm/common/telemetry/defaultConfigs/defaultTelemetryConfiguration.js +4 -1
  46. package/lib/esm/common/telemetry/loggers/ariaTelemetryLogger.js +36 -14
  47. package/lib/esm/common/telemetry/loggers/consoleLogger.js +6 -5
  48. package/lib/esm/common/utils.js +19 -1
  49. package/lib/esm/components/callingcontainerstateful/CallingContainerStateful.js +14 -0
  50. package/lib/esm/components/chatbuttonstateful/ChatButtonStateful.js +18 -6
  51. package/lib/esm/components/confirmationpanestateful/ConfirmationPaneStateful.js +7 -37
  52. package/lib/esm/components/footerstateful/FooterStateful.js +1 -2
  53. package/lib/esm/components/footerstateful/downloadtranscriptstateful/DownloadTranscriptStateful.js +9 -3
  54. package/lib/esm/components/headerstateful/HeaderStateful.js +1 -7
  55. package/lib/esm/components/livechatwidget/common/defaultProps/dummyDefaultProps.js +12 -16
  56. package/lib/esm/components/livechatwidget/common/endChat.js +58 -13
  57. package/lib/esm/components/livechatwidget/common/initCallingSdk.js +1 -1
  58. package/lib/esm/components/livechatwidget/common/initWebChatComposer.js +13 -4
  59. package/lib/esm/components/livechatwidget/common/reconnectChatHelper.js +94 -20
  60. package/lib/esm/components/livechatwidget/common/registerTelemetryLoggers.js +5 -14
  61. package/lib/esm/components/livechatwidget/common/startChat.js +90 -44
  62. package/lib/esm/components/livechatwidget/livechatwidgetstateful/LiveChatWidgetStateful.js +106 -24
  63. package/lib/esm/components/postchatloadingpanestateful/PostChatLoadingPaneStateful.js +6 -0
  64. package/lib/esm/components/prechatsurveypanestateful/PreChatSurveyPaneStateful.js +6 -7
  65. package/lib/esm/components/proactivechatpanestateful/ProactiveChatPaneStateful.js +16 -0
  66. package/lib/esm/components/webchatcontainerstateful/WebChatContainerStateful.js +72 -0
  67. package/lib/esm/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.js +1 -0
  68. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.js +5 -0
  69. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/activityMiddleware.js +16 -2
  70. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.js +41 -0
  71. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.js +94 -0
  72. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/mesageTimestampMiddleware.js +106 -0
  73. package/lib/esm/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.js +32 -0
  74. package/lib/esm/contexts/common/LiveChatWidgetActionType.js +8 -7
  75. package/lib/esm/contexts/common/LiveChatWidgetContextInitialState.js +2 -1
  76. package/lib/esm/contexts/createReducer.js +8 -9
  77. package/lib/esm/plugins/newMessageEventHandler.js +10 -12
  78. package/lib/types/common/Constants.d.ts +23 -2
  79. package/lib/types/common/interfaces/IContextDataStore.d.ts +1 -1
  80. package/lib/types/common/telemetry/TelemetryConstants.d.ts +22 -4
  81. package/lib/types/common/telemetry/TelemetryHelper.d.ts +2 -0
  82. package/lib/types/common/telemetry/definitions/Payload.d.ts +12 -9
  83. package/lib/types/common/telemetry/interfaces/ITelemetryConfig.d.ts +3 -3
  84. package/lib/types/common/utils.d.ts +3 -0
  85. package/lib/types/components/confirmationpanestateful/interfaces/IConfirmationPaneStatefulParams.d.ts +4 -4
  86. package/lib/types/components/footerstateful/audionotificationstateful/interfaces/IAudioNotificationStatefulParams.d.ts +0 -1
  87. package/lib/types/components/livechatwidget/common/endChat.d.ts +4 -1
  88. package/lib/types/components/livechatwidget/common/reconnectChatHelper.d.ts +5 -2
  89. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetComponentOverrides.d.ts +1 -0
  90. package/lib/types/components/livechatwidget/interfaces/ILiveChatWidgetProps.d.ts +1 -1
  91. package/lib/types/components/reconnectchatpanestateful/interfaces/IReconnectChatPaneStatefulProps.d.ts +1 -0
  92. package/lib/types/components/webchatcontainerstateful/interfaces/IBotMagicCodeConfig.d.ts +4 -0
  93. package/lib/types/components/webchatcontainerstateful/interfaces/IWebChatContainerStatefulProps.d.ts +2 -0
  94. package/lib/types/components/webchatcontainerstateful/webchatcontroller/BotMagicCodeStore.d.ts +3 -0
  95. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.d.ts +2 -0
  96. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/cardActionMiddleware.spec.d.ts +1 -0
  97. package/lib/types/components/webchatcontainerstateful/webchatcontroller/middlewares/renderingmiddlewares/mesageTimestampMiddleware.d.ts +5 -0
  98. package/lib/types/components/webchatcontainerstateful/webchatcontroller/webchattelemetry/WebChatLogger.d.ts +1 -0
  99. package/lib/types/contexts/common/ILiveChatWidgetContext.d.ts +1 -0
  100. package/lib/types/contexts/common/LiveChatWidgetActionType.d.ts +9 -8
  101. package/package.json +6 -7
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BotMagicCodeStore = void 0;
7
+
8
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
9
+
10
+ class BotMagicCodeStore {}
11
+
12
+ exports.BotMagicCodeStore = BotMagicCodeStore;
13
+
14
+ _defineProperty(BotMagicCodeStore, "botOAuthSignInId", "");
@@ -75,6 +75,16 @@ const handleSystemMessage = (next, args, card, systemMessageStyleProps) => {
75
75
  }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
76
 
77
77
 
78
+ const isTagIncluded = (card, tag) => {
79
+ return isDataTagsPresent(card) && card.activity.channelData.tags.includes(tag);
80
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+
82
+
83
+ const isDataTagsPresent = card => {
84
+ return card && card.activity && card.activity.channelData && card.activity.channelData.tags && card.activity.channelData.tags.length > 0;
85
+ }; // eslint-disable-next-line @typescript-eslint/no-explicit-any
86
+
87
+
78
88
  const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps) => () => next => function () {
79
89
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
80
90
  args[_key] = arguments[_key];
@@ -83,7 +93,7 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
83
93
  const [card] = args;
84
94
 
85
95
  if (card.activity) {
86
- var _card$activity$from, _card$activity$channe4, _card$activity$channe5;
96
+ var _card$activity$from;
87
97
 
88
98
  if (((_card$activity$from = card.activity.from) === null || _card$activity$from === void 0 ? void 0 : _card$activity$from.role) === _DirectLineSenderRole.DirectLineSenderRole.Channel) {
89
99
  var _card$activity$channe3;
@@ -98,7 +108,11 @@ const createActivityMiddleware = (systemMessageStyleProps, userMessageStyleProps
98
108
  return () => false;
99
109
  }
100
110
 
101
- if ((_card$activity$channe4 = card.activity.channelData) !== null && _card$activity$channe4 !== void 0 && (_card$activity$channe5 = _card$activity$channe4.tags) !== null && _card$activity$channe5 !== void 0 && _card$activity$channe5.includes(_Constants.Constants.systemMessageTag)) {
111
+ if (isTagIncluded(card, _Constants.Constants.hiddenTag)) {
112
+ return () => false;
113
+ }
114
+
115
+ if (isTagIncluded(card, _Constants.Constants.systemMessageTag)) {
102
116
  return handleSystemMessage(next, args, card, systemMessageStyleProps);
103
117
  } else if (card.activity.text && card.activity.type === _DirectLineActivityType.DirectLineActivityType.Message) {
104
118
  if (!card.activity.channelData.isHtmlEncoded && card.activity.channelId === _Constants.Constants.webchatChannelId) {
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createCardActionMiddleware = void 0;
7
+
8
+ var _BotMagicCodeStore = require("../../BotMagicCodeStore");
9
+
10
+ var CardActionType;
11
+
12
+ (function (CardActionType) {
13
+ CardActionType["OpenUrl"] = "openUrl";
14
+ CardActionType["SignIn"] = "signin";
15
+ })(CardActionType || (CardActionType = {}));
16
+
17
+ const validCardActionTypes = [CardActionType.OpenUrl, CardActionType.SignIn];
18
+ const botOauthUrlRegex = /[\S]+.botframework.com\/api\/oauth\/signin\?signin=([\S]+)/;
19
+
20
+ const createCardActionMiddleware = botMagicCodeConfig => {
21
+ const cardActionMiddleware = () => next => function () {
22
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
23
+ args[_key] = arguments[_key];
24
+ }
25
+
26
+ // eslint-disable-line @typescript-eslint/no-explicit-any
27
+ const [card] = args;
28
+
29
+ if (card.cardAction && validCardActionTypes.indexOf(card.cardAction.type) >= 0 && card.cardAction.value) {
30
+ // Override signin url only if fwdUrl is valid & feature is enabled
31
+ if ((botMagicCodeConfig === null || botMagicCodeConfig === void 0 ? void 0 : botMagicCodeConfig.disabled) === true && botMagicCodeConfig !== null && botMagicCodeConfig !== void 0 && botMagicCodeConfig.fwdUrl) {
32
+ const baseUrl = window.location.origin;
33
+ const result = botOauthUrlRegex.exec(card.cardAction.value);
34
+
35
+ if (result) {
36
+ _BotMagicCodeStore.BotMagicCodeStore.botOAuthSignInId = `${result[1]}`;
37
+ } // fwdUrl must be on the same domain as the chat widget
38
+
39
+
40
+ if (botMagicCodeConfig !== null && botMagicCodeConfig !== void 0 && botMagicCodeConfig.fwdUrl.startsWith(baseUrl)) {
41
+ card.cardAction.value += `&fwdUrl=${botMagicCodeConfig.fwdUrl}`;
42
+ }
43
+ }
44
+ }
45
+
46
+ return next(...args);
47
+ };
48
+
49
+ return cardActionMiddleware;
50
+ };
51
+
52
+ exports.createCardActionMiddleware = createCardActionMiddleware;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ require("@testing-library/jest-dom/extend-expect");
4
+
5
+ var _cardActionMiddleware = require("./cardActionMiddleware");
6
+
7
+ describe("cardActionMiddleware test", () => {
8
+ it("createCardActionMiddleware() with undefined botMagicCodeConfig should not change the sign in card url", () => {
9
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
10
+
11
+
12
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
13
+ const args = {
14
+ cardAction: {
15
+ type: "signin",
16
+ value: signInUrl
17
+ }
18
+ };
19
+ const results = (0, _cardActionMiddleware.createCardActionMiddleware)(undefined)()(next)(args);
20
+ expect(signInUrl).toEqual(results.cardAction.value);
21
+ });
22
+ it("createCardActionMiddleware() with botMagicCode enabled should not change the sign in card url", () => {
23
+ const botMagicCodeConfig = {
24
+ disabled: false
25
+ };
26
+
27
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
28
+
29
+
30
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
31
+ const args = {
32
+ cardAction: {
33
+ type: "signin",
34
+ value: signInUrl
35
+ }
36
+ };
37
+ const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
38
+ expect(args.cardAction.value).toEqual(results.cardAction.value);
39
+ });
40
+ it("createCardActionMiddleware() with botMagicCode disabled & no fwdUrl should not change the sign in card url", () => {
41
+ const botMagicCodeConfig = {
42
+ disabled: true
43
+ };
44
+
45
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
46
+
47
+
48
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
49
+ const args = {
50
+ cardAction: {
51
+ type: "signin",
52
+ value: signInUrl
53
+ }
54
+ };
55
+ const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
56
+ expect(args.cardAction.value).toEqual(results.cardAction.value);
57
+ });
58
+ it("createCardActionMiddleware() with botMagicCode disabled & fwdUrl should append the fwdUrl in the sign in card url", () => {
59
+ const botMagicCodeConfig = {
60
+ disabled: true,
61
+ fwdUrl: "http://localhost/forwarder.html"
62
+ };
63
+
64
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
65
+
66
+
67
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
68
+ const args = {
69
+ cardAction: {
70
+ type: "signin",
71
+ value: signInUrl
72
+ }
73
+ };
74
+ const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
75
+ expect(signInUrl === results.cardAction.value).toBe(false);
76
+ expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(true);
77
+ });
78
+ it("createCardActionMiddleware() should not append fwdUrl if fwdUrl & sign in card url are not in the same domain", () => {
79
+ const botMagicCodeConfig = {
80
+ disabled: true,
81
+ fwdUrl: "https://localhost/forwarder.html"
82
+ };
83
+
84
+ const next = args => args; // eslint-disable-line @typescript-eslint/no-explicit-any
85
+
86
+
87
+ const signInUrl = "https://token.botframework.com/api/oauth/signin?signin=[signin]";
88
+ const args = {
89
+ cardAction: {
90
+ type: "signin",
91
+ value: signInUrl
92
+ }
93
+ };
94
+ const results = (0, _cardActionMiddleware.createCardActionMiddleware)(botMagicCodeConfig)()(next)(args);
95
+ expect(signInUrl === results.cardAction.value).toBe(true);
96
+ expect(results.cardAction.value === `${signInUrl}&fwdUrl=${botMagicCodeConfig.fwdUrl}`).toBe(false);
97
+ });
98
+ });
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _WebChatActionType = require("../../enums/WebChatActionType");
9
+
10
+ var _Constants = require("../../../../../common/Constants");
11
+
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
13
+ const createMessageTimeStampMiddleware = _ref => {
14
+ let {
15
+ dispatch
16
+ } = _ref;
17
+ return next => action => {
18
+ if (isApplicable(action)) {
19
+ return next(evaluateTagsAndOverrideTimeStamp(action));
20
+ }
21
+
22
+ return next(action);
23
+ };
24
+ };
25
+
26
+ const isApplicable = action => {
27
+ return action.type === _WebChatActionType.WebChatActionType.DIRECT_LINE_INCOMING_ACTIVITY && isPVAConversation(action) && isPayloadValid(action) && isValidChannel(action);
28
+ };
29
+
30
+ const isPayloadValid = action => {
31
+ var _action$payload;
32
+
33
+ return action === null || action === void 0 ? void 0 : (_action$payload = action.payload) === null || _action$payload === void 0 ? void 0 : _action$payload.activity;
34
+ };
35
+
36
+ const isValidChannel = action => {
37
+ var _action$payload2, _action$payload2$acti;
38
+
39
+ return (action === null || action === void 0 ? void 0 : (_action$payload2 = action.payload) === null || _action$payload2 === void 0 ? void 0 : (_action$payload2$acti = _action$payload2.activity) === null || _action$payload2$acti === void 0 ? void 0 : _action$payload2$acti.channelId) === _Constants.Constants.acsChannel;
40
+ };
41
+
42
+ const isPVAConversation = action => {
43
+ return !isTagIncluded(action, _Constants.Constants.systemMessageTag) && !isTagIncluded(action, _Constants.Constants.publicMessageTag) && !isRoleUserOn(action);
44
+ };
45
+
46
+ const isTagIncluded = (action, tag) => {
47
+ return isDataTagsPresent(action) && action.payload.activity.channelData.tags.includes(tag);
48
+ };
49
+
50
+ const isRoleUserOn = action => {
51
+ var _action$payload3, _action$payload3$acti, _action$payload3$acti2;
52
+
53
+ return (action === null || action === void 0 ? void 0 : (_action$payload3 = action.payload) === null || _action$payload3 === void 0 ? void 0 : (_action$payload3$acti = _action$payload3.activity) === null || _action$payload3$acti === void 0 ? void 0 : (_action$payload3$acti2 = _action$payload3$acti.from) === null || _action$payload3$acti2 === void 0 ? void 0 : _action$payload3$acti2.role) === _Constants.Constants.userMessageTag;
54
+ };
55
+
56
+ const overrideTimeStamp = (timestampOriginal, timeStampNew) => {
57
+ return isTimestampValid(timeStampNew) ? timeStampNew : timestampOriginal;
58
+ };
59
+
60
+ const isTimestampValid = timeStamp => {
61
+ const regex = /(\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])(T)(\d{2})(:{1})(\d{2})(:{1})(\d{2})(.\d+)([Z]{1}))/;
62
+ return regex.test(timeStamp);
63
+ };
64
+
65
+ const isDataTagsPresent = action => {
66
+ var _action$payload4, _action$payload4$acti, _action$payload4$acti2;
67
+
68
+ return (action === null || action === void 0 ? void 0 : (_action$payload4 = action.payload) === null || _action$payload4 === void 0 ? void 0 : (_action$payload4$acti = _action$payload4.activity) === null || _action$payload4$acti === void 0 ? void 0 : (_action$payload4$acti2 = _action$payload4$acti.channelData) === null || _action$payload4$acti2 === void 0 ? void 0 : _action$payload4$acti2.tags) && action.payload.activity.channelData.tags.length > 0;
69
+ };
70
+
71
+ const evaluateTagsAndOverrideTimeStamp = action => {
72
+ const tagValue = tagLookup(action, _Constants.Constants.prefixTimestampTag);
73
+
74
+ if (tagValue) {
75
+ const newTimestamp = extractTimeStamp(tagValue);
76
+ action.payload.activity.timestamp = overrideTimeStamp(action.payload.activity.timestamp, newTimestamp);
77
+ }
78
+
79
+ return action;
80
+ };
81
+
82
+ const extractTimeStamp = timeStamp => {
83
+ if (timeStamp && timeStamp.length > 0) {
84
+ const ts = timeStamp.split(_Constants.Constants.prefixTimestampTag);
85
+
86
+ if (ts && ts.length > 1) {
87
+ return ts[1];
88
+ }
89
+ }
90
+
91
+ return timeStamp;
92
+ };
93
+
94
+ const tagLookup = (action, tag) => {
95
+ if (!isDataTagsPresent(action)) {
96
+ return null;
97
+ }
98
+
99
+ const tags = action.payload.activity.channelData.tags;
100
+ let value;
101
+
102
+ if (tags && tags.length > 0) {
103
+ for (let i = 0; i < tags.length; i++) {
104
+ value = tags[i];
105
+
106
+ if (value && value.indexOf(tag) > -1) {
107
+ return value;
108
+ }
109
+ }
110
+ }
111
+
112
+ return null;
113
+ };
114
+
115
+ var _default = createMessageTimeStampMiddleware;
116
+ exports.default = _default;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createWebChatTelemetry = createWebChatTelemetry;
7
+
8
+ var _TelemetryConstants = require("../../../../common/telemetry/TelemetryConstants");
9
+
10
+ var _TelemetryHelper = require("../../../../common/telemetry/TelemetryHelper");
11
+
12
+ function createWebChatTelemetry() {
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ const handleTelemetry = event => {
15
+ const {
16
+ level
17
+ } = event;
18
+ const loglevel = level ? level.toUpperCase() : "";
19
+
20
+ switch (loglevel) {
21
+ case _TelemetryConstants.LogLevel.DEBUG:
22
+ _TelemetryHelper.TelemetryHelper.logWebChatEvent(_TelemetryConstants.LogLevel.DEBUG, event);
23
+
24
+ break;
25
+
26
+ case _TelemetryConstants.LogLevel.WARN:
27
+ _TelemetryHelper.TelemetryHelper.logWebChatEvent(_TelemetryConstants.LogLevel.WARN, event);
28
+
29
+ break;
30
+
31
+ case _TelemetryConstants.LogLevel.ERROR:
32
+ _TelemetryHelper.TelemetryHelper.logWebChatEvent(_TelemetryConstants.LogLevel.ERROR, event);
33
+
34
+ break;
35
+
36
+ case _TelemetryConstants.LogLevel.INFO:
37
+ default:
38
+ _TelemetryHelper.TelemetryHelper.logWebChatEvent(_TelemetryConstants.LogLevel.INFO, event);
39
+
40
+ break;
41
+ }
42
+ };
43
+
44
+ return handleTelemetry;
45
+ }
@@ -17,13 +17,13 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
17
17
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PREVIOUS_FOCUSED_ELEMENT"] = 6] = "SET_PREVIOUS_FOCUSED_ELEMENT";
18
18
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_OUTSIDE_OPERATING_HOURS"] = 7] = "SET_OUTSIDE_OPERATING_HOURS";
19
19
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRE_CHAT_SURVEY_RESPONSE"] = 8] = "SET_PRE_CHAT_SURVEY_RESPONSE";
20
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_CONFIRMATION"] = 9] = "SET_SHOW_CONFIRMATION";
21
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_EMAIL_TRANSCRIPT_PANE"] = 10] = "SET_SHOW_EMAIL_TRANSCRIPT_PANE";
22
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRECHAT_RESPONSE_EMAIL"] = 11] = "SET_PRECHAT_RESPONSE_EMAIL";
23
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_AUDIO_NOTIFICATION"] = 12] = "SET_AUDIO_NOTIFICATION";
24
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_E2VV_ENABLED"] = 13] = "SET_E2VV_ENABLED";
25
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_CONTEXT"] = 14] = "SET_POST_CHAT_CONTEXT";
26
- LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOULD_SHOW_POST_CHAT"] = 15] = "SET_SHOULD_SHOW_POST_CHAT";
20
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CUSTOM_CONTEXT"] = 9] = "SET_CUSTOM_CONTEXT";
21
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_CONFIRMATION"] = 10] = "SET_SHOW_CONFIRMATION";
22
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_SHOW_EMAIL_TRANSCRIPT_PANE"] = 11] = "SET_SHOW_EMAIL_TRANSCRIPT_PANE";
23
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_PRECHAT_RESPONSE_EMAIL"] = 12] = "SET_PRECHAT_RESPONSE_EMAIL";
24
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_AUDIO_NOTIFICATION"] = 13] = "SET_AUDIO_NOTIFICATION";
25
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_E2VV_ENABLED"] = 14] = "SET_E2VV_ENABLED";
26
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_POST_CHAT_CONTEXT"] = 15] = "SET_POST_CHAT_CONTEXT";
27
27
  LiveChatWidgetActionType[LiveChatWidgetActionType["SHOW_CALLING_CONTAINER"] = 16] = "SHOW_CALLING_CONTAINER";
28
28
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_INCOMING_CALL"] = 17] = "SET_INCOMING_CALL";
29
29
  LiveChatWidgetActionType[LiveChatWidgetActionType["DISABLE_VIDEO_CALL"] = 18] = "DISABLE_VIDEO_CALL";
@@ -39,4 +39,5 @@ exports.LiveChatWidgetActionType = LiveChatWidgetActionType;
39
39
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_CONVERSATION_ENDED_BY_AGENT"] = 28] = "SET_CONVERSATION_ENDED_BY_AGENT";
40
40
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_WIDGET_STATE"] = 29] = "SET_WIDGET_STATE";
41
41
  LiveChatWidgetActionType[LiveChatWidgetActionType["SET_LIVE_CHAT_CONTEXT"] = 30] = "SET_LIVE_CHAT_CONTEXT";
42
+ LiveChatWidgetActionType[LiveChatWidgetActionType["SET_BOT_OAUTH_SIGNIN_ID"] = 31] = "SET_BOT_OAUTH_SIGNIN_ID";
42
43
  })(LiveChatWidgetActionType || (exports.LiveChatWidgetActionType = LiveChatWidgetActionType = {}));
@@ -27,7 +27,8 @@ const getLiveChatWidgetContextInitialState = props => {
27
27
  postChatContext: undefined,
28
28
  telemetryInternalData: {},
29
29
  globalDir: "ltr",
30
- liveChatContext: undefined
30
+ liveChatContext: undefined,
31
+ customContext: undefined
31
32
  },
32
33
  appStates: {
33
34
  conversationState: _ConversationState.ConversationState.Closed,
@@ -7,8 +7,6 @@ exports.createReducer = void 0;
7
7
 
8
8
  var _LiveChatWidgetActionType = require("./common/LiveChatWidgetActionType");
9
9
 
10
- var _TelemetryManager = require("../common/telemetry/TelemetryManager");
11
-
12
10
  /* eslint-disable indent */
13
11
  const createReducer = () => {
14
12
  const reducer = (state, action) => {
@@ -71,6 +69,14 @@ const createReducer = () => {
71
69
  }
72
70
  };
73
71
 
72
+ case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_CUSTOM_CONTEXT:
73
+ return { ...state,
74
+ domainStates: { ...state.domainStates,
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
76
+ customContext: action.payload
77
+ }
78
+ };
79
+
74
80
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_PREVIOUS_FOCUSED_ELEMENT:
75
81
  return { ...state,
76
82
  appStates: { ...state.appStates,
@@ -93,13 +99,6 @@ const createReducer = () => {
93
99
  }
94
100
  };
95
101
 
96
- case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_SHOULD_SHOW_POST_CHAT:
97
- return { ...state,
98
- appStates: { ...state.appStates,
99
- shouldShowPostChat: action.payload
100
- }
101
- };
102
-
103
102
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.SHOW_CALLING_CONTAINER:
104
103
  return { ...state,
105
104
  uiStates: { ...state.uiStates,
@@ -197,7 +196,6 @@ const createReducer = () => {
197
196
  };
198
197
 
199
198
  case _LiveChatWidgetActionType.LiveChatWidgetActionType.SET_TELEMETRY_DATA:
200
- _TelemetryManager.TelemetryManager.InternalTelemetryData = action.payload;
201
199
  return { ...state,
202
200
  domainStates: { ...state.domainStates,
203
201
  telemetryInternalData: action.payload
@@ -13,8 +13,6 @@ var _Constants = require("../common/Constants");
13
13
 
14
14
  var _TelemetryHelper = require("../common/telemetry/TelemetryHelper");
15
15
 
16
- var _TelemetryManager = require("../common/telemetry/TelemetryManager");
17
-
18
16
  const createOnNewAdapterActivityHandler = (chatId, userId) => {
19
17
  const onNewAdapterActivityHandler = activity => {
20
18
  var _activity$channelData, _activity$channelData2, _activity$channelData3;
@@ -29,18 +27,16 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
29
27
 
30
28
  const raiseMessageEvent = activity => {
31
29
  if ((activity === null || activity === void 0 ? void 0 : activity.type) === _Constants.Constants.message) {
32
- var _TelemetryManager$Int, _activity$from;
30
+ var _text, _text2, _activity$channelData4, _activity$from;
33
31
 
34
32
  const payload = {
33
+ // To identify hidden contents vs empty content
35
34
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
- text: activity === null || activity === void 0 ? void 0 : activity.text,
37
- id: activity === null || activity === void 0 ? void 0 : activity.id,
35
+ text: (activity === null || activity === void 0 ? void 0 : (_text = activity.text) === null || _text === void 0 ? void 0 : _text.length) >= 1 ? `*contents hidden (${activity === null || activity === void 0 ? void 0 : (_text2 = activity.text) === null || _text2 === void 0 ? void 0 : _text2.length} chars)*` : "",
38
36
  type: activity === null || activity === void 0 ? void 0 : activity.type,
39
37
  timestamp: activity === null || activity === void 0 ? void 0 : activity.timestamp,
40
- chatId: chatId,
41
38
  userId: userId,
42
- conversationId: ((_TelemetryManager$Int = _TelemetryManager.TelemetryManager.InternalTelemetryData) === null || _TelemetryManager$Int === void 0 ? void 0 : _TelemetryManager$Int.conversationId) ?? "",
43
- channelData: activity === null || activity === void 0 ? void 0 : activity.channelData,
39
+ tags: activity === null || activity === void 0 ? void 0 : (_activity$channelData4 = activity.channelData) === null || _activity$channelData4 === void 0 ? void 0 : _activity$channelData4.tags,
44
40
  messageType: ""
45
41
  };
46
42
 
@@ -59,18 +55,18 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
59
55
  Description: "New message sent"
60
56
  });
61
57
  } else {
62
- var _activity$channelData4, _activity$channelData5;
58
+ var _activity$channelData5, _activity$channelData6;
63
59
 
64
- if (activity !== null && activity !== void 0 && (_activity$channelData4 = activity.channelData) !== null && _activity$channelData4 !== void 0 && (_activity$channelData5 = _activity$channelData4.tags) !== null && _activity$channelData5 !== void 0 && _activity$channelData5.includes(_Constants.Constants.systemMessageTag)) {
60
+ if (activity !== null && activity !== void 0 && (_activity$channelData5 = activity.channelData) !== null && _activity$channelData5 !== void 0 && (_activity$channelData6 = _activity$channelData5.tags) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.includes(_Constants.Constants.systemMessageTag)) {
65
61
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
66
62
  payload.messageType = _Constants.Constants.systemMessageTag;
67
63
  } else {
68
- var _activity$channelData6, _activity$channelData7, _activity$channelData8;
64
+ var _activity$channelData7, _activity$channelData8, _activity$channelData9;
69
65
 
70
66
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
67
  const messageHasNoText = !(activity !== null && activity !== void 0 && activity.text); // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
68
 
73
- const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData6 = activity.channelData) !== null && _activity$channelData6 !== void 0 && _activity$channelData6.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData7 = activity.channelData) === null || _activity$channelData7 === void 0 ? void 0 : (_activity$channelData8 = _activity$channelData7.tags) === null || _activity$channelData8 === void 0 ? void 0 : _activity$channelData8.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
69
+ const messageHasNoTags = !(activity !== null && activity !== void 0 && activity.channelData) || !(activity !== null && activity !== void 0 && (_activity$channelData7 = activity.channelData) !== null && _activity$channelData7 !== void 0 && _activity$channelData7.tags) || (activity === null || activity === void 0 ? void 0 : (_activity$channelData8 = activity.channelData) === null || _activity$channelData8 === void 0 ? void 0 : (_activity$channelData9 = _activity$channelData8.tags) === null || _activity$channelData9 === void 0 ? void 0 : _activity$channelData9.length) === 0; // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
70
 
75
71
  const messageHasNoAttachments = !(activity !== null && activity !== void 0 && activity.attachments) || (activity === null || activity === void 0 ? void 0 : activity.attachments.length) === 0;
76
72
 
@@ -90,7 +86,8 @@ const createOnNewAdapterActivityHandler = (chatId, userId) => {
90
86
 
91
87
  _TelemetryHelper.TelemetryHelper.logActionEvent(_TelemetryConstants.LogLevel.INFO, {
92
88
  Event: _TelemetryConstants.TelemetryEvent.MessageReceived,
93
- Description: "New message received"
89
+ Description: "New message received",
90
+ Data: payload
94
91
  });
95
92
  }
96
93
  }
@@ -4,6 +4,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
4
4
 
5
5
  export class Constants {}
6
6
 
7
+ _defineProperty(Constants, "magicCodeBroadcastChannel", "MagicCodeChannel");
8
+
9
+ _defineProperty(Constants, "magicCodeResponseBroadcastChannel", "MagicCodeResponseChannel");
10
+
7
11
  _defineProperty(Constants, "systemMessageTag", "system");
8
12
 
9
13
  _defineProperty(Constants, "userMessageTag", "user");
@@ -36,8 +40,6 @@ _defineProperty(Constants, "false", "false");
36
40
 
37
41
  _defineProperty(Constants, "maximumUnreadMessageCount", 99);
38
42
 
39
- _defineProperty(Constants, "widgetStateDataKey", "LcwChatWidgetState");
40
-
41
43
  _defineProperty(Constants, "channelIdKey", "ChannelId-");
42
44
 
43
45
  _defineProperty(Constants, "ChannelId", "lcw");
@@ -72,6 +74,14 @@ _defineProperty(Constants, "averageWaitTimeMessageTag", "averagewaittime");
72
74
 
73
75
  _defineProperty(Constants, "message", "message");
74
76
 
77
+ _defineProperty(Constants, "hiddenTag", "Hidden");
78
+
79
+ _defineProperty(Constants, "prefixTimestampTag", "ServerMessageTimestamp_");
80
+
81
+ _defineProperty(Constants, "acsChannel", "ACS_CHANNEL");
82
+
83
+ _defineProperty(Constants, "publicMessageTag", "public");
84
+
75
85
  _defineProperty(Constants, "supportedAdaptiveCardContentTypes", ["application/vnd.microsoft.card.adaptive", "application/vnd.microsoft.card.audio", "application/vnd.microsoft.card.hero", "application/vnd.microsoft.card.receipt", "application/vnd.microsoft.card.thumbnail", "application/vnd.microsoft.card.signin", "application/vnd.microsoft.card.oauth"]);
76
86
 
77
87
  _defineProperty(Constants, "maxUploadFileSize", "500000");
@@ -122,8 +132,6 @@ _defineProperty(Constants, "InputSubmit", "InputSubmit");
122
132
 
123
133
  _defineProperty(Constants, "ReconnectIdAttributeName", "oc.reconnectid");
124
134
 
125
- _defineProperty(Constants, "redirectPageRequest", "redirectPageRequest");
126
-
127
135
  _defineProperty(Constants, "LiveChatWidget", "LiveChatWidgetNew");
128
136
 
129
137
  _defineProperty(Constants, "GuidPattern", "xx-x-4m-ym-xxx");
@@ -148,6 +156,8 @@ _defineProperty(Constants, "internetConnectionTestUrl", "https://ocsdk-prod.azur
148
156
 
149
157
  _defineProperty(Constants, "internetConnectionTestUrlText", "Omnichannel Connect Test");
150
158
 
159
+ _defineProperty(Constants, "ChatWidgetStateChangedPrefix", "ChatWidgetStateChanged");
160
+
151
161
  export const Regex = (_class = class Regex {}, _defineProperty(_class, "EmailRegex", "(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])"), _class);
152
162
  export class HtmlIdNames {}
153
163
 
@@ -257,6 +267,15 @@ export let ChatSDKError;
257
267
  ChatSDKError["WidgetUseOutsideOperatingHour"] = "WidgetUseOutsideOperatingHour";
258
268
  })(ChatSDKError || (ChatSDKError = {}));
259
269
 
270
+ export let EnvironmentVersion;
271
+
272
+ (function (EnvironmentVersion) {
273
+ EnvironmentVersion["prod"] = "prod";
274
+ EnvironmentVersion["dogfood"] = "df";
275
+ EnvironmentVersion["int"] = "int";
276
+ EnvironmentVersion["test"] = "test";
277
+ })(EnvironmentVersion || (EnvironmentVersion = {}));
278
+
260
279
  export class TranscriptConstants {}
261
280
 
262
281
  _defineProperty(TranscriptConstants, "ChatTranscriptsBodyColor", "#F5F5F5");
@@ -277,4 +296,22 @@ _defineProperty(TranscriptConstants, "InternalMode", "internal");
277
296
 
278
297
  _defineProperty(TranscriptConstants, "AgentDialogColor", "#2266E3");
279
298
 
280
- _defineProperty(TranscriptConstants, "AgentFontColor", "white");
299
+ _defineProperty(TranscriptConstants, "AgentFontColor", "white");
300
+
301
+ export class AriaTelemetryConstants {}
302
+
303
+ _defineProperty(AriaTelemetryConstants, "GERMANY_ENDPOINT", "https://de.pipe.aria.microsoft.com/Collector/3.0/");
304
+
305
+ _defineProperty(AriaTelemetryConstants, "GCCH_ENDPOINT", "https://tb.pipe.aria.microsoft.com/Collector/3.0/");
306
+
307
+ _defineProperty(AriaTelemetryConstants, "DOD_ENDPOINT", "https://pf.pipe.aria.microsoft.com/Collector/3.0");
308
+
309
+ _defineProperty(AriaTelemetryConstants, "EUROPE_ENDPOINT", "https://eu-mobile.events.data.microsoft.com/Collector/3.0/");
310
+
311
+ _defineProperty(AriaTelemetryConstants, "MOONCAKE_ENDPOINT", "");
312
+
313
+ _defineProperty(AriaTelemetryConstants, "Public", "Public");
314
+
315
+ _defineProperty(AriaTelemetryConstants, "EU", "Europe");
316
+
317
+ _defineProperty(AriaTelemetryConstants, "lcwEUDomainNames", ["crm4.omnichannelengagementhub.com", "crm12.omnichannelengagementhub.com", "crm16.omnichannelengagementhub.com", "crm17.omnichannelengagementhub.com", "crm19.omnichannelengagementhub.com"]);