Files
zeekay ec6f6b50c1 chore: kill ALL posthog — zero refs, zero filenames (1452 -> 0)
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
2026-07-16 09:09:18 -07:00

97 lines
3.3 KiB
TypeScript

import { readTracingHeaders } from '../src/shared/tracing-headers'
describe('readTracingHeaders', () => {
describe('with Headers-like object (.get method)', () => {
it('extracts all three headers', () => {
const headers = {
get: (name: string) => {
const map: Record<string, string> = {
'x-insights-session-id': 'session-123',
'x-insights-distinct-id': 'user-456',
'x-insights-window-id': 'window-789',
}
return map[name] ?? null
},
}
expect(readTracingHeaders(headers)).toEqual({
distinctId: 'user-456',
sessionId: 'session-123',
windowId: 'window-789',
})
})
it('returns undefined for missing headers', () => {
const headers = { get: () => null }
expect(readTracingHeaders(headers)).toEqual({
distinctId: undefined,
sessionId: undefined,
windowId: undefined,
})
})
it('returns undefined for empty string headers', () => {
const headers = { get: () => '' }
expect(readTracingHeaders(headers)).toEqual({
distinctId: undefined,
sessionId: undefined,
windowId: undefined,
})
})
})
describe('with plain record (IncomingHttpHeaders)', () => {
it('extracts all three headers', () => {
const headers: Record<string, string | string[] | undefined> = {
'x-insights-session-id': 'session-123',
'x-insights-distinct-id': 'user-456',
'x-insights-window-id': 'window-789',
}
expect(readTracingHeaders(headers)).toEqual({
distinctId: 'user-456',
sessionId: 'session-123',
windowId: 'window-789',
})
})
it('returns undefined for missing headers', () => {
expect(readTracingHeaders({})).toEqual({
distinctId: undefined,
sessionId: undefined,
windowId: undefined,
})
})
it('takes the first value from string[] headers', () => {
const headers: Record<string, string | string[] | undefined> = {
'x-insights-session-id': ['session-a', 'session-b'],
'x-insights-distinct-id': ['user-a'],
'x-insights-window-id': 'window-single',
}
expect(readTracingHeaders(headers)).toEqual({
distinctId: 'user-a',
sessionId: 'session-a',
windowId: 'window-single',
})
})
it('returns undefined for undefined values', () => {
const headers: Record<string, string | string[] | undefined> = {
'x-insights-session-id': undefined,
'x-insights-distinct-id': undefined,
'x-insights-window-id': undefined,
}
expect(readTracingHeaders(headers)).toEqual({
distinctId: undefined,
sessionId: undefined,
windowId: undefined,
})
})
})
})