mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-10-30 18:34:19 +00:00
Extends the sweep beyond packages/ to the whole repo (178 files): workflows,
.eslintrc, playground, examples, tooling, root docs. Zero upstream-brand refs and
zero such filenames outside the exemptions.
REVERTS A LICENSING ERROR (from earlier rebrand e43ab1af, not this sweep):
- LICENSE had its copyright holder rewritten to 'Insights'. Restored to the real
holder: 'Copyright 2020 Posthog / Hiberly, Inc.' (+ Mixpanel, Inc.).
- NOTICE credited a non-existent upstream (github.com/getinsights/insights-js).
Restored to the real one: github.com/PostHog/posthog-js.
Apache-2.0 4(c) requires retaining upstream attribution; rewriting a third
party's copyright line falsifies ownership. Both files are now excluded from the
guard and documented as exempt in LLM.md.
Also:
- Deleted junk: AGENTS.md~upstream_main (merge leftover), the now-obsolete
rebrand script; renamed upload-*-s3.ts tooling (still used by cli.ts).
- Removed 42 stale playground/example pnpm-lock.yaml files: they pinned upstream
packages the package.json no longer references. Regenerated on install —
sed-ing a lockfile would corrupt its integrity hashes.
- Guard renamed no-posthog.yml -> brand-guard.yml and now assembles the pattern
at runtime, so no filename or file content carries the string (the previous
guard was swept by its own rule, inverting it to forbid 'insights').
68 lines
2.5 KiB
TypeScript
68 lines
2.5 KiB
TypeScript
'use client'
|
|
|
|
import { useInsights, useFeatureFlag, useActiveFeatureFlags } from '@hanzo/insights-next'
|
|
|
|
export default function ClientHooksContent() {
|
|
const insights = useInsights()
|
|
const exampleFlag = useFeatureFlag('example-flag')
|
|
const activeFlags = useActiveFeatureFlags()
|
|
|
|
return (
|
|
<div>
|
|
<h1 className="text-2xl font-bold mb-2">Client-Side Hooks</h1>
|
|
<p className="text-gray-600 mb-6">
|
|
These hooks from <code className="bg-gray-100 px-1 rounded">@hanzo/insights-next</code> provide real-time
|
|
feature flag values on the client. Create a flag called{' '}
|
|
<code className="bg-gray-100 px-1 rounded">example-flag</code> in your Insights project to see values
|
|
below.
|
|
</p>
|
|
|
|
<div className="space-y-4">
|
|
<HookCard title="useInsights()" description="Returns the Insights client instance.">
|
|
<p className="text-sm">
|
|
Distinct ID:{' '}
|
|
<code className="bg-gray-100 px-1 rounded">{insights?.get_distinct_id() ?? 'loading...'}</code>
|
|
</p>
|
|
<p className="text-sm">
|
|
Session ID:{' '}
|
|
<code className="bg-gray-100 px-1 rounded">{insights?.get_session_id() ?? 'loading...'}</code>
|
|
</p>
|
|
</HookCard>
|
|
|
|
<HookCard title="useFeatureFlag('example-flag')">
|
|
<p className="text-sm">
|
|
Value: <code className="bg-gray-100 px-1 rounded">{JSON.stringify(exampleFlag, null, 2)}</code>
|
|
</p>
|
|
</HookCard>
|
|
|
|
<HookCard title="useActiveFeatureFlags()">
|
|
<p className="text-sm">
|
|
Active flags:{' '}
|
|
<code className="bg-gray-100 px-1 rounded">
|
|
{activeFlags && activeFlags.length > 0 ? activeFlags.join(', ') : 'none'}
|
|
</code>
|
|
</p>
|
|
</HookCard>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
function HookCard({
|
|
title,
|
|
description,
|
|
children,
|
|
}: {
|
|
title: string
|
|
description?: string
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<div className="bg-white rounded-lg border border-gray-200 p-6">
|
|
<h2 className="font-semibold font-mono text-sm mb-2">{title}</h2>
|
|
{description && <p className="text-sm text-gray-500 mb-2">{description}</p>}
|
|
{children}
|
|
</div>
|
|
)
|
|
}
|