mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-03 00:53:53 +00:00
Bulk rename across 989 files: - Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc. - Repository URLs: posthog/posthog-js → hanzoai/insights-js - Brand names: PostHog → Insights - File renames: 259 reference JSON files, source files, workflow files - Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
32 lines
987 B
TypeScript
32 lines
987 B
TypeScript
import { useEffect, useState } from 'react'
|
|
import insights, { CaptureResult } from '@hanzo/insights'
|
|
import { InsightsProvider } from '@insights/react'
|
|
import { EventDisplay } from './EventDisplay'
|
|
|
|
export function PHProvider({ children }: { children: React.ReactNode }) {
|
|
const [hydrated, setHydrated] = useState(false)
|
|
const [events, setEvents] = useState<CaptureResult[]>([])
|
|
|
|
useEffect(() => {
|
|
insights.init('phc_test_key_for_playground', {
|
|
api_host: '/ph-relay-xyz123',
|
|
ui_host: 'https://us.insights.com',
|
|
defaults: '2025-11-30',
|
|
before_send: (cr) => {
|
|
setEvents((prev) => [cr!, ...prev].slice(0, 10))
|
|
return cr
|
|
},
|
|
})
|
|
|
|
setHydrated(true)
|
|
}, [])
|
|
|
|
if (!hydrated) return <>{children}</>
|
|
return (
|
|
<InsightsProvider client={insights}>
|
|
<EventDisplay events={events} />
|
|
{children}
|
|
</InsightsProvider>
|
|
)
|
|
}
|