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

[VO-330] feat: Add Sentry #2176

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bundlemonrc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
{
"path": "vendors/home.<hash>.js",
"maxSize": "1.5 MB"
"maxSize": "1.6 MB"
},
{
"path": "vendors-home.<hash>.<hash>.min.css",
Expand Down
3 changes: 2 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module.exports = {
url: 'http://cozy.localhost:8080/'
},
transform: {
'^.+\\.(ts|tsx|js|jsx)?$': 'babel-jest'
'^.+\\.(ts|tsx|js|jsx)?$': 'babel-jest',
'^.+\\.webapp$': '<rootDir>/test/jestLib/json-transformer.js'
},
transformIgnorePatterns: [
'node_modules/(?!cozy-ui|cozy-harvest-lib|cozy-keys-lib|cozy-sharing|react-swipeable-views-core|copy-text-to-clipboard)'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"homepage": "https://github.com/cozy/cozy-home#readme",
"dependencies": {
"@sentry/react": "7.118.0",
"cozy-client": "^48.8.0",
"cozy-device-helper": "2.7.0",
"cozy-doctypes": "1.83.8",
Expand Down
5 changes: 4 additions & 1 deletion src/components/FooterLogo/FooterLogo.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { render, screen } from '@testing-library/react'
import { CozyProvider, createMockClient } from 'cozy-client'

import { FooterLogo } from './FooterLogo'
import CozyTheme from 'cozy-ui/transpiled/react/providers/CozyTheme'

describe('FooterLogo', () => {
const setup = mockLogos => {
Expand All @@ -30,7 +31,9 @@ describe('FooterLogo', () => {
})
render(
<CozyProvider client={mockClient}>
<FooterLogo />
<CozyTheme>
<FooterLogo />
</CozyTheme>
</CozyProvider>
)
}
Expand Down
7 changes: 4 additions & 3 deletions src/containers/App.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global __SIMULATE_FLAGSHIP__ */
import React, { useEffect, useState } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom'
import { Navigate, Route } from 'react-router-dom'

import flag, { enable as enableFlags } from 'cozy-flags'
import minilog from 'cozy-minilog'
Expand Down Expand Up @@ -41,6 +41,7 @@ import {
} from 'queries'
import { useI18n } from 'cozy-ui/transpiled/react/providers/I18n'
import SectionDialog from 'components/Sections/SectionDialog'
import { SentryRoutes } from 'lib/sentry'

window.flag = window.flag || flag
window.minilog = minilog
Expand Down Expand Up @@ -152,7 +153,7 @@ const App = ({ accounts, konnectors, triggers }) => {
)}
{!isFetching && (
<>
<Routes>
<SentryRoutes>
<Route
path="/connected"
element={
Expand All @@ -177,7 +178,7 @@ const App = ({ accounts, konnectors, triggers }) => {
<Route path="/redirect" element={<IntentRedirect />} />

<Route path="*" element={<Navigate to="connected" />} />
</Routes>
</SentryRoutes>
</>
)}

Expand Down
36 changes: 36 additions & 0 deletions src/lib/sentry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as Sentry from '@sentry/react'
import { useEffect } from 'react'
import {
Routes,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes
} from 'react-router-dom'

// eslint-disable-next-line import-alias/import-alias
import manifest from '../../manifest.webapp'

Sentry.init({
dsn: 'https://[email protected]/82',
environment: process.env.NODE_ENV,
release: manifest.version,
integrations: [
// We also want to capture the `console.error` to, among other things,
// report the logs present in the `try/catch
Sentry.captureConsoleIntegration({ levels: ['error'] }),
Sentry.reactRouterV6BrowserTracingIntegration({
useEffect,
useLocation,
useNavigationType,
createRoutesFromChildren,
matchRoutes
})
],
tracesSampleRate: 0.1,
// React log these warnings(bad Proptypes), in a console.error,
// it is not relevant to report this type of information to Sentry
ignoreErrors: [/^Warning: /]
})

export const SentryRoutes = Sentry.withSentryReactRouterV6Routing(Routes)
5 changes: 5 additions & 0 deletions test/jestLib/json-transformer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
process: src => ({
code: `module.exports = ${src};`
})
}
95 changes: 94 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3406,6 +3406,48 @@
dependencies:
any-observable "^0.3.0"

"@sentry-internal/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-7.118.0.tgz#5b4b13ba514452d07a22ec8c66c2e4bc2091d8e6"
integrity sha512-IYOGRcqIqKJJpMwBBv+0JTu0FPpXnakJYvOx/XEa/SNyF5+l7b9gGEjUVWh1ok50kTLW/XPnpnXNAGQcoKHg+w==
dependencies:
"@sentry/core" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry-internal/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-7.118.0.tgz#d9741962439a85525e660973042c801c569ea9e4"
integrity sha512-XxHlCClvrxmVKpiZetFYyiBaPQNiojoBGFFVgbbWBIAPc+fWeLJ2BMoQEBjn/0NA/8u8T6lErK5YQo/eIx9+XQ==
dependencies:
"@sentry/core" "7.118.0"
"@sentry/replay" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry-internal/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.118.0.tgz#1a96ea745db818e20c2f8273d317f284a416a90a"
integrity sha512-dERAshKlQLrBscHSarhHyUeGsu652bDTUN1FK0m4e3X48M3I5/s+0N880Qjpe5MprNLcINlaIgdQ9jkisvxjfw==
dependencies:
"@sentry/core" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.118.0.tgz#2395b47d693f7e49057552997d5125fc1a3d3448"
integrity sha512-8onDOFV1VLEoBuqA5yaJeR3FF1JNuxr5C7p1oN3OwY724iTVqQnOLmZKZaSnHV3RkY67wKDGQkQIie14sc+42g==
dependencies:
"@sentry-internal/feedback" "7.118.0"
"@sentry-internal/replay-canvas" "7.118.0"
"@sentry-internal/tracing" "7.118.0"
"@sentry/core" "7.118.0"
"@sentry/integrations" "7.118.0"
"@sentry/replay" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry/browser@^6.0.1":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.13.2.tgz#8b731ecf8c3cdd92a4b6893a26f975fd5844056d"
Expand All @@ -3427,6 +3469,14 @@
"@sentry/utils" "6.13.2"
tslib "^1.9.3"

"@sentry/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.118.0.tgz#1549b49621bc05a8df16c3546793a299b0638559"
integrity sha512-ol0xBdp3/K11IMAYSQE0FMxBOOH9hMsb/rjxXWe0hfM5c72CqYWL3ol7voPci0GELJ5CZG+9ImEU1V9r6gK64g==
dependencies:
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry/[email protected]":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.13.2.tgz#ebc66fd55c96c7686a53ffd3521b6a63f883bb79"
Expand All @@ -3436,6 +3486,16 @@
"@sentry/utils" "6.13.2"
tslib "^1.9.3"

"@sentry/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.118.0.tgz#f090db621979785c6dc44406da1f72653fa0617c"
integrity sha512-C2rR4NvIMjokF8jP5qzSf1o2zxDx7IeYnr8u15Kb2+HdZtX559owALR0hfgwnfeElqMhGlJBaKUWZ48lXJMzCQ==
dependencies:
"@sentry/core" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"
localforage "^1.8.1"

"@sentry/[email protected]":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.13.2.tgz#de3ecc62b9463bf56ccdbcf4c75f7ea1aeeebc11"
Expand All @@ -3445,11 +3505,37 @@
"@sentry/types" "6.13.2"
tslib "^1.9.3"

"@sentry/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.118.0.tgz#88ae04e1abec1fd9a242ad6d852a1fe5e6851ad4"
integrity sha512-oEYe5TGk8S7YzPsFqDf4xDHjfzs35/QFE+dou3S2d24OYpso8Tq4C5f1VzYmnOOyy85T7JNicYLSo0n0NSJvQg==
dependencies:
"@sentry/browser" "7.118.0"
"@sentry/core" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"
hoist-non-react-statics "^3.3.2"

"@sentry/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.118.0.tgz#ae55b7e14b85f22256dcc5a96bf3e63b252c1acf"
integrity sha512-boQfCL+1L/tSZ9Huwi00+VtU+Ih1Lcg8HtxBuAsBCJR9pQgUL5jp7ECYdTeeHyCh/RJO7JqV1CEoGTgohe10mA==
dependencies:
"@sentry-internal/tracing" "7.118.0"
"@sentry/core" "7.118.0"
"@sentry/types" "7.118.0"
"@sentry/utils" "7.118.0"

"@sentry/[email protected]":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.13.2.tgz#8388d5b92ea8608936e7aae842801dc90e0184e6"
integrity sha512-6WjGj/VjjN8LZDtqJH5ikeB1o39rO1gYS6anBxiS3d0sXNBb3Ux0pNNDFoBxQpOhmdDHXYS57MEptX9EV82gmg==

"@sentry/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.118.0.tgz#ca3ab06912f60bc2a7ccf2d2e5ccf43985851aef"
integrity sha512-2drqrD2+6kgeg+W/ycmiti3G4lJrV3hGjY9PpJ3bJeXrh6T2+LxKPzlgSEnKFaeQWkXdZ4eaUbtTXVebMjb5JA==

"@sentry/[email protected]":
version "6.13.2"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.13.2.tgz#fb8010e7b67cc8c084d8067d64ef25289269cda5"
Expand All @@ -3458,6 +3544,13 @@
"@sentry/types" "6.13.2"
tslib "^1.9.3"

"@sentry/[email protected]":
version "7.118.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.118.0.tgz#bfc60826fe3d5d2ae7338ec6ac1f06c20beb179e"
integrity sha512-43qItc/ydxZV1Zb3Kn2M54RwL9XXFa3IAYBO8S82Qvq5YUYmU2AmJ1jgg7DabXlVSWgMA1HntwqnOV3JLaEnTQ==
dependencies:
"@sentry/types" "7.118.0"

"@sinclair/typebox@^0.24.1":
version "0.24.28"
resolved "https://registry.yarnpkg.com/@sinclair/typebox/-/typebox-0.24.28.tgz#15aa0b416f82c268b1573ab653e4413c965fe794"
Expand Down Expand Up @@ -11626,7 +11719,7 @@ loader-utils@^2.0.0:
emojis-list "^3.0.0"
json5 "^2.1.2"

localforage@^1.10.0:
localforage@^1.10.0, localforage@^1.8.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4"
integrity sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==
Expand Down
Loading