Skip to content

fix: avoid analytics error banner when tracking is disabled - #549

Open
pepepeboom wants to merge 1 commit into
HemmeligOrg:v7from
pepepeboom:fix/analytics-disabled-error-banner
Open

fix: avoid analytics error banner when tracking is disabled#549
pepepeboom wants to merge 1 commit into
HemmeligOrg:v7from
pepepeboom:fix/analytics-disabled-error-banner

Conversation

@pepepeboom

@pepepeboom pepepeboom commented Jul 23, 2026

Copy link
Copy Markdown

Summary

  • use the existing raw Hono client for best-effort page-view tracking
  • keep expected non-2xx analytics responses out of the global error store

Why

When HEMMELIG_ANALYTICS_ENABLED=false, POST /api/analytics/track returns 403. The normal API client turns that expected response into a user-visible global error, which contradicts the tracker's silent-failure behavior.

Using apiRaw preserves the server-side disable check while preventing the red error banner.

Testing

The change is type-preserving because api and apiRaw use the same generated AppType client. Repository CI should validate formatting and build behavior.

Fixes #477

Summary by CodeRabbit

  • Bug Fixes
    • Improved page-view analytics event delivery by using the appropriate request handling for tracking events.

Use the raw API client for best-effort page-view tracking so expected non-2xx responses do not enter the global error store. Fixes HemmeligOrg#477.
@pepepeboom
pepepeboom requested a review from bjarneo as a code owner July 23, 2026 09:55
@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 54fc09b5-b843-4056-b25e-ae63d1c850b9

📥 Commits

Reviewing files that changed from the base of the PR and between 08511da and 7055654.

📒 Files selected for processing (1)
  • src/lib/analytics.ts

📝 Walkthrough

Walkthrough

trackPageView now submits analytics events through apiRaw instead of api, including the updated module import and POST call.

Changes

Analytics tracking

Layer / File(s) Summary
Use raw client for analytics dispatch
src/lib/analytics.ts
The page-view tracking function imports apiRaw and posts normalized paths through apiRaw.analytics.track.$post(...).

Estimated code review effort: 2 (Simple) | ~5 minutes

Suggested reviewers: bjarneo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: preventing analytics tracking from surfacing an error banner when disabled.
Linked Issues check ✅ Passed The change uses the raw client for page-view tracking, which should keep disabled analytics failures silent and prevent the frontend error banner.
Out of Scope Changes check ✅ Passed The PR is narrowly scoped to the analytics tracking request and does not introduce unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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.

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.

Setting ENV "HEMMELIG_ANALYTICS_ENABLED=false" shows red error banner on frontend

1 participant