Skip to content

Commit e187cf3

Browse files
authored
chore: add CLAUDE.md (#398)
## Summary Add CLAUDE.md ## How did you test this change? ## Are there any deployment considerations? <!-- Backend - Do we need to consider migrations or backfilling data? --> <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: adds documentation only and does not change runtime code, build outputs, or CI behavior. > > **Overview** > Adds `CLAUDE.md`, a repo-specific contributor guide covering the monorepo overview, common Yarn/Turbo commands (build/test/lint/publish), package layout and key `highlight.run` entry points, CI workflow notes, and E2E testing guidance (including cross-origin iframe recording troubleshooting). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 515307d. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 7c4ab46 commit e187cf3

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed

CLAUDE.md

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# CLAUDE.md
2+
3+
## Overview
4+
5+
LaunchDarkly Observability SDK monorepo. Contains browser, Node.js, mobile, and backend SDKs for session replay, error monitoring, logging, and distributed tracing. Fork of highlight.io.
6+
7+
**Package manager:** Yarn 4.9.1 (`yarn install`)
8+
**Build system:** Turborepo
9+
**rrweb:** Git submodule at `rrweb/` - run `git submodule update --init --recursive` after clone (the preinstall hook handles this automatically).
10+
11+
## Key Commands
12+
13+
```bash
14+
yarn install # Install all dependencies
15+
yarn build # Build all packages (excludes rrweb, nextjs)
16+
yarn build:sdk # Build only @launchdarkly/* + highlight.run
17+
yarn test # Build, lint, enforce-size, then test all packages
18+
yarn format-check # Check formatting (prettier)
19+
yarn format:all # Fix formatting
20+
yarn lint # Lint all packages
21+
yarn enforce-size # Check bundle size limits (256KB brotli)
22+
yarn docs # Generate TypeDoc documentation
23+
```
24+
25+
### Filtering to specific packages
26+
27+
```bash
28+
yarn turbo run build --filter @launchdarkly/observability
29+
yarn turbo run test --filter highlight.run
30+
yarn turbo run build --filter '@launchdarkly/*'
31+
```
32+
33+
### Publishing (CI-only, runs on main)
34+
35+
```bash
36+
yarn publish # @launchdarkly/* packages
37+
yarn publish:highlight # highlight.run + @highlight-run/* packages
38+
```
39+
40+
## Package Structure
41+
42+
### LaunchDarkly SDKs (`sdk/@launchdarkly/`)
43+
44+
| Package | Description |
45+
|---------|-------------|
46+
| `observability` | Browser SDK - errors, logs, traces |
47+
| `session-replay` | Browser SDK - session replay (thin wrapper over highlight.run) |
48+
| `observability-shared` | Internal shared types and GraphQL codegen (private) |
49+
| `observability-node` | Node.js SDK |
50+
| `observability-react-native` | React Native SDK |
51+
| `react-native-ld-session-replay` | React Native session replay |
52+
| `observability-python` | Python SDK |
53+
| `observability-dotnet` | .NET SDK |
54+
| `observability-android` | Android SDK |
55+
| `observability-java` | Java SDK |
56+
57+
### Core packages
58+
59+
| Package | Description |
60+
|---------|-------------|
61+
| `sdk/highlight-run` | Core browser library - session replay + observability. Most logic lives here. |
62+
| `rrweb/` | Forked session replay recording library (git submodule, ~15 sub-packages) |
63+
| `go/` | Go observability SDK |
64+
65+
### Key source files in highlight.run
66+
67+
- `src/index.tsx` - Public API, `H` global singleton
68+
- `src/sdk/record.ts` - `RecordSDK` class (session replay recording logic)
69+
- `src/sdk/LDRecord.ts` - `LDRecord` global singleton (LaunchDarkly entry point)
70+
- `src/client/index.tsx` - `Highlight` class (underlying implementation)
71+
- `src/client/workers/highlight-client-worker.ts` - Web Worker for async data upload
72+
- `src/client/types/record.ts` - `RecordOptions` type definition
73+
- `src/client/types/iframe.ts` - Cross-origin iframe protocol types
74+
- `src/client/constants/sessions.ts` - Timing constants (`FIRST_SEND_FREQUENCY`, etc.)
75+
- `src/plugins/record.ts` - LaunchDarkly plugin interface (`LDPlugin`)
76+
77+
### Default backend URL
78+
79+
The SDK sends data to `https://pub.observability.app.launchdarkly.com` by default. Configurable via `backendUrl` option.
80+
81+
## Code Style
82+
83+
**Prettier config** (`.prettierrc`): Tabs, no semicolons, single quotes, trailing commas, 80 char width.
84+
85+
**Pre-commit hook** (husky): Runs `pretty-quick --staged` automatically.
86+
87+
**TypeScript**: Strict mode. All browser SDKs build with Vite (ESM + UMD). Node SDKs use rollup or tsc.
88+
89+
**Bundle size**: All browser packages enforce 256KB brotli limit via `size-limit`. Check with `yarn enforce-size`.
90+
91+
## CI Pipeline
92+
93+
The main workflow is `.github/workflows/turbo.yml` (runs on push to main and PRs):
94+
1. `yarn install`
95+
2. `yarn dedupe --check`
96+
3. `yarn format-check`
97+
4. `yarn test` (which runs build -> lint -> enforce-size -> test)
98+
5. On main: publishes to npm
99+
100+
Other workflows handle language-specific SDKs (Go, Python, .NET, Android, Java, Ruby, Rust, Elixir) and E2E tests.
101+
102+
Releases are managed by `release-please` - version bumps happen automatically via PR.
103+
104+
## E2E Tests
105+
106+
### Framework examples (`e2e/`)
107+
108+
Example apps for testing SDK integrations: React, Next.js, Angular, Express, NestJS, Remix, Hono, Cloudflare Worker, React Native, Go, Python, .NET, Ruby, and more.
109+
110+
```bash
111+
# Run via docker compose
112+
cd e2e
113+
docker compose build sdk && docker compose build base
114+
docker compose build <example> && docker compose up <example>
115+
116+
# Run specific frameworks via turbo
117+
yarn e2e:nextjs
118+
yarn e2e:express
119+
yarn e2e:cloudflare
120+
```
121+
122+
### Pytest E2E (`e2e/tests/`)
123+
124+
Python-based tests that start apps, make requests, and validate data appears in the backend via GraphQL queries. Uses `app_runner.py` for lifecycle management with health check polling.
125+
126+
```bash
127+
cd e2e/tests
128+
poetry install
129+
poetry run python src/app_runner.py <example>
130+
poetry run pytest
131+
```
132+
133+
**Run tests:**
134+
```bash
135+
# Diagnose live customer URLs (headed browser, slow-mo for observation)
136+
yarn test:live
137+
138+
# Run local reproduction tests (headless, uses local Express servers on :3001/:3002)
139+
yarn test:local
140+
141+
# Run everything
142+
yarn test
143+
```

0 commit comments

Comments
 (0)