Skip to content

Fix Sentry noise: downgrade unknown-feature warning from reportError to console.warn#2759

Open
bengotow wants to merge 3 commits into
masterfrom
claude/awesome-ritchie-feature-usage-fix
Open

Fix Sentry noise: downgrade unknown-feature warning from reportError to console.warn#2759
bengotow wants to merge 3 commits into
masterfrom
claude/awesome-ritchie-feature-usage-fix

Conversation

@bengotow

Copy link
Copy Markdown
Collaborator

What was observed

FeatureUsageStore._dataForFeature() called AppEnv.reportError() — which routes to Sentry — whenever a feature key was absent from the user's identity featureUsage map:

if (!usage[feature]) {
  AppEnv.reportError(new Error(`Warning: No usage information available for ${feature}`));
  return EMPTY_FEATURE_USAGE;
}

GrammarCheckToggle.render() calls FeatureUsageStore.isUsable('grammar-check') on every render. Since grammar-check is a newly shipped feature, the server may not have added it to all existing users' identity objects yet. This means every logged-in user who opens the composer generates a "Warning: No usage information available for grammar-check" Sentry event on each render, until their identity is refreshed from the server.

The same pattern would fire for any other feature that is added to the app before the server adds it to the identity schema.

Root cause

AppEnv.reportError was used here to catch coding mistakes (e.g. a typo in a feature ID), but it is too aggressive for production. A feature being absent from the identity is an expected transient state during new-feature rollout, not an application error. Using reportError floods Sentry with noise that obscures real issues.

Fix

Downgrade to console.warn so the warning is still visible in DevTools without reaching Sentry. The return value (EMPTY_FEATURE_USAGE, which causes isUsable to return true) is unchanged, so the feature defaults to "usable" during the rollout window — the correct behaviour.

Test plan

  • Open a composer while logged in — no Sentry event for "No usage information available for grammar-check"
  • Verify console.warn still appears in DevTools when a feature is missing from identity
  • Existing feature-usage-store specs still pass

🤖 Generated with Claude Code

https://claude.ai/code/session_01Wa5rMERDupj7BbeEMtKXe3


Generated by Claude Code

@indent-staging

indent-staging Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor
PR Summary

Replaces AppEnv.reportError with console.warn inside _FeatureUsageStore._dataForFeature when a feature key is missing from the identity's featureUsage map. This stops Sentry noise during new-feature rollouts (e.g. grammar-check) where the server-side identity hasn't yet been updated with the new feature, while keeping the existing EMPTY_FEATURE_USAGE fallback so the feature still defaults to "usable".

  • Swap AppEnv.reportError(new Error(...)) for a console.warn (wrapped per prettier) with a clearer "defaulting to allowed" message in app/src/flux/stores/feature-usage-store.tsx, and add an inline comment explaining why this is not reported to Sentry.
  • Update the matching jasmine spec in app/spec/stores/feature-usage-store-spec.ts so the "returns true if no quota is present" test spies on console.warn instead of AppEnv.reportError.
  • Re-format a pre-existing long if condition in app/internal_packages/composer-grammar-check/lib/grammar-check-store.ts to clear an unrelated prettier lint error that was also blocking CI. No behavior change.
  • No behavior change for callers — return value remains EMPTY_FEATURE_USAGE (quota: 0isUsable returns true).

Issues

No issues found.

CI Checks

All CI checks pass on 40ebc6f8: lint, typecheck, and the full jasmine spec suite (including the updated FeatureUsageStore › isUsable › returns true if no quota is present for the feature spec) are green.

Custom Rules 3 rules evaluated, 3 passed, 0 failed

Passing This is a longer title to see what happens when they are too long to fit
Passing B
Passing Ben Rule

View all rules

claude added 2 commits June 26, 2026 14:24
…to console.warn

AppEnv.reportError (which sends to Sentry) was called inside _dataForFeature
whenever a feature key was absent from the identity's featureUsage map. This
is expected during new-feature rollout — the server hasn't necessarily added
the feature to all users' identities yet. For example, every logged-in user
who opened the composer after the grammar-check feature shipped would generate
a "Warning: No usage information available for grammar-check" Sentry event on
every render of GrammarCheckToggle.

Change to console.warn so the warning is still visible in devtools without
flooding Sentry. Return value (EMPTY_FEATURE_USAGE) is unchanged, so the
feature defaults to "usable" during the rollout window.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wa5rMERDupj7BbeEMtKXe3
- grammar-check-store.ts line 104: wrap long if condition onto multiple lines
- feature-usage-store.tsx line 162: wrap console.warn argument onto its own line

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wa5rMERDupj7BbeEMtKXe3
@bengotow bengotow force-pushed the claude/awesome-ritchie-feature-usage-fix branch from de3a421 to ca6f7d6 Compare June 26, 2026 14:25
…tError

The test for the unknown-feature path was asserting that AppEnv.reportError
was called, which matched the old behavior. Now that the path uses console.warn
to avoid flooding Sentry, update the spy and assertion to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wa5rMERDupj7BbeEMtKXe3
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