Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/upgrade sentry packages #2303

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

norbertschuler
Copy link
Collaborator

@norbertschuler norbertschuler commented Nov 10, 2024

Fixes #

Changes in this pull request:

  • upgrade Sentry packages

Copy link

vercel bot commented Nov 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
planet-webapp-multi-tenancy-setup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 11, 2024 7:46am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
planet-webapp ⬜️ Ignored (Inspect) Nov 11, 2024 7:46am
planet-webapp-temp ⬜️ Ignored (Inspect) Nov 11, 2024 7:46am

Copy link
Contributor

coderabbitai bot commented Nov 10, 2024

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes in this pull request primarily involve updates to the Sentry integration within the Next.js application, including modifications to the Webpack configuration in next.config.js and the handling of Sentry frame rewriting in pages/_app.tsx. Additionally, a new button has been added to the DeleteProfileForm component that triggers an error when clicked. These updates streamline the Sentry setup and enhance the functionality of the video display logic while maintaining the existing structure and flow of the components.

Changes

File Change Summary
next.config.js Updated Sentry Webpack plugin import from default to named import; removed deprecated parameters.
pages/_app.tsx Modified Sentry integration to use rewriteFramesIntegration; refined video display logic.
src/features/user/Settings/DeleteProfile/DeleteProfileForm.tsx Added a button that throws an error when clicked; existing logic remains unchanged.

Poem

🐰 In the code where changes bloom,
Sentry's whispers chase the gloom.
A button here to raise a cheer,
With every click, a new frontier!
Let frames be rewritten, clear and bright,
As we hop along, coding through the night! 🌙


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@norbertschuler norbertschuler marked this pull request as draft November 10, 2024 11:26
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Outside diff range and nitpick comments (2)
pages/_app.tsx (2)

Line range hint 19-19: Remove unused import.

The RewriteFrames import is no longer used after switching to Sentry.rewriteFramesIntegration.

-import { RewriteFrames } from '@sentry/integrations';

101-101: Remove commented code.

The commented denyUrls line provides no value and should be removed.

-    // denyUrls: [], //commented out as this option is currently not utilized
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 355e02b and fa66617.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json, !**/*.json
  • package.json is excluded by !**/*.json
📒 Files selected for processing (3)
  • next.config.js (2 hunks)
  • pages/_app.tsx (2 hunks)
  • src/features/user/Settings/DeleteProfile/DeleteProfileForm.tsx (1 hunks)
🔇 Additional comments (5)
src/features/user/Settings/DeleteProfile/DeleteProfileForm.tsx (1)

75-82: Verify Sentry configuration

Since this button is part of Sentry package upgrades, ensure Sentry is properly configured to capture these errors.

✅ Verification successful

Sentry is properly configured to capture errors

The verification shows that Sentry is correctly set up:

  • Sentry is initialized in pages/_app.tsx with production environment check
  • Error handling is properly configured in pages/_error.js with multiple captureException calls
  • The test error button will work as expected since unhandled errors are automatically captured by Sentry's default configuration
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check Sentry initialization and configuration
echo "Checking Sentry configuration..."
rg -A 5 "Sentry.init" 
echo "Checking for other Sentry error captures..."
rg -A 5 "captureException|captureMessage"

Length of output: 1566

next.config.js (2)

6-6: LGTM: Import statement correctly updated for newer Sentry SDK

The change from default import to named import aligns with the updated Sentry Webpack plugin API.


96-105: Verify source map configuration after parameter removal

The core Sentry configuration looks good, but several source map related parameters have been removed as deprecated. While this aligns with the SDK upgrade, we should ensure:

  1. Source maps are still being generated and uploaded correctly
  2. Stack traces in Sentry still show correct file paths

Let's verify the source map generation:

Consider adding documentation about:

  • The new Sentry source map configuration
  • How to verify source maps are working in the Sentry dashboard
  • Any required Sentry project settings for source map support
✅ Verification successful

Source maps are properly configured despite parameter removal

The verification shows that source maps are correctly configured:

  1. Source map generation is explicitly enabled via productionBrowserSourceMaps: true in next.config.js
  2. The Sentry Webpack Plugin (@sentry/webpack-plugin) is updated to version 2.22.6, which handles source map upload automatically without the need for the deprecated parameters
  3. The removed parameters (include, ignore, stripPrefix, urlPrefix) were from an older version and are no longer required as the new version handles source map processing with sensible defaults

The core configuration using environment variables (org, project, authToken) combined with Next.js's source map generation is sufficient for proper source map functionality in Sentry.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if source maps are still being generated in the build output

# Test 1: Verify source map configuration in next.config.js
echo "Checking source map configuration..."
rg "productionBrowserSourceMaps" -A 2

# Test 2: Look for any Sentry source map documentation
echo "Checking for Sentry source map documentation..."
fd -t f "README|CONTRIBUTING|CHANGELOG" -x rg -l "sentry.*source.*map"

Length of output: 429


Script:

#!/bin/bash
# Let's check for Sentry configuration and source map related settings more thoroughly

# Check for any Sentry webpack plugin imports and configurations
echo "Checking Sentry webpack plugin usage..."
rg "@sentry/webpack-plugin" -A 5

# Check for source map related configurations in webpack or next config
echo "Checking source map configurations..."
rg "sourceMaps|sourceMap" -i

# Look for any Sentry documentation or configuration files
echo "Checking Sentry configuration files..."
fd -t f "sentry.properties|sentry.config" -x cat {}

# Check for any recent changes or documentation about Sentry
echo "Checking git history for Sentry changes..."
git log -p --grep="sentry" --since="3 months ago"

Length of output: 4158

pages/_app.tsx (2)

Line range hint 1-300: Component structure maintains proper separation of concerns.

The Sentry integration changes are well-isolated and don't impact the component's core functionality. The provider hierarchy, authentication flow, and layout handling remain intact.


67-74: Verify Sentry configuration in production.

The Sentry frame rewriting configuration looks correct. However, since this is a significant change to error tracking, please ensure:

  1. Error events are properly captured and symbolicated in production
  2. Source maps are correctly uploaded and applied
  3. Stack traces show correct file paths in the Sentry dashboard
✅ Verification successful

Let me gather more information about the Sentry configuration to provide a comprehensive verification.


Sentry configuration appears properly set up for production

The verification shows that the Sentry setup is correctly configured:

  • Source maps are enabled via productionBrowserSourceMaps: true
  • Webpack is properly configured to use @sentry/browser for client-side bundles
  • Sentry Webpack plugin is configured to upload source maps during build with:
    • Correct organization and project settings
    • Authentication token handling
    • Source map upload capability

The frame rewriting configuration in _app.tsx will work correctly with this setup to provide accurate stack traces in the Sentry dashboard.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Sentry source map configuration in next.config.js

# Test: Check if Sentry Webpack plugin is properly configured
rg -A 10 "SentryWebpackPlugin" next.config.js

# Test: Verify source map generation settings
rg "productionBrowserSourceMaps" next.config.js

Length of output: 130


Script:

#!/bin/bash
# Check for Sentry webpack plugin configuration and source map upload settings
rg -A 20 "webpack:" next.config.js

# Look for any Sentry related configuration in next.config.js
rg -i "sentry" next.config.js

# Check if there are any sentry cli configuration files
fd -g ".sentryclirc"
fd -g "sentry.properties"

Length of output: 3037

Comment on lines 75 to 82
<button
type="button"
onClick={() => {
throw new Error("Sentry Frontend Error");
}}
>
Throw error
</button>
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Consider environment-specific rendering of the error test button

The error test button should only be available in development environments to prevent accidental triggers in production.

Consider this implementation:

-        <button
-          type="button"
-          onClick={() => {
-            throw new Error("Sentry Frontend Error");
-          }}
-        >
-          Throw error
-        </button>
+        {process.env.NODE_ENV === 'development' && (
+          <Button
+            variant="contained"
+            color="warning"
+            onClick={() => {
+              try {
+                throw new Error("Sentry Frontend Error");
+              } catch (error) {
+                // Ensure error is caught by Sentry
+                if (typeof window !== 'undefined' && window.Sentry) {
+                  window.Sentry.captureException(error);
+                }
+                throw error;
+              }
+            }}
+          >
+            Test Sentry Error Tracking
+          </Button>
+        )}

This change:

  1. Restricts the button to development environment
  2. Uses MUI Button component for consistent styling
  3. Adds explicit Sentry error capture
  4. Improves button label clarity
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button
type="button"
onClick={() => {
throw new Error("Sentry Frontend Error");
}}
>
Throw error
</button>
{process.env.NODE_ENV === 'development' && (
<Button
variant="contained"
color="warning"
onClick={() => {
try {
throw new Error("Sentry Frontend Error");
} catch (error) {
// Ensure error is caught by Sentry
if (typeof window !== 'undefined' && window.Sentry) {
window.Sentry.captureException(error);
}
throw error;
}
}}
>
Test Sentry Error Tracking
</Button>
)}

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.

1 participant