From 7e5c9a09681dd412f8b48c547565826731119e78 Mon Sep 17 00:00:00 2001 From: jorg-vr Date: Tue, 4 Jun 2024 15:45:46 +0200 Subject: [PATCH] Add release info to sentry --- app/assets/javascripts/sentry.ts | 13 +++++-------- app/javascript/packs/frame.js | 2 ++ app/views/layouts/application.html.erb | 2 ++ app/views/layouts/frame.html.erb | 2 ++ app/views/layouts/lti.html.erb | 2 ++ 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/sentry.ts b/app/assets/javascripts/sentry.ts index 7ab0736567..17325c4e3d 100644 --- a/app/assets/javascripts/sentry.ts +++ b/app/assets/javascripts/sentry.ts @@ -1,18 +1,15 @@ import * as Sentry from "@sentry/browser"; -const HOST_TO_ENVIRONMENT: Record = { - "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"; + const environmentTag = document.querySelector("meta[name='environment']"); + const environment = environmentTag ? environmentTag.getAttribute("content") : "unknown"; + const releaseTag = document.querySelector("meta[name='version']"); + const release = releaseTag ? releaseTag.getAttribute("content") : "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, + release, }); } diff --git a/app/javascript/packs/frame.js b/app/javascript/packs/frame.js index 824de94580..36022c05cd 100644 --- a/app/javascript/packs/frame.js +++ b/app/javascript/packs/frame.js @@ -1,5 +1,7 @@ import "core-js/stable"; import "regenerator-runtime/runtime"; +import { initSentry } from "sentry"; +initSentry(); // bootstrap import { Alert, Button, Collapse, Dropdown, Modal, Popover, Tab, Tooltip } from "bootstrap"; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 112b99732b..c05777484d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -16,6 +16,8 @@ + + "> "> diff --git a/app/views/layouts/frame.html.erb b/app/views/layouts/frame.html.erb index 4856f80575..abeada8719 100644 --- a/app/views/layouts/frame.html.erb +++ b/app/views/layouts/frame.html.erb @@ -7,6 +7,8 @@ + + <%= yield :meta_tags %> diff --git a/app/views/layouts/lti.html.erb b/app/views/layouts/lti.html.erb index 46acabf3b5..417f79b01c 100644 --- a/app/views/layouts/lti.html.erb +++ b/app/views/layouts/lti.html.erb @@ -4,6 +4,8 @@ + + <%= yield :meta_tags %> Dodona<%= " - #{@title}" if @title %>