Skip to content

Commit

Permalink
fix(sentry): 🐛 set release version for proper tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDynamo committed May 2, 2024
1 parent 00372cc commit 0f4d08c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apps/wizarr-backend/wizarr_backend/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .utils.clear_logs import clear_logs
from .migrator import run_migrations

from utils.software_lifecycle import get_current_version
from sentry_sdk import init as sentry_init

# Get the base directory
Expand All @@ -26,6 +27,7 @@
enable_tracing=True,
traces_sample_rate=1.0,
environment=app.debug and "development" or "production",
release=get_current_version(),
)

# Base route for testing
Expand Down
13 changes: 13 additions & 0 deletions apps/wizarr-frontend/src/plugins/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@ const isBugReporting = () => {
return true;
};

const getVersion = () => {
const localStorage = window.localStorage.getItem("server");

if (localStorage !== null) {
const server = JSON.parse(localStorage);
return server.version;
}

return true;
};

const vuePluginSentry = {
install: (app: App, options?: SentryOptions) => {
const bugReporting = isBugReporting();
const version = getVersion();

console.log("\x1b[32m%s\x1b[0m", "Sentry: Initializing");
console.log(bugReporting ? "\x1b[31m%s\x1b[0m" : "\x1b[32m%s\x1b[0m", "Sentry: Bug Reporting is " + (bugReporting ? "OFF" : "ON"));
Expand All @@ -45,6 +57,7 @@ const vuePluginSentry = {
}),
],
environment: process.env.NODE_ENV,
release: version,
tracesSampleRate: 1.0,
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
Expand Down
3 changes: 3 additions & 0 deletions apps/wizarr-frontend/src/stores/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const useServerStore = defineStore("server", {
if (state.settings.bug_reporting === undefined) return true;
return state.settings.bug_reporting === "true";
},
version(state) {
return state.version;
}
},
actions: {
setServerData(server_data: Partial<Server> | undefined) {
Expand Down

0 comments on commit 0f4d08c

Please sign in to comment.