Enable intercom for self hosted instances (#5871)
This commit is contained in:
parent
5232e1faee
commit
7f95e4d268
1
.github/workflows/client-test.yml
vendored
1
.github/workflows/client-test.yml
vendored
|
|
@ -114,6 +114,7 @@ jobs:
|
|||
REACT_APP_VERSION_ID=${{ steps.vars.outputs.version }} \
|
||||
REACT_APP_VERSION_RELEASE_DATE=$(date -u '+%Y-%m-%dT%H:%M:%SZ') \
|
||||
REACT_APP_GOOGLE_ANALYTICS_ID=${{ secrets.GOOGLE_TAG_MANAGER_ID }} \
|
||||
REACT_APP_INTERCOM_APP_ID=${{ secrets.APPSMITH_INTERCOM_ID }} \
|
||||
REACT_APP_SHOW_ONBOARDING_FORM=true \
|
||||
yarn build
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@
|
|||
// '' (empty strings), 'false' are falsy
|
||||
// could return either boolean or string based on value
|
||||
const parseConfig = (config) => {
|
||||
if (config.indexOf("__") === 0 || config.indexOf("$") === 0)
|
||||
if (config.indexOf("__") === 0 || config.indexOf("$") === 0 || config.indexOf("%") === 0)
|
||||
return "";
|
||||
|
||||
const result = config.trim();
|
||||
|
|
@ -157,13 +157,13 @@
|
|||
const LOG_LEVELS = ["debug", "error"];
|
||||
const CONFIG_LOG_LEVEL_INDEX = LOG_LEVELS.indexOf(parseConfig("__APPSMITH_CLIENT_LOG_LEVEL__"));
|
||||
|
||||
const APP_ID = parseConfig("__APPSMITH_INTERCOM_APP_ID__");
|
||||
const INTERCOM_APP_ID = parseConfig("%REACT_APP_INTERCOM_APP_ID%") || parseConfig("__APPSMITH_INTERCOM_APP_ID__");
|
||||
const CLOUD_HOSTING = parseConfig("__APPSMITH_CLOUD_HOSTING__");
|
||||
const DISABLE_TELEMETRY = parseConfig("__APPSMITH_DISABLE_TELEMETRY__");
|
||||
|
||||
// Initialize the Intercom library
|
||||
if (APP_ID.length && APP_ID[0] !== "%" && CLOUD_HOSTING) {
|
||||
(function () { var w = window; var ic = w.Intercom; if (typeof ic === "function") { ic('reattach_activator'); ic('update', w.intercomSettings); } else { var d = document; var i = function () { i.c(arguments); }; i.q = []; i.c = function (args) { i.q.push(args); }; w.Intercom = i; var l = function () { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.intercom.io/widget/' + APP_ID; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); }; if (document.readyState === 'complete') { l(); } else if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })();
|
||||
if (INTERCOM_APP_ID.length) {
|
||||
(function () { var w = window; var ic = w.Intercom; if (typeof ic === "function") { ic('reattach_activator'); ic('update', w.intercomSettings); } else { var d = document; var i = function () { i.c(arguments); }; i.q = []; i.c = function (args) { i.q.push(args); }; w.Intercom = i; var l = function () { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.intercom.io/widget/' + INTERCOM_APP_ID; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); }; if (document.readyState === 'complete') { l(); } else if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })();
|
||||
}
|
||||
|
||||
window.SENTRY_CONFIG = parseConfig("__APPSMITH_SENTRY_DSN__");
|
||||
|
|
@ -201,7 +201,7 @@
|
|||
id: parseConfig("__APPSMITH_VERSION_ID__"),
|
||||
releaseDate: parseConfig("__APPSMITH_VERSION_RELEASE_DATE__")
|
||||
},
|
||||
intercomAppID: APP_ID,
|
||||
intercomAppID: INTERCOM_APP_ID,
|
||||
mailEnabled: parseConfig("__APPSMITH_MAIL_ENABLED__"),
|
||||
disableTelemetry: DISABLE_TELEMETRY === "" || DISABLE_TELEMETRY,
|
||||
cloudServicesBaseUrl: parseConfig("__APPSMITH_CLOUD_SERVICES_BASE_URL__") || "https://cs.appsmith.com",
|
||||
|
|
|
|||
|
|
@ -25,12 +25,7 @@ import moment from "moment";
|
|||
import { getCurrentUser } from "selectors/usersSelectors";
|
||||
import { User } from "constants/userConstants";
|
||||
|
||||
const {
|
||||
algolia,
|
||||
appVersion,
|
||||
cloudHosting,
|
||||
intercomAppID,
|
||||
} = getAppsmithConfigs();
|
||||
const { algolia, appVersion, intercomAppID } = getAppsmithConfigs();
|
||||
const searchClient = algoliasearch(algolia.apiId, algolia.apiKey);
|
||||
|
||||
const OenLinkIcon = HelpIcons.OPEN_LINK;
|
||||
|
|
@ -116,7 +111,7 @@ function DefaultHelpMenuItem(props: {
|
|||
onClick={() => {
|
||||
if (props.item.link) window.open(props.item.link, "_blank");
|
||||
if (props.item.id === "intercom-trigger") {
|
||||
if (cloudHosting && intercomAppID && window.Intercom) {
|
||||
if (intercomAppID && window.Intercom) {
|
||||
window.Intercom("show");
|
||||
}
|
||||
}
|
||||
|
|
@ -331,11 +326,6 @@ const HELP_MENU_ITEMS: HelpItem[] = [
|
|||
label: "Report a bug",
|
||||
link: "https://github.com/appsmithorg/appsmith/issues/new/choose",
|
||||
},
|
||||
{
|
||||
icon: <StyledChatIcon color="#fff" height={14} width={11.2} />,
|
||||
label: "Chat with us",
|
||||
link: "https://github.com/appsmithorg/appsmith/discussions",
|
||||
},
|
||||
{
|
||||
icon: <StyledDiscordIcon height={16} width={16} />,
|
||||
label: "Join our Discord",
|
||||
|
|
@ -343,12 +333,12 @@ const HELP_MENU_ITEMS: HelpItem[] = [
|
|||
},
|
||||
];
|
||||
|
||||
if (cloudHosting) {
|
||||
HELP_MENU_ITEMS[2] = {
|
||||
if (intercomAppID) {
|
||||
HELP_MENU_ITEMS.push({
|
||||
icon: <StyledChatIcon color="#fff" height={14} width={11.2} />,
|
||||
label: "Chat with us",
|
||||
id: "intercom-trigger",
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
class DocumentationSearch extends React.Component<Props, State> {
|
||||
|
|
@ -360,7 +350,7 @@ class DocumentationSearch extends React.Component<Props, State> {
|
|||
}
|
||||
componentDidMount() {
|
||||
const { user } = this.props;
|
||||
if (cloudHosting && intercomAppID && window.Intercom) {
|
||||
if (intercomAppID && window.Intercom) {
|
||||
window.Intercom("boot", {
|
||||
app_id: intercomAppID,
|
||||
user_id: user?.username,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user