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').
@hanzo/types
Type definitions for the Insights JavaScript SDK.
When to Use This Package
✅ You Need This Package If:
You're loading Insights via a <script> tag and want TypeScript types for window.insights.
<!-- You load Insights like this -->
<script>
!function(t,e){...}(document,window.insights||[]);
insights.init('your-api-key', { api_host: 'https://us.i.insights.hanzo.ai' })
</script>
❌ You Don't Need This Package If:
You're installing any Insights library via npm/yarn/pnpm. The types are already included:
@hanzo/insights- Browser SDK (includes all types)@hanzo/insights-node- Node.js SDK@hanzo/insights-react-native- React Native SDK@hanzo/react- React hooks and components
// Types are already available when you install @hanzo/insights
import insights from '@hanzo/insights'
insights.init('your-api-key')
insights.capture('my_event') // ✅ Fully typed
Installation
npm install @hanzo/types
# or
yarn add @hanzo/types
# or
pnpm add @hanzo/types
Usage
Typing window.insights (Script Tag Usage)
Create a type declaration file to type window.insights:
// insights.d.ts
import type { Insights } from '@hanzo/types'
declare global {
interface Window {
insights?: Insights
}
}
export {}
Now you can use window.insights with full type safety:
// Your code
window.insights?.capture('button_clicked', { button_id: 'signup' })
window.insights?.identify('user-123', { email: '[email protected]' })
const flagValue = window.insights?.getFeatureFlag('my-flag')
if (flagValue === 'variant-a') {
// ...
}
Typing Configuration Objects
import type { InsightsConfig, Properties } from '@hanzo/types'
// Type your configuration
const config: Partial<InsightsConfig> = {
api_host: 'https://us.i.insights.hanzo.ai',
autocapture: true,
capture_pageview: 'history_change',
}
// Type event properties
const eventProps: Properties = {
button_id: 'signup',
page: '/pricing',
}
Version Synchronization
This package's version is synchronized with @hanzo/insights. They are always released together with matching version numbers.
License
MIT