Skip to content

Commit d0ec74f

Browse files
authored
Merge pull request Dokploy#5538 from Dokploy/fix/hubspot-chat-widget
fix(cloud): load HubSpot chat widget for startup plan users
2 parents a0e0574 + 382fdfc commit d0ec74f

3 files changed

Lines changed: 8 additions & 21 deletions

File tree

‎apps/dokploy/components/layouts/dashboard-layout.tsx‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useEffect } from "react";
44
import { api } from "@/utils/api";
55
import { useWhitelabeling } from "@/utils/hooks/use-whitelabeling";
66
import { ImpersonationBar } from "../dashboard/impersonation/impersonation-bar";
7-
import { HubSpotWidget } from "../shared/HubSpotWidget";
7+
import { useHubSpotChat } from "../shared/analytics";
88
import Page from "./side";
99

1010
interface Props {
@@ -26,6 +26,7 @@ export const DashboardLayout = ({ children, metaName }: Props) => {
2626
});
2727

2828
const isChatEnabled = isCloud === true && currentPlan === "startup";
29+
useHubSpotChat(isChatEnabled);
2930

3031
const { data: onboardingStatus } = api.project.onboardingStatus.useQuery();
3132
const shouldRedirectToOnboarding =
@@ -52,12 +53,6 @@ export const DashboardLayout = ({ children, metaName }: Props) => {
5253
</Head>
5354
)}
5455
<Page>{children}</Page>
55-
{isChatEnabled && (
56-
<>
57-
<HubSpotWidget />
58-
</>
59-
)}
60-
6156
{haveRootAccess === true && <ImpersonationBar />}
6257
</>
6358
);

‎apps/dokploy/components/shared/HubSpotWidget.tsx‎

Lines changed: 0 additions & 14 deletions
This file was deleted.

‎apps/dokploy/components/shared/analytics.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,11 @@ export const useHubSpotChat = (enabled: boolean) => {
9292
loadWidget,
9393
];
9494
}
95+
return () => {
96+
window.hsConversationsOnReady = window.hsConversationsOnReady?.filter(
97+
(callback) => callback !== loadWidget,
98+
);
99+
window.HubSpotConversations?.widget.remove();
100+
};
95101
}, [enabled]);
96102
};

0 commit comments

Comments
 (0)