paperclip/server/src
Nicky Leach 8f1e3cfe24
feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The server and the browser need clear error reports when an operator
enables external monitoring.
> - Paperclip already uses an opt-in OpenTelemetry pattern for server
traces.
> - Sentry can provide error reports for both runtime paths when the
operator sets one data source name.
> - This pull request adds one opt-in Sentry gate for the server and the
browser.
> - The benefit is faster diagnosis while the default setup sends no
Sentry data.

## Linked Issues or Issue Description

**What is improved?**

Paperclip gains optional error monitoring for server and browser
failures.

**Subsystem affected**

Cross-cutting (server, UI, and shared authentication data).

**Current behavior**

Paperclip has no built-in Sentry error capture for server failures or
browser boundary failures. Operators must inspect local logs and browser
tools.

**Proposed behavior**

When the operator sets `SENTRY_DSN`, the server and authenticated
browser use the same Sentry project. When the variable is absent, both
paths stay inactive. The server loads Sentry dynamically and fails open
when the optional package is absent.

**Reason and benefit**

Operators can inspect runtime errors in one Sentry project. The default
setup remains local and sends no monitoring data.

**Breaking changes**

None when `SENTRY_DSN` remains unset. Authenticated session responses
add the optional `sentryDsn` field.

**Additional context**

The implementation uses built-in Sentry privacy options. It disables
default HTTP context and breadcrumb integrations and keeps
`sendDefaultPii` false.

## What Changed

- Add an opt-in server Sentry gate with dynamic package loading and
fail-open behavior.
- Add the Sentry data source name to the authenticated session response.
- Add an authenticated browser Sentry gate and React error boundary
capture.
- Add tests for server, browser, route, and application error paths.
- Document activation, installation, privacy settings, capture behavior,
and operator controls.

## Verification

- Run `npx vitest run server/src/__tests__/sentry.test.ts`.
- Run `npx vitest run ui/src/lib/sentry.test.ts`.
- Run `npx vitest run server/src/__tests__/auth-routes.test.ts
server/src/__tests__/shutdown.test.ts`.
- Confirm that the full continuous integration suite passes on this pull
request.
- Leave `SENTRY_DSN` unset and confirm that the server and browser gates
stay inactive.
- Set `SENTRY_DSN` and install the optional Sentry packages before a
manual capture check.

## Risks

The operator controls the Sentry project and accepts the data risk when
the operator enables the feature. Error objects can contain messages,
stacks, or cause chains with private values. The default configuration
sends no data because the feature stays off without `SENTRY_DSN`. A
missing optional server package does not stop server boot.

## Model Used

OpenAI Codex, GPT-5, with tool use, repository inspection, GitHub CLI
operations, and code review support.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-08-26 11:15:45 -07:00
..
__tests__ feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
adapters feat(runner): add flagged Codex execution adapter (#12188) 2026-08-25 16:03:41 -05:00
auth feat(workspaces): sign the workspace login handoff and gate readiness (#11671) 2026-08-19 02:37:02 -05:00
built-ins/agents fix: isolate execution workspace summaries (#10790) 2026-08-11 08:56:32 -04:00
http fix(server): raise company import zip upload limit to 1 GB and make it operator-configurable (#11184) 2026-08-10 12:47:03 -07:00
lib perf(server): reduce issue detail request overhead (#10414) 2026-08-11 14:39:23 -04:00
middleware feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
onboarding-assets fix: reliably show plans in the Plan pane and restore sticky plan confirmation CTAs (#10930) 2026-08-05 19:32:07 -07:00
realtime feat(runner): add hidden server PRP coordinator (#12176) 2026-08-25 14:17:14 -05:00
routes feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
secrets
…
services fix(adapter-utils): harden the referenced-project ignore scan (#12214) 2026-08-26 08:30:42 -07:00
storage
…
types
…
vendor/paperclip-runner feat(runner): add flagged Codex execution adapter (#12188) 2026-08-25 16:03:41 -05:00
agent-auth-jwt.ts fix(server): align agent run JWT default TTL with documented 48h default (#10176) 2026-08-12 16:44:20 -07:00
app.ts fix(ui): keep the installed service worker fresh on parked tabs (#12198) 2026-08-25 16:12:02 -07:00
attachment-types.ts
…
board-claim.ts
…
build-commit.ts
…
build-version.ts
…
config-file.ts fix(config): preserve extensions and guard invalid repairs (#11005) 2026-08-07 00:41:19 -05:00
config.ts feat(server): add a configurable cooldown to the terminal workspace reaper (#11642) 2026-08-18 11:23:27 -07:00
db-errors.ts fix(issues): make DELETE /api/issues/:id succeed for issues with dependents (#11331) 2026-08-13 12:02:15 -07:00
dev-runner-worktree.ts feat(workspaces): sign the workspace login handoff and gate readiness (#11671) 2026-08-19 02:37:02 -05:00
dev-server-status.ts
…
dev-watch-ignore.ts fix(server): ignore sibling worktrees in dev watch (#11074) 2026-08-07 18:30:16 -07:00
duplex-aggregate-ceiling-env.ts feat(duplex): bound aggregate duplex route resource consumption with a process-owned byte ledger (#12003) 2026-08-22 22:14:35 -07:00
embedded-postgres-supervisor.ts fix(workspaces): recover degraded runtime databases (#11651) 2026-08-18 17:40:54 -05:00
errors.ts feat(artifacts): bridge Markdown work products into the document review surface (#11822) 2026-08-20 17:28:01 -07:00
first-admin-claim.ts
…
home-paths.ts
…
index.ts feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
instrumentation.test.ts
…
instrumentation.ts fix(server): stamp built commit into service.version (#11748) 2026-08-19 21:20:40 -07:00
log-redaction.ts
…
paths.ts
…
redaction.ts feat: Claude agent setup-token login in a sandbox (#11286) 2026-08-12 13:02:49 -07:00
runtime-api.ts
…
sentry.ts feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
server-info.ts
…
shutdown.test.ts feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
shutdown.ts feat(observability): add opt-in Sentry error monitoring for the server and the browser (#12190) 2026-08-26 11:15:45 -07:00
startup-banner.ts fix(security): route paperclipai CLI guidance through safe npx form (CWE-78) (#11400) 2026-08-14 22:11:16 -07:00
static-index-html.ts
…
static-ui-cache.ts fix(ui): keep the installed service worker fresh on parked tabs (#12198) 2026-08-25 16:12:02 -07:00
telemetry.ts
…
ui-branding.ts
…
url-utils.test.ts fix(runtime): only rewrite base-URL port for loopback hosts (#10258) 2026-08-13 09:47:13 -07:00
url-utils.ts fix(runtime): only rewrite base-URL port for loopback hosts (#10258) 2026-08-13 09:47:13 -07:00
version.ts
…
vite-html-renderer.ts
…
worktree-config.ts fix(workspaces): make managed runtimes reliable across restarts (#11740) 2026-08-19 14:55:16 -05:00
worktree-seed-manifest.ts feat(workspaces): sign the workspace login handoff and gate readiness (#11671) 2026-08-19 02:37:02 -05:00