@bugsee/react-native 7.0.0-beta3 → 7.0.0-beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +228 -10
- package/android/build.gradle +9 -0
- package/android/consumer-rules.pro +3 -0
- package/android/src/main/java/com/bugsee/reactnative/BreadcrumbFilterBridge.java +224 -20
- package/android/src/main/java/com/bugsee/reactnative/BugseeModule.java +44 -21
- package/android/src/main/java/com/bugsee/reactnative/BugseeOptionEnums.java +15 -0
- package/android/src/main/java/com/bugsee/reactnative/LogFilterBridge.java +119 -5
- package/android/src/main/java/com/bugsee/reactnative/NetworkCaptureProbe.java +107 -0
- package/android/src/main/java/com/bugsee/reactnative/NetworkFilterBridge.java +129 -14
- package/android/src/main/java/com/bugsee/reactnative/ReactNativeWrapperInitProvider.java +48 -0
- package/android/src/main/java/com/bugsee/reactnative/SpanHandles.java +64 -8
- package/android/src/main/java/com/bugsee/reactnative/StartupHold.java +237 -0
- package/ios/BugseeModule.mm +293 -155
- package/ios/Support/Package.resolved +2 -2
- package/ios/Support/Package.swift +1 -1
- package/ios/Support/Sources/BugseeRNSupport/BGSRNBlackout.m +14 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNDeleteCollectedData.m +33 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNFilterArming.m +22 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNFilterDeadline.m +110 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSpanHandles.m +40 -6
- package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapper.m +1 -1
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNBlackout.h +23 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReportOps.h +2 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNDeleteCollectedData.h +29 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNFilterArming.h +26 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNFilterDeadline.h +68 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportHandlerBridge.h +5 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportOps.h +5 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSpanHandles.h +16 -2
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapperChannelHolder.h +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNBlackoutTests.m +38 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNDeleteCollectedDataTests.m +135 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.h +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFilterArmingTests.m +48 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFilterDeadlineTests.m +230 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportHandlerBridgeTests.m +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSpanHandlesTests.m +86 -6
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperChannelHolderTests.m +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperTests.m +1 -1
- package/native-versions.json +2 -2
- package/package.json +1 -1
- package/plugin/build/dsym-script.d.ts +11 -0
- package/plugin/build/dsym-script.js +26 -3
- package/plugin/build/dsym-script.js.map +1 -1
- package/plugin/build/index.d.ts +27 -0
- package/plugin/build/index.js +33 -21
- package/plugin/build/index.js.map +1 -1
- package/plugin/build/manifest.d.ts +37 -0
- package/plugin/build/manifest.js +67 -1
- package/plugin/build/manifest.js.map +1 -1
- package/plugin/build/native-versions.baked.json +1 -1
- package/scripts/compose-then-inject.js +4 -2
- package/scripts/hermes-sourcemaps.js +40 -3
- package/src/NativeBugsee.ts +39 -22
- package/src/apm/span.ts +42 -7
- package/src/breadcrumbs/filter.ts +104 -13
- package/src/breadcrumbs/types.ts +6 -4
- package/src/breadcrumbs/url-scrub.ts +75 -0
- package/src/exceptions/ErrorBoundary.tsx +4 -1
- package/src/exceptions/RootErrorReporter.tsx +1 -1
- package/src/exceptions/handlers.ts +17 -1
- package/src/exceptions/report.ts +30 -8
- package/src/index.ts +125 -33
- package/src/logs/filter.ts +19 -8
- package/src/network/filter.ts +17 -5
- package/src/options/AndroidLaunchOptions.ts +310 -24
- package/src/options/BugseeLaunchOptions.ts +463 -18
- package/src/options/IOSLaunchOptions.ts +164 -8
- package/src/options/android-options-manifest.json +63 -6
- package/src/options/enums.ts +28 -0
- package/src/options/ios-enums.json +6 -5
- package/src/options/ios-options-manifest.json +594 -0
- package/src/options/keys.ts +19 -1
- package/src/options/noAccessor.ts +16 -0
- package/src/options/option-keys.json +9 -3
- package/src/options/unknownKeys.ts +198 -0
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
"kind" : "remoteSourceControl",
|
|
6
6
|
"location" : "https://github.com/bugsee/spm",
|
|
7
7
|
"state" : {
|
|
8
|
-
"revision" : "
|
|
9
|
-
"version" : "7.
|
|
8
|
+
"revision" : "465ec10d05313bca91254a0c8b7adf266d456c93",
|
|
9
|
+
"version" : "7.1.0"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
],
|
|
@@ -28,7 +28,7 @@ let package = Package(
|
|
|
28
28
|
],
|
|
29
29
|
dependencies: [
|
|
30
30
|
// Exact, not a range: SwiftPM will not admit a prerelease into one.
|
|
31
|
-
.package(url: "https://github.com/bugsee/spm", exact: "7.
|
|
31
|
+
.package(url: "https://github.com/bugsee/spm", exact: "7.1.0")
|
|
32
32
|
],
|
|
33
33
|
targets: [
|
|
34
34
|
.target(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import "BGSRNBlackout.h"
|
|
2
|
+
|
|
3
|
+
BOOL BGSRNEndBlackoutForStopWithStatus(BugseeStatus status) {
|
|
4
|
+
if (status == BugseeStatusStopped || ![Bugsee isBlackout]) {
|
|
5
|
+
return NO;
|
|
6
|
+
}
|
|
7
|
+
[Bugsee endBlackout];
|
|
8
|
+
return YES;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
BOOL BGSRNEndBlackoutForStop(void) {
|
|
12
|
+
Bugsee *instance = [Bugsee sharedInstance];
|
|
13
|
+
return BGSRNEndBlackoutForStopWithStatus(instance != nil ? instance.status : BugseeStatusStopped);
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#import "BGSRNDeleteCollectedData.h"
|
|
2
|
+
|
|
3
|
+
const int64_t BGSRNDeleteCollectedDataBackstopMs = 60000;
|
|
4
|
+
|
|
5
|
+
NSString *const BGSRNDeleteTimeoutCode = @"E_DELETE_TIMEOUT";
|
|
6
|
+
|
|
7
|
+
void BGSRNDeleteCollectedData(BGSRNDeleteSDKCall sdkCall,
|
|
8
|
+
int64_t backstopMs,
|
|
9
|
+
dispatch_queue_t queue,
|
|
10
|
+
void (^resolve)(BOOL success),
|
|
11
|
+
void (^reject)(NSString *code)) {
|
|
12
|
+
// Every touch of `settled` is on `queue`, which is serial, so a plain flag
|
|
13
|
+
// is enough: the completion and the backstop cannot interleave.
|
|
14
|
+
__block BOOL settled = NO;
|
|
15
|
+
|
|
16
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, backstopMs * (int64_t)NSEC_PER_MSEC), queue, ^{
|
|
17
|
+
if (settled) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
settled = YES;
|
|
21
|
+
reject(BGSRNDeleteTimeoutCode);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
sdkCall(^(BOOL success) {
|
|
25
|
+
dispatch_async(queue, ^{
|
|
26
|
+
if (settled) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
settled = YES;
|
|
30
|
+
resolve(success);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#import "BGSRNFilterArming.h"
|
|
2
|
+
|
|
3
|
+
@implementation BGSRNFilterArming {
|
|
4
|
+
__weak id _owner;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
- (void)armFor:(id)owner {
|
|
8
|
+
@synchronized (self) {
|
|
9
|
+
_owner = owner;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
- (BOOL)isArmedFor:(id)owner {
|
|
14
|
+
if (owner == nil) {
|
|
15
|
+
return NO;
|
|
16
|
+
}
|
|
17
|
+
@synchronized (self) {
|
|
18
|
+
return _owner == owner;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#import "BGSRNFilterDeadline.h"
|
|
2
|
+
|
|
3
|
+
const int64_t BGSRNFilterDeadlineMs = 9000;
|
|
4
|
+
|
|
5
|
+
dispatch_block_t BGSRNArmFilterDeadline(int64_t deadlineMs, dispatch_queue_t queue, dispatch_block_t expire) {
|
|
6
|
+
if (queue == nil || expire == nil) {
|
|
7
|
+
return nil;
|
|
8
|
+
}
|
|
9
|
+
dispatch_block_t token = dispatch_block_create(0, expire);
|
|
10
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, deadlineMs * (int64_t)NSEC_PER_MSEC), queue, token);
|
|
11
|
+
return token;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void BGSRNCancelFilterDeadline(dispatch_block_t token) {
|
|
15
|
+
if (token != nil) {
|
|
16
|
+
dispatch_block_cancel(token);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static uint64_t BGSRNNowNanos(void) {
|
|
21
|
+
return clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// Removes the item. `overdue` says its deadline has passed, whether or not
|
|
25
|
+
/// the timer block has run: a starved queue can run it late, and a reply that
|
|
26
|
+
/// gets here first must not be applied past 9 s.
|
|
27
|
+
static id BGSRNTakeRaw(NSMutableDictionary<NSString *, id> *table,
|
|
28
|
+
id lock,
|
|
29
|
+
NSString *requestId,
|
|
30
|
+
BOOL *overdue) {
|
|
31
|
+
*overdue = NO;
|
|
32
|
+
if (table == nil || lock == nil || requestId == nil) {
|
|
33
|
+
return nil;
|
|
34
|
+
}
|
|
35
|
+
id item = nil;
|
|
36
|
+
@synchronized (lock) {
|
|
37
|
+
item = table[requestId];
|
|
38
|
+
if (item != nil) {
|
|
39
|
+
[table removeObjectForKey:requestId];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (item != nil && [item respondsToSelector:NSSelectorFromString(@"deadline")]) {
|
|
43
|
+
BGSRNCancelFilterDeadline([item valueForKey:@"deadline"]);
|
|
44
|
+
}
|
|
45
|
+
if (item != nil && [item respondsToSelector:NSSelectorFromString(@"expiresAt")]) {
|
|
46
|
+
NSNumber *expiresAt = [item valueForKey:@"expiresAt"];
|
|
47
|
+
*overdue = expiresAt != nil && BGSRNNowNanos() >= expiresAt.unsignedLongLongValue;
|
|
48
|
+
}
|
|
49
|
+
return item;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static void BGSRNAnswerNil(id item) {
|
|
53
|
+
void (^decision)(id) = [item valueForKey:@"decision"];
|
|
54
|
+
if (decision != nil) {
|
|
55
|
+
decision(nil);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
id BGSRNTakePendingFilter(NSMutableDictionary<NSString *, id> *table, id lock, NSString *requestId) {
|
|
60
|
+
BOOL overdue = NO;
|
|
61
|
+
id item = BGSRNTakeRaw(table, lock, requestId, &overdue);
|
|
62
|
+
if (item != nil && overdue) {
|
|
63
|
+
// Past the deadline the answer is refused: drop, never apply the reply.
|
|
64
|
+
BGSRNAnswerNil(item);
|
|
65
|
+
return nil;
|
|
66
|
+
}
|
|
67
|
+
return item;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
BOOL BGSRNDropPendingFilter(NSMutableDictionary<NSString *, id> *table, id lock, NSString *requestId) {
|
|
71
|
+
BOOL overdue = NO;
|
|
72
|
+
id item = BGSRNTakeRaw(table, lock, requestId, &overdue);
|
|
73
|
+
if (item == nil) {
|
|
74
|
+
return NO;
|
|
75
|
+
}
|
|
76
|
+
BGSRNAnswerNil(item);
|
|
77
|
+
return YES;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
void BGSRNArmPendingFilterDeadlineAfter(int64_t deadlineMs,
|
|
81
|
+
dispatch_queue_t queue,
|
|
82
|
+
NSMutableDictionary<NSString *, id> *table,
|
|
83
|
+
id lock,
|
|
84
|
+
NSString *requestId) {
|
|
85
|
+
const uint64_t expiresAt = BGSRNNowNanos() + (uint64_t)deadlineMs * NSEC_PER_MSEC;
|
|
86
|
+
dispatch_block_t token = BGSRNArmFilterDeadline(deadlineMs, queue, ^{
|
|
87
|
+
BGSRNDropPendingFilter(table, lock, requestId);
|
|
88
|
+
});
|
|
89
|
+
if (token == nil) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
id item = nil;
|
|
93
|
+
@synchronized (lock) {
|
|
94
|
+
item = table[requestId];
|
|
95
|
+
}
|
|
96
|
+
if (item != nil && [item respondsToSelector:NSSelectorFromString(@"setDeadline:")]) {
|
|
97
|
+
[item setValue:token forKey:@"deadline"];
|
|
98
|
+
if ([item respondsToSelector:NSSelectorFromString(@"setExpiresAt:")]) {
|
|
99
|
+
[item setValue:@(expiresAt) forKey:@"expiresAt"];
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
// Nothing to hold it, or already answered: the timer finds nothing.
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void BGSRNArmPendingFilterDeadline(NSMutableDictionary<NSString *, id> *table, id lock, NSString *requestId) {
|
|
107
|
+
BGSRNArmPendingFilterDeadlineAfter(BGSRNFilterDeadlineMs,
|
|
108
|
+
dispatch_get_global_queue(QOS_CLASS_UTILITY, 0),
|
|
109
|
+
table, lock, requestId);
|
|
110
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
@interface BGSRNSpanEntry : NSObject
|
|
6
6
|
@property (nonatomic, strong) id identity;
|
|
7
7
|
@property (nonatomic, strong) id<BGSRNRetainedSpan> adapter;
|
|
8
|
+
@property (nonatomic) BOOL owned;
|
|
8
9
|
@end
|
|
9
10
|
|
|
10
11
|
@implementation BGSRNSpanEntry
|
|
@@ -41,6 +42,10 @@
|
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
- (NSString *)retainSpan:(id)span adapter:(id<BGSRNRetainedSpan>)adapter {
|
|
45
|
+
return [self retainSpan:span adapter:adapter owned:YES];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (NSString *)retainSpan:(id)span adapter:(id<BGSRNRetainedSpan>)adapter owned:(BOOL)owned {
|
|
44
49
|
os_unfair_lock_lock(&_lock);
|
|
45
50
|
NSString *handle = @"";
|
|
46
51
|
if (!_closed && span != nil && adapter != nil) {
|
|
@@ -53,6 +58,7 @@
|
|
|
53
58
|
BGSRNSpanEntry *entry = [BGSRNSpanEntry new];
|
|
54
59
|
entry.identity = span;
|
|
55
60
|
entry.adapter = adapter;
|
|
61
|
+
entry.owned = owned;
|
|
56
62
|
_byHandle[handle] = entry;
|
|
57
63
|
[_byIdentity setObject:handle forKey:span];
|
|
58
64
|
}
|
|
@@ -61,7 +67,7 @@
|
|
|
61
67
|
return handle;
|
|
62
68
|
}
|
|
63
69
|
|
|
64
|
-
- (NSArray<
|
|
70
|
+
- (NSArray<NSDictionary *> *)finishHandle:(NSString *)handle status:(NSNumber *)status {
|
|
65
71
|
// The adapter's finish is outside the lock: os_unfair_lock does not
|
|
66
72
|
// re-enter, and a parent finish runs the child's finish on this thread.
|
|
67
73
|
os_unfair_lock_lock(&_lock);
|
|
@@ -73,7 +79,7 @@
|
|
|
73
79
|
}
|
|
74
80
|
[adapter bgsrnFinishWithStatus:status];
|
|
75
81
|
os_unfair_lock_lock(&_lock);
|
|
76
|
-
NSArray<
|
|
82
|
+
NSArray<NSDictionary *> *released = _closed ? @[] : [self dropCalled:handle];
|
|
77
83
|
os_unfair_lock_unlock(&_lock);
|
|
78
84
|
return released;
|
|
79
85
|
}
|
|
@@ -86,6 +92,34 @@
|
|
|
86
92
|
os_unfair_lock_unlock(&_lock);
|
|
87
93
|
}
|
|
88
94
|
|
|
95
|
+
- (void)cancelOpenAndReleaseAll {
|
|
96
|
+
os_unfair_lock_lock(&_lock);
|
|
97
|
+
NSArray<NSString *> *handles = [_byHandle.allKeys sortedArrayUsingComparator:^NSComparisonResult(NSString *a, NSString *b) {
|
|
98
|
+
NSComparisonResult byLength = [@(a.length) compare:@(b.length)];
|
|
99
|
+
return byLength != NSOrderedSame ? byLength : [a compare:b];
|
|
100
|
+
}];
|
|
101
|
+
NSMutableArray<id<BGSRNRetainedSpan>> *owned = [NSMutableArray array];
|
|
102
|
+
for (NSString *handle in handles) {
|
|
103
|
+
BGSRNSpanEntry *entry = _byHandle[handle];
|
|
104
|
+
if (entry.owned) {
|
|
105
|
+
[owned addObject:entry.adapter];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
_closed = YES;
|
|
109
|
+
[_byHandle removeAllObjects];
|
|
110
|
+
[_byIdentity removeAllObjects];
|
|
111
|
+
os_unfair_lock_unlock(&_lock);
|
|
112
|
+
for (id<BGSRNRetainedSpan> adapter in owned) {
|
|
113
|
+
@try {
|
|
114
|
+
if (![adapter bgsrnIsFinished]) {
|
|
115
|
+
[adapter bgsrnFinishWithStatus:@(3)];
|
|
116
|
+
}
|
|
117
|
+
} @catch (NSException *exception) {
|
|
118
|
+
// One span the SDK refuses must not strand the others.
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
89
123
|
- (BOOL)containsHandle:(NSString *)handle {
|
|
90
124
|
os_unfair_lock_lock(&_lock);
|
|
91
125
|
const BOOL contains = handle != nil && _byHandle[handle] != nil;
|
|
@@ -109,13 +143,13 @@
|
|
|
109
143
|
}
|
|
110
144
|
|
|
111
145
|
/// Caller holds the lock. `called` is removed whether or not it reports finished.
|
|
112
|
-
- (NSArray<
|
|
113
|
-
NSMutableArray<
|
|
146
|
+
- (NSArray<NSDictionary *> *)dropCalled:(NSString *)called {
|
|
147
|
+
NSMutableArray<NSDictionary *> *released = [NSMutableArray array];
|
|
114
148
|
BGSRNSpanEntry *calledEntry = called == nil ? nil : _byHandle[called];
|
|
115
149
|
if (calledEntry != nil) {
|
|
116
150
|
[_byIdentity removeObjectForKey:calledEntry.identity];
|
|
117
151
|
[_byHandle removeObjectForKey:called];
|
|
118
|
-
[released addObject:called];
|
|
152
|
+
[released addObject:@{@"handle": called, @"status": @([calledEntry.adapter bgsrnStatus])}];
|
|
119
153
|
}
|
|
120
154
|
NSMutableArray<NSString *> *finished = [NSMutableArray array];
|
|
121
155
|
for (NSString *handle in _byHandle) {
|
|
@@ -128,7 +162,7 @@
|
|
|
128
162
|
BGSRNSpanEntry *entry = _byHandle[handle];
|
|
129
163
|
[_byIdentity removeObjectForKey:entry.identity];
|
|
130
164
|
[_byHandle removeObjectForKey:handle];
|
|
131
|
-
[released addObject:handle];
|
|
165
|
+
[released addObject:@{@"handle": handle, @"status": @([entry.adapter bgsrnStatus])}];
|
|
132
166
|
}
|
|
133
167
|
return released;
|
|
134
168
|
}
|
|
@@ -46,7 +46,7 @@ static NSString *BGSRNStringOr(NSDictionary *source, NSString *key, NSString *fa
|
|
|
46
46
|
// test compares the three so they cannot drift.
|
|
47
47
|
return [self wrapperWithIdentity:@{
|
|
48
48
|
@"type" : @"react_native",
|
|
49
|
-
@"version" : @"7.0.0-
|
|
49
|
+
@"version" : @"7.0.0-beta4",
|
|
50
50
|
@"context" : @{},
|
|
51
51
|
}];
|
|
52
52
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <Bugsee/Bugsee.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
/// TODO(#143): temporary wrapper workaround. The contract is that a blackout
|
|
7
|
+
/// lasts until `endBlackout()` or `stop()`; Android's SDK ends it on stop, the
|
|
8
|
+
/// iOS SDK does not, so it survived into the next `launch()`. This belongs in
|
|
9
|
+
/// the iOS SDK (every wrapper is affected); delete this once it ends the
|
|
10
|
+
/// blackout itself.
|
|
11
|
+
///
|
|
12
|
+
/// Ends a blackout in force and returns YES, when `status` is not Stopped. A
|
|
13
|
+
/// Stopped SDK is left alone: a `startBlackout()` made before `launch()` is
|
|
14
|
+
/// deliberately held until launch, and `stop()` on a never-launched SDK must
|
|
15
|
+
/// not cancel it. NO, and no `endBlackout`, when there is nothing to end (so
|
|
16
|
+
/// no spurious `BlackoutEnded`).
|
|
17
|
+
FOUNDATION_EXPORT BOOL BGSRNEndBlackoutForStopWithStatus(BugseeStatus status);
|
|
18
|
+
|
|
19
|
+
/// The same, reading the SDK's current status. Call on the main queue, ahead
|
|
20
|
+
/// of the native stop.
|
|
21
|
+
FOUNDATION_EXPORT BOOL BGSRNEndBlackoutForStop(void);
|
|
22
|
+
|
|
23
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/// The longest `BGSRNDeleteCollectedData` waits for the SDK completion. Long on
|
|
6
|
+
/// purpose: a deletion that is merely slow (it can queue behind an upload that
|
|
7
|
+
/// holds the SDK's processing queue) must still report its real outcome, so
|
|
8
|
+
/// this is a backstop against a promise that never settles, not a deadline.
|
|
9
|
+
FOUNDATION_EXPORT const int64_t BGSRNDeleteCollectedDataBackstopMs;
|
|
10
|
+
|
|
11
|
+
/// Reject code when the backstop fires first. The deletion may still finish
|
|
12
|
+
/// later; the caller learns that the outcome is unknown, not that it failed.
|
|
13
|
+
FOUNDATION_EXPORT NSString *const BGSRNDeleteTimeoutCode;
|
|
14
|
+
|
|
15
|
+
/// The SDK call, handed the completion to invoke with the SDK's outcome.
|
|
16
|
+
typedef void (^BGSRNDeleteSDKCall)(void (^completion)(BOOL success));
|
|
17
|
+
|
|
18
|
+
/// Runs `sdkCall` and settles exactly once, on `queue` (which must be serial):
|
|
19
|
+
/// `resolve` with the SDK's success, or `reject` with
|
|
20
|
+
/// `BGSRNDeleteTimeoutCode` if `backstopMs` passes first. A completion that
|
|
21
|
+
/// arrives after the backstop, or a second completion, is ignored. The
|
|
22
|
+
/// completion may be called on any thread.
|
|
23
|
+
FOUNDATION_EXPORT void BGSRNDeleteCollectedData(BGSRNDeleteSDKCall sdkCall,
|
|
24
|
+
int64_t backstopMs,
|
|
25
|
+
dispatch_queue_t queue,
|
|
26
|
+
void (^resolve)(BOOL success),
|
|
27
|
+
void (^reject)(NSString *code));
|
|
28
|
+
|
|
29
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/// Which module's JS has installed a filter.
|
|
6
|
+
///
|
|
7
|
+
/// The native filter blocks and their flags are process statics, so they
|
|
8
|
+
/// outlive a JavaScript reload. The new module attaches as the sink, but its
|
|
9
|
+
/// JS has not subscribed, and a request emitted to it would never be
|
|
10
|
+
/// answered: on iOS it stays pending until process death. A filter block
|
|
11
|
+
/// therefore asks `isArmedFor:` with the current module and drops at once
|
|
12
|
+
/// when this returns NO.
|
|
13
|
+
///
|
|
14
|
+
/// The owner is held weakly: an invalidated module that is released reads as
|
|
15
|
+
/// not armed. Thread-safe: the SDK calls filters from any thread.
|
|
16
|
+
@interface BGSRNFilterArming : NSObject
|
|
17
|
+
|
|
18
|
+
/// `owner`'s JS has installed the filter. Replaces any earlier owner.
|
|
19
|
+
- (void)armFor:(id)owner;
|
|
20
|
+
|
|
21
|
+
/// YES only when `owner` is the module that last called `armFor:`.
|
|
22
|
+
- (BOOL)isArmedFor:(nullable id)owner;
|
|
23
|
+
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/// How long JS gets to answer one filter request (log, network, breadcrumb)
|
|
6
|
+
/// before the wrapper drops the item.
|
|
7
|
+
///
|
|
8
|
+
/// The iOS SDK has no timeout for any of these filters: a late decision is
|
|
9
|
+
/// still recorded, and one that never comes leaves the request, and the event
|
|
10
|
+
/// it retains, in the bridge's pending table until the process dies. The
|
|
11
|
+
/// wrapper therefore sets its own, failing closed: past the deadline the
|
|
12
|
+
/// decision block is called with nil (drop), the entry is removed, and a late
|
|
13
|
+
/// reply finds nothing and is a no-op. It is never answered with the original
|
|
14
|
+
/// item: that would pass through exactly what the filter exists to redact.
|
|
15
|
+
///
|
|
16
|
+
/// 9 s is the Android number: its log and network bridges forget a request at
|
|
17
|
+
/// 9 s, inside the SDK's own 10 s recycle.
|
|
18
|
+
FOUNDATION_EXPORT const int64_t BGSRNFilterDeadlineMs;
|
|
19
|
+
|
|
20
|
+
/// Runs `expire` on `queue` after `deadlineMs`. Returns a token for
|
|
21
|
+
/// `BGSRNCancelFilterDeadline`; the timer itself is a `dispatch_after`, which
|
|
22
|
+
/// GCD cannot unschedule, so cancelling stops the block from running but the
|
|
23
|
+
/// (tiny) block stays queued until the 9 s are up.
|
|
24
|
+
FOUNDATION_EXPORT _Nullable dispatch_block_t BGSRNArmFilterDeadline(
|
|
25
|
+
int64_t deadlineMs,
|
|
26
|
+
dispatch_queue_t _Nullable queue,
|
|
27
|
+
dispatch_block_t _Nullable expire);
|
|
28
|
+
|
|
29
|
+
FOUNDATION_EXPORT void BGSRNCancelFilterDeadline(_Nullable dispatch_block_t token);
|
|
30
|
+
|
|
31
|
+
/// Removes and returns the pending item for `requestId`, or nil when it was
|
|
32
|
+
/// already answered, expired, or torn down. The removal is under `lock`, so a
|
|
33
|
+
/// reply and the deadline cannot both take the same item: whoever gets it
|
|
34
|
+
/// calls the SDK's decision block, and the other does nothing. If the item has
|
|
35
|
+
/// a `deadline` property, its timer is cancelled here, so every reply path
|
|
36
|
+
/// that takes the item also stops its timer. If it has an `expiresAt`
|
|
37
|
+
/// property (a monotonic `CLOCK_UPTIME_RAW` instant in nanoseconds, set when
|
|
38
|
+
/// the deadline is armed) and that instant has passed, the item is overdue
|
|
39
|
+
/// even though the timer block may not have run (a starved queue): it is
|
|
40
|
+
/// answered with nil here and nil is returned, so a late reply is never
|
|
41
|
+
/// applied.
|
|
42
|
+
FOUNDATION_EXPORT _Nullable id BGSRNTakePendingFilter(NSMutableDictionary<NSString *, id> *table,
|
|
43
|
+
id lock,
|
|
44
|
+
NSString *_Nullable requestId);
|
|
45
|
+
|
|
46
|
+
/// Starts the deadline for a request already in `table`. When it passes and
|
|
47
|
+
/// the request is still pending, the item is taken and its `decision` block is
|
|
48
|
+
/// called with nil (drop). Never with the original. Stores the timer token in
|
|
49
|
+
/// the item's `deadline` property when it has one.
|
|
50
|
+
FOUNDATION_EXPORT void BGSRNArmPendingFilterDeadline(NSMutableDictionary<NSString *, id> *table,
|
|
51
|
+
id lock,
|
|
52
|
+
NSString *requestId);
|
|
53
|
+
|
|
54
|
+
/// As above with an explicit deadline and queue, for tests.
|
|
55
|
+
FOUNDATION_EXPORT void BGSRNArmPendingFilterDeadlineAfter(int64_t deadlineMs,
|
|
56
|
+
dispatch_queue_t queue,
|
|
57
|
+
NSMutableDictionary<NSString *, id> *table,
|
|
58
|
+
id lock,
|
|
59
|
+
NSString *requestId);
|
|
60
|
+
|
|
61
|
+
/// Takes `requestId` and answers its `decision` block with nil. Returns
|
|
62
|
+
/// whether it was still pending. The deadline's whole effect, separate so it
|
|
63
|
+
/// can be tested without waiting.
|
|
64
|
+
FOUNDATION_EXPORT BOOL BGSRNDropPendingFilter(NSMutableDictionary<NSString *, id> *table,
|
|
65
|
+
id lock,
|
|
66
|
+
NSString *requestId);
|
|
67
|
+
|
|
68
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
// Not `@import Bugsee;`: this header is included from ObjC++, where C++ modules
|
|
3
3
|
// are off on both delivery paths and a module import is a hard error.
|
|
4
4
|
#import <Bugsee/Bugsee.h>
|
|
5
|
+
// 7.0 GA moves the wrapper contract to the Bugsee.SPI submodule (BugseeSPI.h);
|
|
6
|
+
// the 7.0 betas declare it in Bugsee.h.
|
|
7
|
+
#if __has_include(<Bugsee/BugseeSPI.h>)
|
|
8
|
+
#import <Bugsee/BugseeSPI.h>
|
|
9
|
+
#endif
|
|
5
10
|
|
|
6
11
|
NS_ASSUME_NONNULL_BEGIN
|
|
7
12
|
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
// Not `@import Bugsee;`: this header is included from ObjC++, where C++ modules
|
|
3
3
|
// are off on both delivery paths and a module import is a hard error.
|
|
4
4
|
#import <Bugsee/Bugsee.h>
|
|
5
|
+
// 7.0 GA moves the wrapper contract to the Bugsee.SPI submodule (BugseeSPI.h);
|
|
6
|
+
// the 7.0 betas declare it in Bugsee.h.
|
|
7
|
+
#if __has_include(<Bugsee/BugseeSPI.h>)
|
|
8
|
+
#import <Bugsee/BugseeSPI.h>
|
|
9
|
+
#endif
|
|
5
10
|
|
|
6
11
|
NS_ASSUME_NONNULL_BEGIN
|
|
7
12
|
|
|
@@ -11,6 +11,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
11
11
|
/// `status` nil is the no-arg finish.
|
|
12
12
|
- (void)bgsrnFinishWithStatus:(NSNumber *_Nullable)status;
|
|
13
13
|
- (BOOL)bgsrnIsFinished;
|
|
14
|
+
/// The SDK status (`BGSSpanStatus` integer), read now.
|
|
15
|
+
- (NSInteger)bgsrnStatus;
|
|
14
16
|
@end
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -28,15 +30,27 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
28
30
|
/// issued and does not store `adapter` again.
|
|
29
31
|
- (NSString *)retainSpan:(id)span adapter:(id<BGSRNRetainedSpan>)adapter;
|
|
30
32
|
|
|
33
|
+
/// `owned` is YES for a span JS started, NO for one it only adopted (the
|
|
34
|
+
/// active span). Only owned spans are cancelled by `cancelOpenAndReleaseAll`.
|
|
35
|
+
- (NSString *)retainSpan:(id)span adapter:(id<BGSRNRetainedSpan>)adapter owned:(BOOL)owned;
|
|
36
|
+
|
|
31
37
|
/// Finishes `handle`, then drops that handle even when it still reports
|
|
32
38
|
/// unfinished. Other retained spans are dropped only when they now report
|
|
33
|
-
/// finished.
|
|
34
|
-
|
|
39
|
+
/// finished. Each item is `@{@"handle": NSString, @"status": NSNumber}` with
|
|
40
|
+
/// the status the span holds after the finish. Empty when `handle` is not held.
|
|
41
|
+
- (NSArray<NSDictionary *> *)finishHandle:(NSString *)handle
|
|
35
42
|
status:(NSNumber *_Nullable)status;
|
|
36
43
|
|
|
37
44
|
/// Drops every handle and refuses later retains. Does not finish the spans.
|
|
38
45
|
- (void)releaseAll;
|
|
39
46
|
|
|
47
|
+
/// Finishes every owned span that is still open with Cancelled (status 3),
|
|
48
|
+
/// then does what `releaseAll` does; adopted spans are only dropped. Parents
|
|
49
|
+
/// are visited before their children, so a child a parent finish already
|
|
50
|
+
/// cancelled is skipped. A span that throws is skipped. The adapter calls
|
|
51
|
+
/// run outside the registry lock; the caller picks the thread.
|
|
52
|
+
- (void)cancelOpenAndReleaseAll;
|
|
53
|
+
|
|
40
54
|
/// The registry `invalidate` hands out. It retains nothing.
|
|
41
55
|
+ (BGSRNSpanHandles *)closedRegistry;
|
|
42
56
|
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
// Not `@import Bugsee;`: this header is included from ObjC++, where C++ modules
|
|
3
3
|
// are off on both delivery paths and a module import is a hard error.
|
|
4
4
|
#import <Bugsee/Bugsee.h>
|
|
5
|
+
// 7.0 GA moves the wrapper contract to the Bugsee.SPI submodule (BugseeSPI.h);
|
|
6
|
+
// the 7.0 betas declare it in Bugsee.h.
|
|
7
|
+
#if __has_include(<Bugsee/BugseeSPI.h>)
|
|
8
|
+
#import <Bugsee/BugseeSPI.h>
|
|
9
|
+
#endif
|
|
5
10
|
|
|
6
11
|
NS_ASSUME_NONNULL_BEGIN
|
|
7
12
|
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
@import XCTest;
|
|
2
|
+
@import BugseeRNSupport;
|
|
3
|
+
@import Bugsee;
|
|
4
|
+
|
|
5
|
+
/// Pins `BGSRNEndBlackoutForStop` against the real SDK: `stop()` ends a
|
|
6
|
+
/// blackout on iOS as it does on Android (#143), and a pre-launch
|
|
7
|
+
/// `startBlackout()` on a never-launched SDK is left alone.
|
|
8
|
+
@interface BGSRNBlackoutTests : XCTestCase
|
|
9
|
+
@end
|
|
10
|
+
|
|
11
|
+
@implementation BGSRNBlackoutTests
|
|
12
|
+
|
|
13
|
+
- (void)tearDown {
|
|
14
|
+
[Bugsee endBlackout];
|
|
15
|
+
[super tearDown];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
- (void)testEndsABlackoutWhenTheSdkIsNotStopped {
|
|
19
|
+
[Bugsee startBlackout];
|
|
20
|
+
XCTAssertTrue([Bugsee isBlackout]);
|
|
21
|
+
XCTAssertTrue(BGSRNEndBlackoutForStopWithStatus(BugseeStatusLaunched));
|
|
22
|
+
XCTAssertFalse([Bugsee isBlackout]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (void)testLeavesAPreLaunchBlackoutWhenStopped {
|
|
26
|
+
[Bugsee startBlackout];
|
|
27
|
+
XCTAssertFalse(BGSRNEndBlackoutForStopWithStatus(BugseeStatusStopped));
|
|
28
|
+
XCTAssertTrue([Bugsee isBlackout]);
|
|
29
|
+
XCTAssertFalse(BGSRNEndBlackoutForStop()); // never launched here: Stopped
|
|
30
|
+
XCTAssertTrue([Bugsee isBlackout]);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
- (void)testDoesNothingWhenNoBlackout {
|
|
34
|
+
XCTAssertFalse([Bugsee isBlackout]);
|
|
35
|
+
XCTAssertFalse(BGSRNEndBlackoutForStopWithStatus(BugseeStatusLaunched));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@end
|