Skip to content

Conversation

@valoriecarli
Copy link
Contributor

@valoriecarli valoriecarli commented Dec 11, 2025

Existing @commercetools-frontend/sentry package is not compatible with react 19 and causing peer dependency conflicts. Official React 19 support was added in Sentry v8.

References:
https://commercetools.atlassian.net/browse/CRAFT-1995
#3879

Note that this PR intentionally keeps deprecated Sentry v8 types (Event, Extra, Extras) for now to minimize breaking changes.


1.) Upgraded the following Sentry packages from v7.120.4 → v8.55.0 and resolved breaking changes:
@sentry/react, @sentry/browser, @sentry/types

  1. API Migration
// v7 (deprecated)
Sentry.configureScope((scope) => {  scope.clear();});

// v8 (new API)
Sentry.getCurrentScope().clear();
  1. TS Fixes - Sentry v8 introduced stricter types for the beforeSend callback:

Issues:

  • v8 requires both event and hint parameters
  • Return type changed from Event to ErrorEvent | null
  • Importing ErrorEvent from @sentry/types shadowed the global DOM ErrorEvent type

Resolutions:

  • Aliased import as SentryErrorEvent to avoid name collision with DOM types
  • Added _hint parameter (underscore prefix for intentionally unused param)
  • Cast return type as SentryErrorEvent (safe since beforeSend only receives error events)

4.) Added a few tests to ensures the v8 API migration (configureScope → getCurrentScope()) works correctly.


Testing notes

**dependencies:**
+ @commercetools-frontend/sentry 24.12.0
- @sentry/react 7.120.4

 WARN  Issues with peer dependencies found
.
└─┬ @commercetools-frontend/sentry 24.12.0
  └─┬ @sentry/react 7.120.4
    └── ✕ unmet peer react@"15.x || 16.x || 17.x || 18.x": found 19.2.1
    
    

dependencies:

- @commercetools-frontend/sentry 24.12.0
+ @commercetools-frontend/sentry 0.0.0-CRAFT-1995-upgrade-sentry-react-20251211194319 (24.12.0 is available)

Done in 3.4s using pnpm v9.15.9

@valoriecarli valoriecarli requested a review from a team as a code owner December 11, 2025 16:46
@changeset-bot
Copy link

changeset-bot bot commented Dec 11, 2025

🦋 Changeset detected

Latest commit: 2fb6ff3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 36 packages
Name Type
@commercetools-frontend/sentry Patch
@commercetools-frontend/actions-global Patch
@commercetools-frontend/application-components Patch
@commercetools-frontend/application-shell-connectors Patch
@commercetools-frontend/application-shell Patch
@commercetools-frontend/i18n Patch
@commercetools-frontend/l10n Patch
@commercetools-frontend/permissions Patch
@commercetools-frontend/react-notifications Patch
@commercetools-applications/merchant-center-template-starter-typescript Patch
@commercetools-applications/merchant-center-template-starter Patch
@commercetools-applications/merchant-center-custom-view-template-starter-typescript Patch
@commercetools-applications/merchant-center-custom-view-template-starter Patch
@commercetools-local/playground Patch
@commercetools-frontend/codemod Patch
@commercetools-frontend/mc-scripts Patch
@commercetools-local/visual-testing-app Patch
@commercetools-website/components-playground Patch
@commercetools-frontend/cypress Patch
@commercetools-backend/eslint-config-node Patch
@commercetools-backend/express Patch
@commercetools-backend/loggers Patch
@commercetools-frontend/application-config Patch
@commercetools-frontend/assets Patch
@commercetools-frontend/babel-preset-mc-app Patch
@commercetools-frontend/browser-history Patch
@commercetools-frontend/constants Patch
@commercetools-frontend/create-mc-app Patch
@commercetools-frontend/eslint-config-mc-app Patch
@commercetools-frontend/jest-preset-mc-app Patch
@commercetools-frontend/jest-stylelint-runner Patch
@commercetools-frontend/mc-dev-authentication Patch
@commercetools-frontend/mc-html-template Patch
@commercetools-frontend/notifications Patch
@commercetools-frontend/sdk Patch
@commercetools-frontend/url-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
mc-app-kit-playground Ready Ready Preview, Comment Dec 15, 2025 5:31pm
merchant-center-application-kit-components-playground Ready Ready Preview, Comment Dec 15, 2025 5:31pm

@codecov-commenter
Copy link

codecov-commenter commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.06%. Comparing base (7d71e06) to head (2fb6ff3).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3904      +/-   ##
==========================================
+ Coverage   75.04%   75.06%   +0.02%     
==========================================
  Files         259      260       +1     
  Lines        6355     6361       +6     
  Branches     1978     2009      +31     
==========================================
+ Hits         4769     4775       +6     
  Misses       1565     1565              
  Partials       21       21              
Components Coverage Δ
Application Components 81.18% <ø> (ø)
Application Shell 74.41% <ø> (ø)
Application Shell Connectors 77.54% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d71e06...2fb6ff3. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@tylermorrisford tylermorrisford left a comment

Choose a reason for hiding this comment

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

relatively minor nit, otherwise this looks nice pending checks and a good build ❤️

@valoriecarli
Copy link
Contributor Author

[preview_deployment]

@github-actions
Copy link
Contributor

Release workflow failed ❌\nSee details: Workflow Run

@valoriecarli
Copy link
Contributor Author

[preview_deployment]

@github-actions
Copy link
Contributor

Release workflow succeeded ✅\nSee details: Workflow Run

@valoriecarli
Copy link
Contributor Author

relatively minor nit, otherwise this looks nice pending checks and a good build ❤️

@tylermorrisford good call. Updated the comment a bit to make it clearer, and noted it in the pr description as well. TL;DR - this was purely for type checking. Sentry v8's beforeSend requires both parameters in the signature, even if we don't need them (yet). v8 introduced a number of newly deprecated types that I started working on, but noped out to keep this minimal to focus on React 19 compatibility.

@valoriecarli valoriecarli merged commit 1a8c379 into main Dec 15, 2025
21 checks passed
@valoriecarli valoriecarli deleted the CRAFT-1995-upgrade-sentry/react branch December 15, 2025 17:39
@ct-changesets ct-changesets bot mentioned this pull request Dec 15, 2025
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.

4 participants