Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename APM tracking feature flags to tracing and enable features by default #1222

Merged
merged 11 commits into from
Jan 16, 2023
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 All @@ -168,8 +167,9 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
val name = sdk["name"] as? String
val version = sdk["version"] as? String
if (name != null && version != null) {
val sdkVersion = SdkVersion(name, version)
options.setSentryClientName(name)
options.setSdkVersion(version)
options.setSdkVersion(sdkVersion)
denrase marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand All @@ -179,13 +179,13 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
event
}

// missing proxy, enableScopeSync
// missing proxy
}
result.success("")
}

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

private fun beginNativeFrames(result: Result) {
if (!autoPerformanceTrackingEnabled) {
if (!autoPerformanceTracingEnabled) {
result.success(null)
return
}
Expand All @@ -221,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 @@ -272,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
8 changes: 4 additions & 4 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 @@ -239,7 +239,7 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {

if didReceiveDidBecomeActiveNotification &&
(PrivateSentrySDKOnly.options.enableAutoSessionTracking ||
PrivateSentrySDKOnly.options.enableOutOfMemoryTracking) {
PrivateSentrySDKOnly.options.enableWatchdogTerminationTracking) {
// We send a SentryHybridSdkDidBecomeActive to the Sentry Cocoa SDK, so the SDK will mimics
// the didBecomeActiveNotification notification. This is needed for session and OOM tracking.
NotificationCenter.default.post(name: Notification.Name("SentryHybridSdkDidBecomeActive"), object: nil)
Expand Down Expand Up @@ -319,8 +319,8 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
options.maxCacheItems = maxCacheItems
}

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

if let sendClientReports = arguments["sendClientReports"] as? Bool {
Expand Down
6 changes: 3 additions & 3 deletions flutter/ios/sentry_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Sentry SDK for Flutter with support to native through sentry-cocoa.
s.source_files = 'Classes/**/*'
s.public_header_files = 'Classes/**/*.h'
s.dependency 'Sentry/HybridSDK', '8.0.0-rc.1'
denrase marked this conversation as resolved.
Show resolved Hide resolved
s.dependency 'Sentry/HybridSDK', '7.31.5'
s.dependency 'Sentry/HybridSDK', '8.0.0-rc.1'
s.ios.dependency 'Flutter'
s.osx.dependency 'FlutterMacOS'
s.ios.deployment_target = '9.0'
s.osx.deployment_target = '10.11'
s.ios.deployment_target = '11.0'
s.osx.deployment_target = '10.13'

# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.ios.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
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
6 changes: 3 additions & 3 deletions min_version_test/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -350,7 +350,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -399,7 +399,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down