Files
zeekay e43ab1afe7 chore: rename all PostHog references to Insights/Hanzo
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)
2026-03-06 01:41:12 -08:00

2.2 KiB

@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