mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-07 19:49:29 +00:00
feat: error reporting with logs (#45)
* feat: add ability to get logs file from ui * test: add unit test for log line parsing in logs_provider * refactor: update all logs to obfuscate sensitive information * feat: generate dynamic zip file name for logs export * feat: enhance logging in audiobook player and provider for better debugging * refactor: extract user display logic into UserBar widget for offline access of settings and logs * feat: add About section with app metadata and source code link in YouPage
This commit is contained in:
parent
7b0c2c4b88
commit
35a2d7cfce
44 changed files with 861 additions and 176 deletions
125
lib/shared/extensions/obfuscation.dart
Normal file
125
lib/shared/extensions/obfuscation.dart
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:vaani/settings/models/api_settings.dart';
|
||||
import 'package:vaani/settings/models/audiobookshelf_server.dart';
|
||||
import 'package:vaani/settings/models/authenticated_user.dart';
|
||||
|
||||
// bool kReleaseMode = true;
|
||||
|
||||
extension ObfuscateString on String {
|
||||
String obfuscate() {
|
||||
if (!kReleaseMode) {
|
||||
return this;
|
||||
}
|
||||
return 'obfuscated';
|
||||
}
|
||||
}
|
||||
|
||||
extension ObfuscateURI on Uri {
|
||||
/// keeps everything except the base url for security reasons
|
||||
Uri obfuscate() {
|
||||
if (!kReleaseMode) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// do not obfuscate the local host
|
||||
if ([null, 'localhost'].contains(host)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// do not obfuscate file urls
|
||||
if (scheme == 'file') {
|
||||
return this;
|
||||
}
|
||||
|
||||
return replace(
|
||||
userInfo: userInfo == '' ? '' : 'userInfoObfuscated',
|
||||
host: 'hostObfuscated',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension ObfuscateList<T> on List<T> {
|
||||
List<T> obfuscate() {
|
||||
return map((e) {
|
||||
if (e is AuthenticatedUser) {
|
||||
return e.obfuscate() as T;
|
||||
} else if (e is AudiobookShelfServer) {
|
||||
return e.obfuscate() as T;
|
||||
} else if (e is Uri) {
|
||||
return e.obfuscate() as T;
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
extension ObfuscateSet<T> on Set<T> {
|
||||
Set<T> obfuscate() {
|
||||
return toList().obfuscate().toSet();
|
||||
}
|
||||
}
|
||||
|
||||
extension ObfuscateAuthenticatedUser on AuthenticatedUser {
|
||||
AuthenticatedUser obfuscate() {
|
||||
if (!kReleaseMode) {
|
||||
return this;
|
||||
}
|
||||
return copyWith(
|
||||
password: password == null ? null : 'passwordObfuscated',
|
||||
username: username == null ? null : 'usernameObfuscated',
|
||||
authToken: 'authTokenObfuscated',
|
||||
server: server.obfuscate(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension ObfuscateServer on AudiobookShelfServer {
|
||||
AudiobookShelfServer obfuscate() {
|
||||
if (!kReleaseMode) {
|
||||
return this;
|
||||
}
|
||||
return copyWith(
|
||||
serverUrl: serverUrl.obfuscate(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension ObfuscateApiSettings on ApiSettings {
|
||||
ApiSettings obfuscate() {
|
||||
if (!kReleaseMode) {
|
||||
return this;
|
||||
}
|
||||
return copyWith(
|
||||
activeServer: activeServer?.obfuscate(),
|
||||
activeUser: activeUser?.obfuscate(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension ObfuscateRequest on http.BaseRequest {
|
||||
http.BaseRequest obfuscate() {
|
||||
if (!kReleaseMode) {
|
||||
return this;
|
||||
}
|
||||
return http.Request(
|
||||
method,
|
||||
url.obfuscate(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension ObfuscateResponse on http.Response {
|
||||
http.Response obfuscate() {
|
||||
if (!kReleaseMode) {
|
||||
return this;
|
||||
}
|
||||
return http.Response(
|
||||
body,
|
||||
statusCode,
|
||||
headers: headers,
|
||||
request: request?.obfuscate(),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue