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

77 lines
2.5 KiB
TypeScript

import { expect, test, WindowWithInsights } from './utils/insights-playwright-test-base'
import { start } from './utils/setup'
import { BeforeSendFn } from '@/types'
const startOptions = {
options: {
session_recording: {},
},
flagsResponseOverrides: {
sessionRecording: {
endpoint: '/ses/',
},
capturePerformance: true,
},
url: '/playground/cypress-full/index.html',
}
test.describe('before_send', () => {
test('can sample and edit with before_send', async ({ page, context }) => {
await start(startOptions, page, context)
await page.evaluate(() => {
const insights = (window as WindowWithInsights).insights
if (!insights) {
throw new Error('Insights is not initialized')
}
let counter = 0
// box the original before_send function
const og: BeforeSendFn[] = Array.isArray(insights.config.before_send)
? insights.config.before_send
: insights.config.before_send !== undefined
? [insights.config.before_send]
: []
insights.config.before_send = [
(cr) => {
if (!cr) {
return null
}
if (cr.event === 'custom-event') {
counter++
if (counter === 2) {
return null
}
}
if (cr.event === '$autocapture') {
return {
...cr,
event: 'redacted',
}
}
return cr
},
// these tests rely on existing before_send function to capture events
// so we have to add it back in here
...og,
]
})
await page.locator('[data-cy-custom-event-button]').click()
await page.locator('[data-cy-custom-event-button]').click()
const captures = (await page.capturedEvents()).map((x) => x.event)
expect(captures).toEqual([
// before adding the new before sendfn
'$pageview',
'redacted',
'custom-event',
// second button click only has the redacted autocapture event
'redacted',
// because the second custom-event is rejected
])
})
})