feat(apex): add browser sentry monitoring#562
Conversation
Issue: AP-381
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds browser-side Sentry error monitoring to the Apex app. A new worker endpoint ChangesApex Sentry Integration
Sequence Diagram(s)sequenceDiagram
participant client.ts
participant initApexBrowserSentry
participant WorkerFetch as GET /__client/config.json
participant handleClientConfig
participant SentryInit as Sentry.init
client.ts->>initApexBrowserSentry: void initApexBrowserSentry()
initApexBrowserSentry->>initApexBrowserSentry: guard: no window → exit
initApexBrowserSentry->>initApexBrowserSentry: guard: already initialized → return cached promise
initApexBrowserSentry->>WorkerFetch: fetch(APEX_CLIENT_CONFIG_PATH, same-origin/json)
WorkerFetch->>handleClientConfig: route match CLIENT_CONFIG_PATH
handleClientConfig-->>WorkerFetch: JSON {sentry:{dsn, environment}}, no-store
WorkerFetch-->>initApexBrowserSentry: config response
initApexBrowserSentry->>initApexBrowserSentry: validate/trim DSN → exit if null
initApexBrowserSentry->>SentryInit: init({dsn, environment, sendDefaultPii:false, tracesSampleRate:0.1, integrations:[browserTracingIntegration]})
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
First-pass review (AP-381)
Risk: medium
Decision: comment only
Ticket triage
- Intended change: Add browser-side Sentry to the apex marketing client, served via same-origin
/__client/config.json, with CSP + optional deploy secret routing forSENTRY_DSN. - Scope match: Yes — all acceptance criteria appear covered (conditional init, no cookies on config route, US ingest CSP, optional apex secret provisioning, focused tests).
Review findings
Blocking:
- CI
Validatefailed on this run (@agent-paste/jobs#test:coverageand a flaky@agent-paste/dbRLS coverage test). These failures are outside the PR diff; apex lint/build/test (88 tests) passed in the same workflow.
Non-blocking:
@sentry/browseris always bundled even when no DSN is configured — expected tradeoff for this slice; dynamic import could be a follow-up if bundle size matters.initApexBrowserSentrydoes not retry after a non-throwing miss (!response.ok/ empty DSN); acceptable for a one-shot bootstrap, but transient config fetch failures would skip monitoring for that page load.
Merge checklist
- Ticket linked: ✅ AP-381
- Scope matches: ✅
- Checks green: ❌ Validate failed (unrelated packages)
- Tests/docs appropriate: ✅ for changed surface
- No blocking code findings: ✅
- No high-risk areas: ✅ (optional public DSN exposure follows existing web/MCP patterns; deploy routing mirrors MCP)
- Merge-safe: ⏸️ after CI green
Summary
Implementation is clean, mirrors existing Sentry/CSP conventions (https://*.ingest.us.sentry.io), and respects the privacy posture (Sentry is not gated by optional analytics/GPC). Not approving yet because the required CI gate is red on unrelated failures — please rerun Validate (or fix the failing jobs coverage/RLS flake if reproducible), then this should be good to merge.
Sent by Cursor Automation: First Pass PR Reviewer
…-browser-sentry-monitoring
|
agent-paste PR preview resources were cleaned up. The shared Preview GitHub Environment is retained for future preview deploys. |


Summary
Adds apex browser-side Sentry monitoring without committing a DSN. The browser client loads same-origin runtime config from the apex Worker and initializes Sentry only when
SENTRY_DSNis configured.Changes
@sentry/browserbootstrap for the apex client bundle./__client/config.jsonfrom the apex Worker with no-store JSON config.connect-src.SENTRY_DSNthrough deploy secret planning.Risk: MEDIUM
Test plan
pnpm install --frozen-lockfile --strict-peer-dependenciespnpm --filter @agent-paste/apex... buildpnpm --filter @agent-paste/apex testpnpm --filter @agent-paste/apex typecheckpnpm --filter @agent-paste/apex lintpnpm --filter @agent-paste/apex test:coveragepnpm exec vitest run scripts/lib/secret-routing.test.mjs scripts/deploy.test.mjspnpm verifypnpm test:coverage:strictpnpm smoke:localgitleaks,biome,typechecktest:coverage:strict,pnpm verifyziw-code-review: READY FOR PR, no findingsIssue: AP-381
Summary by CodeRabbit
New Features
__client/config.jsonendpoint.__client/config.jsonwith monitoring DSN and environment (no DSN returnsnull).Bug Fixes
Chores
SENTRY_DSN.