Skip to content

Commit

Permalink
Ignore hydration errors on rollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-bizz committed Dec 19, 2024
1 parent 89c49ed commit 3cd6e30
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pages/_app.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ const App = ({
},
},
enabled: !!process.env.ROLLBAR_ACCESS_TOKEN,
checkIgnore: (_, args) => {

Check warning on line 100 in pages/_app.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/_app.page.tsx#L100

Added line #L100 was not covered by tests
// Ignore React hydration warnings
return (

Check warning on line 102 in pages/_app.page.tsx

View check run for this annotation

Codecov / codecov/patch

pages/_app.page.tsx#L102

Added line #L102 was not covered by tests
typeof args[0] === 'string' && args[0].includes('Minified React error')
);
},

Check warning on line 105 in pages/_app.page.tsx

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Large Method

App increases from 135 to 140 lines of code, threshold = 120. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
};
const emotionCache = createEmotionCache({ key: 'css' });

Expand Down
6 changes: 6 additions & 0 deletions pages/api/utils/rollBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ const rollbar = new Rollbar({
captureUncaught: true,
captureUnhandledRejections: true,
enabled: isRollBarEnabled,
checkIgnore: (_, args) => {
// Ignore React hydration warnings
return (
typeof args[0] === 'string' && args[0].includes('Expected server HTML')
);
},
});

export const logErrorOnRollbar = (error: unknown, page: string) => {
Expand Down

0 comments on commit 3cd6e30

Please sign in to comment.