2022-07-28 08:38:37 +00:00
|
|
|
import { getAppsmithConfigs } from "@appsmith/configs";
|
2022-09-02 17:15:08 +00:00
|
|
|
import {
|
|
|
|
|
createMessage,
|
|
|
|
|
UPGRADE_TO_EE_GENERIC,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2022-07-28 08:38:37 +00:00
|
|
|
import AnalyticsUtil, { EventName } from "utils/AnalyticsUtil";
|
|
|
|
|
|
|
|
|
|
const { intercomAppID } = getAppsmithConfigs();
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
intercomMessage?: string;
|
|
|
|
|
logEventName?: EventName;
|
|
|
|
|
logEventData?: any;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const useOnUpgrade = (props: Props) => {
|
|
|
|
|
const { intercomMessage, logEventData, logEventName } = props;
|
|
|
|
|
|
|
|
|
|
const triggerIntercom = (message: string) => {
|
|
|
|
|
if (intercomAppID && window.Intercom) {
|
|
|
|
|
window.Intercom("showNewMessage", message);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onUpgrade = () => {
|
|
|
|
|
AnalyticsUtil.logEvent(
|
|
|
|
|
logEventName || "ADMIN_SETTINGS_UPGRADE",
|
|
|
|
|
logEventData,
|
|
|
|
|
);
|
|
|
|
|
triggerIntercom(intercomMessage || createMessage(UPGRADE_TO_EE_GENERIC));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return { onUpgrade };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default useOnUpgrade;
|