Skip to content

Commit

Permalink
fix: bug reporting & updates (#2249)
Browse files Browse the repository at this point in the history
* refactor: moved bug reporting init into own file

* fix: sentry dsn

* fix: auto updater only initialized on platforms that support it

* fix: available updates not shown for older or same version

* refactor: fix log level

* refactor: add dev-app-update.yml

* refactor: rename dev-app-update

* refactor: changed update badge label
  • Loading branch information
sr258 committed Apr 16, 2022
1 parent c1f814e commit f51ce08
Show file tree
Hide file tree
Showing 47 changed files with 476 additions and 310 deletions.
3 changes: 3 additions & 0 deletions _dev-app-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
provider: generic
url: http://localhost:8082/
updaterCacheDirName: lumi-updater
49 changes: 20 additions & 29 deletions client/src/helpers/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ export type logLevel =
| 'silly';

export default class Logger {
constructor(scope: string) {
this.scope = scope;

constructor(private scope: string) {
this.DEBUG =
this.ERROR =
this.INFO =
Expand All @@ -29,57 +27,50 @@ export default class Logger {
this.WARN =
debug(`lumi:${this.scope}`);

try {
this.logLevel =
(window.localStorage.logLevel as logLevel) || 'info';
} catch (error: any) {
this.ERROR(error as string);
this.logLevel = 'info';
}
this.logLevel = 'info';
}

private DEBUG: (message: string) => void;
private ERROR: (message: string) => void;
private INFO: (message: string) => void;
private DEBUG: (...args: any[]) => any;
private ERROR: (...args: any[]) => any;
private INFO: (...args: any[]) => any;
private logLevel: logLevel;
private scope: string;
private SILLY: (message: string) => void;
private VERBOSE: (message: string) => void;
private WARN: (message: string) => void;
private SILLY: (...args: any[]) => any;
private VERBOSE: (...args: any[]) => any;
private WARN: (...args: any[]) => any;

public debug(message: string): void {
public debug(...args: any[]): void {
if (logLevelNumber[this.logLevel] >= logLevelNumber.debug) {
this.DEBUG(message);
this.DEBUG(...args);
}
}

public error(message: string): void {
public error(...args: any[]): void {
if (logLevelNumber[this.logLevel] >= logLevelNumber.error) {
this.ERROR(message);
this.ERROR(...args);
}
}

public info(message: string): void {
public info(...args: any[]): void {
if (logLevelNumber[this.logLevel] >= logLevelNumber.info) {
this.INFO(message);
this.INFO(...args);
}
}

public silly(message: string): void {
public silly(...args: any[]): void {
if (logLevelNumber[this.logLevel] >= logLevelNumber.silly) {
this.SILLY(message);
this.SILLY(...args);
}
}

public verbose(message: string): void {
public verbose(...args: any[]): void {
if (logLevelNumber[this.logLevel] >= logLevelNumber.verbose) {
this.VERBOSE(message);
this.VERBOSE(...args);
}
}

public warn(message: string): void {
public warn(...args: any[]): void {
if (logLevelNumber[this.logLevel] >= logLevelNumber.warn) {
this.WARN(message);
this.WARN(...args);
}
}
}
12 changes: 11 additions & 1 deletion client/src/services/UpdatesAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@ import superagent from 'superagent';
import { IUpdateInfo } from '../state/Updates/UpdatesTypes';

export async function getUpdates(): Promise<IUpdateInfo> {
return (await superagent.get(`/api/v1/updates`)).body;
const result = await superagent.get('/api/v1/updates');
if (result.statusCode === 200) {
return result.body;
} else {
return {
version: '',
releaseDate: '',
releaseName: '',
releaseNotes: ''
};
}
}

export async function update(): Promise<void> {
Expand Down
1 change: 0 additions & 1 deletion client/src/state/Updates/UpdatesReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from './UpdatesTypes';

export const initialState: IUpdatesState = {
updateAvailable: false,
checkingForUpdates: false,
updateInfo: {
version: '',
Expand Down
1 change: 0 additions & 1 deletion client/src/state/Updates/UpdatesTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export interface IUpdateInfo {
}

export interface IUpdatesState {
updateAvailable: boolean;
checkingForUpdates: boolean;
updateInfo: IUpdateInfo;
downloadProgress: {
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default function FullScreenDialog() {
);

const updateAvailable = useSelector(
(state: IState) => state.updates.updateInfo.releaseName !== ''
(state: IState) => state.updates.updateInfo.version !== ''
);

const allowPrerelease = useSelector(
Expand Down
2 changes: 1 addition & 1 deletion client/src/views/components/Settings/UpdatesSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default function UpdatesSettingsList() {
</ListItem>
</List>

{updateInfo.releaseName !== '' && (
{updateInfo.version !== '' && (
<UpdateInfoCard
updateCallback={() => dispatch(actions.updates.update())}
releaseName={updateInfo.releaseName}
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/af.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"checkButton": "Tjek"
},
"restartAndInstall": "Installeer en herbegin",
"badge": "Opdateer"
"badge": "Opdatering beskikbaar"
},
"language": {
"title": "Taal",
Expand Down Expand Up @@ -288,7 +288,8 @@
},
"updater": {
"availableText": "Opdatering is beskikbaar. Die toepassing sal die opdatering installeer en herbegin.",
"availableTitle": "Installeer opdaterings"
"availableTitle": "Installeer opdaterings",
"updateDownloaded": "Opdatering is afgelaai en sal geïnstalleer word sodra jy Lumi verlaat."
}
},
"auth": {
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"checkButton": "ይፈትሹ"
},
"restartAndInstall": "ይጫኑ እና እንደገና ያስጀምሩ",
"badge": "አዘምን"
"badge": "ማዘመን አለ።"
},
"language": {
"title": "ቋንቋ",
Expand Down Expand Up @@ -288,7 +288,8 @@
},
"updater": {
"availableText": "ማዘመን አለ። አፕሊኬሽኑ ዝመናውን ይጭናል እና እንደገና ይጀምራል።",
"availableTitle": "ዝመናዎችን ጫን"
"availableTitle": "ዝመናዎችን ጫን",
"updateDownloaded": "ዝማኔ ወርዷል እና Lumiን ከለቀቀ በኋላ ይጫናል።"
}
},
"auth": {
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"checkButton": "التحقق من"
},
"restartAndInstall": "التثبيت وإعادة التشغيل",
"badge": "تحديث"
"badge": "التحديث متاح"
},
"language": {
"title": "لغة",
Expand Down Expand Up @@ -288,7 +288,8 @@
},
"updater": {
"availableText": "يتوفر التحديث. سيقوم التطبيق بتثبيت التحديث وإعادة التشغيل.",
"availableTitle": "تثبيت التحديثات"
"availableTitle": "تثبيت التحديثات",
"updateDownloaded": "تم تنزيل التحديث وسيتم تثبيته بمجرد إنهاء Lumi."
}
},
"auth": {
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/bg.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"checkButton": "Проверете"
},
"restartAndInstall": "Инсталирайте и рестартирайте",
"badge": "Актуализиране"
"badge": "Налична е актуализация"
},
"language": {
"title": "Език",
Expand Down Expand Up @@ -288,7 +288,8 @@
},
"updater": {
"availableText": "Актуализацията е налична. Приложението ще инсталира актуализацията и ще се рестартира.",
"availableTitle": "Инсталирайте актуализации"
"availableTitle": "Инсталирайте актуализации",
"updateDownloaded": "Актуализацията беше изтеглена и ще бъде инсталирана, след като излезете от Lumi."
}
},
"auth": {
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"checkButton": "Proveri"
},
"restartAndInstall": "Instalirajte i ponovo pokrenite",
"badge": "Update"
"badge": "Dostupno je ažuriranje"
},
"language": {
"title": "Jezik",
Expand Down Expand Up @@ -288,7 +288,8 @@
},
"updater": {
"availableText": "Ažuriranje je dostupno. Aplikacija će instalirati ažuriranje i ponovo pokrenuti.",
"availableTitle": "Instalirajte ažuriranja"
"availableTitle": "Instalirajte ažuriranja",
"updateDownloaded": "Ažuriranje je preuzeto i biće instalirano nakon što napustite Lumi."
}
},
"auth": {
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
"checkButton": "Comprovar"
},
"restartAndInstall": "Instal·leu i reinicieu",
"badge": "Actualització"
"badge": "Actualització disponible"
},
"language": {
"title": "Llenguatge",
Expand Down Expand Up @@ -288,7 +288,8 @@
},
"updater": {
"availableText": "L'actualització està disponible. L'aplicació instal·larà l'actualització i reiniciarà.",
"availableTitle": "Instal·leu les actualitzacions"
"availableTitle": "Instal·leu les actualitzacions",
"updateDownloaded": "L'actualització s'ha baixat i s'instal·larà un cop sortiu de Lumi."
}
},
"auth": {
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/cs.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@
},
"updater": {
"availableText": "Aktualizace je k dispozici. Aplikace nainstaluje aktualizaci a restartuje se.",
"availableTitle": "Nainstalujte aktualizace"
"availableTitle": "Nainstalujte aktualizace",
"updateDownloaded": "Aktualizace byla stažena a bude nainstalována, jakmile Lumi ukončíte."
}
},
"privacy_policy": {
Expand Down Expand Up @@ -311,7 +312,7 @@
"checkButton": "Šek"
},
"restartAndInstall": "Nainstalujte a restartujte",
"badge": "Aktualizace"
"badge": "Aktualizace k dispozici"
},
"usage_statistics": {
"consent": "Povoluji této aplikaci odesílat anonymní statistiky používání.",
Expand Down
7 changes: 4 additions & 3 deletions locales/lumi/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@
},
"updater": {
"availableText": "Update ist verfügbar. Die Anwendung installiert das Update und startet neu.",
"availableTitle": "Installiere Updates"
"availableTitle": "Installiere Updates",
"updateDownloaded": "Das Update wurde heruntergeladen und wird installiert, sobald Sie Lumi beenden."
}
},
"prerelease": {
Expand Down Expand Up @@ -355,7 +356,6 @@
"description": "Der Schutz der Privatsphäre des Einzelnen ist uns wichtig. Wir sammeln nur die Informationen, die du auswählst, und verarbeiten sie mit deiner Zustimmung. Wir wollen so transparent wie möglich sein. Lumi ist jedoch auf einige Internet-Verbindungen und Datenübertragungen angewiesen, um zu funktionieren."
},
"updates": {
"badge": "Aktualisieren",
"checkForUpdate": {
"checkButton": "Prüfen",
"description": "Auf Updates prüfen",
Expand All @@ -364,7 +364,8 @@
"consent": "Ich erlaube dieser Anwendung, automatisch nach Updates zu suchen.",
"description": "Bleibe auf dem neuesten Stand und installiere automatisch die neueste Version.",
"restartAndInstall": "Installieren und neu starten",
"title": "Automatische Updates"
"title": "Automatische Updates",
"badge": "Update verfügbar"
},
"usage_statistics": {
"consent": "Ich erlaube dieser Anwendung, anonyme Nutzungsstatistiken zu senden.",
Expand Down
7 changes: 4 additions & 3 deletions locales/lumi/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@
},
"updater": {
"availableText": "Η ενημέρωση είναι διαθέσιμη. Η εφαρμογή θα εγκαταστήσει την ενημέρωση και θα επανεκκινήσει.",
"availableTitle": "Εγκαταστήστε τις ενημερώσεις"
"availableTitle": "Εγκαταστήστε τις ενημερώσεις",
"updateDownloaded": "Η ενημέρωση έγινε λήψη και θα εγκατασταθεί μόλις κλείσετε το Lumi."
}
},
"prerelease": {
Expand Down Expand Up @@ -355,7 +356,6 @@
"description": "Η προστασία της ιδιωτικής ζωής του ατόμου είναι σημαντική για εμάς. Συλλέγουμε μόνο τις πληροφορίες που επιλέγετε να μας δώσετε και τις επεξεργαζόμαστε με τη συγκατάθεσή σας. Θέλουμε να είμαστε όσο το δυνατόν πιο διαφανείς. Ωστόσο, η Lumi βασίζεται σε ορισμένες συνδέσεις και μεταφορές δεδομένων στην εργασία."
},
"updates": {
"badge": "Εκσυγχρονίζω",
"checkForUpdate": {
"checkButton": "Ελεγχος",
"description": "Ελεγχος για ενημερώσεις",
Expand All @@ -364,7 +364,8 @@
"consent": "Επιτρέπω σε αυτήν την εφαρμογή να ελέγχει αυτόματα για ενημερώσεις.",
"description": "Λάβετε αυτόματα την πιο πρόσφατη έκδοση.",
"restartAndInstall": "Εγκατάσταση και επανεκκίνηση",
"title": "Αυτόματες ενημερώσεις"
"title": "Αυτόματες ενημερώσεις",
"badge": "Διαθέσιμη ενημέρωση"
},
"usage_statistics": {
"consent": "Επιτρέπω σε αυτήν την εφαρμογή να στέλνει ανώνυμα στατιστικά χρήσης.",
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@
},
"updater": {
"availableText": "Update is available. The application will install the update and restart.",
"availableTitle": "Install Updates"
"availableTitle": "Install Updates",
"updateDownloaded": "Update was downloaded and will be installed once you quit Lumi."
}
},
"prerelease": {
Expand Down Expand Up @@ -355,7 +356,7 @@
"description": "Protecting the individual's privacy is important for us. We only collect the information you choose to give us, and we process it with your consent. We want to be as transparent as possible. However Lumi relies on some connections and data transfers to work."
},
"updates": {
"badge": "Update",
"badge": "Update available",
"checkForUpdate": {
"checkButton": "Check",
"description": "Check for updates",
Expand Down
7 changes: 4 additions & 3 deletions locales/lumi/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@
},
"updater": {
"availableText": "Actualización disponible. La aplicación instalará la actualización y se reiniciará.",
"availableTitle": "Instalar actualizaciones"
"availableTitle": "Instalar actualizaciones",
"updateDownloaded": "La actualización se descargó y se instalará una vez que salgas de Lumi."
}
},
"prerelease": {
Expand Down Expand Up @@ -355,7 +356,6 @@
"description": "Proteger la privacidad del individuo es importante para nosotros. Solo recopilamos la información que usted elige darnos y la procesamos con su consentimiento. Queremos ser lo más transparentes posible. Sin embargo, Lumi depende de algunas conexiones y transferencias de datos para funcionar."
},
"updates": {
"badge": "Actualizar",
"checkForUpdate": {
"checkButton": "Cheque",
"description": "Buscar actualizaciones",
Expand All @@ -364,7 +364,8 @@
"consent": "Yo permito que esta aplicación busque actualizaciones automáticamente.",
"description": "Obtenga la última versión automáticamente.",
"restartAndInstall": "Instalar y reiniciar",
"title": "Actualizaciones Automáticas"
"title": "Actualizaciones Automáticas",
"badge": "Actualización disponible"
},
"usage_statistics": {
"consent": "Yo permito que esta aplicación envíe estadísticas de uso anónimas.",
Expand Down
5 changes: 3 additions & 2 deletions locales/lumi/et.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@
},
"updater": {
"availableText": "Värskendus on saadaval. Rakendus installib värskenduse ja taaskäivitab.",
"availableTitle": "Installige värskendused"
"availableTitle": "Installige värskendused",
"updateDownloaded": "Värskendus laaditi alla ja installitakse pärast Lumist väljumist."
}
},
"privacy_policy": {
Expand Down Expand Up @@ -311,7 +312,7 @@
"checkButton": "Kontrollima"
},
"restartAndInstall": "Installige ja taaskäivitage",
"badge": "Värskenda"
"badge": "Uuendus saadaval"
},
"usage_statistics": {
"consent": "Luban sellel rakendusel saata anonüümset kasutusstatistikat.",
Expand Down

0 comments on commit f51ce08

Please sign in to comment.