# Sentry JavaScript SDK Monorepo with 40+ packages in `@sentry/*`, managed with pnpm workspaces and Nx. ## Setup - pnpm manages Node.js and pnpm versions (see `CONTRIBUTING.md`): Node.js in `devEngines.runtime`, pnpm in `packageManager` - After cloning: `pnpm install && pnpm run build` - Never change Node.js, pnpm, or package manager versions unless explicitly asked ### Code Intelligence Prefer LSP over Grep/Read for code navigation — it's faster, precise, and avoids reading entire files: - `workspaceSymbol` to find where something is defined - `findReferences` to see all usages across the codebase - `goToDefinition` / `goToImplementation` to jump to source - `hover` for type info without reading the file Use Grep only when LSP isn't available or for text/pattern searches (comments, strings, config). After writing or editing code, check LSP diagnostics and fix errors before proceeding. ## Package Manager Use **pnpm**, never npm or yarn. Scripts live in the root `package.json`. `pnpm run build:dev:filter @sentry/` builds one package and its deps. Single package: `cd packages/ && pnpm run test` ## Commit Attribution AI commits MUST include a `Co-Authored-By` line with the appropriate committer email when known: ``` Co-Authored-By: Co-Authored-By: Co-Authored-By: ``` Use the Cursor email for Cursor, even when it runs a Claude or OpenAI model. Omit the line only when there is no known committer email address for the agent. ## Git Workflow Uses **Git Flow** (see `docs/gitflow.md`). - **All PRs target `develop`** (NOT `master`) - `master` = last released state — never merge directly - Feature branches: `feat/descriptive-name` - Never update dependencies, `package.json`, or build scripts unless explicitly asked ## Before Every Pull Request 1. `pnpm run format` 2. `pnpm run build:dev` 3. `pnpm run lint` 4. Run the unit and integration/E2E tests for the affected packages. 5. NEVER push on `develop` ## Pull Requests - Use `.github/PULL_REQUEST_TEMPLATE.md` for the body (`gh pr create --body` skips it). Ideally 1-2 sentences per field, no AI walkthrough. - Always open PRs as draft. - Never apply the `Accept Bundlesize Increase` label. - When you review, do not ask for a regression test on a `fix(deps)` PR that only bumps a first-party package (`sentry`, `@sentry/*`) to a version with the fix, or on an early PR of a stack when a later PR of the stack adds the tests. - **Keep PR descriptions condensed** — usually a few sentences. Explain the _reasoning_: why the change is needed, and any non-obvious decisions or tradeoffs made along the way. Do **not** walk through the implementation or describe what changed file-by-file — the diff already shows that. Only go longer when the decisions genuinely warrant it. ## Architecture - Types live in `packages/core/`. The `@sentry/types` package is gone. - An AI provider integration spans two places, both in `packages/server-utils/`: the gen-AI instrumentation logic in `src/ai/{provider}/`, and the integration that wires it up in `src/integrations/{provider}.ts`, registered in `getTracingIntegrations()`. Runtime packages (`node`, `cloudflare`, ...) re-export from `@sentry/server-utils` rather than defining their own. - `Sentry.init()` follows one rule for repeated calls: the first call wins. See `docs/repeated-init.md` before you add or change an `init()`. - In the `exports` of a framework SDK, put the `workerd` and `worker` keys before `browser`. Cloudflare bundlers also set the `browser` condition, and the first key that matches wins. - Span origins must follow the [trace origin spec](https://develop.sentry.dev/sdk/telemetry/traces/trace-origin/): `...`, at most four parts, no skipped parts, only `[a-zA-Z0-9_]` within a part. `category` is the span op category (`auto.queue.kafkajs.producer`, not `auto.kafkajs.producer`). Don't encode tooling like `otel` or `orchestrion` in the origin. ## Linting & Formatting - This project uses **Oxlint** and **Oxfmt** — NOT ESLint or Prettier - Never run `eslint`, `npx eslint`, or any ESLint CLI — use `pnpm run lint` (Oxlint) instead - Never run `prettier` — use `pnpm run format` (Oxfmt) instead - ESLint packages in the repo are legacy/e2e test app dependencies — ignore them - Do not create, modify, or suggest `.eslintrc`, `eslint.config.*`, or `.prettierrc` files ## Coding Standards - Follow existing conventions — check neighboring files - Reach for existing utils before writing a new one. Most shared helpers live in `@sentry/core` (`packages/core/src/utils/`), with browser helpers in `packages/browser-utils/`. Search first (LSP `workspaceSymbol` or grep) for common needs (type guards in `is.ts`, object/array helpers, `normalize`, `dsn`, `merge`, string/url helpers). Reuse or extend the existing util rather than adding a near-duplicate; only introduce a new util when nothing fits. - When `JSON.stringify` output goes into generated code (bundler plugins, loaders, virtual modules, `define`), use `stringifyForCodeInjection` from `@sentry/core` instead. It escapes `<`, `>`, U+2028 and U+2029, so the code stays safe when inlined in a `