mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-10-30 18:34:19 +00:00
* feat(next): Introduce a first class Next.js integration * feat(next): Next.js app router example * feat(next): Provide default client configuration * feat(next): Composable middleware; allow first-class proxy * refactor(next): Use `resolveApiKey` * feat(next): Example uses proxied PostHog at /ingest * fix(next): Skip initial client flag load when flags are bootstrapped via SSR * feat(next): Deduplicate flag evaluation with React.cache * refactor(next): Use `readPostHogCookie` * feat(next): Sync $sesid and $device_id from cookies in server clients * feat(next): Scope server-side client via `enterContext()` * fix(next): Eagerly init the client-side PostHog client This avoids a race condition where the client may be used before it's initialized * feat(next): Next SSR is aware of client opt-out consent When configured, the server will respect the clients opt-out consent configuration. * chore(next): Update the app router example * fix(next): Wrap PostHogPageView in Suspense * docs(next): Add README and USAGE * refactor(next): Drop explicit force-dynamic in example * feat(next): Use a composable pages API * feat(next): Integrate `waitUntil` automatically in Vercel; expose serverOptions * chore(next): Clean up tsconfig * fix(next): finalizing clean up * chore(next): add changeset * fix(next): packaging and bug fixes Getting the example back in running order * chore(next): move the app-router example * chore(next): fix the vercel build * fix: greptile comments * fix: ClientPostHogProvider warns on missing api key * test: validate pageview on router ready * trigger ci * fix: greptile * chore: prettier
16 lines
504 B
TypeScript
16 lines
504 B
TypeScript
import { generateAnonymousId } from '../src/shared/identity'
|
|
|
|
const UUIDV7_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/
|
|
|
|
describe('generateAnonymousId', () => {
|
|
it('returns a valid UUIDv7 string', () => {
|
|
const id = generateAnonymousId()
|
|
expect(id).toMatch(UUIDV7_REGEX)
|
|
})
|
|
|
|
it('generates unique IDs', () => {
|
|
const ids = new Set(Array.from({ length: 100 }, () => generateAnonymousId()))
|
|
expect(ids.size).toBe(100)
|
|
})
|
|
})
|