Files
supabase/apps/www/lib/telemetry.ts
Charis 6c560e1adb prevent www nav bar bailing out ssr (#45422)
www pages that use DefaultLayout are bailing out of SSR because of
useSearchParams. Removing the useSearchParams opts more pages (including
the pricing page) into SSR.

_However_, it breaks the build because once blog pages are opted into
SSR, they fail due to next-mdx-remote/codehike incompatibilities. So we
also need to opt blog pages back _out_ of SSR using next/dynamic. This
reproduces previous behaviour for the blog.

Also had to remove suspense wrapper around everything because that was
causing the content div to be streamed in a hidden later chunk

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added support for the Contribute section with improved state
management integration.

* **Performance Improvements**
  * Optimized blog post rendering with client-side enhancements.
  * Improved navigation and layout loading strategies.

* **Refactor**
  * Simplified provider architecture for better maintainability.
  * Restructured internal component organization.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-04-30 23:19:56 +03:00

23 lines
610 B
TypeScript

'use client'
import { sendTelemetryEvent } from 'common'
import type { TelemetryEvent } from 'common/telemetry-constants'
import { API_URL } from 'lib/constants'
import { usePathname } from 'next/navigation'
import { useCallback } from 'react'
export function useSendTelemetryEvent() {
const pathname = usePathname()
return useCallback(
(event: TelemetryEvent) => {
const url = new URL(API_URL ?? 'http://localhost:3000')
url.pathname = pathname ?? ''
url.search = window.location.search
return sendTelemetryEvent(API_URL, event, url.toString())
},
[pathname]
)
}