refactor: remove sentry and crowdin (#730)

We no longer use sentry and crowdin.
This commit is contained in:
Aunali321
2023-03-05 14:42:46 +05:30
committed by GitHub
parent 68ccefc59f
commit 5617535a63
19 changed files with 198 additions and 283 deletions

View File

@ -1,63 +0,0 @@
import 'package:dio/dio.dart';
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
import 'package:injectable/injectable.dart' hide Environment;
import 'package:revanced_manager/utils/environment.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
@lazySingleton
class CrowdinAPI {
late Dio _dio = Dio();
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final apiKey = Environment.crowdinKEY;
Future<void> initialize() async {
try {
_dio = Dio(
BaseOptions(
baseUrl: 'https://api.crowdin.com/api/v2',
),
);
_dio.interceptors.add(_dioCacheManager.interceptor);
_dio.addSentry(
captureFailedRequests: true,
);
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
}
}
Future<void> clearAllCache() async {
try {
await _dioCacheManager.clearAll();
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
}
}
Future<List> getLanguages() async {
try {
final response = await _dio.get(
'/projects',
options: buildCacheOptions(
const Duration(hours: 6),
maxStale: const Duration(days: 1),
options: Options(
headers: {
'Authorization': 'Bearer $apiKey',
},
contentType: 'application/json',
),
),
);
final List targetLanguages =
await response.data['data'][0]['data']['targetLanguages'];
return targetLanguages;
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return [];
}
}
}

View File

@ -4,11 +4,10 @@ import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dio/dio.dart';
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart';
import 'package:revanced_manager/models/patch.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
@lazySingleton
class GithubAPI {
@ -38,19 +37,20 @@ class GithubAPI {
);
_dio.interceptors.add(_dioCacheManager.interceptor);
_dio.addSentry(
captureFailedRequests: true,
);
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
Future<void> clearAllCache() async {
try {
await _dioCacheManager.clearAll();
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
@ -61,8 +61,10 @@ class GithubAPI {
options: _cacheOptions,
);
return response.data[0];
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
}
@ -92,10 +94,12 @@ class GithubAPI {
'\n' as String,
)
.toList();
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return List.empty();
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
return [];
}
Future<File?> getLatestReleaseFile(String extension, String repoName) async {
@ -112,9 +116,10 @@ class GithubAPI {
);
}
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return null;
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
return null;
}
@ -127,10 +132,12 @@ class GithubAPI {
final List<dynamic> list = jsonDecode(f.readAsStringSync());
patches = list.map((patch) => Patch.fromJson(patch)).toList();
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return List.empty();
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
return patches;
}
@ -142,9 +149,12 @@ class GithubAPI {
} else {
return 'Unknown';
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
return '';
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return 'Unknown';
}
}
}

View File

@ -1,6 +1,7 @@
import 'dart:convert';
import 'dart:io';
import 'package:device_apps/device_apps.dart';
import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
@ -10,7 +11,6 @@ import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/github_api.dart';
import 'package:revanced_manager/services/revanced_api.dart';
import 'package:revanced_manager/services/root_api.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';
@lazySingleton
@ -98,14 +98,6 @@ class ManagerAPI {
await _prefs.setBool('useDarkTheme', value);
}
bool isSentryEnabled() {
return _prefs.getBool('sentryEnabled') ?? true;
}
Future<void> setSentryStatus(bool value) async {
await _prefs.setBool('sentryEnabled', value);
}
bool areUniversalPatchesEnabled() {
return _prefs.getBool('universalPatchesEnabled') ?? false;
}
@ -179,8 +171,10 @@ class ManagerAPI {
try {
_revancedAPI.clearAllCache();
_githubAPI.clearAllCache();
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
@ -196,8 +190,10 @@ class ManagerAPI {
} else {
return await _githubAPI.getPatches(repoName);
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return [];
}
}
@ -213,8 +209,10 @@ class ManagerAPI {
} else {
return await _githubAPI.getLatestReleaseFile('.jar', repoName);
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
}
@ -230,8 +228,10 @@ class ManagerAPI {
} else {
return await _githubAPI.getLatestReleaseFile('.apk', repoName);
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
}

View File

@ -13,7 +13,6 @@ import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/models/patched_application.dart';
import 'package:revanced_manager/services/manager_api.dart';
import 'package:revanced_manager/services/root_api.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:share_extend/share_extend.dart';
@lazySingleton
@ -49,8 +48,10 @@ class PatcherAPI {
if (_patches.isEmpty) {
_patches = await _managerAPI.getPatches();
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
_patches = List.empty();
}
}
@ -91,9 +92,10 @@ class PatcherAPI {
filteredApps.add(app);
}
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
continue;
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
}
@ -151,8 +153,10 @@ class PatcherAPI {
);
}
return originalFilePath;
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return originalFilePath;
}
}
@ -173,9 +177,10 @@ class PatcherAPI {
if (settingsPatch != null) {
selectedPatches.add(settingsPatch);
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
// ignore
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
final File? patchBundleFile = await _managerAPI.downloadPatches();
@ -207,11 +212,10 @@ class PatcherAPI {
'keyStoreFilePath': _keyStoreFile.path,
},
);
} on Exception catch (e, s) {
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
throw await Sentry.captureException(e, stackTrace: s);
}
}
}
@ -232,8 +236,10 @@ class PatcherAPI {
await AppInstaller.installApk(_outFile!.path);
return await DeviceApps.isAppInstalled(patchedApp.packageName);
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return false;
}
}
@ -244,11 +250,17 @@ class PatcherAPI {
try {
if (_outFile != null) {
final String newName = _getFileName(appName, version);
CRFileSaver.saveFileWithDialog(SaveFileDialogParams(
sourceFilePath: _outFile!.path, destinationFileName: newName,),);
CRFileSaver.saveFileWithDialog(
SaveFileDialogParams(
sourceFilePath: _outFile!.path,
destinationFileName: newName,
),
);
}
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s);
}
}
@ -262,8 +274,10 @@ class PatcherAPI {
final File shareFile = _outFile!.copySync(newPath);
ShareExtend.share(shareFile.path, 'file');
}
} on Exception catch (e, s) {
Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}

View File

@ -4,13 +4,12 @@ import 'dart:io';
import 'package:collection/collection.dart';
import 'package:dio/dio.dart';
import 'package:dio_http_cache_lts/dio_http_cache_lts.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:injectable/injectable.dart';
import 'package:native_dio_client/native_dio_client.dart';
import 'package:revanced_manager/models/patch.dart';
import 'package:revanced_manager/utils/check_for_gms.dart';
import 'package:sentry_dio/sentry_dio.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:timeago/timeago.dart';
@lazySingleton
@ -42,19 +41,20 @@ class RevancedAPI {
log('ReVanced API: Using CronetEngine + $isGMSInstalled');
}
_dio.interceptors.add(_dioCacheManager.interceptor);
_dio.addSentry(
captureFailedRequests: true,
);
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
Future<void> clearAllCache() async {
try {
await _dioCacheManager.clearAll();
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
}
}
@ -67,8 +67,10 @@ class RevancedAPI {
final String name = repo['name'];
contributors[name] = repo['contributors'];
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return {};
}
return contributors;
@ -79,8 +81,10 @@ class RevancedAPI {
final response = await _dio.get('/patches', options: _cacheOptions);
final List<dynamic> patches = response.data;
return patches.map((patch) => Patch.fromJson(patch)).toList();
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return List.empty();
}
}
@ -97,8 +101,10 @@ class RevancedAPI {
t['repository'] == repoName &&
(t['name'] as String).endsWith(extension),
);
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
}
@ -115,8 +121,10 @@ class RevancedAPI {
if (release != null) {
return release['version'];
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
return null;
@ -132,8 +140,10 @@ class RevancedAPI {
final String url = release['browser_download_url'];
return await DefaultCacheManager().getSingleFile(url);
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
return null;
@ -153,8 +163,10 @@ class RevancedAPI {
DateTime.parse(release['timestamp'] as String);
return format(timestamp, locale: 'en_short');
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return null;
}
return null;

View File

@ -1,5 +1,5 @@
import 'package:flutter/foundation.dart';
import 'package:root/root.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class RootAPI {
final String _managerDirPath = '/data/local/tmp/revanced-manager';
@ -10,8 +10,10 @@ class RootAPI {
try {
final bool? isRooted = await Root.isRootAvailable();
return isRooted != null && isRooted;
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return false;
}
}
@ -24,8 +26,10 @@ class RootAPI {
return isRooted != null && isRooted;
}
return false;
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return false;
}
}
@ -78,8 +82,10 @@ class RootAPI {
apps.removeWhere((pack) => pack.isEmpty);
return apps.map((pack) => pack.trim()).toList();
}
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return List.empty();
}
return List.empty();
@ -125,8 +131,10 @@ class RootAPI {
await installApk(packageName, patchedFilePath);
await mountApk(packageName, originalFilePath);
return true;
} on Exception catch (e, s) {
await Sentry.captureException(e, stackTrace: s);
} on Exception catch (e) {
if (kDebugMode) {
print(e);
}
return false;
}
}