Skip to content

Develop - #38

Merged
unjica merged 4 commits into
mainfrom
develop
Apr 19, 2026
Merged

unjica merged 4 commits into
mainfrom
develop

Conversation

@unjica

@unjica unjica commented Apr 19, 2026 •

Copy link
Copy Markdown
Collaborator

Update dependencies and enhance API observability

  • Added @sentry/node for improved error tracking and monitoring.
  • Refactored API initialization to modularize route registration with rate limiting based on environment settings.
  • Updated ENTITLEMENTS.md to reflect implementation status and future plans for retention enforcement.
  • Adjusted pnpm-lock.yaml to include new dependencies and versions for better compatibility.

Note

Medium Risk
Changes request handling at the Fastify entrypoint (CORS behavior in production and per-scope rate limiting), which can impact client access and traffic patterns. Adds optional Sentry initialization and error capture, introducing new runtime dependencies and startup-order sensitivity.

Overview
Adds optional Sentry-based observability to the API: index.ts now initializes Sentry (when SENTRY_DSN is set) before loading the app, and Fastify gets a request ID generator plus an onError hook that logs structured error context and reports exceptions to Sentry.

Refactors server setup to apply environment-driven CORS (CORS_ORIGINS/DASHBOARD_ORIGIN allowlist in prod) and scoped rate limiting with separate configurable caps for public, ingest, auth, and API surfaces (RATE_LIMIT_*_MAX). Documentation is updated to clarify which entitlement/plan limits are implemented vs still defaults.

Reviewed by Cursor Bugbot for commit 205cea3. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • Added error tracking and logging capabilities for enhanced observability
    • Enhanced CORS configuration with environment-aware origin controls for production deployments
    • Implemented per-scope rate limiting with category-specific request caps for ingest, auth, and API endpoints
    • Added request ID tracking for improved request traceability
  • Documentation

    • Updated entitlements documentation clarifying implementation status of platform features

unjica added 2 commits April 19, 2026 14:10
- Integrated Sentry for error tracking and observability.
- Updated CORS configuration to use a dedicated build function.
- Implemented scoped rate limiting for ingest, auth, and API routes to improve performance and control.
- Added implementation status section to documentation for better alignment with code.
…opentelemetry' packages with updated versions. Adjusted 'next' version references to include '@opentelemetry/api'.
@coderabbitai

coderabbitai Bot commented Apr 19, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@unjica has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 3 minutes and 5 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 3 minutes and 5 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Free

Run ID: e7819015-6559-4827-b956-a215a50293cf

📥 Commits

Reviewing files that changed from the base of the PR and between 2ad7394 and 205cea3.

📒 Files selected for processing (4)
  • apps/api/src/app.ts
  • apps/api/src/index.ts
  • apps/api/src/lib/observability.ts
  • apps/api/src/lib/rate-limit-env.ts
📝 Walkthrough

Walkthrough

This pull request introduces observability infrastructure by integrating Sentry for error tracking and request logging, refactors rate limiting from global to per-scope configuration, implements dynamic CORS origin validation based on environment variables, and reorganizes app route registration including moving project dashboard routes into the /api scope.

Changes

Cohort / File(s) Summary
Dependency & Core App Setup
apps/api/package.json, apps/api/src/app.ts
Added Sentry dependency. Refactored app initialization to conditionally initialize Sentry, register observability hooks, generate request IDs, apply environment-aware CORS config, and implement per-scope rate limiting instead of global registration. Routes reorganized with project dashboard moved into /api scope.
Configuration Utilities
apps/api/src/lib/cors-config.ts, apps/api/src/lib/rate-limit-env.ts, apps/api/src/lib/observability.ts
New utility modules: CORS builder with environment-aware origin validation (permissive in non-prod, allowlist-based in prod); rate limit configuration with per-category caps (ingest, auth, api) and test overrides; observability module with Sentry initialization guard, error logging hook, and request ID generation.
Documentation
docs/ENTITLEMENTS.md
Added implementation status section clarifying which entitlement features are coded versus pending, noting that PLAN_LIMITS defaults are not fully enforced in routes yet and retention by tier is unimplemented.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 Sentry now watches from on high,
With errors caught as they fly by,
Rate limits scoped, just right and tight,
CORS origins burning bright,
Observability takes its flight! ✨


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread apps/api/src/lib/observability.ts Resolved
Comment thread apps/api/src/lib/rate-limit-env.ts Resolved
- Moved Sentry initialization to index.ts to ensure it runs before app imports for proper instrumentation.
- Updated rate limit parsing logic to enforce positive values only, enhancing validation.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0b34c6c. Configure here.

Comment thread apps/api/src/app.ts Resolved
- Introduced a new rate limit function for public endpoints to enhance API performance.
- Refactored the health check endpoint to be registered within a scoped Fastify instance for better organization and maintainability.
- Ensured the health check can verify database connectivity based on an environment variable, maintaining existing functionality.
@unjica unjica self-assigned this Apr 19, 2026
@unjica
unjica merged commit f253926 into main Apr 19, 2026
2 checks passed
unjica added a commit that referenced this pull request Jul 18, 2026
FelineFantasy pushed a commit to FelineFantasy/telemetry-tracker that referenced this pull request Jul 20, 2026
Override transitive shell-quote so react-devtools-core and @flydotio/dockerfile resolve the CVE-2026-9277 patched release.

Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant