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
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
jest.mock('server-only', () => ({}))
|
|
|
|
const mockVercelWaitUntil = jest.fn()
|
|
|
|
jest.mock('@vercel/functions', () => ({
|
|
waitUntil: mockVercelWaitUntil,
|
|
}))
|
|
|
|
const mockInsightsConstructor = jest.fn()
|
|
|
|
jest.mock('@hanzo/insights-node', () => ({
|
|
Insights: mockInsightsConstructor,
|
|
}))
|
|
|
|
describe('nodeClientCache waitUntil auto-detection', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks()
|
|
jest.resetModules()
|
|
})
|
|
|
|
it('auto-detects @vercel/functions waitUntil and applies to new clients', async () => {
|
|
const { getOrCreateNodeClient } = require('../src/server/nodeClientCache')
|
|
|
|
await getOrCreateNodeClient('phc_test', { host: 'https://test.com' })
|
|
|
|
expect(mockInsightsConstructor).toHaveBeenCalledWith(
|
|
'phc_test',
|
|
expect.objectContaining({ waitUntil: mockVercelWaitUntil })
|
|
)
|
|
})
|
|
|
|
it('explicit options.waitUntil takes priority over auto-detected', async () => {
|
|
const { getOrCreateNodeClient } = require('../src/server/nodeClientCache')
|
|
|
|
const explicitWaitUntil = jest.fn()
|
|
await getOrCreateNodeClient('phc_test3', { host: 'https://test3.com', waitUntil: explicitWaitUntil })
|
|
|
|
expect(mockInsightsConstructor).toHaveBeenCalledWith(
|
|
'phc_test3',
|
|
expect.objectContaining({ waitUntil: explicitWaitUntil })
|
|
)
|
|
})
|
|
})
|