mirror of
				https://github.com/inventree/inventree-app.git
				synced 2025-10-30 21:05:42 +00:00 
			
		
		
		
	Simplify DSN file (#475)
* Add checks for empty sentry DSN * Add default DSN key * Fix CI workflows
This commit is contained in:
		
							
								
								
									
										1
									
								
								.github/workflows/android.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/android.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -37,5 +37,4 @@ jobs: | |||||||
|     - name: Build for Android |     - name: Build for Android | ||||||
|       run: | |       run: | | ||||||
|         flutter pub get |         flutter pub get | ||||||
|         cp lib/dummy_dsn.dart lib/dsn.dart |  | ||||||
|         flutter build apk --debug |         flutter build apk --debug | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								.github/workflows/ci.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/ci.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -43,7 +43,6 @@ jobs: | |||||||
|           python3 collect_translations.py |           python3 collect_translations.py | ||||||
|       - name: Static Analysis Tests |       - name: Static Analysis Tests | ||||||
|         run: | |         run: | | ||||||
|           cp lib/dummy_dsn.dart lib/dsn.dart |  | ||||||
|           python3 find_dart_files.py |           python3 find_dart_files.py | ||||||
|           flutter pub get |           flutter pub get | ||||||
|           flutter analyze |           flutter analyze | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								.github/workflows/ios.yaml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/workflows/ios.yaml
									
									
									
									
										vendored
									
									
								
							| @@ -38,5 +38,4 @@ jobs: | |||||||
|         pod repo update |         pod repo update | ||||||
|         pod install |         pod install | ||||||
|         cd .. |         cd .. | ||||||
|         cp lib/dummy_dsn.dart lib/dsn.dart |  | ||||||
|         flutter build ios --release --no-codesign --no-tree-shake-icons |         flutter build ios --release --no-codesign --no-tree-shake-icons | ||||||
|   | |||||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -15,9 +15,6 @@ coverage/* | |||||||
| test/coverage_helper_test.dart | test/coverage_helper_test.dart | ||||||
| InvenTreeSettings.db | InvenTreeSettings.db | ||||||
|  |  | ||||||
| # Sentry API key |  | ||||||
| lib/dsn.dart |  | ||||||
|  |  | ||||||
| # App signing key | # App signing key | ||||||
| android/key.properties | android/key.properties | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										7
									
								
								lib/dsn.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								lib/dsn.dart
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | |||||||
|  |  | ||||||
|  | /* | ||||||
|  |  * For integration with sentry.io, fill out the SENTRY_DSN_KEY value below. | ||||||
|  |  * This should be set to a valid DSN key, from your sentry.io account | ||||||
|  |  * | ||||||
|  |  */ | ||||||
|  | String SENTRY_DSN_KEY = "https://fea705aa4b8e4c598dcf9b146b3d1b86@o378676.ingest.sentry.io/5202450"; | ||||||
| @@ -1,3 +0,0 @@ | |||||||
| // Dummy DSN to use for unit testing, etc |  | ||||||
|  |  | ||||||
| const String SENTRY_DSN_KEY = "https://12345678901234567890@abcdef.ingest.sentry.io/11223344"; |  | ||||||
| @@ -6,6 +6,7 @@ import "package:package_info_plus/package_info_plus.dart"; | |||||||
| import "package:sentry_flutter/sentry_flutter.dart"; | import "package:sentry_flutter/sentry_flutter.dart"; | ||||||
|  |  | ||||||
| import "package:inventree/api.dart"; | import "package:inventree/api.dart"; | ||||||
|  | import "package:inventree/dsn.dart"; | ||||||
| import "package:inventree/preferences.dart"; | import "package:inventree/preferences.dart"; | ||||||
|  |  | ||||||
| Future<Map<String, dynamic>> getDeviceInfo() async { | Future<Map<String, dynamic>> getDeviceInfo() async { | ||||||
| @@ -85,6 +86,10 @@ bool isInDebugMode() { | |||||||
|  |  | ||||||
| Future<bool> sentryReportMessage(String message, {Map<String, String>? context}) async { | Future<bool> sentryReportMessage(String message, {Map<String, String>? context}) async { | ||||||
|  |  | ||||||
|  |   if (SENTRY_DSN_KEY.isEmpty) { | ||||||
|  |     return false; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   final server_info = getServerInfo(); |   final server_info = getServerInfo(); | ||||||
|   final app_info = await getAppInfo(); |   final app_info = await getAppInfo(); | ||||||
|   final device_info = await getDeviceInfo(); |   final device_info = await getDeviceInfo(); | ||||||
| @@ -164,6 +169,10 @@ Future<void> sentryReportError(String source, dynamic error, StackTrace? stackTr | |||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   if (SENTRY_DSN_KEY.isEmpty) { | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |  | ||||||
|   final upload = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool; |   final upload = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool; | ||||||
|  |  | ||||||
|   if (!upload) { |   if (!upload) { | ||||||
|   | |||||||
| @@ -34,6 +34,7 @@ Future<void> main() async { | |||||||
|  |  | ||||||
|     String release = "${pkg}@${version}:${build}"; |     String release = "${pkg}@${version}:${build}"; | ||||||
|  |  | ||||||
|  |     if (SENTRY_DSN_KEY.isNotEmpty) { | ||||||
|       await Sentry.init((options) { |       await Sentry.init((options) { | ||||||
|         options.dsn = SENTRY_DSN_KEY; |         options.dsn = SENTRY_DSN_KEY; | ||||||
|         options.release = release; |         options.release = release; | ||||||
| @@ -41,6 +42,7 @@ Future<void> main() async { | |||||||
|         options.diagnosticLevel = SentryLevel.debug; |         options.diagnosticLevel = SentryLevel.debug; | ||||||
|         options.attachStacktrace = true; |         options.attachStacktrace = true; | ||||||
|       }); |       }); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     // Pass any flutter errors off to the Sentry reporting context! |     // Pass any flutter errors off to the Sentry reporting context! | ||||||
|     FlutterError.onError = (FlutterErrorDetails details) async { |     FlutterError.onError = (FlutterErrorDetails details) async { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user