Skip to content

Notifications: report standalone widget errors to Sentry#111825

Draft
StevenDufresne wants to merge 1 commit into
trunkfrom
add/notifications-sentry-error-logging
Draft

Notifications: report standalone widget errors to Sentry#111825
StevenDufresne wants to merge 1 commit into
trunkfrom
add/notifications-sentry-error-logging

Conversation

@StevenDufresne

Copy link
Copy Markdown
Contributor

Proposed Changes

  • Add a small Sentry wrapper (apps/notifications/src/lib/sentry.ts) — reuses the shared Calypso DSN and tags events as the wp-admin notifications surface. captureException is a no-op until initSentry runs, so the shared REST client stays silent on surfaces that don't opt in (the old panel, the in-Calypso popover).
  • Wire init into the standalone-app boot; catch the previously-unhandled createClient() rejection and the swallowed tracks/locale catches.
  • Add a React error boundary with a fallback (message + Reload) so a render crash is reported and recoverable instead of unmounting to a dead spinner.
  • Report the first top-window getNotes() failure of a streak — the path that retries forever without ever clearing the loading state.

Why are these changes being made?

The wp-admin notifications widget shipped with no error reporting, so the recent redesign's failure modes (a hung boot, a render crash, a stuck fetch) reached users only as an endless spinner with zero signal on our side. This makes the next occurrence observable and gives users a way to recover. It is instrumentation, not the root-cause fix — it lets us confirm which trigger is actually firing in production.

Testing Instructions

  • yarn test-apps apps/notifications — new suites for the Sentry wrapper and the error boundary pass (44 tests total).
  • apps/notifications typechecks and lints clean.
  • Manual: load the widget with the network offline or third-party cookies blocked → expect a Sentry event plus the fallback message instead of an endless spinner.

Notes / follow-ups

  • Source-map upload (sentry-webpack-plugin) for symbolicated stack traces is a sensible follow-up.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • For UI changes, have you tested the affected components in dark mode?
  • Have you tested accessibility for your changes?
  • Have you used memoizing on expensive computations?
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-aUh-p2)?

🤖 Generated with Claude Code

The wp-admin notifications widget had no error reporting, so boot
failures and render crashes surfaced only as an endless spinner with no
signal on our side. Add Sentry to the standalone app, capture the known
silent failure points, and show a recoverable fallback instead of a
frozen spinner.

- Add a small Sentry wrapper (src/lib/sentry); reuse the shared Calypso
  DSN, tag events as the wp-admin notifications surface. captureException
  is a no-op until initSentry runs, so the shared REST client stays
  silent on surfaces that don't opt in (old panel, in-Calypso popover).
- Wire init into the standalone-app boot; catch the createClient()
  rejection (previously unhandled) and the swallowed tracks/locale
  catches.
- Add an error boundary with a fallback (message + reload) so a render
  crash is reported instead of unmounting to a dead spinner.
- Report the first top-window getNotes() failure of a streak — the path
  that retries forever without ever clearing the loading state.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@matticbot

Copy link
Copy Markdown
Contributor

This PR modifies the release build for the following Calypso Apps:

For info about this notification, see here: PCYsg-OT6-p2

  • help-center
  • notifications
  • wpcom-block-editor

To test WordPress.com changes, run install-plugin.sh $pluginSlug add/notifications-sentry-error-logging on your sandbox.

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