diff --git a/apps/dokploy/components/layouts/dashboard-layout.tsx b/apps/dokploy/components/layouts/dashboard-layout.tsx
index 816e7bc6e..6762f127a 100644
--- a/apps/dokploy/components/layouts/dashboard-layout.tsx
+++ b/apps/dokploy/components/layouts/dashboard-layout.tsx
@@ -4,7 +4,7 @@ import { useEffect } from "react";
import { api } from "@/utils/api";
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
import { ImpersonationBar } from "../dashboard/impersonation/impersonation-bar";
-import { HubSpotWidget } from "../shared/HubSpotWidget";
+import { useHubSpotChat } from "../shared/analytics";
import Page from "./side";
interface Props {
@@ -26,6 +26,7 @@ export const DashboardLayout = ({ children, metaName }: Props) => {
});
const isChatEnabled = isCloud === true && currentPlan === "startup";
+ useHubSpotChat(isChatEnabled);
const { data: onboardingStatus } = api.project.onboardingStatus.useQuery();
const shouldRedirectToOnboarding =
@@ -52,12 +53,6 @@ export const DashboardLayout = ({ children, metaName }: Props) => {
)}
{children}
- {isChatEnabled && (
- <>
-
- >
- )}
-
{haveRootAccess === true && }
>
);
diff --git a/apps/dokploy/components/shared/HubSpotWidget.tsx b/apps/dokploy/components/shared/HubSpotWidget.tsx
deleted file mode 100644
index ff3013459..000000000
--- a/apps/dokploy/components/shared/HubSpotWidget.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import Script from "next/script";
-
-export const HubSpotWidget = () => {
- return (
-
- );
-};
diff --git a/apps/dokploy/components/shared/analytics.tsx b/apps/dokploy/components/shared/analytics.tsx
index ab1acb283..ac00db958 100644
--- a/apps/dokploy/components/shared/analytics.tsx
+++ b/apps/dokploy/components/shared/analytics.tsx
@@ -92,5 +92,11 @@ export const useHubSpotChat = (enabled: boolean) => {
loadWidget,
];
}
+ return () => {
+ window.hsConversationsOnReady = window.hsConversationsOnReady?.filter(
+ (callback) => callback !== loadWidget,
+ );
+ window.HubSpotConversations?.widget.remove();
+ };
}, [enabled]);
};