mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-03 00:53:53 +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
70 lines
2.4 KiB
TypeScript
70 lines
2.4 KiB
TypeScript
import { expect, test } from './utils/insights-playwright-test-base'
|
|
import { start } from './utils/setup'
|
|
import { pollUntilEventCaptured } from './utils/event-capture-utils'
|
|
|
|
const startOptions = {
|
|
options: {
|
|
cookieless_mode: 'always' as const,
|
|
capture_performance: {
|
|
web_vitals: true,
|
|
},
|
|
},
|
|
flagsResponseOverrides: {
|
|
capturePerformance: true,
|
|
},
|
|
url: '/playground/cypress/index.html',
|
|
}
|
|
|
|
test.describe('Web Vitals in cookieless mode', () => {
|
|
test('captures web vitals without session or window ids when cookieless', async ({ page, context }) => {
|
|
await start(startOptions, page, context)
|
|
|
|
await pollUntilEventCaptured(page, '$web_vitals')
|
|
|
|
const webVitalsEvents = (await page.capturedEvents()).filter((event) => event.event === '$web_vitals')
|
|
expect(webVitalsEvents.length).toBeGreaterThan(0)
|
|
|
|
const webVitalsEvent = webVitalsEvents[0]
|
|
expect(webVitalsEvent.properties).toMatchObject({
|
|
$current_url: expect.any(String),
|
|
$cookieless_mode: true,
|
|
$web_vitals_FCP_value: expect.any(Number),
|
|
})
|
|
|
|
expect(webVitalsEvent.properties.$session_id).toBeUndefined()
|
|
expect(webVitalsEvent.properties.$window_id).toBeUndefined()
|
|
expect(webVitalsEvent.properties.distinct_id).toBe('$insights_cookieless')
|
|
|
|
expect(webVitalsEvent.properties.$web_vitals_FCP_event).toMatchObject({
|
|
name: 'FCP',
|
|
value: expect.any(Number),
|
|
$current_url: expect.any(String),
|
|
timestamp: expect.any(Number),
|
|
})
|
|
|
|
expect(webVitalsEvent.properties.$web_vitals_FCP_event.$session_id).toBeUndefined()
|
|
expect(webVitalsEvent.properties.$web_vitals_FCP_event.$window_id).toBeUndefined()
|
|
})
|
|
|
|
test('does not capture web vitals when cookieless but vitals disabled', async ({ page, context }) => {
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: {
|
|
cookieless_mode: 'always' as const,
|
|
capture_performance: {
|
|
web_vitals: false,
|
|
},
|
|
},
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.waitForTimeout(5000)
|
|
|
|
const webVitalsEvents = (await page.capturedEvents()).filter((event) => event.event === '$web_vitals')
|
|
expect(webVitalsEvents.length).toBe(0)
|
|
})
|
|
})
|