From f00a1c04474fa5888a9894d63fea7d78270e43ba Mon Sep 17 00:00:00 2001 From: Rohan Bansal Date: Thu, 30 Nov 2023 16:21:29 +0530 Subject: [PATCH] fix: update Sentry SDKs --- .flake8 | 1 + .pre-commit-config.yaml | 18 +++---- package.json | 5 +- pyproject.toml | 2 +- sentry/public/js/sentry.js | 67 ++++++++++++------------ sentry/sentry/utils.py | 6 +-- yarn.lock | 101 +++++++++++++++++-------------------- 7 files changed, 95 insertions(+), 105 deletions(-) diff --git a/.flake8 b/.flake8 index 2de7a15..e783fbb 100644 --- a/.flake8 +++ b/.flake8 @@ -69,6 +69,7 @@ ignore = F841, E713, E712, + B028, max-line-length = 200 exclude=,test_*.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b3ea6d..83171d5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -35,21 +35,21 @@ repos: rev: v2.7.1 hooks: - id: prettier - types_or: [javascript] + types_or: [javascript, vue, scss] # Ignore any files that might contain jinja / bundles exclude: | (?x)^( - frappe/public/dist/.*| - .*node_modules.*| .*boilerplate.*| - frappe/www/website_script.js| - frappe/templates/includes/.*| - frappe/public/js/lib/.* + .*node_modules.*| + sentry/public/dist/.*| + sentry/public/js/lib/.*| + sentry/templates/includes/.*| + sentry/website/doctype/website_theme/website_theme_template.scss| + sentry/www/website_script.js )$ - - - repo: https://github.com/timothycrosley/isort - rev: 5.9.1 + - repo: https://github.com/PyCQA/isort + rev: 5.12.0 hooks: - id: isort diff --git a/package.json b/package.json index 25d105b..5034cf7 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,7 @@ "url": "https://github.com/ParsimonyGit/frappe-sentry/issues" }, "dependencies": { - "@sentry/browser": "^7.28.1", - "@sentry/integrations": "^7.28.1", - "@sentry/tracing": "^7.28.1" + "@sentry/browser": "^7.83.0", + "@sentry/integrations": "^7.83.0" } } diff --git a/pyproject.toml b/pyproject.toml index 7ddf75a..318780c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ requires-python = ">=3.10" readme = "README.md" dynamic = ["version"] dependencies = [ - "sentry-sdk~=1.12.1", + "sentry-sdk[rq]~=1.38.0", ] [build-system] diff --git a/sentry/public/js/sentry.js b/sentry/public/js/sentry.js index 3252d28..202701d 100644 --- a/sentry/public/js/sentry.js +++ b/sentry/public/js/sentry.js @@ -1,39 +1,38 @@ -import * as Sentry from '@sentry/browser' -import { CaptureConsole, Offline } from '@sentry/integrations' -import { Integrations } from "@sentry/tracing" +import * as Sentry from "@sentry/browser"; +import { CaptureConsole } from "@sentry/integrations"; if (frappe.boot.sentry?.dsn) { - Sentry.init( - { - dsn: frappe.boot.sentry.dsn, - integrations: [ - new Integrations.BrowserTracing({ - beforeNavigate: context => { - const route = frappe.router.current_route - // get a shallow copy of the route to avoid modifying cache - ? frappe.get_route().slice() - : ["app"]; + Sentry.init({ + dsn: frappe.boot.sentry.dsn, + transport: Sentry.makeBrowserOfflineTransport(Sentry.makeFetchTransport), + transportOptions: { maxQueueSize: 25 }, + integrations: [ + new Sentry.BrowserTracing({ + beforeNavigate: (context) => { + const route = frappe.router.current_route + ? frappe.get_route().slice() // get a shallow copy of the route to avoid modifying cache + : ["app"]; - if (route[0].toLowerCase() === "form") { - route[2] = ""; - } - - return { - ...context, - name: route.join("/") - } + if (route[0].toLowerCase() === "form") { + route[2] = ""; } - }), - new CaptureConsole({ levels: ['warn', 'error', 'debug'] }), - new Offline({ maxStoredEvents: 25 }) - ], - tracesSampleRate: 1.0, // adjust value once we're live - }); - Sentry.configureScope(scope => { - scope.setUser({ email: frappe.boot.user.email }) - scope.setTag("site", frappe.boot.sentry.site) - scope.setTag("project", frappe.boot.sentry.project) - scope.setTag("server_name", frappe.boot.sentry.server_name) - }) -} \ No newline at end of file + return { + ...context, + name: route.join("/"), + }; + }, + }), + new CaptureConsole({ levels: ["warn", "error", "debug"] }), + ], + tracesSampleRate: 0.5, + profilesSampleRate: 0.5, + }); + + Sentry.configureScope((scope) => { + scope.setUser({ email: frappe.boot.user.email }); + scope.setTag("site", frappe.boot.sentry.site); + scope.setTag("project", frappe.boot.sentry.project); + scope.setTag("server_name", frappe.boot.sentry.server_name); + }); +} diff --git a/sentry/sentry/utils.py b/sentry/sentry/utils.py index 74bf2bd..13317b1 100644 --- a/sentry/sentry/utils.py +++ b/sentry/sentry/utils.py @@ -11,12 +11,10 @@ def init_sentry(): if sentry_enabled(): sentry_sdk.init( sentry_details.dsn, - debug=True, + enable_tracing=True, integrations=[RqIntegration()], traces_sample_rate=1.0, - _experiments={ - "profiles_sample_rate": 1.0, - }, + profiles_sample_rate=1.0, ) diff --git a/yarn.lock b/yarn.lock index 9325f21..045c4df 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,67 +2,65 @@ # yarn lockfile v1 -"@sentry/browser@^7.28.1": - version "7.28.1" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.28.1.tgz#c8086e26079809aa401a05d9b4a6e4df63a9c965" - integrity sha512-N8j93IcrWKWorfJ5D+RSKVAvcR4S5tIcZ/HvFPMrQWnfVa/jtJcrKThdjZYteA0wjmPiy8/D3KA8nB91yulBPA== +"@sentry-internal/tracing@7.83.0": + version "7.83.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.83.0.tgz#8f69d339569b020c495f8350a8ea527c369586e8" + integrity sha512-fY1ZyOiQaaUTuoq5rO+G4/5Ov3n8BnfNK7ck97yAGxy3w+E1CwhVZkXHEvTngNfdYV3ArxvlrtPRb9STFRqXvQ== dependencies: - "@sentry/core" "7.28.1" - "@sentry/replay" "7.28.1" - "@sentry/types" "7.28.1" - "@sentry/utils" "7.28.1" - tslib "^1.9.3" + "@sentry/core" "7.83.0" + "@sentry/types" "7.83.0" + "@sentry/utils" "7.83.0" -"@sentry/core@7.28.1": - version "7.28.1" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.28.1.tgz#c712ce17469b18b01606108817be24a99ed2116e" - integrity sha512-7wvnuvn/mrAfcugWoCG/3pqDIrUgH5t+HisMJMGw0h9Tc33KqrmqMDCQVvjlrr2pWrw/vuUCFdm8CbUHJ832oQ== +"@sentry/browser@^7.83.0": + version "7.83.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.83.0.tgz#01e8ba0d3f4d4652e67c8b0d955d2f3903a19ab0" + integrity sha512-8v7QEaC/fVAHn8pi59ZlJznr7ZdOQIgtz8DAOJeJsC2vHTAxQ9nVkoMkJWjTp/qaDHUjSe5ob6eqaChuhi6t2g== dependencies: - "@sentry/types" "7.28.1" - "@sentry/utils" "7.28.1" - tslib "^1.9.3" + "@sentry-internal/tracing" "7.83.0" + "@sentry/core" "7.83.0" + "@sentry/replay" "7.83.0" + "@sentry/types" "7.83.0" + "@sentry/utils" "7.83.0" -"@sentry/integrations@^7.28.1": - version "7.28.1" - resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.28.1.tgz#f0cba627b9ed03f1a54d91385126019f332a575d" - integrity sha512-opeXVR1L9mZmZcpAs9kX+4JPY7pXhVupy17Sbz+43zd5CshYTveIcttGNPp+EPT3j7mMU+1TMAYZspKqJXtEBQ== +"@sentry/core@7.83.0": + version "7.83.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.83.0.tgz#29bdd5aba40a6f25c01c68387b6a9aa13e27f20a" + integrity sha512-fglvpw8aWM6nWXzCjAVXIMTiTEAQ9G9b85IpDd/7L8fuwaFTPQAUSJXupF2PfbpQ3FUYbJt80dxshbERVJG8vQ== dependencies: - "@sentry/types" "7.28.1" - "@sentry/utils" "7.28.1" - localforage "^1.8.1" - tslib "^1.9.3" + "@sentry/types" "7.83.0" + "@sentry/utils" "7.83.0" -"@sentry/replay@7.28.1": - version "7.28.1" - resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.28.1.tgz#fbdd377923e082423b95e3f128cb9af9451aca70" - integrity sha512-Os0PzMjKlwtHwzTU0kfVzGzsi4Vaj3g2arCl4Qnr3b6kYTb9WOFZo/n/v56ss7Z+nZG3K8W5PisoD4MRsRJRig== +"@sentry/integrations@^7.83.0": + version "7.83.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.83.0.tgz#c9256bd6168bef587e4bde04b66609aaea16a3ab" + integrity sha512-KyptWUyg/Z+3qN1dBDDVcNNUzIwWpCO3mfiToV20LSeA+e/NS4IWTtsZKo2mqvoQQ/4QKcrMj7NbF5iOjKckaQ== dependencies: - "@sentry/core" "7.28.1" - "@sentry/types" "7.28.1" - "@sentry/utils" "7.28.1" + "@sentry/core" "7.83.0" + "@sentry/types" "7.83.0" + "@sentry/utils" "7.83.0" + localforage "^1.8.1" -"@sentry/tracing@^7.28.1": - version "7.28.1" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-7.28.1.tgz#d276e4d17a79190a88112696c73de12c209607a1" - integrity sha512-uWspnuz+7FyW8ES5lRaVA7O/YJSzMlSkvBFtgzaoKmdaueokU/sRLwlCsrdgwavG1wpm79df7R1iiSeqhaXDlw== +"@sentry/replay@7.83.0": + version "7.83.0" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.83.0.tgz#14fd39a638911f60b780d232d2056f0d19ed478e" + integrity sha512-B/rzmjmQ3ZWE68m4Z9rHIN3Fa/wkfVVTK+iSQtqErFflyMETMNwtWRNd6P9FhXnphEINZEbcn/UZF5w5xu/DfA== dependencies: - "@sentry/core" "7.28.1" - "@sentry/types" "7.28.1" - "@sentry/utils" "7.28.1" - tslib "^1.9.3" + "@sentry-internal/tracing" "7.83.0" + "@sentry/core" "7.83.0" + "@sentry/types" "7.83.0" + "@sentry/utils" "7.83.0" -"@sentry/types@7.28.1": - version "7.28.1" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.28.1.tgz#9018b4c152b475de9bedd267237393d3c9b1253d" - integrity sha512-DvSplMVrVEmOzR2M161V5+B8Up3vR71xMqJOpWTzE9TqtFJRGPtqT/5OBsNJJw1+/j2ssMcnKwbEo9Q2EGeS6g== +"@sentry/types@7.83.0": + version "7.83.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.83.0.tgz#117e45900603190c547e52bba35e1b3d539d47fb" + integrity sha512-Bd+zJcy8p1VgCfQqUprmUaw0QPWUV+GmCt6zJRHrHTb2pwLahXv6sHJvQ8F8Va6S7Keuy088U+kHzUFGQLMZMQ== -"@sentry/utils@7.28.1": - version "7.28.1" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.28.1.tgz#0a7b6aa4b09e91e4d1aded2a8c8dbaf818cee96e" - integrity sha512-75/jzLUO9HH09iC9TslNimGbxOP3jgn89P+q7uR+rp2fJfRExHVeKJZQdK0Ij4/SmE7TJ3Uh2r154N0INZEx1g== +"@sentry/utils@7.83.0": + version "7.83.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.83.0.tgz#ec0fc0a468ec35ab9623603f1ba218dd58233eda" + integrity sha512-7SrZtgAn3pHFBqSSvV/VL0CWTBQ7VenJjok4+WGWd6/FhP3fKrEEd9rjVTUb2Pzq9WLJJYzdvxAG8RlggG+H4g== dependencies: - "@sentry/types" "7.28.1" - tslib "^1.9.3" + "@sentry/types" "7.83.0" immediate@~3.0.5: version "3.0.6" @@ -82,8 +80,3 @@ localforage@^1.8.1: integrity sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg== dependencies: lie "3.1.1" - -tslib@^1.9.3: - version "1.14.1" - resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" - integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==