Files
zooqueen a93e642791 chore: complete posthog->insights rebrand (zero @posthog/* identity)
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.
2026-06-19 18:44:26 -07:00

85 lines
3.2 KiB
TypeScript

'use client'
import { useState } from 'react'
import Link from 'next/link'
import { usePostHog } from '@hanzo/insights-next'
export default function AuthPage() {
const posthog = usePostHog()
const [email, setEmail] = useState('[email protected]')
const [loggedInAs, setLoggedInAs] = useState<string | null>(() => {
if (typeof window !== 'undefined') {
return localStorage.getItem('posthog-example-user')
}
return null
})
function handleLogin(e: React.FormEvent) {
e.preventDefault()
if (!email) return
posthog.identify(email, { email })
localStorage.setItem('posthog-example-user', email)
setLoggedInAs(email)
setEmail('')
window.dispatchEvent(new Event('auth-change'))
}
function handleLogout() {
posthog.reset()
localStorage.removeItem('posthog-example-user')
setLoggedInAs(null)
window.dispatchEvent(new Event('auth-change'))
}
return (
<div>
<h1 className="text-2xl font-bold mb-2">Authentication</h1>
<p className="text-gray-600 mb-6">
This demo uses <code className="bg-gray-100 px-1 rounded">posthog.identify()</code> and{' '}
<code className="bg-gray-100 px-1 rounded">posthog.reset()</code> to manage user identity. After logging
in, visit the{' '}
<Link href="/server-flags" className="text-blue-600 underline">
Server Flags
</Link>{' '}
page to see the same identity reflected server-side.
</p>
{loggedInAs ? (
<div className="bg-white rounded-lg border border-gray-200 p-6">
<p className="mb-4">
Logged in as <strong>{loggedInAs}</strong>
</p>
<p className="text-sm text-gray-500 mb-4">
Distinct ID: <code className="bg-gray-100 px-1 rounded">{posthog.get_distinct_id()}</code>
</p>
<button
onClick={handleLogout}
className="px-4 py-2 bg-gray-900 text-white rounded hover:bg-gray-700"
>
Log out
</button>
</div>
) : (
<form onSubmit={handleLogin} className="bg-white rounded-lg border border-gray-200 p-6">
<label htmlFor="email" className="block mb-2 text-sm font-medium">
Email
</label>
<input
id="email"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
placeholder="[email protected]"
className="w-full px-3 py-2 border border-gray-300 rounded mb-4"
required
/>
<button type="submit" className="px-4 py-2 bg-gray-900 text-white rounded hover:bg-gray-700">
Log in
</button>
</form>
)}
</div>
)
}