mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-03 00:53:53 +00:00
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)
146 lines
4.7 KiB
TypeScript
146 lines
4.7 KiB
TypeScript
import { test } from './utils/insights-playwright-test-base'
|
|
import { start } from './utils/setup'
|
|
|
|
const startOptions = {
|
|
options: {},
|
|
flagsResponseOverrides: {
|
|
sessionRecording: {
|
|
endpoint: '/ses/',
|
|
},
|
|
capturePerformance: true,
|
|
},
|
|
url: '/playground/cypress/index.html',
|
|
}
|
|
|
|
test.describe('autocapture config', () => {
|
|
test('do not capture click if not in allowlist', async ({ page, context }) => {
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: {
|
|
...startOptions.options,
|
|
capture_pageview: false,
|
|
autocapture: {
|
|
dom_event_allowlist: ['change'],
|
|
},
|
|
},
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.locator('[data-cy-custom-event-button]').click()
|
|
// no autocapture event from click
|
|
await page.expectCapturedEventsToBe(['custom-event'])
|
|
|
|
await page.locator('[data-cy-input]').fill('hello insights!')
|
|
// blur the input
|
|
await page.locator('body').click()
|
|
await page.expectCapturedEventsToBe(['custom-event', '$autocapture'])
|
|
})
|
|
|
|
test('capture clicks when configured to', async ({ page, context }) => {
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: { ...startOptions.options, autocapture: { dom_event_allowlist: ['click'] } },
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.locator('[data-cy-custom-event-button]').click()
|
|
await page.expectCapturedEventsToBe(['$pageview', '$autocapture', 'custom-event'])
|
|
|
|
await page.locator('[data-cy-input]').fill('hello insights!')
|
|
// blur the input
|
|
await page.locator('body').click()
|
|
// no change autocapture event
|
|
await page.expectCapturedEventsToBe(['$pageview', '$autocapture', 'custom-event'])
|
|
})
|
|
|
|
test('obeys url allowlist', async ({ page, context }) => {
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: { ...startOptions.options, autocapture: { url_allowlist: ['.*test-is-not-on-this.*'] } },
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.locator('[data-cy-custom-event-button]').click()
|
|
await page.expectCapturedEventsToBe(['$pageview', 'custom-event'])
|
|
|
|
await page.resetCapturedEvents()
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: { ...startOptions.options, autocapture: { url_allowlist: ['.*cypress.*'] } },
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.locator('[data-cy-custom-event-button]').click()
|
|
await page.expectCapturedEventsToBe(['$pageview', '$autocapture', 'custom-event'])
|
|
})
|
|
|
|
test('obeys element allowlist', async ({ page, context }) => {
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: { ...startOptions.options, autocapture: { element_allowlist: ['button'] } },
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.locator('[data-cy-custom-event-button]').click()
|
|
await page.expectCapturedEventsToBe(['$pageview', '$autocapture', 'custom-event'])
|
|
|
|
await page.resetCapturedEvents()
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: { ...startOptions.options, autocapture: { element_allowlist: ['input'] } },
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.locator('[data-cy-custom-event-button]').click()
|
|
await page.expectCapturedEventsToBe(['$pageview', 'custom-event'])
|
|
})
|
|
|
|
test('obeys css selector allowlist', async ({ page, context }) => {
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: {
|
|
...startOptions.options,
|
|
autocapture: { css_selector_allowlist: ['[data-cy-custom-event-button]'] },
|
|
},
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.locator('[data-cy-custom-event-button]').click()
|
|
await page.expectCapturedEventsToBe(['$pageview', '$autocapture', 'custom-event'])
|
|
|
|
await page.resetCapturedEvents()
|
|
await start(
|
|
{
|
|
...startOptions,
|
|
options: { ...startOptions.options, autocapture: { css_selector_allowlist: ['[data-cy-input]'] } },
|
|
},
|
|
page,
|
|
context
|
|
)
|
|
|
|
await page.locator('[data-cy-custom-event-button]').click()
|
|
await page.expectCapturedEventsToBe(['$pageview', 'custom-event'])
|
|
})
|
|
})
|