From 2d979de34fbb86f6dfd72dceb33e7511c9427415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Advaita=20K=E1=B9=9B=E1=B9=A3=E1=B9=87a=20D=C4=81sa?= Date: Sat, 18 Feb 2023 14:21:10 +0100 Subject: [PATCH] Fix Sentry app version Fixes #154 --- package-lock.json | 2 +- package.json | 2 +- src/init/stage-0/initSentry.ts | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index b9e17f3b..1760e49f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "1.1.0", "dependencies": { "@akdasa-studios/shlokas-core": "1.0.2", - "@capacitor/app": "4.1.0", + "@capacitor/app": "^4.1.0", "@capacitor/assets": "^2.0.4", "@capacitor/core": "4.4.0", "@capacitor/device": "^4.1.0", diff --git a/package.json b/package.json index a0a89b29..a2d8a9b5 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ }, "dependencies": { "@akdasa-studios/shlokas-core": "1.0.2", - "@capacitor/app": "4.1.0", + "@capacitor/app": "^4.1.0", "@capacitor/assets": "^2.0.4", "@capacitor/core": "4.4.0", "@capacitor/device": "^4.1.0", diff --git a/src/init/stage-0/initSentry.ts b/src/init/stage-0/initSentry.ts index 74e30c7a..8c0ab8f1 100644 --- a/src/init/stage-0/initSentry.ts +++ b/src/init/stage-0/initSentry.ts @@ -1,23 +1,29 @@ import * as Sentry from '@sentry/capacitor' import { BrowserTracing } from '@sentry/tracing' import * as SentrySibling from '@sentry/vue' +import { App } from '@capacitor/app' import { InitArgs } from '../initialization' /** * Initialize the sentry plugin to track errors */ export async function initSentry({ vue }: InitArgs) { - if (process.env.NODE_ENV === 'development') { - return + if (process.env.NODE_ENV === 'development') { return } + + let version = 'unknown' + try { + const info = await App.getInfo() + version = info.version + } catch (e) { + console.error('Failed to get app version', e) } - const VERSION = process.env.npm_package_version const DSN = 'https://e09ab355192945fb87bc01882eb62578@o257342.ingest.sentry.io/4504486578225152' Sentry.init({ app: vue, dsn: DSN, - release: `shlokas@${VERSION}`, + release: `shlokas@${version}`, dist: '1', tracesSampleRate: 1.0, integrations: [