Skip to content

Commit 895becc

Browse files
fix(sdk): Add event.origin and event.environment on unhandled native exceptions (#1419)
1 parent 211a7aa commit 895becc

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixes
6+
7+
- Fix `event.origin` and `event.environment` on unhandled exceptions ([#1419](https://github.com/getsentry/sentry-dart/pull/1419))
8+
59
### Dependencies
610

711
- Bump Android SDK from v6.17.0 to v6.18.1 ([#1415](https://github.com/getsentry/sentry-dart/pull/1415))

flutter/android/src/main/kotlin/io/sentry/flutter/SentryFlutterPlugin.kt

+7-9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
4040
private var framesTracker: ActivityFramesTracker? = null
4141
private var autoPerformanceTracingEnabled = false
4242

43+
private val flutterSdk = "sentry.dart.flutter"
44+
private val androidSdk = "sentry.java.android.flutter"
45+
private val nativeSdk = "sentry.native.android"
46+
4347
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
4448
context = flutterPluginBinding.applicationContext
4549
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "sentry_flutter")
@@ -169,17 +173,15 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
169173

170174
args.getIfNotNull<Long>("maxAttachmentSize") { options.maxAttachmentSize = it }
171175

172-
val name = "sentry.java.android.flutter"
173-
174176
var sdkVersion = options.sdkVersion
175177
if (sdkVersion == null) {
176-
sdkVersion = SdkVersion(name, VERSION_NAME)
178+
sdkVersion = SdkVersion(androidSdk, VERSION_NAME)
177179
} else {
178-
sdkVersion.name = name
180+
sdkVersion.name = androidSdk
179181
}
180182

181183
options.sdkVersion = sdkVersion
182-
options.sentryClientName = "$name/$VERSION_NAME"
184+
options.sentryClientName = "$androidSdk/$VERSION_NAME"
183185

184186
options.setBeforeSend { event, _ ->
185187
setEventOriginTag(event)
@@ -464,10 +466,6 @@ class SentryFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
464466
result.success("")
465467
}
466468

467-
private val flutterSdk = "sentry.dart.flutter"
468-
private val androidSdk = "sentry.java.android"
469-
private val nativeSdk = "sentry.native"
470-
471469
private fun setEventOriginTag(event: SentryEvent) {
472470
event.sdk?.let {
473471
when (it.name) {

flutter/ios/Classes/SentryFlutterPluginApple.swift

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import AppKit
1212
// swiftlint:disable:next type_body_length
1313
public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
1414

15+
private static let nativeClientName = "sentry.cocoa.flutter"
16+
1517
// The Cocoa SDK is init. after the notification didBecomeActiveNotification is registered.
1618
// We need to be able to receive this notification and start a session when the SDK is fully operational.
1719
private var didReceiveDidBecomeActiveNotification = false
@@ -257,9 +259,8 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
257259
#endif
258260
}
259261

260-
let name = "sentry.cocoa.flutter"
261262
let version = PrivateSentrySDKOnly.getSdkVersionString()
262-
PrivateSentrySDKOnly.setSdkName(name, andVersionString: version)
263+
PrivateSentrySDKOnly.setSdkName(SentryFlutterPluginApple.nativeClientName, andVersionString: version)
263264

264265
// note : for now, in sentry-cocoa, beforeSend is not called before captureEnvelope
265266
options.beforeSend = { event in
@@ -409,7 +410,7 @@ public class SentryFlutterPluginApple: NSObject, FlutterPlugin {
409410
if isValidSdk(sdk: sdk) {
410411

411412
switch sdk["name"] as? String {
412-
case "sentry.cocoa":
413+
case SentryFlutterPluginApple.nativeClientName:
413414
#if os(OSX)
414415
let origin = "mac"
415416
#elseif os(watchOS)

0 commit comments

Comments
 (0)