From 361a06e5b3d0c0820894e1471f46fb3a44ee8e29 Mon Sep 17 00:00:00 2001 From: Sli Date: Sun, 13 Oct 2024 16:47:33 +0200 Subject: [PATCH] Migrate sentry to webpack --- core/static/vendored/sentry/bundle.min.js | 1 - core/static/webpack/sentry-popup-index.ts | 24 +++++ core/templates/core/500.jinja | 34 +++---- package-lock.json | 103 ++++++++++++++++++++++ package.json | 1 + sith/settings.py | 1 - sith/urls.py | 1 + 7 files changed, 146 insertions(+), 19 deletions(-) delete mode 100644 core/static/vendored/sentry/bundle.min.js create mode 100644 core/static/webpack/sentry-popup-index.ts diff --git a/core/static/vendored/sentry/bundle.min.js b/core/static/vendored/sentry/bundle.min.js deleted file mode 100644 index f44b712b..00000000 --- a/core/static/vendored/sentry/bundle.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(n,e,r,t,i,o,a,c,s){for(var u=s,f=0;f-1){u&&"no"===document.scripts[f].getAttribute("data-lazy")&&(u=!1);break}var p=[];function l(n){return"e"in n}function d(n){return"p"in n}function _(n){return"f"in n}var v=[];function y(n){u&&(l(n)||d(n)||_(n)&&n.f.indexOf("capture")>-1||_(n)&&n.f.indexOf("showReportDialog")>-1)&&m(),v.push(n)}function g(){y({e:[].slice.call(arguments)})}function h(n){y({p:n})}function E(){try{n.SENTRY_SDK_SOURCE="loader";var e=n[i],o=e.init;e.init=function(i){n.removeEventListener(r,g),n.removeEventListener(t,h);var a=c;for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(a[s]=i[s]);!function(n,e){var r=n.integrations||[];if(!Array.isArray(r))return;var t=r.map((function(n){return n.name}));n.tracesSampleRate&&-1===t.indexOf("BrowserTracing")&&(e.browserTracingIntegration?r.push(e.browserTracingIntegration({enableInp:!0})):e.BrowserTracing&&r.push(new e.BrowserTracing));(n.replaysSessionSampleRate||n.replaysOnErrorSampleRate)&&-1===t.indexOf("Replay")&&(e.replayIntegration?r.push(e.replayIntegration()):e.Replay&&r.push(new e.Replay));n.integrations=r}(a,e),o(a)},setTimeout((function(){return function(e){try{"function"==typeof n.sentryOnLoad&&(n.sentryOnLoad(),n.sentryOnLoad=void 0);for(var r=0;r { + Sentry.init({ + dsn: options.dsn, + }); + Sentry.showReportDialog({ + eventId: options.eventId, + ...(options.user ?? {}), + }); +}); diff --git a/core/templates/core/500.jinja b/core/templates/core/500.jinja index e5a4fe07..c743cca0 100644 --- a/core/templates/core/500.jinja +++ b/core/templates/core/500.jinja @@ -1,26 +1,26 @@ {% extends "core/base.jinja" %} -{% block head %} - {{ super() }} - -{% endblock head %} +{% block additional_js %} + {% if settings.SENTRY_DSN %} + + {% endif %} +{% endblock additional_js %} {% block content %}

{% trans %}500, Server Error{% endtrans %}

{% if settings.SENTRY_DSN %} {% endif %} {% endblock content %} diff --git a/package-lock.json b/package-lock.json index ac2d0e41..b4154374 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@fortawesome/fontawesome-free": "^6.6.0", "@hey-api/client-fetch": "^0.4.0", + "@sentry/browser": "^8.34.0", "@zip.js/zip.js": "^2.7.52", "alpinejs": "^3.14.1", "cytoscape": "^3.30.2", @@ -2180,6 +2181,108 @@ "integrity": "sha512-8LduaNlMZGwdZ6qWrKlfa+2M4gahzFkprZiAt2TF8uS0qQgBizKXpXURqvTJ4WtmupWxaLqjRb2UCTe72mu+Aw==", "dev": true }, + "node_modules/@sentry-internal/browser-utils": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/browser-utils/-/browser-utils-8.34.0.tgz", + "integrity": "sha512-4AcYOzPzD1tL5eSRQ/GpKv5enquZf4dMVUez99/Bh3va8qiJrNP55AcM7UzZ7WZLTqKygIYruJTU5Zu2SpEAPQ==", + "dependencies": { + "@sentry/core": "8.34.0", + "@sentry/types": "8.34.0", + "@sentry/utils": "8.34.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry-internal/feedback": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/feedback/-/feedback-8.34.0.tgz", + "integrity": "sha512-aYSM2KPUs0FLPxxbJCFSwCYG70VMzlT04xepD1Y/tTlPPOja/02tSv2tyOdZbv8Uw7xslZs3/8Lhj74oYcTBxw==", + "dependencies": { + "@sentry/core": "8.34.0", + "@sentry/types": "8.34.0", + "@sentry/utils": "8.34.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry-internal/replay": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay/-/replay-8.34.0.tgz", + "integrity": "sha512-EoMh9NYljNewZK1quY23YILgtNdGgrkzJ9TPsj6jXUG0LZ0Q7N7eFWd0xOEDBvFxrmI3cSXF1i4d1sBb+eyKRw==", + "dependencies": { + "@sentry-internal/browser-utils": "8.34.0", + "@sentry/core": "8.34.0", + "@sentry/types": "8.34.0", + "@sentry/utils": "8.34.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry-internal/replay-canvas": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@sentry-internal/replay-canvas/-/replay-canvas-8.34.0.tgz", + "integrity": "sha512-x8KhZcCDpbKHqFOykYXiamX6x0LRxv6N1OJHoH+XCrMtiDBZr4Yo30d/MaS6rjmKGMtSRij30v+Uq+YWIgxUrg==", + "dependencies": { + "@sentry-internal/replay": "8.34.0", + "@sentry/core": "8.34.0", + "@sentry/types": "8.34.0", + "@sentry/utils": "8.34.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry/browser": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-8.34.0.tgz", + "integrity": "sha512-3HHG2NXxzHq1lVmDy2uRjYjGNf9NsJsTPlOC70vbQdOb+S49EdH/XMPy+J3ruIoyv6Cu0LwvA6bMOM6rHZOgNQ==", + "dependencies": { + "@sentry-internal/browser-utils": "8.34.0", + "@sentry-internal/feedback": "8.34.0", + "@sentry-internal/replay": "8.34.0", + "@sentry-internal/replay-canvas": "8.34.0", + "@sentry/core": "8.34.0", + "@sentry/types": "8.34.0", + "@sentry/utils": "8.34.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry/core": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-8.34.0.tgz", + "integrity": "sha512-adrXCTK/zsg5pJ67lgtZqdqHvyx6etMjQW3P82NgWdj83c8fb+zH+K79Z47pD4zQjX0ou2Ws5nwwi4wJbz4bfA==", + "dependencies": { + "@sentry/types": "8.34.0", + "@sentry/utils": "8.34.0" + }, + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry/types": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-8.34.0.tgz", + "integrity": "sha512-zLRc60CzohGCo6zNsNeQ9JF3SiEeRE4aDCP9fDDdIVCOKovS+mn1rtSip0qd0Vp2fidOu0+2yY0ALCz1A3PJSQ==", + "engines": { + "node": ">=14.18" + } + }, + "node_modules/@sentry/utils": { + "version": "8.34.0", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-8.34.0.tgz", + "integrity": "sha512-W1KoRlFUjprlh3t86DZPFxLfM6mzjRzshVfMY7vRlJFymBelJsnJ3A1lPeBZM9nCraOSiw6GtOWu6k5BAkiGIg==", + "dependencies": { + "@sentry/types": "8.34.0" + }, + "engines": { + "node": ">=14.18" + } + }, "node_modules/@sinclair/typebox": { "version": "0.27.8", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.27.8.tgz", diff --git a/package.json b/package.json index 68ece814..55f081e6 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "dependencies": { "@fortawesome/fontawesome-free": "^6.6.0", "@hey-api/client-fetch": "^0.4.0", + "@sentry/browser": "^8.34.0", "@zip.js/zip.js": "^2.7.52", "alpinejs": "^3.14.1", "cytoscape": "^3.30.2", diff --git a/sith/settings.py b/sith/settings.py index 73412a47..1a74a018 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -750,7 +750,6 @@ if SENTRY_DSN: SITH_FRONT_DEP_VERSIONS = { "https://github.com/chartjs/Chart.js/": "2.6.0", - "https://github.com/getsentry/sentry-javascript/": "8.26.0", "https://github.com/mrdoob/three.js/": "r148", "https://github.com/vasturiano/three-spritetext": "1.6.5", "https://github.com/vasturiano/3d-force-graph/": "1.70.19", diff --git a/sith/urls.py b/sith/urls.py index 2befa281..5729db7d 100644 --- a/sith/urls.py +++ b/sith/urls.py @@ -71,6 +71,7 @@ if settings.DEBUG: urlpatterns += [path("__debug__/", include(debug_toolbar.urls))] +if settings.SENTRY_ENV == "development": """Sentry debug endpoint This function always crash and allows us to test