Skip to content

fix(marketing): suppress expected session fetch errors from Sentry - #1237

Closed
saddlepaddle wants to merge 1 commit into
mainfrom
fix-failed-to-get-session-api-error-marketing-17
Closed

saddlepaddle wants to merge 1 commit into
mainfrom
fix-failed-to-get-session-api-error-marketing-17

Conversation

@saddlepaddle

@saddlepaddle saddlepaddle commented Feb 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds beforeSend filter in Sentry server and edge configs to drop APIError: Failed to get session events (MARKETING-17)
  • Downgrades console.error to console.warn in CTAButtons since failed session fetch is expected behavior on the marketing site
  • Removes unused error variable from catch block

Context

The marketing site's CTAButtons component calls auth.api.getSession() on every page to show logged-in vs logged-out CTAs in the header. When visitors have stale or invalid cookies (e.g., leftover Clerk cookies from the auth migration), BetterAuth throws an APIError("Failed to get session"). This is expected and non-actionable — the component already gracefully falls back to showing logged-out CTAs — but it was generating Sentry noise (94 events).

Test plan

  • Typecheck passes (bun run typecheck --filter=@superset/marketing)
  • Lint passes (bun run lint:fix)
  • Verify in Sentry that MARKETING-17 stops receiving new events after deploy

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of session retrieval failures on the marketing site to prevent unnecessary disruptions.
  • Chores

    • Refined error tracking to exclude expected session-related failures.

…ARKETING-17)

The marketing site calls getSession to show logged-in vs logged-out CTAs.
When visitors have stale/invalid cookies, BetterAuth throws an APIError
which is expected and non-actionable. This was generating noise in Sentry
(94 events). Fix by:
- Adding beforeSend filter in Sentry server/edge configs to drop these events
- Downgrading console.error to console.warn since failed session is expected
@coderabbitai

coderabbitai Bot commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The PR adds Sentry filtering to exclude "Failed to get session" APIError events from error reporting across marketing site edge and server configurations, and updates the CTAButtons component to log session retrieval failures as warnings instead of errors, treating them as expected behavior.

Changes

Cohort / File(s) Summary
Sentry Configuration
apps/marketing/sentry.edge.config.ts, apps/marketing/sentry.server.config.ts
Both files add a beforeSend filter function to the Sentry.init configuration that drops events containing APIError exceptions with "Failed to get session" message, allowing other events to pass through.
Component Error Handling
apps/marketing/src/app/components/CTAButtons/CTAButtons.tsx
Changes session fetch error handling from console.error to console.warn with updated comments, reflecting that session retrieval failures are expected and non-critical on the marketing site.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A session came knockin', but sometimes it fails,
No crash, just a warning when cookies turn stale,
We filter the noise from our error report,
Sentry stays silent on errors of short,
Expected mishaps won't bring down the site! 📝✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding Sentry filters to suppress expected session fetch errors from the marketing site.
Description check ✅ Passed The PR description includes a clear summary, context explaining why the change is needed, and a test plan, though it doesn't fully match the template structure with explicit sections.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-failed-to-get-session-api-error-marketing-17

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.

@github-actions

github-actions Bot commented Feb 5, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ✅ Electric Fly.io app
  • ⚠️ Streams Fly.io app

Thank you for your contribution! 🎉

@Kitenite Kitenite left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review: LGTM

Clean, well-scoped PR. The approach (Sentry beforeSend filter + console.warn downgrade) is the standard way to suppress expected-but-noisy errors.

What's good

  • Defensive filtering — checks both e.type === "APIError" and e.value?.includes("Failed to get session"), so it won't accidentally suppress unrelated errors.
  • Correct log level — downgrading console.error → console.warn is appropriate since the session fetch failure is expected and non-actionable on the marketing site.
  • Parameterless catch {} — clean removal of the unused error variable.
  • Solid PR description — clear context on why this is expected (stale Clerk cookies), the Sentry noise impact (94 events), and the fallback behavior.

Minor nit (non-blocking)

The beforeSend block is copy-pasted identically across sentry.edge.config.ts and sentry.server.config.ts. These files were already identical before this PR so this follows the existing pattern, but if more filters accumulate over time it may be worth extracting a shared config helper. Not needed now though.

@Kitenite Kitenite left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review: LGTM

Clean, well-scoped PR. The approach (Sentry beforeSend filter + console.warn downgrade) is the standard way to suppress expected-but-noisy errors.

What's good

  • Defensive filtering — checks both e.type === "APIError" and e.value?.includes("Failed to get session"), so it won't accidentally suppress unrelated errors.
  • Correct log level — downgrading console.error to console.warn is appropriate since the session fetch failure is expected and non-actionable on the marketing site.
  • Parameterless catch {} — clean removal of the unused error variable.
  • Solid PR description — clear context on why this is expected (stale Clerk cookies), the Sentry noise impact (94 events), and the fallback behavior.

Minor nit (non-blocking)

The beforeSend block is copy-pasted identically across sentry.edge.config.ts and sentry.server.config.ts. These files were already identical before this PR so this follows the existing pattern, but if more filters accumulate over time it may be worth extracting a shared config helper. Not needed now though.

@Kitenite
Kitenite deleted the fix-failed-to-get-session-api-error-marketing-17 branch February 12, 2026 04:32

This branch was previously deployed

1 inactive deployment
preview — 6b6f6d22 Deployed Feb 5, 2026 by saddlepaddle via Deploy Admin #1534
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.

2 participants