Skip to content

Commit 6bcf81b

Browse files
committed
Update
1 parent 8eb5153 commit 6bcf81b

File tree

10 files changed

+3833
-183
lines changed

10 files changed

+3833
-183
lines changed

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -443,16 +443,6 @@ class SentryFlutterPlugin :
443443
}
444444
}
445445

446-
@Suppress("unused") // Used by native/jni bindings
447-
@JvmStatic
448-
fun addBreadcrumbAsBytes(breadcrumbBytes: ByteArray) {
449-
val logger = ScopesAdapter.getInstance().options.logger
450-
val breadcrumbJson = breadcrumbBytes.toString(Charsets.UTF_8)
451-
val reader = JsonObjectReader(StringReader(breadcrumbJson))
452-
val breadcrumb = Breadcrumb.Deserializer().deserialize(reader, logger)
453-
Sentry.addBreadcrumb(breadcrumb)
454-
}
455-
456446
private fun List<DebugImage>?.serialize() = this?.map { it.serialize() }
457447

458448
private fun DebugImage.serialize() =

packages/flutter/ffi-jni.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ classes:
1717
- io.sentry.android.replay.ReplayIntegration
1818
- io.sentry.flutter.SentryFlutterPlugin
1919
- io.sentry.Sentry
20+
- io.sentry.Breadcrumb
21+
- io.sentry.ScopesAdapter
2022
- android.graphics.Bitmap

packages/flutter/ios/sentry_flutter/Sources/sentry_flutter/SentryFlutterPlugin.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -618,24 +618,6 @@ public class SentryFlutterPlugin: NSObject, FlutterPlugin {
618618
return nil
619619
}
620620
}
621-
622-
@objc public class func addBreadcrumbAsBytes(_ breadcrumbBytes: NSData) {
623-
guard let breadcrumbDict = try? JSONSerialization.jsonObject(
624-
with: breadcrumbBytes as Data,
625-
options: []
626-
) as? [String: Any] else {
627-
print("addBreadcrumb failed in native cocoa: could not parse bytes")
628-
return
629-
}
630-
let breadcrumbInstance = PrivateSentrySDKOnly.breadcrumb(with: breadcrumbDict)
631-
SentrySDK.addBreadcrumb(breadcrumbInstance)
632-
}
633-
634-
@objc public class func clearBreadcrumbs() {
635-
SentrySDK.configureScope { scope in
636-
scope.clearBreadcrumbs()
637-
}
638-
}
639621
}
640622
// swiftlint:enable type_body_length
641623

packages/flutter/ios/sentry_flutter/Sources/sentry_flutter_objc/SentryFlutterPlugin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@
88
+ (nullable NSData *)fetchNativeAppStartAsBytes;
99
+ (nullable NSData *)loadContextsAsBytes;
1010
+ (nullable NSData *)loadDebugImagesAsBytes:(NSSet<NSString *> *)instructionAddresses;
11-
+ (void)addBreadcrumbAsBytes:(NSData *)breadcrumbBytes;
1211
@end
1312
#endif

packages/flutter/ios/sentry_flutter/Sources/sentry_flutter_objc/include/ns_number.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// We need to add this file until we update the objective_c package due to a bug
6+
// See the issue: https://github.com/dart-lang/native/pull/2581
7+
58
#ifndef OBJECTIVE_C_SRC_NS_NUMBER_H_
69
#define OBJECTIVE_C_SRC_NS_NUMBER_H_
710

packages/flutter/ios/sentry_flutter/Sources/sentry_flutter_objc/ns_number.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
// We need to add this file until we update the objective_c package due to a bug
6+
// See the issue: https://github.com/dart-lang/native/pull/2581
7+
58
#import "ns_number.h"
69

710
@implementation NSNumber (NSNumberIsFloat)

packages/flutter/lib/src/native/cocoa/binding.dart

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,6 @@ late final _sel_fetchNativeAppStartAsBytes =
14471447
late final _sel_loadContextsAsBytes = objc.registerName("loadContextsAsBytes");
14481448
late final _sel_loadDebugImagesAsBytes_ =
14491449
objc.registerName("loadDebugImagesAsBytes:");
1450-
late final _sel_addBreadcrumbAsBytes_ =
1451-
objc.registerName("addBreadcrumbAsBytes:");
14521450

14531451
/// SentryFlutterPlugin
14541452
class SentryFlutterPlugin extends objc.NSObject {
@@ -1507,12 +1505,6 @@ class SentryFlutterPlugin extends objc.NSObject {
15071505
: objc.NSData.castFromPointer(_ret, retain: true, release: true);
15081506
}
15091507

1510-
/// addBreadcrumbAsBytes:
1511-
static void addBreadcrumbAsBytes(objc.NSData breadcrumbBytes) {
1512-
_objc_msgSend_xtuoz7(_class_SentryFlutterPlugin, _sel_addBreadcrumbAsBytes_,
1513-
breadcrumbBytes.ref.pointer);
1514-
}
1515-
15161508
/// init
15171509
SentryFlutterPlugin init() {
15181510
objc.checkOsVersionInternal('SentryFlutterPlugin.init',

packages/flutter/lib/src/native/cocoa/sentry_native_cocoa.dart

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:async';
2-
import 'dart:convert';
32
import 'dart:typed_data';
43
import 'package:meta/meta.dart';
54
import 'package:objective_c/objective_c.dart';
@@ -8,7 +7,6 @@ import '../../../sentry_flutter.dart';
87
import '../../replay/replay_config.dart';
98
import '../native_app_start.dart';
109
import '../sentry_native_channel.dart';
11-
import '../utils/data_normalizer.dart';
1210
import '../utils/utf8_json.dart';
1311
import 'binding.dart' as cocoa;
1412
import 'cocoa_replay_recorder.dart';
@@ -192,46 +190,46 @@ class SentryNativeCocoa extends SentryNativeChannel {
192190
tryCatchSync('addBreadcrumb', () {
193191
final nativeBreadcrumb =
194192
cocoa.PrivateSentrySDKOnly.breadcrumbWithDictionary(
195-
deepConvertMapNonNull(breadcrumb.toJson()).toNSDictionary());
193+
_deepConvertMapNonNull(breadcrumb.toJson()).toNSDictionary());
196194
cocoa.SentrySDK.addBreadcrumb(nativeBreadcrumb);
197195
});
198196

199-
Map<Object, Object> deepConvertMapNonNull(Map<String, dynamic> input) {
200-
final out = <Object, Object>{};
201-
202-
for (final entry in input.entries) {
203-
final value = entry.value;
204-
if (value == null) continue;
205-
206-
out[entry.key] = switch (value) {
207-
Map<String, dynamic> m => deepConvertMapNonNull(m),
208-
List<dynamic> l => [
209-
for (final e in l)
210-
if (e != null)
211-
e is Map<String, dynamic>
212-
? deepConvertMapNonNull(e)
213-
: e as Object
214-
],
215-
_ => value as Object,
216-
};
217-
}
218-
219-
return out;
220-
}
221-
222197
@override
223-
void clearBreadcrumbs() {
224-
tryCatchSync('clearBreadcrumbs', () {
225-
cocoa.SentrySDK.configureScope(
226-
cocoa.ObjCBlock_ffiVoid_SentryScope.fromFunction(
227-
(cocoa.SentryScope scope) {
228-
scope.clearBreadcrumbs();
229-
}));
230-
});
231-
}
198+
void clearBreadcrumbs() => tryCatchSync('clearBreadcrumbs', () {
199+
cocoa.SentrySDK.configureScope(
200+
cocoa.ObjCBlock_ffiVoid_SentryScope.fromFunction(
201+
(cocoa.SentryScope scope) {
202+
scope.clearBreadcrumbs();
203+
}));
204+
});
232205

233206
@override
234207
void resumeAppHangTracking() => tryCatchSync('resumeAppHangTracking', () {
235208
cocoa.SentrySDK.resumeAppHangTracking();
236209
});
237210
}
211+
212+
/// This map conversion is needed so we can use the toNSDictionary extension function
213+
/// provided by the objective_c package.
214+
Map<Object, Object> _deepConvertMapNonNull(Map<String, dynamic> input) {
215+
final out = <Object, Object>{};
216+
217+
for (final entry in input.entries) {
218+
final value = entry.value;
219+
if (value == null) continue;
220+
221+
out[entry.key] = switch (value) {
222+
Map<String, dynamic> m => _deepConvertMapNonNull(m),
223+
List<dynamic> l => [
224+
for (final e in l)
225+
if (e != null)
226+
e is Map<String, dynamic>
227+
? _deepConvertMapNonNull(e)
228+
: e as Object
229+
],
230+
_ => value as Object,
231+
};
232+
}
233+
234+
return out;
235+
}

0 commit comments

Comments
 (0)