From 90db9ff6c609bc213a723fd0f6bbdcede4b98722 Mon Sep 17 00:00:00 2001 From: William Zischang Cisang Date: Mon, 6 Mar 2023 12:34:08 -0300 Subject: [PATCH] Include and set ProGuard uuid in Flutter Options (#1312) Co-authored-by: Manoel Aranda Neto --- CHANGELOG.md | 4 ++++ .../main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt | 1 + flutter/config/detekt-bl.xml | 1 + flutter/lib/src/integrations/native_sdk_integration.dart | 1 + flutter/lib/src/sentry_flutter_options.dart | 3 +++ .../integrations/init_native_sdk_integration_test.dart | 9 ++++++--- flutter/test/mocks.dart | 1 + 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3a50407ed..6a49a226eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Add proguard_uui property to SentryFlutterOptions to set proguard information at runtime ([#1312](https://github.com/getsentry/sentry-dart/pull/1312)) + ### Fixes - Change podspec `EXCLUDED_ARCHS` value to allow podfiles to add more excluded architetures ([#1303](https://github.com/getsentry/sentry-dart/pull/1303)) diff --git a/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt b/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt index 4279a0bf32..b38dec8e78 100644 --- a/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt +++ b/flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt @@ -145,6 +145,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { args.getIfNotNull("anrEnabled") { options.isAnrEnabled = it } args.getIfNotNull("sendDefaultPii") { options.isSendDefaultPii = it } args.getIfNotNull("enableNdkScopeSync") { options.isEnableScopeSync = it } + args.getIfNotNull("proguardUuid") { options.proguardUuid = it } val nativeCrashHandling = (args["enableNativeCrashHandling"] as? Boolean) ?: true // nativeCrashHandling has priority over anrEnabled diff --git a/flutter/config/detekt-bl.xml b/flutter/config/detekt-bl.xml index a3fafd4210..c1eb7af938 100644 --- a/flutter/config/detekt-bl.xml +++ b/flutter/config/detekt-bl.xml @@ -3,6 +3,7 @@ ComplexMethod:SentryFlutterPlugin.kt$SentryFlutterPlugin$override fun onMethodCall(call: MethodCall, result: Result) + LongMethod:SentryFlutterPlugin.kt$SentryFlutterPlugin$private fun initNativeSdk(call: MethodCall, result: Result) MagicNumber:MainActivity.kt$MainActivity$6_000 TooGenericExceptionCaught:MainActivity.kt$MainActivity$e: Exception TooGenericExceptionThrown:MainActivity.kt$MainActivity$throw Exception("Catch this java exception thrown from Kotlin thread!") diff --git a/flutter/lib/src/integrations/native_sdk_integration.dart b/flutter/lib/src/integrations/native_sdk_integration.dart index 091a4607db..a96b5213cf 100644 --- a/flutter/lib/src/integrations/native_sdk_integration.dart +++ b/flutter/lib/src/integrations/native_sdk_integration.dart @@ -44,6 +44,7 @@ class NativeSdkIntegration extends Integration { 'enableNdkScopeSync': options.enableNdkScopeSync, 'enableAutoPerformanceTracking': options.enableAutoPerformanceTracking, 'sendClientReports': options.sendClientReports, + 'proguardUuid': options.proguardUuid, }); options.sdk.addIntegration('nativeSdkIntegration'); diff --git a/flutter/lib/src/sentry_flutter_options.dart b/flutter/lib/src/sentry_flutter_options.dart index 1f5318f96d..733c58d36d 100644 --- a/flutter/lib/src/sentry_flutter_options.dart +++ b/flutter/lib/src/sentry_flutter_options.dart @@ -202,6 +202,9 @@ class SentryFlutterOptions extends SentryOptions { /// runApp(SentryUserInteractionWidget(child: App())); bool enableUserInteractionTracing = false; + /// Sets the Proguard uuid for Android platform. + String? proguardUuid; + @internal late RendererWrapper rendererWrapper = RendererWrapper(); diff --git a/flutter/test/integrations/init_native_sdk_integration_test.dart b/flutter/test/integrations/init_native_sdk_integration_test.dart index d33f845d9d..a4fbb1060c 100644 --- a/flutter/test/integrations/init_native_sdk_integration_test.dart +++ b/flutter/test/integrations/init_native_sdk_integration_test.dart @@ -55,7 +55,8 @@ void main() { 'enableOutOfMemoryTracking': true, 'enableNdkScopeSync': false, 'enableAutoPerformanceTracking': true, - 'sendClientReports': true + 'sendClientReports': true, + 'proguardUuid': null }); }); @@ -88,7 +89,8 @@ void main() { ..enableOutOfMemoryTracking = false ..enableNdkScopeSync = true ..enableAutoPerformanceTracking = false - ..sendClientReports = false; + ..sendClientReports = false + ..proguardUuid = fakeProguardUuid; options.sdk.addIntegration('foo'); options.sdk.addPackage('bar', '1'); @@ -124,7 +126,8 @@ void main() { 'enableOutOfMemoryTracking': false, 'enableNdkScopeSync': true, 'enableAutoPerformanceTracking': false, - 'sendClientReports': false + 'sendClientReports': false, + 'proguardUuid': fakeProguardUuid }); }); diff --git a/flutter/test/mocks.dart b/flutter/test/mocks.dart index dc86fdedc3..a5badb9092 100644 --- a/flutter/test/mocks.dart +++ b/flutter/test/mocks.dart @@ -17,6 +17,7 @@ import 'mocks.mocks.dart'; import 'no_such_method_provider.dart'; const fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; +const fakeProguardUuid = '3457d982-65ef-576d-a6ad-65b5f30f49a5'; // https://github.com/dart-lang/mockito/blob/master/NULL_SAFETY_README.md#fallback-generators ISentrySpan startTransactionShim(