mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-02 14:31:14 +00:00
Decomplect the half-finished fork so the dependency graph has ONE source with no posthog package identity, living under github.com/hanzoinsights. LAYER 1 (package identity): rename straggler package.json names — @posthog/next->@hanzo/insights-next (Next.js SDK; distinct from the existing @hanzo/insights-nextjs config helper), @posthog/mcp->@hanzo/insights-mcp, @posthog/plugin-utils->@hanzo/insights-plugin-utils, @posthog/react-slim->@hanzo/react-slim, @posthog-tooling/release-> @hanzo/insights-tooling-release, and the @posthog/rrweb* family->@hanzo/rrweb* (matching the already-published @hanzo/rrweb*@0.0.47 + minimumReleaseAgeExclude). Repoint every repository.url/homepage/bugs to github.com/hanzoinsights/insights-js and rebrand the PostHog author/description identity to Hanzo AI. LAYER 2 (cross-package imports): rewrite every internal @posthog/* import to its @hanzo/insights*|@hanzo/rrweb* equivalent and the bare module specifiers posthog-js->@hanzo/insights, posthog-node->@hanzo/insights-node, mirrored in package.json deps + the pnpm-lock importer keys. Result: 0 @posthog/* specifiers in packages/tooling/examples/playground source. LAYER 4 (wire protocol) PRESERVED: window.posthog global, ph_* keys, $-prefixed event names, distinct_id, /decide, /e/, /flags, and the __PosthogExtensions__ hook are left unchanged — the Insights server expects them. Also repair pre-existing fork merge damage that blocked compilation (unrelated to naming; identical to origin/main): restore the @hanzo/insights-core ./process subpath (spawn-local/utils, re-matching the published artifact), the lost constructor/var declarations in core + node clients, the mangled external-scripts-loader, the missing TreeShakeable/isPlainError imports, the DeviceId enum member, and stale ../posthog-core-stateless module paths. 26/34 turbo build tasks now pass; remaining failures (browser/react-native and their dependents) are pre-existing fork damage, not rebrand-caused.
71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
'use client'
|
|
|
|
import { usePostHog } from '@hanzo/insights-next'
|
|
import { useEffect, useState } from 'react'
|
|
|
|
type ConsentState = 'pending' | 'granted' | 'denied'
|
|
|
|
export function ConsentBanner() {
|
|
const posthog = usePostHog()
|
|
const [consent, setConsent] = useState<ConsentState | null>(null)
|
|
|
|
useEffect(() => {
|
|
setConsent(posthog.get_explicit_consent_status())
|
|
}, [posthog])
|
|
|
|
const accept = () => {
|
|
posthog.opt_in_capturing()
|
|
setConsent('granted')
|
|
}
|
|
|
|
const decline = () => {
|
|
posthog.opt_out_capturing()
|
|
setConsent('denied')
|
|
}
|
|
|
|
const reset = () => {
|
|
posthog.clear_opt_in_out_capturing()
|
|
setConsent('pending')
|
|
}
|
|
|
|
if (consent === 'pending') {
|
|
return (
|
|
<div className="fixed bottom-0 inset-x-0 bg-white border-t border-gray-200 shadow-lg p-4 z-50">
|
|
<div className="max-w-4xl mx-auto flex items-center justify-between gap-4">
|
|
<p className="text-sm text-gray-700">
|
|
This site uses cookies for analytics. Do you consent to tracking?
|
|
</p>
|
|
<div className="flex gap-2 shrink-0">
|
|
<button
|
|
onClick={decline}
|
|
className="px-4 py-2 text-sm border border-gray-300 rounded hover:bg-gray-50"
|
|
>
|
|
Decline
|
|
</button>
|
|
<button
|
|
onClick={accept}
|
|
className="px-4 py-2 text-sm bg-blue-600 text-white rounded hover:bg-blue-700"
|
|
>
|
|
Accept
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
consent && (
|
|
<div className="fixed bottom-4 right-4 z-50">
|
|
<button
|
|
onClick={reset}
|
|
className="px-3 py-1.5 text-xs bg-gray-100 border border-gray-300 rounded hover:bg-gray-200"
|
|
title="Reset consent for testing"
|
|
>
|
|
Reset consent ({consent})
|
|
</button>
|
|
</div>
|
|
)
|
|
)
|
|
}
|