PromucFlow_constructor/app/client/src/utils/hooks/useOnUpgrade.ts

33 lines
887 B
TypeScript
Raw Normal View History

import { useSelector } from "react-redux";
import { getInstanceId } from "@appsmith/selectors/tenantSelectors";
import { PRICING_PAGE_URL } from "constants/ThirdPartyConstants";
import AnalyticsUtil, { EventName } from "utils/AnalyticsUtil";
import { getAppsmithConfigs } from "@appsmith/configs";
type Props = {
intercomMessage?: string;
logEventName?: EventName;
logEventData?: any;
};
const useOnUpgrade = (props: Props) => {
const { logEventData, logEventName } = props;
const instanceId = useSelector(getInstanceId);
const appsmithConfigs = getAppsmithConfigs();
const onUpgrade = () => {
AnalyticsUtil.logEvent(
logEventName || "ADMIN_SETTINGS_UPGRADE",
logEventData,
);
window.open(
PRICING_PAGE_URL(appsmithConfigs.pricingUrl, "CE", instanceId),
"_blank",
);
};
return { onUpgrade };
};
export default useOnUpgrade;