Files
zeekay e43ab1afe7 chore: rename all PostHog references to Insights/Hanzo
Bulk rename across 989 files:
- Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc.
- Repository URLs: posthog/posthog-js → hanzoai/insights-js
- Brand names: PostHog → Insights
- File renames: 259 reference JSON files, source files, workflow files
- Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights

Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
2026-03-06 01:41:12 -08:00

116 lines
3.8 KiB
TypeScript

import { test, WindowWithInsights } from './utils/insights-playwright-test-base'
import { start, gotoPage } from './utils/setup'
test.describe('opting out', () => {
test.describe('when not initialized', () => {
test('does not capture events without init', async ({ page }) => {
await gotoPage(page, './playground/cypress/index.html')
await page.type('[data-cy-input]', 'hello insights!')
await page.expectCapturedEventsToBe([])
})
})
test.describe('when starting disabled in some way', () => {
test('does not capture events when config opts out by default', async ({ page, context }) => {
await start(
{
flagsResponseOverrides: {
autocapture_opt_out: true,
},
options: {
opt_out_capturing_by_default: true,
},
url: '/playground/cypress/index.html',
},
page,
context
)
await page.expectCapturedEventsToBe([])
await page.type('[data-cy-input]', 'hello insights!')
await page.expectCapturedEventsToBe([])
})
test('sends a $pageview event when opting in', async ({ page, context }) => {
await start(
{
flagsResponseOverrides: {
autocapture_opt_out: true,
},
options: {
opt_out_capturing_by_default: true,
},
url: '/playground/cypress/index.html',
},
page,
context
)
await page.expectCapturedEventsToBe([])
await page.evaluate(() => {
;(window as WindowWithInsights).insights?.opt_in_capturing()
})
await page.expectCapturedEventsToBe(['$opt_in', '$pageview'])
})
test('does not send a duplicate $pageview event when opting in', async ({ page, context }) => {
await start(
{
flagsResponseOverrides: {
autocapture_opt_out: true,
},
options: {
// start opted in!
opt_out_capturing_by_default: false,
},
url: '/playground/cypress/index.html',
},
page,
context
)
await page.expectCapturedEventsToBe(['$pageview'])
await page.evaluate(() => {
;(window as WindowWithInsights).insights?.opt_in_capturing()
})
await page.expectCapturedEventsToBe(['$pageview', '$opt_in'])
})
})
test.describe('user opts out after start', () => {
test('does not send any events after that', async ({ page, context }) => {
await start(
{
flagsResponseOverrides: {
autocapture_opt_out: false,
},
url: '/playground/cypress/index.html',
},
page,
context
)
await page.expectCapturedEventsToBe(['$pageview'])
await page.click('[data-cy-custom-event-button]')
await page.expectCapturedEventsToBe(['$pageview', '$autocapture', 'custom-event'])
await page.evaluate(() => {
;(window as WindowWithInsights).insights?.opt_out_capturing()
})
await page.click('[data-cy-custom-event-button]')
// no new events
await page.expectCapturedEventsToBe(['$pageview', '$autocapture', 'custom-event'])
})
})
})