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

Add sentry #5556

Merged
merged 19 commits into from
Jun 3, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ junit.xml

/app/assets/builds/*
!/app/assets/builds/.keep

# Sentry Config File
.env.sentry-build-plugin
18 changes: 18 additions & 0 deletions app/assets/javascripts/sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import * as Sentry from "@sentry/browser";

Check warning on line 1 in app/assets/javascripts/sentry.ts

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/sentry.ts#L1

Added line #L1 was not covered by tests

const HOST_TO_ENVIRONMENT: Record<string, string> = {
"dodona.localhost": "development",
"naos.dodona.be": "staging",
"dodona.be": "production",
};

export function initSentry(): void {
const environment = window.location.hostname in HOST_TO_ENVIRONMENT ?
HOST_TO_ENVIRONMENT[window.location.hostname] : "unknown";

// config options can be found at https://docs.sentry.io/platforms/javascript/configuration/
Sentry.init({
dsn: "https://18315b6d60f9329de56983fd94f67db9@o4507329115783168.ingest.de.sentry.io/4507333215256657",
environment,
});
}
3 changes: 3 additions & 0 deletions app/javascript/packs/application_pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import Rails from "@rails/ujs";

Rails.start();

import { initSentry } from "sentry";
initSentry();

import { i18n } from "i18n/i18n";

// bootstrap
Expand Down
6 changes: 4 additions & 2 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
'https://cdn.jsdelivr.net/pyodide/',
'https://*.googleapis.com',
'http://localhost:3035', 'ws://localhost:3035',
'https://dolos.ugent.be/api/reports'
'https://dolos.ugent.be/api/reports',
'https://o4507329115783168.ingest.de.sentry.io/api/'
else
policy.connect_src :self,
'https://cdn.jsdelivr.net/pyodide/',
'https://cdn.jsdelivr.net/npm/mathjax@3/',
'https://dolos.ugent.be/api/reports'
'https://dolos.ugent.be/api/reports',
'https://o4507329115783168.ingest.de.sentry.io/api/'
end

policy.font_src :self, 'https://fonts.gstatic.com',
Expand Down
11 changes: 11 additions & 0 deletions config/webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require("path");
const fs = require("fs");
const { sentryWebpackPlugin } = require("@sentry/webpack-plugin");

// https://stackoverflow.com/questions/34907999/best-way-to-have-all-files-in-a-directory-be-entry-points-in-webpack
const sourceDirectory = "./app/javascript/packs";
Expand Down Expand Up @@ -67,6 +68,16 @@ const config = {
modules: ["node_modules", "app/assets/javascripts"],
extensions: [".tsx", ".ts", ".mjs", ".js", ".sass", ".scss", ".css", ".module.sass", ".module.scss", ".module.css", ".png", ".svg", ".gif", ".jpeg", ".jpg"]
},
devtool: "source-map", // Source map generation must be turned on
plugins: [
// Put the Sentry Webpack plugin after all other plugins
sentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: "dodona",
project: "dodona-frontend",
}),
],

};

if (process.env.NODE_ENV === "development") {
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
"@rails/activestorage": "^7.1.3",
"@rails/ujs": "^7.1.3",
"@replit/codemirror-lang-csharp": "^6.2.0",
"@sentry/browser": "^8.5.0",
"@sentry/webpack-plugin": "^2.17.0",
"@types/bootstrap": "^5.2.10",
"@types/d3": "^7.4.3",
"@types/dragula": "^3.7.5",
Expand Down
Loading