From 271fe3c4b91eabc2c20e49064662836eadd8baf6 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Fri, 24 Apr 2026 22:14:49 -0400 Subject: [PATCH] chore: remove HubSpot chat integration --- src/hooks/useHubSpotChat.ts | 74 ------------------------------------- src/hooks/useScript.ts | 39 ------------------- src/routes/__root.tsx | 4 -- src/styles/app.css | 7 ---- 4 files changed, 124 deletions(-) delete mode 100644 src/hooks/useHubSpotChat.ts delete mode 100644 src/hooks/useScript.ts diff --git a/src/hooks/useHubSpotChat.ts b/src/hooks/useHubSpotChat.ts deleted file mode 100644 index e26c5d172..000000000 --- a/src/hooks/useHubSpotChat.ts +++ /dev/null @@ -1,74 +0,0 @@ -import * as React from 'react' -import { useLocation } from '@tanstack/react-router' -import { useScript } from './useScript' - -/** - * Configuration for HubSpot chat widget - */ -export interface HubSpotChatConfig { - /** - * Array of path patterns where HubSpot should load. - * Can be exact paths or path prefixes (e.g., '/paid-support' or '/workshops') - * @default ['/paid-support', '/workshops'] - */ - enabledPaths?: string[] - /** - * HubSpot script source URL - * @default '//js-na1.hs-scripts.com/45982155.js' - */ - scriptSrc?: string - /** - * HubSpot script ID - * @default 'hs-script-loader' - */ - scriptId?: string -} - -const defaultConfig = { - enabledPaths: ['/paid-support', '/workshops'], - scriptSrc: '//js-na1.hs-scripts.com/45982155.js', - scriptId: 'hs-script-loader', -} - -/** - * Hook to conditionally load HubSpot chat widget based on current route - * @param config Optional configuration object to override defaults - */ -export function useHubSpotChat(config?: HubSpotChatConfig) { - const location = useLocation() - const { enabledPaths, scriptSrc, scriptId } = { - ...defaultConfig, - ...config, - } - - const shouldLoad = React.useMemo(() => { - return enabledPaths.some((path) => { - // Exact match - if (location.pathname === path) { - return true - } - // Prefix match (e.g., '/paid-support' matches '/paid-support/anything') - if (location.pathname.startsWith(path + '/')) { - return true - } - return false - }) - }, [location.pathname, enabledPaths]) - - // Only load the script if we should load the chat widget - useScript( - shouldLoad - ? { - id: scriptId, - async: true, - defer: true, - src: scriptSrc, - } - : { - id: scriptId, - async: true, - defer: true, - src: '', // Empty src prevents loading - }, - ) -} diff --git a/src/hooks/useScript.ts b/src/hooks/useScript.ts deleted file mode 100644 index dc6da771d..000000000 --- a/src/hooks/useScript.ts +++ /dev/null @@ -1,39 +0,0 @@ -import * as React from 'react' - -export function useScript( - attrs: React.HTMLProps, - opts?: { - delay?: number - }, -) { - const attrsStringified = JSON.stringify(attrs) - - React.useEffect(() => { - const addScript = () => { - const script = document.createElement('script') - Object.assign(script, attrs) - document.body.appendChild(script) - - return () => { - document.body.removeChild(script) - } - } - - if (opts?.delay) { - let remove: ReturnType | undefined - - const timeout = setTimeout(() => { - remove = addScript() - }, opts.delay) - - return () => { - clearTimeout(timeout) - remove?.() - } - } - - return addScript() - - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [attrsStringified]) -} diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index 547813608..33cf76f80 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -36,7 +36,6 @@ import { Spinner } from '~/components/Spinner' import { ThemeProvider, useHtmlClass } from '~/components/ThemeProvider' import { Navbar } from '~/components/Navbar' import { THEME_COLORS } from '~/utils/utils' -import { useHubSpotChat } from '~/hooks/useHubSpotChat' import { trackPageView } from '~/utils/analytics' import { twMerge } from 'tailwind-merge' @@ -148,9 +147,6 @@ function ShellComponent({ children }: { children: React.ReactNode }) { select: (matches) => matches.find((d) => d.staticData?.baseParent), }) - // HubSpot chat loads on configured pages (see useHubSpotChat hook) - useHubSpotChat() - const isNavigating = useRouterState({ select: (s) => s.isLoading || s.isTransitioning, }) diff --git a/src/styles/app.css b/src/styles/app.css index 778cb8796..8d15655d5 100644 --- a/src/styles/app.css +++ b/src/styles/app.css @@ -706,13 +706,6 @@ html.dark .shiki.aurora-x span[style*='color:#546E7A'] { @apply border-t-0 border-gray-500/10 shadow-md text-gray-800; } -/* Hubspot */ - -#hubspot-messages-iframe-container { - @apply translate-x-[10px] translate-y-[10px]; - @apply dark:scheme-dark; -} - /* Markdown Alerts */ .not-prose .markdown-alert {