diff --git a/app/client/src/Heartbeat.tsx b/app/client/src/Heartbeat.tsx new file mode 100644 index 00000000000..1dfccffb3e0 --- /dev/null +++ b/app/client/src/Heartbeat.tsx @@ -0,0 +1,34 @@ +import { useEffect } from "react"; +import log from "loglevel"; +const Heartbeat = () => { + const heartbeatUrl = + "https://uptime.betterstack.com/api/v1/heartbeat/71SZmsvAVW73QvEPQzLvxwEL"; + const interval = 30 * 1000; // 30 secs in milliseconds + + const sendHeartbeat = async () => { + try { + const response = await fetch(heartbeatUrl); + + if (response.ok) { + log.info("Heartbeat sent successfully"); + } else { + log.error("Failed to send heartbeat", response.status); + } + } catch (error) { + log.error("Error sending heartbeat:", error); + } + }; + + useEffect(() => { + const heartbeatInterval = setInterval(() => { + sendHeartbeat(); + }, interval); + + // Cleanup the interval when the component is unmounted + return () => clearInterval(heartbeatInterval); + }, []); // Empty dependency array ensures this runs once on mount + + return null; // This component doesn't render anything +}; + +export default Heartbeat; diff --git a/app/client/src/index.tsx b/app/client/src/index.tsx index c5c6db423d3..115c8fba1b7 100755 --- a/app/client/src/index.tsx +++ b/app/client/src/index.tsx @@ -30,7 +30,7 @@ import { PageViewTiming } from "@newrelic/browser-agent/features/page_view_timin import { PageViewEvent } from "@newrelic/browser-agent/features/page_view_event"; import { Agent } from "@newrelic/browser-agent/loaders/agent"; import { getCommonTelemetryAttributes } from "UITelemetry/generateTraces"; - +import Heartbeat from "Heartbeat"; const { newRelic } = getAppsmithConfigs(); const { enableNewRelic } = newRelic; @@ -73,8 +73,12 @@ if (enableNewRelic) { newRelicBrowserAgent.setCustomAttribute("appMode", appMode); } +const { cloudHosting } = getAppsmithConfigs(); + const shouldAutoFreeze = process.env.NODE_ENV === "development"; +const isProduction = process.env.NODE_ENV === "production"; + setAutoFreeze(shouldAutoFreeze); runSagaMiddleware(); @@ -96,6 +100,7 @@ function App() { + {cloudHosting && isProduction && }