diff --git a/src/__tests__/identity.test.ts b/src/__tests__/identity.test.ts index 73e022f6..7662241c 100644 --- a/src/__tests__/identity.test.ts +++ b/src/__tests__/identity.test.ts @@ -2828,6 +2828,16 @@ describe('identity copy', () => { expect(contact).toContain('min-width: 44px'); }); + it('exposes window.posthog after idle init so hire Contact card can capture (#hire-ph)', () => { + const ph = readFileSync('src/components/PostHog.astro', 'utf8'); + expect(ph).toContain("await import('posthog-js')"); + expect(ph).toContain('posthog.init('); + expect(ph).toMatch(/window\.posthog\s*=\s*posthog/); + expect(ph).toContain('PUBLIC_POSTHOG_KEY'); + expect(ph).toContain('requestIdleCallback'); + expect(ph).not.toMatch(/^import\s+.*from\s+['"]posthog-js['"]/m); + }); + it('footer colophon has no visitor visit-count control (#1045)', () => { const footer = readFileSync('src/components/Footer.astro', 'utf8'); expect(footer).toContain('class="colophon"'); diff --git a/src/components/PostHog.astro b/src/components/PostHog.astro index 0be0f2d6..4ee32470 100644 --- a/src/components/PostHog.astro +++ b/src/components/PostHog.astro @@ -15,6 +15,7 @@ api_host: posthogHost, person_profiles: 'identified_only', }); + window.posthog = posthog; } const scheduleIdle =