Skip to content

feat(observability): add Sentry error tracking across backend, web, and mobile#25

Merged
GRACENOBLE merged 2 commits into
mainfrom
observability.sentry
Jun 15, 2026
Merged

feat(observability): add Sentry error tracking across backend, web, and mobile#25
GRACENOBLE merged 2 commits into
mainfrom
observability.sentry

Conversation

@GRACENOBLE

@GRACENOBLE GRACENOBLE commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Backendsentry-go v0.46.2 + sentry-go/gin: SentryMiddleware(dsn) registered first in the Gin chain (no-op when SENTRY_DSN is unset); panics are re-raised after capture so the existing Recovery middleware still handles them
  • Web@sentry/nextjs v10.57.0: per-runtime config files (client / server / edge), next.config.ts wrapped with withSentryConfig, opt-in via NEXT_PUBLIC_SENTRY_DSN
  • Mobilesentry-android v8.14.0: initialised in MainActivity.onCreate before setContent, guarded by BuildConfig.SENTRY_DSN (empty string default = disabled); DSN is injected at build time, never in source
  • Docs — new observability.md for all three layers; stale bootstrap, routing, middleware, environment docs corrected for Firebase additions; new auth.md created

Activating Sentry

Set the DSN in the appropriate env file — all three default to disabled:

Layer Variable File
Backend SENTRY_DSN backend/.env
Web NEXT_PUBLIC_SENTRY_DSN web/.env.local
Mobile SENTRY_DSN (build-time) buildConfigField override or -PSENTRY_DSN=... CLI flag

Fill in org and project in web/next.config.ts to enable source map uploads.

Test plan

  • Backend: go test ./internal/transport/middleware/...TestSentryMiddleware_NoDSN_IsNoOp and TestSentryMiddleware_WithDSN_ReturnsHandler pass
  • Backend: go test ./internal/bootstrap/...TestLoadConfig_SentryDSN_Set and TestLoadConfig_SentryDSN_Unset pass
  • Web: pnpm test — 3 Sentry config import tests pass; pnpm build clean
  • Mobile: ./gradlew testSentryInitTest (3 cases) passes; ./gradlew assembleDebug and ./gradlew lint clean
  • End-to-end: paste a real DSN into each env, trigger an error, verify it appears in the Sentry dashboard

Summary by CodeRabbit

  • New Features

    • Added Sentry error tracking and observability across backend, mobile, and web applications
    • Added Firebase authentication support to backend
  • Documentation

    • Added comprehensive observability and authentication documentation
    • Updated environment configuration guides with new optional settings
  • Chores

    • Added Sentry dependencies and configuration files across platforms
    • Updated environment variable templates with Sentry DSN and Firebase configuration options

…nd mobile

- Backend: SentryMiddleware (sentry-go v0.46.2 + sentry-go/gin), registered first in Gin middleware chain, opt-in via SENTRY_DSN env var
- Web: @sentry/nextjs v10.57.0 with client/server/edge config files, next.config wrapped with withSentryConfig, opt-in via NEXT_PUBLIC_SENTRY_DSN
- Mobile: sentry-android v8.14.0 initialised in MainActivity.onCreate, guarded by BuildConfig.SENTRY_DSN (empty by default)
- Docs: created observability.md for all three layers; fixed stale bootstrap, routing, middleware, environment docs; added auth.md
@github-actions github-actions Bot added area: backend Go REST API area: web Next.js web app area: mobile Android app (Kotlin + Jetpack Compose) type: chore Cleanup or maintenance tasks labels Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@GRACENOBLE, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 8 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5824b352-f52c-4ec8-8bd3-080eaaf2806b

📥 Commits

Reviewing files that changed from the base of the PR and between 8ff3c44 and 05dc1b8.

📒 Files selected for processing (8)
  • backend/.env.example
  • backend/docs/bootstrap.md
  • backend/docs/observability.md
  • backend/docs/routing.md
  • backend/internal/transport/middleware/sentry.go
  • mobile/app/build.gradle.kts
  • web/docs/_index.md
  • web/docs/observability.md
📝 Walkthrough

Walkthrough

Adds Sentry error-tracking integration across the Go backend, Next.js web app, and Android mobile app. Each platform reads a DSN from an environment variable, conditionally initializes Sentry (no-op when the DSN is absent), wires the SDK into the existing middleware/config pipeline, and adds unit tests and documentation.

Changes

Backend Sentry Integration

Layer / File(s) Summary
SentryMiddleware implementation and tests
backend/go.mod, backend/internal/transport/middleware/sentry.go, backend/internal/transport/middleware/sentry_test.go
Adds Sentry Go/Gin indirect dependencies, defines SentryMiddleware as a no-op when DSN is empty and a sentrygin handler with Repanic: true when non-empty, and tests both paths.
Config.SentryDSN field, bootstrap loading, and route wiring
backend/internal/bootstrap/bootstrap.go, backend/internal/bootstrap/bootstrap_test.go, backend/internal/server/server.go, backend/internal/transport/handlers/routes.go, backend/.env.example
Adds SentryDSN to Config, reads SENTRY_DSN in loadConfig, extends RegisterRoutes signature to accept sentryDSN, passes app.Config.SentryDSN in NewServer, and documents the env placeholder.
Backend documentation updates
backend/docs/observability.md, backend/docs/bootstrap.md, backend/docs/environment.md, backend/docs/middleware.md, backend/docs/routing.md, backend/docs/auth.md, backend/docs/_index.md
Adds observability page, updates bootstrap/environment/middleware/routing docs to reflect new Sentry and Firebase fields/routes, adds auth.md describing the Firebase flow end-to-end, and updates the index.

Web (Next.js) Sentry Integration

Layer / File(s) Summary
Sentry SDK setup, runtime configs, and tests
web/package.json, web/next.config.ts, web/sentry.client.config.ts, web/sentry.server.config.ts, web/sentry.edge.config.ts, web/.env.example, web/.gitignore, web/__tests__/sentry.test.ts
Adds @sentry/nextjs, creates three runtime init modules reading NEXT_PUBLIC_SENTRY_DSN, wraps nextConfig with withSentryConfig, documents the env var, fixes .gitignore to preserve .env.example, and tests that all three config modules import without error.
Web observability docs
web/docs/observability.md, web/docs/_index.md
Adds observability page covering SDK version, config file behavior, env var semantics, and withSentryConfig options; adds index entry.

Mobile (Android) Sentry Integration

Layer / File(s) Summary
Gradle dependency wiring
mobile/gradle/libs.versions.toml, mobile/app/build.gradle.kts
Adds sentry = "8.14.0" and sentry-android to the version catalog, exposes SENTRY_DSN as a buildConfigField, enables BuildConfig generation, and adds the dependency.
shouldInitSentry helper, MainActivity initialization, and unit tests
mobile/app/src/main/java/com/company/template/MainActivity.kt, mobile/app/src/test/java/com/company/template/SentryInitTest.kt
Adds shouldInitSentry(dsn) pure helper and conditional SentryAndroid.init call in onCreate, validated by three JUnit tests covering empty, blank, and non-empty DSN inputs.
Mobile observability docs
mobile/docs/observability.md, mobile/docs/_index.md
Adds observability page covering dependency, BuildConfig.SENTRY_DSN generation and override patterns, shouldInitSentry behavior, and init flow; adds index entry.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • GRACENOBLE/fullstack-template#24: This PR extends the same RegisterRoutes signature and server.go wiring introduced in #24 for Firebase auth by adding the sentryDSN parameter to the same call chain.

Suggested labels

area: backend, area: web, area: mobile, type: chore

Poem

🐇 Hop, hop, errors beware!
A DSN string floats through the air,
If empty — no-op, calm as can be,
If set — Sentry wakes, wild and free!
Three platforms patched with one little key. 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding Sentry error tracking integration across all three application layers (backend, web, mobile).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch observability.sentry

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
backend/docs/environment.md (1)

22-36: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Add SENTRY_DSN to environment variable table.

Per coding guidelines, "every new environment variable in Go loadConfig() must appear in backend/.env.example with a safe placeholder value and a comment explaining the format." The SENTRY_DSN variable is not documented in this file.

Add a row to the environment variables table (after RATE_LIMIT_BURST or near other observability config):

| `SENTRY_DSN` | `bootstrap.go`, `internal/server/server.go` | — | Sentry DSN for error tracking. Middleware is no-op when empty (optional). Format: `https://key@o0.ingest.sentry.io/projectid` |

Also ensure SENTRY_DSN appears in backend/.env.example with a safe placeholder value and comment.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/docs/environment.md` around lines 22 - 36, The SENTRY_DSN environment
variable is not documented in the environment variables table, which violates
the coding guidelines requiring all environment variables in loadConfig() to be
documented. Add a new row to the environment variables table in
backend/docs/environment.md after RATE_LIMIT_BURST with the SENTRY_DSN entry
showing it is used in bootstrap.go and internal/server/server.go, has no default
value, and explains it is for Sentry error tracking with optional usage.
Additionally, add SENTRY_DSN to backend/.env.example with a safe placeholder
value (such as a commented example URL format) and a descriptive comment
explaining its purpose and optional nature.

Source: Coding guidelines

backend/docs/middleware.md (1)

15-35: ⚠️ Potential issue | 🟠 Major

Update Registration order section to include SentryMiddleware as the first middleware.

The code in internal/transport/handlers/routes.go registers SentryMiddleware as the first handler in the chain, but the Registration order section of middleware.md omits it entirely. Update lines 15–35 to reflect the actual order:

Updated registration order
// 1. Sentry (first in chain; no-op when SENTRY_DSN is unset)
r.Use(middleware.SentryMiddleware(sentryDSN))
// 2. Recovery + logger (debug: gin.Logger, release: middleware.Logger)
r.Use(gin.Recovery(), middleware.Logger())
// 3. Rate limiter (no-op when RPS <= 0)
r.Use(middleware.RateLimit(rps, burst))
// 4. CORS
r.Use(cors.New(...))

// Global routes (no auth):
r.GET("/", h.HelloWorldHandler)
r.GET("/health", h.HealthHandler)
r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))

// Protected group — FirebaseAuth applied when verifier != nil:
api := r.Group("/api/v1")
if verifier != nil {
    api.Use(middleware.FirebaseAuth(verifier))
}
api.GET("/me", h.MeHandler)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/docs/middleware.md` around lines 15 - 35, The Registration order
section in middleware.md is missing SentryMiddleware, which is registered first
in the actual codebase. Update the section to add SentryMiddleware as item 1
with the comment indicating it is the first in chain and no-op when SENTRY_DSN
is unset, then renumber the subsequent middleware steps (Recovery + logger
becomes 2, Rate limiter becomes 3, CORS becomes 4) to match the actual
registration order in internal/transport/handlers/routes.go.
backend/docs/bootstrap.md (1)

42-51: ⚠️ Potential issue | 🟡 Minor

Update bootstrap.md to reflect SentryDSN in Config and clarify Sentry middleware initialization location.

The Config struct in the documentation (lines 27–38) is missing the SentryDSN field, which is present in the code and read in loadConfig(). Additionally, the Run sequence does not acknowledge Sentry at all, even as a no-op when the DSN is absent.

Since SentryMiddleware is initialized in server.NewServer() via RegisterRoutes() (not in bootstrap.Run()), update the documentation to:

  1. Add SentryDSN to the Config struct listing (after FirebaseServiceAccountJSON)
  2. Either note in the Run sequence that Sentry DSN is loaded but middleware is applied later, or add a note after step 7 clarifying: "Sentry middleware is attached during HTTP server routing in server.NewServer(), not in bootstrap."
Current code shows SentryDSN is loaded and applied here:
bootstrap.Run: cfg := loadConfig() reads SENTRY_DSN env var
server.NewServer: h.RegisterRoutes(..., app.Config.SentryDSN) applies middleware
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/docs/bootstrap.md` around lines 42 - 51, Update the bootstrap.md
documentation to include missing Sentry configuration details. First, add the
SentryDSN field to the Config struct listing (after FirebaseServiceAccountJSON)
to document that this environment variable is loaded during configuration.
Second, clarify in the Run sequence that while loadConfig() reads the SENTRY_DSN
environment variable as part of step 1, the actual SentryMiddleware
initialization occurs later in server.NewServer() during HTTP server routing,
not within bootstrap.Run() itself. You can either add this as a note after step
7 or mention it inline with step 1 to indicate that the DSN is loaded but the
middleware attachment happens separately in RegisterRoutes().
🧹 Nitpick comments (2)
web/__tests__/sentry.test.ts (1)

8-20: ⚡ Quick win

Strengthen these tests to verify Sentry init contract, not just import success.

Right now, imports can succeed even if config wiring breaks. Assert that init is called with expected fields (dsn, tracesSampleRate, debug) per module and environment setup.

Suggested test shape
 import { vi, describe, it, expect } from "vitest";

-vi.mock("`@sentry/nextjs`", () => ({
-  init: vi.fn(),
-}));
+const initMock = vi.fn();
+vi.mock("`@sentry/nextjs`", () => ({ init: initMock }));

 describe("Sentry config", () => {
+  it("server config calls init with expected options", async () => {
+    process.env.NEXT_PUBLIC_SENTRY_DSN = "https://example@sentry.io/123";
+    initMock.mockClear();
+    await import("../sentry.server.config");
+    expect(initMock).toHaveBeenCalledWith(
+      expect.objectContaining({
+        dsn: "https://example@sentry.io/123",
+        tracesSampleRate: 1.0,
+        debug: false,
+      }),
+    );
+  });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/__tests__/sentry.test.ts` around lines 8 - 20, The current tests for the
Sentry configuration modules (sentry.client.config, sentry.server.config,
sentry.edge.config) only verify that imports succeed without checking the actual
Sentry initialization contract. Replace the simple import resolution checks with
tests that mock the Sentry init function and verify it is called with the
expected configuration fields. For each of the three test cases (client, server,
edge), mock the Sentry module's init function before importing the config
module, then assert that init was called with an object containing the required
fields: dsn, tracesSampleRate, and debug. This ensures the configuration modules
not only load but actually initialize Sentry correctly with the proper setup.
web/sentry.server.config.ts (1)

5-5: Use environment-driven trace sampling instead of hardcoded 1.0 for production.

Both Sentry configs hardcode tracesSampleRate: 1.0, which captures every transaction and can lead to excessive telemetry volume and cost in production. Sentry recommends 10–20% (0.1–0.2) for production environments.

Update both files to read the sampling rate from an environment variable or apply a safer default for production:

  • web/sentry.server.config.ts#L5
  • web/sentry.edge.config.ts#L5

Consider using a tracesSampler function for more granular control across different transaction types.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/sentry.server.config.ts` at line 5, The hardcoded tracesSampleRate: 1.0
in both web/sentry.server.config.ts (line 5) and web/sentry.edge.config.ts (line
5) captures every transaction, leading to excessive telemetry volume and cost in
production. Replace the hardcoded 1.0 value at both locations with an
environment-driven sampling rate read from an environment variable (e.g.,
SENTRY_TRACES_SAMPLE_RATE) with a safer production default like 0.1 or 0.2.
Alternatively, consider implementing a tracesSampler function to provide more
granular control based on transaction types across both configuration files.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/.env.example`:
- Around line 14-16: The FIREBASE_SERVICE_ACCOUNT_JSON and FIREBASE_PROJECT_ID
environment variables use inline comments (=# format) which standard dotenv
parsers interpret as literal values rather than comments. Remove the inline
comment text from these variables, leaving them with empty values (=), and move
the guidance information to separate comment-only lines placed above each
variable definition, matching the correct format already used by SENTRY_DSN.

In `@backend/docs/bootstrap.md`:
- Around line 30-37: The Config struct documentation is incomplete and missing
an entry for the SentryDSN field that exists in the actual Config struct. Add
the SentryDSN field to the documentation list with the same formatting and
structure as the other fields (Port, Env, DB, RedisURL, RateLimitRPS,
RateLimitBurst, FirebaseProjectID, FirebaseServiceAccountJSON), specifying it as
a string type to match the implementation.

In `@backend/docs/observability.md`:
- Around line 66-68: The markdown code fence containing the SENTRY_DSN
configuration example is missing a language label, which violates markdown lint
rules. Add "dotenv" as the language specifier immediately after the opening
triple backticks (```) to properly label this as a dotenv environment file
format.

In `@backend/docs/routing.md`:
- Line 54: The RegisterRoutes function signature documented in the routing.md
file is missing the sentryDSN parameter that is present in the actual
implementation. Update the documented RegisterRoutes method signature to include
the sentryDSN string parameter as the fourth parameter (after verifier).
Additionally, add documentation explaining that this sentryDSN parameter is
passed to middleware.SentryMiddleware(sentryDSN) in the middleware chain to
ensure the documentation accurately reflects the current implementation.

In `@backend/internal/transport/handlers/routes.go`:
- Around line 20-24: The SentryMiddleware function is discarding the error from
sentry.Init(...) and RegisterRoutes has no error return path, which silently
swallows Sentry initialization failures. Update the SentryMiddleware function
signature at backend/internal/transport/middleware/sentry.go:16 to return
(gin.HandlerFunc, error) instead of just gin.HandlerFunc, capturing and
returning the error from sentry.Init(...). Then update the RegisterRoutes
function signature at backend/internal/transport/handlers/routes.go:20 to return
(http.Handler, error) instead of just http.Handler, and propagate the error
returned by SentryMiddleware when it is called. Finally, update the call site in
backend/internal/server/server.go that invokes RegisterRoutes to handle the
returned error instead of ignoring it.

In `@backend/internal/transport/middleware/sentry.go`:
- Around line 16-17: The error returned by sentry.Init() in the initialization
block is being silently discarded with `_`, violating the principle of not
swallowing errors. Since the function returns gin.HandlerFunc and cannot return
an error, address this by either: (1) adding a logger parameter and logging the
actual error from sentry.Init() to surface configuration issues, (2) adding a
comment explaining why silent fallback is intentional as a tradeoff for graceful
degradation of observability, or (3) moving the Sentry initialization and
validation logic to server.NewServer where you have access to *slog.Logger and
can properly validate the initialization before wiring the middleware. Choose
the approach that aligns with your error handling strategy.

In `@mobile/app/build.gradle.kts`:
- Line 22: The buildConfigField for SENTRY_DSN on line 22 is hardcoded to an
empty string instead of reading from local.properties. Replace the hardcoded
empty value by reading the SENTRY_DSN property from the gradle properties (which
loads from local.properties), using a safe pattern like project.findProperty()
with an appropriate default value if the property is not defined. This allows
the DSN to be injected at build time from local.properties without modifying
tracked files.

In `@web/docs/_index.md`:
- Line 13: The documentation index table in the Observability row contains a
stale reference to `.env.local.example` which no longer exists. Replace this
filename with `web/.env.example` in the table entry on line 13 to point to the
correct environment configuration example file and ensure the documentation
reference is accurate.

In `@web/docs/observability.md`:
- Around line 49-51: The fenced code block containing the Sentry DSN
configuration is missing a language identifier after the opening triple
backticks, which violates markdown linting rule MD040. Add a language identifier
to the code fence at line 49 by changing the opening ``` to ```env (or ```bash)
to specify that this is environment variable configuration and satisfy lint
compliance.

---

Outside diff comments:
In `@backend/docs/bootstrap.md`:
- Around line 42-51: Update the bootstrap.md documentation to include missing
Sentry configuration details. First, add the SentryDSN field to the Config
struct listing (after FirebaseServiceAccountJSON) to document that this
environment variable is loaded during configuration. Second, clarify in the Run
sequence that while loadConfig() reads the SENTRY_DSN environment variable as
part of step 1, the actual SentryMiddleware initialization occurs later in
server.NewServer() during HTTP server routing, not within bootstrap.Run()
itself. You can either add this as a note after step 7 or mention it inline with
step 1 to indicate that the DSN is loaded but the middleware attachment happens
separately in RegisterRoutes().

In `@backend/docs/environment.md`:
- Around line 22-36: The SENTRY_DSN environment variable is not documented in
the environment variables table, which violates the coding guidelines requiring
all environment variables in loadConfig() to be documented. Add a new row to the
environment variables table in backend/docs/environment.md after
RATE_LIMIT_BURST with the SENTRY_DSN entry showing it is used in bootstrap.go
and internal/server/server.go, has no default value, and explains it is for
Sentry error tracking with optional usage. Additionally, add SENTRY_DSN to
backend/.env.example with a safe placeholder value (such as a commented example
URL format) and a descriptive comment explaining its purpose and optional
nature.

In `@backend/docs/middleware.md`:
- Around line 15-35: The Registration order section in middleware.md is missing
SentryMiddleware, which is registered first in the actual codebase. Update the
section to add SentryMiddleware as item 1 with the comment indicating it is the
first in chain and no-op when SENTRY_DSN is unset, then renumber the subsequent
middleware steps (Recovery + logger becomes 2, Rate limiter becomes 3, CORS
becomes 4) to match the actual registration order in
internal/transport/handlers/routes.go.

---

Nitpick comments:
In `@web/__tests__/sentry.test.ts`:
- Around line 8-20: The current tests for the Sentry configuration modules
(sentry.client.config, sentry.server.config, sentry.edge.config) only verify
that imports succeed without checking the actual Sentry initialization contract.
Replace the simple import resolution checks with tests that mock the Sentry init
function and verify it is called with the expected configuration fields. For
each of the three test cases (client, server, edge), mock the Sentry module's
init function before importing the config module, then assert that init was
called with an object containing the required fields: dsn, tracesSampleRate, and
debug. This ensures the configuration modules not only load but actually
initialize Sentry correctly with the proper setup.

In `@web/sentry.server.config.ts`:
- Line 5: The hardcoded tracesSampleRate: 1.0 in both
web/sentry.server.config.ts (line 5) and web/sentry.edge.config.ts (line 5)
captures every transaction, leading to excessive telemetry volume and cost in
production. Replace the hardcoded 1.0 value at both locations with an
environment-driven sampling rate read from an environment variable (e.g.,
SENTRY_TRACES_SAMPLE_RATE) with a safer production default like 0.1 or 0.2.
Alternatively, consider implementing a tracesSampler function to provide more
granular control based on transaction types across both configuration files.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ab240e5d-2a9d-4e9a-80f2-17e8ce64f4e3

📥 Commits

Reviewing files that changed from the base of the PR and between 38eacd3 and 8ff3c44.

⛔ Files ignored due to path filters (2)
  • backend/go.sum is excluded by !**/*.sum
  • web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (31)
  • backend/.env.example
  • backend/docs/_index.md
  • backend/docs/auth.md
  • backend/docs/bootstrap.md
  • backend/docs/environment.md
  • backend/docs/middleware.md
  • backend/docs/observability.md
  • backend/docs/routing.md
  • backend/go.mod
  • backend/internal/bootstrap/bootstrap.go
  • backend/internal/bootstrap/bootstrap_test.go
  • backend/internal/server/server.go
  • backend/internal/transport/handlers/routes.go
  • backend/internal/transport/middleware/sentry.go
  • backend/internal/transport/middleware/sentry_test.go
  • mobile/app/build.gradle.kts
  • mobile/app/src/main/java/com/company/template/MainActivity.kt
  • mobile/app/src/test/java/com/company/template/SentryInitTest.kt
  • mobile/docs/_index.md
  • mobile/docs/observability.md
  • mobile/gradle/libs.versions.toml
  • web/.env.example
  • web/.gitignore
  • web/__tests__/sentry.test.ts
  • web/docs/_index.md
  • web/docs/observability.md
  • web/next.config.ts
  • web/package.json
  • web/sentry.client.config.ts
  • web/sentry.edge.config.ts
  • web/sentry.server.config.ts

Comment thread backend/.env.example Outdated
Comment thread backend/docs/bootstrap.md
Comment thread backend/docs/observability.md Outdated
Comment thread backend/docs/routing.md Outdated
Comment thread backend/internal/transport/handlers/routes.go
Comment thread backend/internal/transport/middleware/sentry.go Outdated
Comment thread mobile/app/build.gradle.kts Outdated
Comment thread web/docs/_index.md Outdated
Comment thread web/docs/observability.md Outdated
- backend/.env.example: separate inline comments from FIREBASE var values so dotenv parsers don't treat # as a literal value
- backend/docs/bootstrap.md: add missing SentryDSN field to Config struct docs
- backend/docs/routing.md: update RegisterRoutes signature and NewServer wiring snippet to include sentryDSN param
- backend/docs/observability.md: add dotenv language tag to code fence
- middleware/sentry.go: log sentry.Init errors instead of discarding with _; degrade to no-op on failure
- mobile/build.gradle.kts: read SENTRY_DSN from local.properties (gitignored) instead of hardcoding empty string
- web/docs: fix stale .env.local.example references to .env.example; add language tag to code fence

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@GRACENOBLE GRACENOBLE merged commit ca3564f into main Jun 15, 2026
5 checks passed
@GRACENOBLE GRACENOBLE deleted the observability.sentry branch June 15, 2026 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: backend Go REST API area: mobile Android app (Kotlin + Jetpack Compose) area: web Next.js web app type: chore Cleanup or maintenance tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant