@rh-support/react-context 2.5.268 → 2.5.271
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/esm/GlobalContextWrapper.d.ts +1 -3
- package/lib/esm/GlobalContextWrapper.d.ts.map +1 -1
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts +6 -0
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.d.ts.map +1 -1
- package/lib/esm/components/EmbeddedServiceChat/EmbeddedServiceChat.js +16 -51
- package/lib/esm/components/EmbeddedServiceChat/embeddedServiceChat.css +0 -51
- package/lib/esm/hooks/index.d.ts +0 -1
- package/lib/esm/hooks/index.d.ts.map +1 -1
- package/lib/esm/hooks/index.js +0 -1
- package/lib/esm/hooks/useChatConfig.d.ts +9 -17
- package/lib/esm/hooks/useChatConfig.d.ts.map +1 -1
- package/lib/esm/hooks/useChatConfig.js +11 -43
- package/lib/esm/hooks/useChatInit.d.ts +9 -13
- package/lib/esm/hooks/useChatInit.d.ts.map +1 -1
- package/lib/esm/hooks/useChatInit.js +59 -119
- package/package.json +5 -5
- package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts +0 -12
- package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.d.ts.map +0 -1
- package/lib/esm/components/EmbeddedServiceChat/ExtraPreChatInfo.js +0 -29
- package/lib/esm/hooks/usePreChatFormDetails.d.ts +0 -12
- package/lib/esm/hooks/usePreChatFormDetails.d.ts.map +0 -1
- package/lib/esm/hooks/usePreChatFormDetails.js +0 -61
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalContextWrapper.d.ts","sourceRoot":"","sources":["../../src/GlobalContextWrapper.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAenD,UAAU,MAAM;IACZ,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACzC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,
|
|
1
|
+
{"version":3,"file":"GlobalContextWrapper.d.ts","sourceRoot":"","sources":["../../src/GlobalContextWrapper.tsx"],"names":[],"mappings":"AAWA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAenD,UAAU,MAAM;IACZ,QAAQ,EAAE,GAAG,CAAC,OAAO,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;CACzC;AAED,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,EAAE,GAAG,CAAC;QACf,oBAAoB,EAAE,GAAG,CAAC;QAC1B,MAAM,EAAE,GAAG,CAAC;QACZ,KAAK,EAAE,GAAG,CAAC;QACX,yBAAyB,EAAE,GAAG,CAAC;KAClC;IAED,UAAU,QAAQ;QACd,YAAY,EAAE,GAAG,CAAC;KACrB;CACJ;AA2GD,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,sBAKjD,CAAC"}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import './embeddedServiceChat.css';
|
|
2
2
|
import { FC } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* Bootstraps Salesforce Enhanced Messaging.
|
|
5
|
+
* The messaging widget (button + chat window) is rendered by the Salesforce
|
|
6
|
+
* bootstrap script; this component only triggers initialisation and shows a
|
|
7
|
+
* spinner while the script loads.
|
|
8
|
+
*/
|
|
3
9
|
export declare const EmbeddedServiceChat: FC;
|
|
4
10
|
//# sourceMappingURL=EmbeddedServiceChat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"EmbeddedServiceChat.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/EmbeddedServiceChat.tsx"],"names":[],"mappings":"AAAA,OAAO,2BAA2B,CAAC;AAGnC,OAAc,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAIlC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,EAYjC,CAAC"}
|
|
@@ -1,55 +1,20 @@
|
|
|
1
1
|
import './embeddedServiceChat.css';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { Spinner } from '@patternfly/react-core';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useChatInit } from '../../hooks/useChatInit';
|
|
5
|
+
/**
|
|
6
|
+
* Bootstraps Salesforce Enhanced Messaging.
|
|
7
|
+
* The messaging widget (button + chat window) is rendered by the Salesforce
|
|
8
|
+
* bootstrap script; this component only triggers initialisation and shows a
|
|
9
|
+
* spinner while the script loads.
|
|
10
|
+
*/
|
|
8
11
|
export const EmbeddedServiceChat = () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const { loadingChat, isChatStarted, onStartChat, hasChatDomainsBlocked, hasBlockedByBrowser, chatServiceNotAvailable, hasBlockedByCookie, getChatFormDetails, } = useChatInit();
|
|
12
|
-
const [isBlockedErrorBoxVisible, setIsBlockedErrorBoxVisible] = useState(true);
|
|
13
|
-
const [chatClicked, setChatClicked] = useState(false);
|
|
14
|
-
const { t } = useTranslation();
|
|
15
|
-
const sessionId = (_a = getChatFormDetails().find((item) => item.label === 'SessionId')) === null || _a === void 0 ? void 0 : _a.value;
|
|
16
|
-
const shouldClose = () => {
|
|
17
|
-
setIsBlockedErrorBoxVisible(false);
|
|
18
|
-
};
|
|
19
|
-
const shouldOpen = () => {
|
|
20
|
-
setIsBlockedErrorBoxVisible(true);
|
|
21
|
-
};
|
|
22
|
-
const chatErrorMessagePopover = (param) => (React.createElement("div", { className: "chatButton chatError", id: "chat-blocked-popover-selector" },
|
|
23
|
-
React.createElement(Popover, { "aria-label": t('Cannot connect to chat support'), alertSeverityVariant: 'danger', position: PopoverPosition.top, hasAutoWidth: true, maxWidth: '420px', headerIcon: React.createElement(ExclamationCircleIcon, { className: "pf-v6-u-danger-color-100" }), headerComponent: "h1", headerContent: React.createElement(Trans, null, "Cannot connect to chat support"), bodyContent: param === 'cookie' ? (React.createElement("p", { className: "pf-v6-u-px-md" },
|
|
24
|
-
React.createElement(Trans, null,
|
|
25
|
-
"Accept functional cookies in your",
|
|
26
|
-
' ',
|
|
27
|
-
React.createElement(Button, { variant: ButtonVariant.link, isInline: true, onClick: (e) => {
|
|
28
|
-
e.preventDefault();
|
|
29
|
-
document.querySelector('#teconsent a[role="link"]').click();
|
|
30
|
-
} }, "cookie preferences"),
|
|
31
|
-
' ',
|
|
32
|
-
"to enable the Red Hat Chat Support, then refresh page."))) : (React.createElement("p", { className: "pf-v6-u-px-md" },
|
|
33
|
-
React.createElement(Trans, null, "There are multiple problems that can cause this error."),
|
|
34
|
-
React.createElement("br", null),
|
|
35
|
-
React.createElement("a", { href: `https://access.redhat.com/articles/313583#${hasBlockedByBrowser
|
|
36
|
-
? 'troubleshoot_browser'
|
|
37
|
-
: hasChatDomainsBlocked
|
|
38
|
-
? 'troubleshoot_network'
|
|
39
|
-
: ''}`, target: "_blank", rel: "noreferrer noopener" },
|
|
40
|
-
React.createElement(Trans, null, "See a list of possible causes.")))), isVisible: isBlockedErrorBoxVisible, shouldClose: shouldClose, shouldOpen: shouldOpen },
|
|
41
|
-
React.createElement(Button, { variant: ButtonVariant.link, className: "pf-v6-u-m-0 pf-v6-u-p-0" },
|
|
42
|
-
React.createElement(ChatSVGIcon, null)))));
|
|
43
|
-
if (chatServiceNotAvailable)
|
|
12
|
+
const { loadingChat, chatServiceNotAvailable, hasBlockedByCookie } = useChatInit();
|
|
13
|
+
if (chatServiceNotAvailable || hasBlockedByCookie)
|
|
44
14
|
return React.createElement(React.Fragment, null);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
}, "data-tracking-id": "embedded-service-chat", ref: componentRef, id: "chat-bot-wrapper" },
|
|
52
|
-
React.createElement(ChatSVGIcon, null),
|
|
53
|
-
React.createElement(NewFeaturePopoverAnnouncement, { "aria-label": t('Support now has a chatbot (beta). Try it if you need help with a case.'), featureName: FeatureAnnouncementKeys.CHAT_BOT, sectionRef: componentRef, bodyContent: React.createElement("div", null,
|
|
54
|
-
React.createElement(Trans, null, "Support now has a chatbot (beta). Try it if you need help with a case.")), triggerRef: () => document.getElementById('chat-bot-wrapper') }))) : (React.createElement(React.Fragment, null));
|
|
15
|
+
if (loadingChat) {
|
|
16
|
+
return (React.createElement("div", { className: "chatButton" },
|
|
17
|
+
React.createElement(Spinner, { diameter: "28px", className: "pf-v6-u-m-xs" })));
|
|
18
|
+
}
|
|
19
|
+
return React.createElement(React.Fragment, null);
|
|
55
20
|
};
|
|
@@ -18,54 +18,3 @@
|
|
|
18
18
|
body:has(.pf-chatbot) .chatButton {
|
|
19
19
|
display: none !important;
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
.chatError {
|
|
23
|
-
opacity: 0.7;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* Requested by CCM team */
|
|
27
|
-
.agent .chat-content[CLWCP-lwcchatpack_lwcchatpack] {
|
|
28
|
-
text-align: left;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/* Adding fowling CSS as requested by CCM team (Sudhir Panda) */
|
|
32
|
-
.embeddedServiceLiveAgentStateChat .chatSessionStartTime {
|
|
33
|
-
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
34
|
-
}
|
|
35
|
-
.embeddedServiceLiveAgentStateChatItem.chatMessage {
|
|
36
|
-
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
37
|
-
}
|
|
38
|
-
.embeddedServiceLiveAgentStateChatItem.chatMessage button {
|
|
39
|
-
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
40
|
-
}
|
|
41
|
-
.embeddedServiceHelpButton .helpButton .uiButton {
|
|
42
|
-
background-color: #005290;
|
|
43
|
-
font-family: 'Arial', sans-serif;
|
|
44
|
-
}
|
|
45
|
-
.embeddedServiceHelpButton .helpButton .uiButton:focus {
|
|
46
|
-
outline: 1px solid #005290;
|
|
47
|
-
}
|
|
48
|
-
.agent .chat-content[CLWCP-lwcchatpack_lwcchatpack] {
|
|
49
|
-
text-align: left;
|
|
50
|
-
font-family: 'Red Hat Text', 'RedHatText', 'Overpass', Overpass, Arial, sans-serif;
|
|
51
|
-
}
|
|
52
|
-
/* red hat chat icon */
|
|
53
|
-
.embeddedServiceLiveAgentStateChatAvatar.isLightningOutContext .agentIconColor0 {
|
|
54
|
-
background-image: url('https://access.redhat.com/chrome_themes/nimbus/img/red-hat-customer-portal.svg');
|
|
55
|
-
background-repeat: no-repeat;
|
|
56
|
-
background-size: 420% !important;
|
|
57
|
-
font-size: 0 !important;
|
|
58
|
-
background-color: #fff !important;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/* user chat bubble */
|
|
62
|
-
.chasitor.chat-content[CLWCP-lwcchatpack_lwcchatpack] {
|
|
63
|
-
background: #fff !important;
|
|
64
|
-
color: #0066cc !important;
|
|
65
|
-
border: #0066cc 1px solid !important;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/* timeout text background color */
|
|
69
|
-
.embeddedServiceSidebar .headerAnnouncement p {
|
|
70
|
-
background-color: #151515;
|
|
71
|
-
}
|
package/lib/esm/hooks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
package/lib/esm/hooks/index.js
CHANGED
|
@@ -1,20 +1,12 @@
|
|
|
1
|
+
export interface IEnhancedChatConfig {
|
|
2
|
+
orgId: string;
|
|
3
|
+
deploymentDevName: string;
|
|
4
|
+
siteURL: string;
|
|
5
|
+
scrt2URL: string;
|
|
6
|
+
bootstrapScriptURL: string;
|
|
7
|
+
}
|
|
1
8
|
/**
|
|
2
|
-
*
|
|
3
|
-
* This hook is used for selected chat configuration based on environment
|
|
9
|
+
* Returns Salesforce Enhanced Messaging configuration for the current environment.
|
|
4
10
|
*/
|
|
5
|
-
export declare const useChatConfig: () =>
|
|
6
|
-
host: string;
|
|
7
|
-
sandBox: string;
|
|
8
|
-
gslbBaseURL: string;
|
|
9
|
-
key: string;
|
|
10
|
-
appName: string;
|
|
11
|
-
extra: {
|
|
12
|
-
baseLiveAgentContentURL: string;
|
|
13
|
-
deploymentId: string;
|
|
14
|
-
buttonId: string;
|
|
15
|
-
baseLiveAgentURL: string;
|
|
16
|
-
eswLiveAgentDevName: string;
|
|
17
|
-
isOfflineSupportEnabled: boolean;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
11
|
+
export declare const useChatConfig: () => IEnhancedChatConfig;
|
|
20
12
|
//# sourceMappingURL=useChatConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatConfig.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useChatConfig.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatConfig.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;CAC9B;AAED;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,mBAwBhC,CAAC"}
|
|
@@ -1,58 +1,26 @@
|
|
|
1
1
|
import { Env } from '@cee-eng/hydrajs';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* This hook is used for selected chat configuration based on environment
|
|
3
|
+
* Returns Salesforce Enhanced Messaging configuration for the current environment.
|
|
5
4
|
*/
|
|
6
5
|
export const useChatConfig = () => {
|
|
7
6
|
const env = Env.getEnvName();
|
|
8
7
|
switch (env) {
|
|
9
8
|
case Env.EnvNames.QA:
|
|
10
|
-
return {
|
|
11
|
-
host: 'https://gss--qa.sandbox.my.salesforce.com',
|
|
12
|
-
sandBox: 'https://gss--qa.sandbox.my.site.com/botchat',
|
|
13
|
-
gslbBaseURL: 'https://service.force.com',
|
|
14
|
-
key: '00D8I0000016hOv',
|
|
15
|
-
appName: 'RedHatChatBot',
|
|
16
|
-
extra: {
|
|
17
|
-
baseLiveAgentContentURL: 'https://c.la4-c1cs-ia4.salesforceliveagent.com/content',
|
|
18
|
-
deploymentId: '5726R000000sXtR',
|
|
19
|
-
buttonId: '5736R000000wk2n',
|
|
20
|
-
baseLiveAgentURL: 'https://d.la4-c1cs-ia4.salesforceliveagent.com/chat',
|
|
21
|
-
eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I6R000000wk2oUAA_180f4e169cb',
|
|
22
|
-
isOfflineSupportEnabled: false,
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
9
|
case Env.EnvNames.STAGE:
|
|
26
10
|
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
extra: {
|
|
33
|
-
baseLiveAgentContentURL: 'https://c.la3-c1cs-ia7.salesforceliveagent.com/content',
|
|
34
|
-
deploymentId: '5726R000000sXtR',
|
|
35
|
-
buttonId: '5736R000000wk2n',
|
|
36
|
-
baseLiveAgentURL: 'https://d.la3-c1cs-ia7.salesforceliveagent.com/chat',
|
|
37
|
-
eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I6R000000wk2oUAA_180f4e169cb',
|
|
38
|
-
isOfflineSupportEnabled: false,
|
|
39
|
-
},
|
|
11
|
+
orgId: '00DEk00000R3Rgr',
|
|
12
|
+
deploymentDevName: 'Red_Hat_Enhanced_Chat',
|
|
13
|
+
siteURL: 'https://redhatsupport--stage.sandbox.my.site.com/ESWRedHatEnhancedChat1772111580668',
|
|
14
|
+
scrt2URL: 'https://redhatsupport--stage.sandbox.my.salesforce-scrt.com',
|
|
15
|
+
bootstrapScriptURL: 'https://redhatsupport--stage.sandbox.my.site.com/ESWRedHatEnhancedChat1772111580668/assets/js/bootstrap.min.js',
|
|
40
16
|
};
|
|
41
17
|
default:
|
|
42
18
|
return {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
extra: {
|
|
49
|
-
baseLiveAgentContentURL: 'https://c.la3-c1-ia6.salesforceliveagent.com/content',
|
|
50
|
-
deploymentId: '5726R000000sXtR',
|
|
51
|
-
buttonId: '5736R000000wk2n',
|
|
52
|
-
baseLiveAgentURL: 'https://d.la3-c1-ia6.salesforceliveagent.com/chat',
|
|
53
|
-
eswLiveAgentDevName: 'EmbeddedServiceLiveAgent_Parent04I6R000000wk2oUAA_180f4e169cb',
|
|
54
|
-
isOfflineSupportEnabled: false,
|
|
55
|
-
},
|
|
19
|
+
orgId: '00DEk00000R3Rgr',
|
|
20
|
+
deploymentDevName: 'Red_Hat_Enhanced_Chat',
|
|
21
|
+
siteURL: 'https://redhatsupport--stage.sandbox.my.site.com/ESWRedHatEnhancedChat1772111580668',
|
|
22
|
+
scrt2URL: 'https://redhatsupport--stage.sandbox.my.salesforce-scrt.com',
|
|
23
|
+
bootstrapScriptURL: 'https://redhatsupport--stage.sandbox.my.site.com/ESWRedHatEnhancedChat1772111580668/assets/js/bootstrap.min.js',
|
|
56
24
|
};
|
|
57
25
|
}
|
|
58
26
|
};
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import { IPreChatFormDetails } from './usePreChatFormDetails';
|
|
2
1
|
interface IChatOptions {
|
|
3
2
|
loadingChat: boolean;
|
|
4
|
-
isChatStarted: boolean;
|
|
5
|
-
hasBlockedByBrowser: boolean;
|
|
6
|
-
hasChatDomainsBlocked: boolean;
|
|
7
|
-
initEmbedChat: () => void;
|
|
8
|
-
onStartChat: () => void;
|
|
9
3
|
chatServiceNotAvailable: boolean;
|
|
10
4
|
hasBlockedByCookie: boolean;
|
|
11
|
-
/** Pre-chat form details (SSO, sessionId, etc.). From single usePreChatFormDetails instance to avoid duplicate API calls. */
|
|
12
|
-
getChatFormDetails: () => IPreChatFormDetails[];
|
|
13
5
|
}
|
|
14
6
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
7
|
+
* Dynamically loads the Salesforce Enhanced Messaging bootstrap script and
|
|
8
|
+
* calls `embeddedservice_bootstrap.init()` once the script is ready.
|
|
9
|
+
*
|
|
10
|
+
* The script is injected only after TrustArc functional-cookie consent is
|
|
11
|
+
* confirmed, and the `onload` callback is used instead of polling so we
|
|
12
|
+
* never race against network latency.
|
|
13
|
+
*
|
|
14
|
+
* @see https://developer.salesforce.com/docs/service/messaging-web/guide/set-up-embedded-messaging.html
|
|
19
15
|
*/
|
|
20
|
-
export declare const useChatInit: (
|
|
16
|
+
export declare const useChatInit: () => IChatOptions;
|
|
21
17
|
export {};
|
|
22
18
|
//# sourceMappingURL=useChatInit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useChatInit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useChatInit.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,QAAO,YAkE9B,CAAC"}
|
|
@@ -1,134 +1,74 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { enableScripts, getCookieValue, waitForWindowVariable } from '@rh-support/utils';
|
|
11
|
-
import { useEffect, useState } from 'react';
|
|
12
|
-
import { extraPreChatInfo } from '../components/EmbeddedServiceChat/ExtraPreChatInfo';
|
|
1
|
+
import { getCookieValue } from '@rh-support/utils';
|
|
2
|
+
import { useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { GlobalMetadataStateContext } from '../context/GlobalMetadataContext';
|
|
13
4
|
import { useChatConfig } from './useChatConfig';
|
|
14
|
-
import { usePreChatFormDetails } from './usePreChatFormDetails';
|
|
15
5
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
6
|
+
* Dynamically loads the Salesforce Enhanced Messaging bootstrap script and
|
|
7
|
+
* calls `embeddedservice_bootstrap.init()` once the script is ready.
|
|
8
|
+
*
|
|
9
|
+
* The script is injected only after TrustArc functional-cookie consent is
|
|
10
|
+
* confirmed, and the `onload` callback is used instead of polling so we
|
|
11
|
+
* never race against network latency.
|
|
12
|
+
*
|
|
13
|
+
* @see https://developer.salesforce.com/docs/service/messaging-web/guide/set-up-embedded-messaging.html
|
|
20
14
|
*/
|
|
21
|
-
export const useChatInit = (
|
|
22
|
-
const [isChatStarted, setChatStart] = useState(initialState);
|
|
23
|
-
// Need to set loading status true as it will prevent starting chat before loading necessary dependencies
|
|
15
|
+
export const useChatInit = () => {
|
|
24
16
|
const [loadingChat, setLoadingChat] = useState(true);
|
|
25
|
-
const [hasBlockedByBrowser, setHasBlockedByBrowser] = useState(false);
|
|
26
|
-
const [hasChatDomainsBlocked, setHasChatDomainsBlocked] = useState(false);
|
|
27
17
|
const [chatServiceNotAvailable, setChatServiceNotAvailable] = useState(false);
|
|
28
18
|
const [hasBlockedByCookie, setHasBlockedByCookie] = useState(false);
|
|
29
|
-
const
|
|
30
|
-
const
|
|
19
|
+
const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
|
|
20
|
+
const ssoName = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data.getSSOUsername();
|
|
21
|
+
const { orgId, deploymentDevName, siteURL, scrt2URL, bootstrapScriptURL } = useChatConfig();
|
|
22
|
+
const ssoNameRef = useRef(ssoName);
|
|
23
|
+
ssoNameRef.current = ssoName;
|
|
31
24
|
useEffect(() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
1-> Required Cookies
|
|
36
|
-
2-> Functional Cookies
|
|
37
|
-
3-> Advertising Cookies
|
|
38
|
-
we need to make sure 2 that indicates functional cookies is included in value
|
|
39
|
-
*/
|
|
40
|
-
var preferences = getCookieValue('cmapi_cookie_privacy');
|
|
41
|
-
if (preferences && preferences.includes('2')) {
|
|
42
|
-
// based on TrustArc cookie consent, cookie is allowed
|
|
43
|
-
enableScripts();
|
|
44
|
-
const initChatService = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
try {
|
|
46
|
-
yield waitForWindowVariable('embedded_svc', 10000);
|
|
47
|
-
initEmbedChat();
|
|
48
|
-
}
|
|
49
|
-
catch (e) {
|
|
50
|
-
console.error('Error: Chat service not available', e.message);
|
|
51
|
-
setLoadingChat(false);
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
initChatService();
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
25
|
+
var _a;
|
|
26
|
+
const preferences = getCookieValue('cmapi_cookie_privacy');
|
|
27
|
+
if (!preferences || !preferences.includes('2')) {
|
|
57
28
|
setHasBlockedByCookie(true);
|
|
58
|
-
}
|
|
59
|
-
setLoadingChat(false);
|
|
60
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
-
}, []);
|
|
62
|
-
const onStartChat = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
setLoadingChat(true);
|
|
64
|
-
try {
|
|
65
|
-
// if chat didn't start after a long wait
|
|
66
|
-
// then we assume browser has blocked the script
|
|
67
|
-
const blockedTimeOut = setTimeout(() => {
|
|
68
|
-
if (!window.$Lightning) {
|
|
69
|
-
setHasBlockedByBrowser(true);
|
|
70
|
-
setLoadingChat(false);
|
|
71
|
-
}
|
|
72
|
-
}, 10000);
|
|
73
|
-
yield window.embedded_svc.liveAgentAPI.startChat({
|
|
74
|
-
extraPrechatInfo: extraPreChatInfo,
|
|
75
|
-
extraPrechatFormDetails: getChatFormDetails(),
|
|
76
|
-
});
|
|
77
|
-
clearTimeout(blockedTimeOut);
|
|
78
|
-
setHasBlockedByBrowser(false);
|
|
79
|
-
setChatStart(true);
|
|
80
29
|
setLoadingChat(false);
|
|
30
|
+
return;
|
|
81
31
|
}
|
|
82
|
-
|
|
32
|
+
const onMessagingReady = () => {
|
|
33
|
+
window.embeddedservice_bootstrap.prechatAPI.setHiddenPrechatFields({
|
|
34
|
+
username: ssoNameRef.current,
|
|
35
|
+
});
|
|
83
36
|
setLoadingChat(false);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
37
|
+
};
|
|
38
|
+
const initChat = () => {
|
|
39
|
+
try {
|
|
40
|
+
window.embeddedservice_bootstrap.settings.language = 'en_US';
|
|
41
|
+
window.embeddedservice_bootstrap.init(orgId, deploymentDevName, siteURL, { scrt2URL });
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
console.error('Error loading Enhanced Messaging: ', err);
|
|
45
|
+
setChatServiceNotAvailable(true);
|
|
46
|
+
setLoadingChat(false);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
window.addEventListener('onEmbeddedMessagingReady', onMessagingReady);
|
|
50
|
+
if ((_a = window.embeddedservice_bootstrap) === null || _a === void 0 ? void 0 : _a.prechatAPI) {
|
|
51
|
+
onMessagingReady();
|
|
91
52
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
console.log(e);
|
|
53
|
+
else if (window.embeddedservice_bootstrap) {
|
|
54
|
+
initChat();
|
|
95
55
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
window.embedded_svc.init(host, sandBox, gslbBaseURL, key, appName, extra);
|
|
105
|
-
// Fired when Embedded Service Chat has ended and the application is closed.
|
|
106
|
-
window.embedded_svc.addEventHandler('afterDestroy', function (data) {
|
|
107
|
-
setChatStart(false);
|
|
108
|
-
});
|
|
109
|
-
// if chat didn't initialized after a long wait then we assume
|
|
110
|
-
// chat domains blocked by client network or browser
|
|
111
|
-
const blockedByNetworkTimeOut = setTimeout(() => {
|
|
112
|
-
if (!window.liveAgentDeployment) {
|
|
113
|
-
setHasChatDomainsBlocked(true);
|
|
56
|
+
else {
|
|
57
|
+
const script = document.createElement('script');
|
|
58
|
+
script.src = bootstrapScriptURL;
|
|
59
|
+
script.type = 'text/javascript';
|
|
60
|
+
script.onload = initChat;
|
|
61
|
+
script.onerror = () => {
|
|
62
|
+
console.error('Failed to load Enhanced Messaging bootstrap script');
|
|
63
|
+
setChatServiceNotAvailable(true);
|
|
114
64
|
setLoadingChat(false);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
123
|
-
return {
|
|
124
|
-
loadingChat,
|
|
125
|
-
isChatStarted,
|
|
126
|
-
hasBlockedByBrowser,
|
|
127
|
-
hasChatDomainsBlocked,
|
|
128
|
-
initEmbedChat,
|
|
129
|
-
onStartChat,
|
|
130
|
-
chatServiceNotAvailable,
|
|
131
|
-
hasBlockedByCookie,
|
|
132
|
-
getChatFormDetails,
|
|
133
|
-
};
|
|
65
|
+
};
|
|
66
|
+
document.body.appendChild(script);
|
|
67
|
+
}
|
|
68
|
+
return () => {
|
|
69
|
+
window.removeEventListener('onEmbeddedMessagingReady', onMessagingReady);
|
|
70
|
+
};
|
|
71
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
+
}, []);
|
|
73
|
+
return { loadingChat, chatServiceNotAvailable, hasBlockedByCookie };
|
|
134
74
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/react-context",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.271",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"@cee-eng/hydrajs": "4.18.111",
|
|
37
37
|
"@patternfly/react-core": "6.2.1",
|
|
38
38
|
"@patternfly/react-icons": "6.2.1",
|
|
39
|
-
"@rh-support/components": "2.5.
|
|
39
|
+
"@rh-support/components": "2.5.177",
|
|
40
40
|
"@rh-support/types": "2.0.26",
|
|
41
|
-
"@rh-support/user-permissions": "2.5.
|
|
42
|
-
"@rh-support/utils": "2.5.
|
|
41
|
+
"@rh-support/user-permissions": "2.5.123",
|
|
42
|
+
"@rh-support/utils": "2.5.106",
|
|
43
43
|
"i18next": "^23.15.0",
|
|
44
44
|
"localforage": "^1.10.0",
|
|
45
45
|
"lodash": "^4.17.21",
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
"defaults and supports es6-module",
|
|
90
90
|
"maintained node versions"
|
|
91
91
|
],
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "7b1306d35722c768378d97b4c6f9895c6a66bce8"
|
|
93
93
|
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const extraPreChatInfo: {
|
|
2
|
-
entityFieldMaps: {
|
|
3
|
-
doCreate: boolean;
|
|
4
|
-
doFind: boolean;
|
|
5
|
-
fieldName: string;
|
|
6
|
-
isExactMatch: boolean;
|
|
7
|
-
label: string;
|
|
8
|
-
}[];
|
|
9
|
-
entityName: string;
|
|
10
|
-
saveToTranscript: string;
|
|
11
|
-
}[];
|
|
12
|
-
//# sourceMappingURL=ExtraPreChatInfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExtraPreChatInfo.d.ts","sourceRoot":"","sources":["../../../../src/components/EmbeddedServiceChat/ExtraPreChatInfo.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;GA6B5B,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const extraPreChatInfo = [
|
|
2
|
-
{
|
|
3
|
-
entityFieldMaps: [
|
|
4
|
-
{
|
|
5
|
-
doCreate: false,
|
|
6
|
-
doFind: true,
|
|
7
|
-
fieldName: 'SSO_Username__c',
|
|
8
|
-
isExactMatch: true,
|
|
9
|
-
label: 'SSO Name',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
doCreate: false,
|
|
13
|
-
doFind: true,
|
|
14
|
-
fieldName: 'ContactSessionId__c',
|
|
15
|
-
isExactMatch: false,
|
|
16
|
-
label: 'SessionId',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
doCreate: false,
|
|
20
|
-
doFind: true,
|
|
21
|
-
fieldName: 'Account',
|
|
22
|
-
isExactMatch: true,
|
|
23
|
-
label: 'account',
|
|
24
|
-
},
|
|
25
|
-
],
|
|
26
|
-
entityName: '',
|
|
27
|
-
saveToTranscript: 'SSO_Username__c',
|
|
28
|
-
},
|
|
29
|
-
];
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface IPreChatFormDetails {
|
|
2
|
-
label: string;
|
|
3
|
-
value: string;
|
|
4
|
-
transcriptFields?: Array<string>;
|
|
5
|
-
displayToAgent: boolean;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* The use of this hook is to generate form details based on user current screen
|
|
10
|
-
*/
|
|
11
|
-
export declare const usePreChatFormDetails: () => (() => IPreChatFormDetails[]);
|
|
12
|
-
//# sourceMappingURL=usePreChatFormDetails.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePreChatFormDetails.d.ts","sourceRoot":"","sources":["../../../src/hooks/usePreChatFormDetails.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC;CAC3B;AAED;;;GAGG;AAEH,eAAO,MAAM,qBAAqB,QAAO,CAAC,MAAM,mBAAmB,EAAE,CA+CpE,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { publicApi } from '@cee-eng/hydrajs';
|
|
11
|
-
import { useContext, useEffect, useState } from 'react';
|
|
12
|
-
import { GlobalMetadataStateContext } from '../context/GlobalMetadataContext';
|
|
13
|
-
/**
|
|
14
|
-
*
|
|
15
|
-
* The use of this hook is to generate form details based on user current screen
|
|
16
|
-
*/
|
|
17
|
-
export const usePreChatFormDetails = () => {
|
|
18
|
-
const { globalMetadataState: { loggedInUserRights }, } = useContext(GlobalMetadataStateContext);
|
|
19
|
-
const [sessionId, setSessionId] = useState('');
|
|
20
|
-
const loggedInUserRightsData = loggedInUserRights === null || loggedInUserRights === void 0 ? void 0 : loggedInUserRights.data;
|
|
21
|
-
const ssoName = loggedInUserRightsData.getSSOUsername();
|
|
22
|
-
const name = loggedInUserRightsData.getUserFullName();
|
|
23
|
-
const accountNumber = loggedInUserRightsData.getAccountNumber();
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
try {
|
|
26
|
-
const fetchChatSessionId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
const { message } = yield publicApi.chat.getChatSession();
|
|
28
|
-
setSessionId(message);
|
|
29
|
-
});
|
|
30
|
-
fetchChatSessionId();
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
console.log('Error', error);
|
|
34
|
-
}
|
|
35
|
-
}, []);
|
|
36
|
-
const getChatFormDetails = () => [
|
|
37
|
-
{
|
|
38
|
-
label: 'SSO Name',
|
|
39
|
-
value: ssoName,
|
|
40
|
-
transcriptFields: ['SSO_Username__c'],
|
|
41
|
-
displayToAgent: true,
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
label: 'SessionId',
|
|
45
|
-
value: sessionId,
|
|
46
|
-
transcriptFields: ['SessionId__c'],
|
|
47
|
-
displayToAgent: true,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
label: 'name',
|
|
51
|
-
value: name,
|
|
52
|
-
displayToAgent: true,
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
label: 'account',
|
|
56
|
-
value: accountNumber,
|
|
57
|
-
displayToAgent: true,
|
|
58
|
-
},
|
|
59
|
-
];
|
|
60
|
-
return getChatFormDetails;
|
|
61
|
-
};
|