Skip to content

Commit

Permalink
Add release info to sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Jun 4, 2024
1 parent 5f55689 commit 7e5c9a0
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
13 changes: 5 additions & 8 deletions app/assets/javascripts/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import * as Sentry from "@sentry/browser";

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";
const environmentTag = document.querySelector("meta[name='environment']");

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

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/sentry.ts#L4

Added line #L4 was not covered by tests
const environment = environmentTag ? environmentTag.getAttribute("content") : "unknown";
const releaseTag = document.querySelector("meta[name='version']");

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

View check run for this annotation

Codecov / codecov/patch

app/assets/javascripts/sentry.ts#L6

Added line #L6 was not covered by tests
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,
});
}
2 changes: 2 additions & 0 deletions app/javascript/packs/frame.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<meta property="og:image" content="<%= root_url(locale: nil) %>social-image.png">
<meta name="msapplication-TileColor" content="#2196F3"/>
<meta name="msapplication-TileImage" content="/icon.png"/>
<meta name="version" content="<%= Dodona::Application::VERSION %>">
<meta name="environment" content="<%= Rails.env %>">
<link rel="apple-touch-icon-precomposed" href="/icon.png"/>
<link rel="shortcut icon" sizes="192x192" href="<%= @dot_icon&.any? ? "/icon-not.png" : "/icon.png" %>">
<link rel="shortcut icon" href="<%= @dot_icon&.any? ? "/favicon-not.ico" : "/favicon.ico" %>">
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/frame.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="version" content="<%= Dodona::Application::VERSION %>">
<meta name="environment" content="<%= Rails.env %>">
<%= yield :meta_tags %>
<meta property="og:image" content="<%= root_url(locale: nil) %>icon.png">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/lti.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="version" content="<%= Dodona::Application::VERSION %>">
<meta name="environment" content="<%= Rails.env %>">
<%= yield :meta_tags %>
<title>Dodona<%= " - #{@title}" if @title %></title>
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
Expand Down

0 comments on commit 7e5c9a0

Please sign in to comment.