- test/a1/capacity.ts runs the service as its own process and samples RSS from outside; result written to docs/analytics/CAPACITY.md. - docs/analytics/oss/A1.md: pinned SDKs and libraries, the files ported from the upstream persons code (MIT, cbb1e9253027), the wire protocol, and the hand-offs to A2/A3 (including the SDK's /static/ extension scripts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
3.8 KiB
Markdown
43 lines
3.8 KiB
Markdown
# A1 open-source record: ingest, storage, SDKs, identify and groups, privacy
|
|
|
|
Package A1 of `docs/analytics/PLAN.md` (section 9.1). Licences were read from each project's `LICENSE` (see `../OSS.md` for the index and the rejected options).
|
|
|
|
## Used unmodified (dependencies, pinned)
|
|
|
|
| Project | Version | Licence | Where | Why |
|
|
|---|---|---|---|---|
|
|
| `posthog-js` | 1.435.1 | Apache-2.0 AND MIT (browser package MIT) | `packages/analytics-js` dependency; service dev dependency for tests | Browser capture, autocapture, page views, recorder, flags client, offline retry |
|
|
| `posthog-react-native` | 4.78.2 | MIT | `packages/analytics-js` dependency (React Native entry) | Screens, app lifecycle, on-device queue |
|
|
| `posthog-node` | 5.54.1 | MIT | `packages/analytics-node` dependency; service dev dependency for tests | Server capture, identify, alias, groups, flag checks |
|
|
| `hono`, `@hono/node-server` | 4.13.11, 2.1.3 | MIT | service | HTTP server |
|
|
| `pg` | 8.23.0 | MIT | service | Postgres client |
|
|
| `fflate` | 0.8.3 | MIT | service | gzip decode of SDK batches |
|
|
| `jose` | 6.2.12 | MIT | service | Verifies the console's HS256 org token |
|
|
| `jsdom`, `playwright-core`, `@babel/runtime`, `react` | 30.1.1, 1.63.0, 7.28.4, 18.3.1 | MIT, Apache-2.0, MIT, MIT | tests only | Run the unmodified SDKs in the loop |
|
|
|
|
## Ported (semantics or data re-expressed in our code, with the notice)
|
|
|
|
Source: PostHog/posthog, MIT (Expat) outside `ee/`, commit `cbb1e9253027`. Notice: `apps/product-analytics/NOTICE`.
|
|
|
|
| Upstream file | Our file | What was taken |
|
|
|---|---|---|
|
|
| `nodejs/src/common/persons/person-utils.ts` | `src/persons/ids.ts` | The case-sensitive and case-insensitive illegal distinct-id lists (with quoted forms), `isDistinctIdIllegal`, `isDistinctIdUnmergeable` |
|
|
| `nodejs/src/common/persons/person-property-utils.ts` | `src/persons/properties.ts` | The event-to-person and campaign property sets and the `$initial_*` rule |
|
|
| `nodejs/src/ingestion/common/persons/person-merge-service.ts` | `src/persons/service.ts` | `handleIdentifyOrAlias` and `merge` rules: `$create_alias` / `$merge_dangerously` with `alias`, `$identify` with `$anon_distinct_id`, create with both ids, add the missing id, refuse when the source person is identified unless `$merge_dangerously`, target properties win; re-implemented on Postgres |
|
|
| Person overrides approach (same persons module) | `src/persons/overrides.ts`, `db/migrations/0003_persons.sql` | Merges never rewrite events; queries read `coalesce(o.new_person_id, e.person_id)` |
|
|
| Group type numbering (same ingestion code) | `src/groups/groups.ts` | Five group types per project, numbered in first-seen order; `$groupidentify` sets `$group_set` |
|
|
|
|
Not copied: no code from `ee/`, no ClickHouse or Kafka code, nothing from `sidequery/hogflare` (no licence; it only confirmed the "compatible backend" pattern).
|
|
|
|
## Wire protocol spoken (so the SDKs above work unmodified)
|
|
|
|
`/e/`, `/i/v0/e/`, `/batch/`, `/capture/` (GET and POST), `/engage/`, `/groups/`, `/flags/?v=2`, `/decide/`, `/array/:token/config`, `/array/:token/config.js`; JSON, `compression=gzip-js`, `Content-Encoding: gzip`, `compression=base64`, form `data=`.
|
|
|
|
## Hand-offs recorded by A1
|
|
|
|
- `src/routes.ts` mounts empty routers: `src/insights/routes.ts` (A2); `src/{replay,heatmaps,surveys,experiments,exports}/routes.ts` (A3).
|
|
- `src/remote-config/sections.ts`: empty `replay`, `heatmaps`, `surveys` providers (A3).
|
|
- `src/flags/variants.ts`: returns `null` (A3).
|
|
- `src/replay/gdpr.ts`, `src/surveys/gdpr.ts`: privacy hooks that delete and export nothing yet (A3).
|
|
- The browser SDK's default build lazy-loads extension scripts (for example `surveys.js`, the recorder) from `<host>/static/...`. The service does not serve them yet; A3 serves the ones it turns on (with CORS), or switches the web entry to a bundle that includes them.
|