mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-10-30 18:34:19 +00:00
We own the ingestion server (hanzoai/insights: Django + rust/capture + nodejs plugin) AND this SDK, so there is no external wire contract to preserve. The server is already 100% posthog-free; this SDK was the last laggard. - $last_posthog_reset -> $last_insights_reset. This FIXES A LIVE MISMATCH: the server taxonomy (insights/taxonomy/taxonomy.py, insights/insightsql/ai.py) already expected the insights form while the SDK emitted the posthog form. - __PosthogExtensions__ -> __InsightsExtensions__; all PostHog/posthog/POSTHOG identifiers -> Insights/insights/INSIGHTS (src, tests, playground, playwright, scripts, rrweb subpackages, package.json keywords). - Hosts: DEFAULT_PLUGIN_HOST + DEFAULT_NUXT_HOST + the core host default pointed at PostHog's cloud (us.i.posthog.com) — a real bug. All -> insights.hanzo.ai. - Removed the us-assets/eu-assets CDN split in getRemoteConfig (PostHog-specific; Hanzo serves remote config from the same host) — it had degenerated to a no-op. - Fixed generate-docs writing to a stray references/@hanzo/ subdir. - Renamed the 3 posthog-named test files; dropped 58MB of stale reference snapshots named for upstream posthog versions we never shipped (they are generated output — references/ is now gitignored). Verified: typecheck errors 42 (HEAD) -> 18 (all pre-existing test-mock looseness); types package 0; every package.json valid with @hanzo/* names. Guard: grep -rioE 'posthog' packages ... | wc -l => 0
66 lines
2.4 KiB
TypeScript
66 lines
2.4 KiB
TypeScript
/**
|
|
* @jest-environment jsdom
|
|
*
|
|
* Smoke tests for the per-runtime barrels resolved by the `browser`
|
|
* exports condition. Asserts that client-only barrels expose the
|
|
* documented client-safe surface and DO NOT re-export anything that
|
|
* pulls in `server-only` or `insights-node`. If a server-only symbol
|
|
* leaks in here, Next.js's enforcement plugin will reject the client
|
|
* bundle in consumer apps.
|
|
*/
|
|
|
|
jest.mock('next/router.js', () => ({ useRouter: jest.fn() }))
|
|
jest.mock('next/navigation.js', () => ({
|
|
usePathname: jest.fn(),
|
|
useSearchParams: jest.fn(),
|
|
}))
|
|
jest.mock('@hanzo/insights-react', () => ({
|
|
InsightsContext: { Provider: ({ children }: { children: unknown }) => children },
|
|
useInsights: jest.fn(),
|
|
useFeatureFlagResult: jest.fn(),
|
|
useActiveFeatureFlags: jest.fn(),
|
|
InsightsFeature: jest.fn(() => null),
|
|
}))
|
|
jest.mock('@hanzo/insights', () => ({ __esModule: true, default: { __loaded: false, init: jest.fn() } }))
|
|
|
|
import * as pagesClient from '../src/pages.client'
|
|
import * as indexClient from '../src/index.client'
|
|
|
|
const asRecord = (mod: unknown) => mod as Record<string, unknown>
|
|
|
|
describe('client barrels (browser exports condition)', () => {
|
|
describe("@hanzo/insights-next/pages → 'browser' → pages.client", () => {
|
|
it.each([
|
|
['InsightsProvider', 'function'],
|
|
['InsightsPageView', 'function'],
|
|
['DEFAULT_INGEST_PATH', 'string'],
|
|
])('exposes %s as %s', (name, expectedType) => {
|
|
expect(typeof asRecord(pagesClient)[name]).toBe(expectedType)
|
|
})
|
|
|
|
it.each(['getServerSideInsights', 'getInsights', 'insightsMiddleware'])(
|
|
'omits %s',
|
|
(name) => {
|
|
expect(asRecord(pagesClient)[name]).toBeUndefined()
|
|
}
|
|
)
|
|
})
|
|
|
|
describe("@hanzo/insights-next → 'browser' → index.client", () => {
|
|
it.each([
|
|
['InsightsPageView', 'function'],
|
|
['useInsights', 'function'],
|
|
['useFeatureFlag', 'function'],
|
|
['useActiveFeatureFlags', 'function'],
|
|
['InsightsFeature', 'function'],
|
|
['DEFAULT_INGEST_PATH', 'string'],
|
|
])('exposes %s as %s', (name, expectedType) => {
|
|
expect(typeof asRecord(indexClient)[name]).toBe(expectedType)
|
|
})
|
|
|
|
it.each(['InsightsProvider', 'getInsights', 'insightsMiddleware'])('omits %s', (name) => {
|
|
expect(asRecord(indexClient)[name]).toBeUndefined()
|
|
})
|
|
})
|
|
})
|