Skip to content

Commit 714279e

Browse files
committed
Update
1 parent aacf1ff commit 714279e

File tree

5 files changed

+70
-54
lines changed

5 files changed

+70
-54
lines changed

packages/flutter/ffi-cocoa.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,16 @@ objc-interfaces:
1919
- PrivateSentrySDKOnly
2020
- SentryId
2121
- SentryFlutterPlugin
22+
- SentrySDK
2223
module:
2324
'SentryId': 'Sentry'
25+
'SentrySDK': 'Sentry'
26+
member-filter:
27+
SentrySDK:
28+
include:
29+
- 'crash'
30+
- 'pauseAppHangTracking'
31+
- 'resumeAppHangTracking'
2432
preamble: |
2533
// ignore_for_file: type=lint, unused_element
2634

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -520,18 +520,6 @@ public class SentryFlutterPlugin: NSObject, FlutterPlugin {
520520
#endif
521521
}
522522

523-
@objc public class func nativeCrash() {
524-
SentrySDK.crash()
525-
}
526-
527-
@objc public class func pauseAppHangTracking() {
528-
SentrySDK.pauseAppHangTracking()
529-
}
530-
531-
@objc public class func resumeAppHangTracking() {
532-
SentrySDK.resumeAppHangTracking()
533-
}
534-
535523
@objc(loadDebugImagesAsBytes:)
536524
public class func loadDebugImagesAsBytes(instructionAddresses: Set<String>) -> NSData? {
537525
var debugImages: [DebugMeta] = []

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,5 @@
88
+ (nullable NSData *)fetchNativeAppStartAsBytes;
99
+ (nullable NSData *)loadContextsAsBytes;
1010
+ (nullable NSData *)loadDebugImagesAsBytes:(NSSet<NSString *> *)instructionAddresses;
11-
+ (void)nativeCrash;
12-
+ (void)pauseAppHangTracking;
13-
+ (void)resumeAppHangTracking;
1411
@end
1512
#endif

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

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,15 +1120,8 @@ class SentryId$1 extends objc.NSObject {
11201120
factory SentryId$1() => new$();
11211121
}
11221122

1123-
late final _class_SentryFlutterPlugin = objc.getClass("SentryFlutterPlugin");
1124-
late final _sel_getDisplayRefreshRate =
1125-
objc.registerName("getDisplayRefreshRate");
1126-
late final _sel_fetchNativeAppStartAsBytes =
1127-
objc.registerName("fetchNativeAppStartAsBytes");
1128-
late final _sel_loadContextsAsBytes = objc.registerName("loadContextsAsBytes");
1129-
late final _sel_loadDebugImagesAsBytes_ =
1130-
objc.registerName("loadDebugImagesAsBytes:");
1131-
late final _sel_nativeCrash = objc.registerName("nativeCrash");
1123+
late final _class_SentrySDK = objc.getClass("Sentry.SentrySDK");
1124+
late final _sel_crash = objc.registerName("crash");
11321125
final _objc_msgSend_1pl9qdv = objc.msgSendPointer
11331126
.cast<
11341127
ffi.NativeFunction<
@@ -1142,6 +1135,59 @@ late final _sel_pauseAppHangTracking =
11421135
late final _sel_resumeAppHangTracking =
11431136
objc.registerName("resumeAppHangTracking");
11441137

1138+
/// The main entry point for the Sentry SDK.
1139+
/// We recommend using <code>start(configureOptions:)</code> to initialize Sentry.
1140+
class SentrySDK extends objc.NSObject {
1141+
SentrySDK._(ffi.Pointer<objc.ObjCObject> pointer,
1142+
{bool retain = false, bool release = false})
1143+
: super.castFromPointer(pointer, retain: retain, release: release);
1144+
1145+
/// Constructs a [SentrySDK] that points to the same underlying object as [other].
1146+
SentrySDK.castFrom(objc.ObjCObjectBase other)
1147+
: this._(other.ref.pointer, retain: true, release: true);
1148+
1149+
/// Constructs a [SentrySDK] that wraps the given raw object pointer.
1150+
SentrySDK.castFromPointer(ffi.Pointer<objc.ObjCObject> other,
1151+
{bool retain = false, bool release = false})
1152+
: this._(other, retain: retain, release: release);
1153+
1154+
/// Returns whether [obj] is an instance of [SentrySDK].
1155+
static bool isInstance(objc.ObjCObjectBase obj) {
1156+
return _objc_msgSend_19nvye5(
1157+
obj.ref.pointer, _sel_isKindOfClass_, _class_SentrySDK);
1158+
}
1159+
1160+
/// This forces a crash, useful to test the <code>SentryCrash</code> integration.
1161+
/// note:
1162+
/// The SDK can’t report a crash when a debugger is attached. Your application needs to run
1163+
/// without a debugger attached to capture the crash and send it to Sentry the next time you launch
1164+
/// your application.
1165+
static void crash() {
1166+
_objc_msgSend_1pl9qdv(_class_SentrySDK, _sel_crash);
1167+
}
1168+
1169+
/// Pauses sending detected app hangs to Sentry.
1170+
/// This method doesn’t close the detection of app hangs. Instead, the app hang detection
1171+
/// will ignore detected app hangs until you call <code>resumeAppHangTracking</code>.
1172+
static void pauseAppHangTracking() {
1173+
_objc_msgSend_1pl9qdv(_class_SentrySDK, _sel_pauseAppHangTracking);
1174+
}
1175+
1176+
/// Resumes sending detected app hangs to Sentry.
1177+
static void resumeAppHangTracking() {
1178+
_objc_msgSend_1pl9qdv(_class_SentrySDK, _sel_resumeAppHangTracking);
1179+
}
1180+
}
1181+
1182+
late final _class_SentryFlutterPlugin = objc.getClass("SentryFlutterPlugin");
1183+
late final _sel_getDisplayRefreshRate =
1184+
objc.registerName("getDisplayRefreshRate");
1185+
late final _sel_fetchNativeAppStartAsBytes =
1186+
objc.registerName("fetchNativeAppStartAsBytes");
1187+
late final _sel_loadContextsAsBytes = objc.registerName("loadContextsAsBytes");
1188+
late final _sel_loadDebugImagesAsBytes_ =
1189+
objc.registerName("loadDebugImagesAsBytes:");
1190+
11451191
/// SentryFlutterPlugin
11461192
class SentryFlutterPlugin extends objc.NSObject {
11471193
SentryFlutterPlugin._(ffi.Pointer<objc.ObjCObject> pointer,
@@ -1199,23 +1245,6 @@ class SentryFlutterPlugin extends objc.NSObject {
11991245
: objc.NSData.castFromPointer(_ret, retain: true, release: true);
12001246
}
12011247

1202-
/// nativeCrash
1203-
static void nativeCrash() {
1204-
_objc_msgSend_1pl9qdv(_class_SentryFlutterPlugin, _sel_nativeCrash);
1205-
}
1206-
1207-
/// pauseAppHangTracking
1208-
static void pauseAppHangTracking() {
1209-
_objc_msgSend_1pl9qdv(
1210-
_class_SentryFlutterPlugin, _sel_pauseAppHangTracking);
1211-
}
1212-
1213-
/// resumeAppHangTracking
1214-
static void resumeAppHangTracking() {
1215-
_objc_msgSend_1pl9qdv(
1216-
_class_SentryFlutterPlugin, _sel_resumeAppHangTracking);
1217-
}
1218-
12191248
/// init
12201249
SentryFlutterPlugin init() {
12211250
objc.checkOsVersionInternal('SentryFlutterPlugin.init',

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,21 +178,15 @@ class SentryNativeCocoa extends SentryNativeChannel {
178178
);
179179

180180
@override
181-
void nativeCrash() {
182-
cocoa.SentryFlutterPlugin.nativeCrash();
183-
}
181+
void nativeCrash() => cocoa.SentrySDK.crash();
184182

185183
@override
186-
void pauseAppHangTracking() {
187-
tryCatchSync('pauseAppHangTracking', () {
188-
cocoa.SentryFlutterPlugin.pauseAppHangTracking();
189-
});
190-
}
184+
void pauseAppHangTracking() => tryCatchSync('pauseAppHangTracking', () {
185+
cocoa.SentrySDK.pauseAppHangTracking();
186+
});
191187

192188
@override
193-
void resumeAppHangTracking() {
194-
tryCatchSync('resumeAppHangTracking', () {
195-
cocoa.SentryFlutterPlugin.resumeAppHangTracking();
196-
});
197-
}
189+
void resumeAppHangTracking() => tryCatchSync('resumeAppHangTracking', () {
190+
cocoa.SentrySDK.resumeAppHangTracking();
191+
});
198192
}

0 commit comments

Comments
 (0)