Skip to content

Commit

Permalink
Rename APM tracking feature flags to tracing and enable features by d…
Browse files Browse the repository at this point in the history
…efault (#1222)
  • Loading branch information
marandaneto authored Jan 16, 2023
1 parent eb2f1ff commit ea6679c
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 30 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@

### Breaking Changes

- Enable APM features by default ([#1217](https://github.com/getsentry/sentry-dart/pull/1217))
- captureFailedRequests
- enableStructuredDataTracing
- enableUserInteractionTracing
- Enable and rename APM features by default ([#1217](https://github.com/getsentry/sentry-dart/pull/1217)) and ([#1222](https://github.com/getsentry/sentry-dart/pull/1222))
- Enable by default
- captureFailedRequests
- enableStructuredDataTracing
- enableUserInteractionTracing
- Rename
- enableAutoPerformanceTracking to enableAutoPerformanceTracing
- enableOutOfMemoryTracking to enableWatchdogTerminationTracking
- Mark transaction as internal_error in case of unhandled errors ([#1218](https://github.com/getsentry/sentry-dart/pull/1218))

## 7.0.0-alpha.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ import java.lang.ref.WeakReference
import java.util.Locale
import java.util.UUID

@Suppress("TooManyFunctions")
class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
private lateinit var channel: MethodChannel
private lateinit var context: Context

private var activity: WeakReference<Activity>? = null
private var framesTracker: ActivityFramesTracker? = null
private var autoPerformanceTrackingEnabled = false
private var autoPerformanceTracingEnabled = false

override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
context = flutterPluginBinding.applicationContext
Expand Down Expand Up @@ -155,9 +154,9 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
// options.isEnableNdk = false
}

args.getIfNotNull<Boolean>("enableAutoPerformanceTracking") { enableAutoPerformanceTracking ->
if (enableAutoPerformanceTracking) {
autoPerformanceTrackingEnabled = true
args.getIfNotNull<Boolean>("enableAutoPerformanceTracing") { enableAutoPerformanceTracing ->
if (enableAutoPerformanceTracing) {
autoPerformanceTracingEnabled = true
framesTracker = ActivityFramesTracker(LoadClass(), options)
}
}
Expand Down Expand Up @@ -186,7 +185,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}

private fun fetchNativeAppStart(result: Result) {
if (!autoPerformanceTrackingEnabled) {
if (!autoPerformanceTracingEnabled) {
result.success(null)
return
}
Expand All @@ -209,7 +208,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}

private fun beginNativeFrames(result: Result) {
if (!autoPerformanceTrackingEnabled) {
if (!autoPerformanceTracingEnabled) {
result.success(null)
return
}
Expand All @@ -222,7 +221,7 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {

private fun endNativeFrames(id: String?, result: Result) {
val activity = activity?.get()
if (!autoPerformanceTrackingEnabled || activity == null || id == null) {
if (!autoPerformanceTracingEnabled || activity == null || id == null) {
if (id == null) {
Log.w("Sentry", "Parameter id cannot be null when calling endNativeFrames.")
}
Expand Down Expand Up @@ -273,7 +272,6 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
}
}

@Suppress("ComplexMethod")
private fun setUser(user: Map<String, Any?>?, result: Result) {
if (user == null) {
Sentry.setUser(null)
Expand Down
5 changes: 4 additions & 1 deletion flutter/config/detekt-bl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<SmellBaseline>
<ManuallySuppressedIssues></ManuallySuppressedIssues>
<CurrentIssues>
<ID>ComplexMethod:SentryFlutterPlugin.kt$SentryFlutterPlugin$override fun onMethodCall(call: MethodCall, result: Result)</ID>
<ID>CyclomaticComplexMethod:SentryFlutterPlugin.kt$SentryFlutterPlugin$override fun onMethodCall(call: MethodCall, result: Result)</ID>
<ID>CyclomaticComplexMethod:SentryFlutterPlugin.kt$SentryFlutterPlugin$private fun setUser(user: Map&lt;String, Any?&gt;?, result: Result)</ID>
<ID>LongMethod:SentryFlutterPlugin.kt$SentryFlutterPlugin$private fun initNativeSdk(call: MethodCall, result: Result)</ID>
<ID>MagicNumber:MainActivity.kt$MainActivity$6_000</ID>
<ID>TooGenericExceptionCaught:MainActivity.kt$MainActivity$e: Exception</ID>
<ID>TooGenericExceptionThrown:MainActivity.kt$MainActivity$throw Exception("Catch this java exception thrown from Kotlin thread!")</ID>
<ID>TooGenericExceptionThrown:MainActivity.kt$MainActivity$throw RuntimeException("Catch this java exception!")</ID>
<ID>TooGenericExceptionThrown:MainActivity.kt$MainActivity$throw RuntimeException("Catch this platform exception!")</ID>
<ID>TooManyFunctions:SentryFlutterPlugin.kt$SentryFlutterPlugin : FlutterPluginMethodCallHandlerActivityAware</ID>
</CurrentIssues>
</SmellBaseline>
6 changes: 3 additions & 3 deletions flutter/example/macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down Expand Up @@ -491,7 +491,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
Expand Down Expand Up @@ -538,7 +538,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
Expand Down
6 changes: 3 additions & 3 deletions flutter/ios/Classes/SentryFlutterPluginApple.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
SentrySDK.start { options in
self.updateOptions(arguments: arguments, options: options)

if arguments["enableAutoPerformanceTracking"] as? Bool ?? false {
if arguments["enableAutoPerformanceTracing"] as? Bool ?? false {
PrivateSentrySDKOnly.appStartMeasurementHybridSDKMode = true
#if os(iOS) || targetEnvironment(macCatalyst)
PrivateSentrySDKOnly.framesTrackingMeasurementHybridSDKMode = true
Expand Down Expand Up @@ -319,8 +319,8 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
options.maxCacheItems = maxCacheItems
}

if let enableOutOfMemoryTracking = arguments["enableOutOfMemoryTracking"] as? Bool {
options.enableWatchdogTerminationTracking = enableOutOfMemoryTracking
if let enableWatchdogTerminationTracking = arguments["enableWatchdogTerminationTracking"] as? Bool {
options.enableWatchdogTerminationTracking = enableWatchdogTerminationTracking
}

if let sendClientReports = arguments["sendClientReports"] as? Bool {
Expand Down
5 changes: 3 additions & 2 deletions flutter/lib/src/integrations/native_sdk_integration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ class NativeSdkIntegration extends Integration<SentryFlutterOptions> {
'enableAutoNativeBreadcrumbs': options.enableAutoNativeBreadcrumbs,
'maxCacheItems': options.maxCacheItems,
'sendDefaultPii': options.sendDefaultPii,
'enableOutOfMemoryTracking': options.enableOutOfMemoryTracking,
'enableWatchdogTerminationTracking':
options.enableWatchdogTerminationTracking,
'enableNdkScopeSync': options.enableNdkScopeSync,
'enableAutoPerformanceTracking': options.enableAutoPerformanceTracking,
'enableAutoPerformanceTracing': options.enableAutoPerformanceTracing,
'sendClientReports': options.sendClientReports,
'sdk': {
'name': options.sdk.name,
Expand Down
4 changes: 2 additions & 2 deletions flutter/lib/src/sentry_flutter_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ class SentryFlutterOptions extends SentryOptions {
/// Enables Out of Memory Tracking for iOS and macCatalyst.
/// See the following link for more information and possible restrictions:
/// https://docs.sentry.io/platforms/apple/guides/ios/configuration/out-of-memory/
bool enableOutOfMemoryTracking = true;
bool enableWatchdogTerminationTracking = true;

/// Enable scope sync from Java to NDK.
/// Only available on Android.
bool enableNdkScopeSync = false;

/// Enable auto performance tracking by default.
bool enableAutoPerformanceTracking = true;
bool enableAutoPerformanceTracing = true;

/// Automatically track app start measurement and send it with the
/// first transaction. Set to false when configuring option to disable or if
Expand Down
12 changes: 6 additions & 6 deletions flutter/test/integrations/init_native_sdk_integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ void main() {
'enableAutoNativeBreadcrumbs': true,
'maxCacheItems': 30,
'sendDefaultPii': false,
'enableOutOfMemoryTracking': true,
'enableWatchdogTerminationTracking': true,
'enableNdkScopeSync': false,
'enableAutoPerformanceTracking': true,
'enableAutoPerformanceTracing': true,
'sendClientReports': true,
'sdk': {
'name': 'sentry.dart.flutter',
Expand Down Expand Up @@ -89,9 +89,9 @@ void main() {
..enableAutoNativeBreadcrumbs = false
..maxCacheItems = 0
..sendDefaultPii = true
..enableOutOfMemoryTracking = false
..enableWatchdogTerminationTracking = false
..enableNdkScopeSync = true
..enableAutoPerformanceTracking = false
..enableAutoPerformanceTracing = false
..sendClientReports = false;

options.sdk.addIntegration('foo');
Expand Down Expand Up @@ -125,9 +125,9 @@ void main() {
'enableAutoNativeBreadcrumbs': false,
'maxCacheItems': 0,
'sendDefaultPii': true,
'enableOutOfMemoryTracking': false,
'enableWatchdogTerminationTracking': false,
'enableNdkScopeSync': true,
'enableAutoPerformanceTracking': false,
'enableAutoPerformanceTracing': false,
'sendClientReports': false,
'sdk': {
'name': 'sentry.dart.flutter',
Expand Down

0 comments on commit ea6679c

Please sign in to comment.