Skip to content

Commit c84d9fc

Browse files
committed
simplify(landing): drop unnecessary Suspense from HubSpot pageview tracker
usePathname() alone doesn't require a Suspense boundary to preserve static rendering — only useSearchParams() does. The tracker only needs the path, not the query string, so drop useSearchParams and the Suspense wrapper entirely. Simpler, and no risk to the landing site's static rendering/LCP.
1 parent 6ce1b5d commit c84d9fc

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

apps/sim/app/(landing)/hubspot-page-view-tracker.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useEffect, useRef } from 'react'
4-
import { usePathname, useSearchParams } from 'next/navigation'
4+
import { usePathname } from 'next/navigation'
55

66
declare global {
77
interface Window {
@@ -18,7 +18,6 @@ declare global {
1818
*/
1919
export function HubspotPageViewTracker() {
2020
const pathname = usePathname()
21-
const searchParams = useSearchParams()
2221
const isInitialRender = useRef(true)
2322

2423
useEffect(() => {
@@ -27,13 +26,10 @@ export function HubspotPageViewTracker() {
2726
return
2827
}
2928

30-
const query = searchParams.toString()
31-
const path = query ? `${pathname}?${query}` : pathname
32-
3329
window._hsq = window._hsq || []
34-
window._hsq.push(['setPath', path])
30+
window._hsq.push(['setPath', pathname])
3531
window._hsq.push(['trackPageView'])
36-
}, [pathname, searchParams])
32+
}, [pathname])
3733

3834
return null
3935
}

apps/sim/app/(landing)/layout.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { ReactNode } from 'react'
2-
import { Suspense } from 'react'
32
import type { Metadata } from 'next'
43
import Script from 'next/script'
54
import { isHosted } from '@/lib/core/config/env-flags'
@@ -37,9 +36,7 @@ export default function LandingLayout({ children }: { children: ReactNode }) {
3736
{isHosted && (
3837
<>
3938
<Script id='hs-script-loader' src={HUBSPOT_SCRIPT_SRC} strategy='afterInteractive' />
40-
<Suspense fallback={null}>
41-
<HubspotPageViewTracker />
42-
</Suspense>
39+
<HubspotPageViewTracker />
4340
</>
4441
)}
4542
</LandingShell>

0 commit comments

Comments
 (0)