@logbrew/react-native 0.1.22 → 0.1.24
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/LogBrewReactNative.podspec +1 -0
- package/README.md +70 -7
- package/android/CMakeLists.txt +7 -0
- package/android/build.gradle +12 -0
- package/android/src/main/cpp/android_diagnostics.cpp +363 -0
- package/android/src/main/java/co/logbrew/reactnative/AndroidDiagnosticsRuntime.java +214 -0
- package/android/src/main/java/co/logbrew/reactnative/AndroidNativeDiagnostics.java +363 -0
- package/android/src/main/java/co/logbrew/reactnative/AndroidNativeSignalStore.java +233 -0
- package/android/src/main/java/co/logbrew/reactnative/AndroidParentDirectorySync.java +12 -12
- package/android/src/main/java/co/logbrew/reactnative/EventRecordStore.java +15 -5
- package/android/src/main/java/co/logbrew/reactnative/FatalStoreModuleImpl.java +127 -156
- package/android/src/newarch/java/co/logbrew/reactnative/FatalStoreModule.java +17 -17
- package/android/src/oldarch/java/co/logbrew/reactnative/FatalStoreModule.java +17 -17
- package/android-native-diagnostics.d.ts +29 -0
- package/android-native-diagnostics.js +176 -0
- package/fatal-replay.cjs +35 -3
- package/global-errors.d.cts +3 -3
- package/global-errors.d.ts +3 -3
- package/global-errors.native.js +1 -12
- package/index.cjs +27 -5
- package/index.native.d.ts +4 -0
- package/index.native.js +29 -4
- package/ios/AppleDiagnostics/LBRNAppleNativeDiagnostics.swift +1 -1
- package/ios/GeneratedAppleDiagnostics/LogBrew/LogBrewLogger.swift +2 -10
- package/ios/GeneratedAppleDiagnostics/LogBrew/OperationTrace.swift +56 -0
- package/ios/GeneratedAppleDiagnostics/LogBrew/URLSessionTracer.swift +48 -56
- package/ios/GeneratedAppleDiagnostics/LogBrew/Validation.swift +6 -0
- package/ios/GeneratedAppleDiagnostics/LogBrewCrash/NativeCrashCorrelation.swift +0 -1
- package/ios/GeneratedAppleDiagnostics/SOURCE-MANIFEST.json +5 -4
- package/ios/LBRNFatalStoreModule.mm +34 -86
- package/package.json +17 -5
- package/persistent-delivery.native.js +4 -3
- package/resource-fetch.js +5 -463
- package/src/NativeLogBrewFatalStore.ts +6 -4
- package/android/src/main/java/co/logbrew/reactnative/FatalRecordStore.java +0 -623
- package/ios/LBRNFatalRecordStore.h +0 -25
- package/ios/LBRNFatalRecordStore.m +0 -542
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#import "LBRNFatalStoreModule.h"
|
|
2
2
|
|
|
3
3
|
#import "LBRNEventRecordStore.h"
|
|
4
|
-
#import "LBRNFatalRecordStore.h"
|
|
5
4
|
#import "LBRNPrivateStorage.h"
|
|
6
5
|
|
|
7
6
|
#import <CommonCrypto/CommonDigest.h>
|
|
7
|
+
#import <Security/SecRandom.h>
|
|
8
8
|
#import <TargetConditionals.h>
|
|
9
|
+
#import <math.h>
|
|
9
10
|
|
|
10
11
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
11
12
|
#import <LogBrewReactNativeSpec/LogBrewReactNativeSpec.h>
|
|
@@ -61,39 +62,10 @@ static NSString *LBRNQueueHash(NSString *queueKey)
|
|
|
61
62
|
return value;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
|
-
static NSDictionary *LBRNNormalizeRecord(NSDictionary *record)
|
|
65
|
-
{
|
|
66
|
-
if (![record isKindOfClass:[NSDictionary class]]) {
|
|
67
|
-
return @{};
|
|
68
|
-
}
|
|
69
|
-
id framesValue = record[@"stackFrames"];
|
|
70
|
-
if (![framesValue isKindOfClass:[NSArray class]]) {
|
|
71
|
-
return record;
|
|
72
|
-
}
|
|
73
|
-
NSMutableArray *frames = [NSMutableArray arrayWithCapacity:[framesValue count]];
|
|
74
|
-
for (id value in framesValue) {
|
|
75
|
-
if (![value isKindOfClass:[NSDictionary class]]) {
|
|
76
|
-
return record;
|
|
77
|
-
}
|
|
78
|
-
NSMutableDictionary *frame = [value mutableCopy];
|
|
79
|
-
NSString *filename = frame[@"filename"];
|
|
80
|
-
if ([filename isKindOfClass:[NSString class]]
|
|
81
|
-
&& [filename hasPrefix:@"/"]
|
|
82
|
-
&& [[filename substringFromIndex:1] rangeOfString:@"/"].location == NSNotFound) {
|
|
83
|
-
frame[@"filename"] = [filename substringFromIndex:1];
|
|
84
|
-
}
|
|
85
|
-
[frames addObject:frame];
|
|
86
|
-
}
|
|
87
|
-
NSMutableDictionary *normalized = [record mutableCopy];
|
|
88
|
-
normalized[@"stackFrames"] = frames;
|
|
89
|
-
return normalized;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
65
|
@interface LBRNFatalStoreModule ()
|
|
93
66
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
94
67
|
<NativeLogBrewFatalStoreSpec>
|
|
95
68
|
#endif
|
|
96
|
-
@property (nonatomic, nullable) LBRNFatalRecordStore *store;
|
|
97
69
|
@property (nonatomic, nullable) NSURL *eventStoreParentURL;
|
|
98
70
|
@property (nonatomic) NSMutableDictionary<NSString *, LBRNEventRecordStore *> *eventStores;
|
|
99
71
|
@end
|
|
@@ -117,19 +89,28 @@ RCT_EXPORT_MODULE(LogBrewFatalStore)
|
|
|
117
89
|
if (baseURL != nil && LBRNPreparePrivateRootDirectory(baseURL)) {
|
|
118
90
|
_eventStoreParentURL = baseURL;
|
|
119
91
|
_eventStores = [NSMutableDictionary dictionary];
|
|
120
|
-
NSURL *directoryURL = [baseURL URLByAppendingPathComponent:@"LogBrewFatalJS"
|
|
121
|
-
isDirectory:YES];
|
|
122
|
-
LBRNFatalDirectoryPreparation directoryPreparation = ^BOOL(NSURL *preparedURL) {
|
|
123
|
-
return LBRNPrepareProtectedDirectory(preparedURL);
|
|
124
|
-
};
|
|
125
|
-
_store = [[LBRNFatalRecordStore alloc]
|
|
126
|
-
initWithDirectoryURL:directoryURL
|
|
127
|
-
directoryPreparation:directoryPreparation];
|
|
128
92
|
}
|
|
129
93
|
}
|
|
130
94
|
return self;
|
|
131
95
|
}
|
|
132
96
|
|
|
97
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(secureRandomHex:(double)length)
|
|
98
|
+
{
|
|
99
|
+
if (!isfinite(length) || length < 1 || length > 64 || floor(length) != length) {
|
|
100
|
+
return @"";
|
|
101
|
+
}
|
|
102
|
+
uint8_t bytes[64];
|
|
103
|
+
NSUInteger byteCount = (NSUInteger)length;
|
|
104
|
+
if (SecRandomCopyBytes(kSecRandomDefault, byteCount, bytes) != errSecSuccess) {
|
|
105
|
+
return @"";
|
|
106
|
+
}
|
|
107
|
+
NSMutableString *output = [NSMutableString stringWithCapacity:byteCount * 2];
|
|
108
|
+
for (NSUInteger index = 0; index < byteCount; index += 1) {
|
|
109
|
+
[output appendFormat:@"%02x", bytes[index]];
|
|
110
|
+
}
|
|
111
|
+
return output;
|
|
112
|
+
}
|
|
113
|
+
|
|
133
114
|
- (nullable LBRNEventRecordStore *)eventStoreForQueueKey:(NSString *)queueKey
|
|
134
115
|
{
|
|
135
116
|
NSString *queueHash = LBRNQueueHash(queueKey);
|
|
@@ -154,54 +135,6 @@ RCT_EXPORT_MODULE(LogBrewFatalStore)
|
|
|
154
135
|
}
|
|
155
136
|
}
|
|
156
137
|
|
|
157
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(writeFatalRecord:(NSDictionary *)record)
|
|
158
|
-
{
|
|
159
|
-
if (self.store == nil) {
|
|
160
|
-
return LBRNStorageError();
|
|
161
|
-
}
|
|
162
|
-
@try {
|
|
163
|
-
return [self.store writeRecord:LBRNNormalizeRecord(record)];
|
|
164
|
-
} @catch (__unused NSException *exception) {
|
|
165
|
-
return LBRNStorageError();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(readFatalRecord)
|
|
170
|
-
{
|
|
171
|
-
if (self.store == nil) {
|
|
172
|
-
return LBRNStorageError();
|
|
173
|
-
}
|
|
174
|
-
@try {
|
|
175
|
-
return [self.store readRecord];
|
|
176
|
-
} @catch (__unused NSException *exception) {
|
|
177
|
-
return LBRNStorageError();
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(acknowledgeFatalRecord:(NSString *)recordId)
|
|
182
|
-
{
|
|
183
|
-
if (self.store == nil || ![recordId isKindOfClass:[NSString class]]) {
|
|
184
|
-
return LBRNStorageError();
|
|
185
|
-
}
|
|
186
|
-
@try {
|
|
187
|
-
return [self.store acknowledgeRecordId:recordId];
|
|
188
|
-
} @catch (__unused NSException *exception) {
|
|
189
|
-
return LBRNStorageError();
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(discardFatalRecord)
|
|
194
|
-
{
|
|
195
|
-
if (self.store == nil) {
|
|
196
|
-
return LBRNStorageError();
|
|
197
|
-
}
|
|
198
|
-
@try {
|
|
199
|
-
return [self.store discardRecord];
|
|
200
|
-
} @catch (__unused NSException *exception) {
|
|
201
|
-
return LBRNStorageError();
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
138
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(loadEventRecords:(NSString *)queueKey)
|
|
206
139
|
{
|
|
207
140
|
LBRNEventRecordStore *eventStore = [self eventStoreForQueueKey:queueKey];
|
|
@@ -281,6 +214,21 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(closeEventStore:(NSString *)queueKey)
|
|
|
281
214
|
}
|
|
282
215
|
}
|
|
283
216
|
|
|
217
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(installAndroidDiagnostics:(NSDictionary *)configuration)
|
|
218
|
+
{
|
|
219
|
+
return @{ @"status" : @"error", @"code" : @"unsupported_platform" };
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(androidDiagnosticsStatus)
|
|
223
|
+
{
|
|
224
|
+
return @{ @"status" : @"not_installed", @"pending" : @0 };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(uninstallAndroidDiagnostics)
|
|
228
|
+
{
|
|
229
|
+
return @{ @"status" : @"not_installed", @"pending" : @0 };
|
|
230
|
+
}
|
|
231
|
+
|
|
284
232
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
285
233
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
286
234
|
(const facebook::react::ObjCTurboModule::InitParams &)params
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logbrew/react-native",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "React Native offline delivery,
|
|
3
|
+
"version": "0.1.24",
|
|
4
|
+
"description": "React Native offline delivery, native diagnostics, screen, error, trace, action, and network timeline helpers for LogBrew.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"module": "./index.js",
|
|
@@ -126,6 +126,17 @@
|
|
|
126
126
|
},
|
|
127
127
|
"default": "./apple-native-diagnostics.js"
|
|
128
128
|
},
|
|
129
|
+
"./android-native-diagnostics": {
|
|
130
|
+
"react-native": {
|
|
131
|
+
"types": "./android-native-diagnostics.d.ts",
|
|
132
|
+
"default": "./android-native-diagnostics.js"
|
|
133
|
+
},
|
|
134
|
+
"import": {
|
|
135
|
+
"types": "./android-native-diagnostics.d.ts",
|
|
136
|
+
"default": "./android-native-diagnostics.js"
|
|
137
|
+
},
|
|
138
|
+
"default": "./android-native-diagnostics.js"
|
|
139
|
+
},
|
|
129
140
|
"./expo": {
|
|
130
141
|
"import": {
|
|
131
142
|
"types": "./expo.d.ts",
|
|
@@ -185,16 +196,17 @@
|
|
|
185
196
|
"metro.d.cts",
|
|
186
197
|
"apple-native-diagnostics.js",
|
|
187
198
|
"apple-native-diagnostics.d.ts",
|
|
199
|
+
"android-native-diagnostics.js",
|
|
200
|
+
"android-native-diagnostics.d.ts",
|
|
188
201
|
"expo.cjs",
|
|
189
202
|
"expo.js",
|
|
190
203
|
"expo.d.ts",
|
|
191
204
|
"LogBrewReactNative.podspec",
|
|
192
205
|
"android/build.gradle",
|
|
206
|
+
"android/CMakeLists.txt",
|
|
193
207
|
"android/src/main",
|
|
194
208
|
"android/src/oldarch",
|
|
195
209
|
"android/src/newarch",
|
|
196
|
-
"ios/LBRNFatalRecordStore.h",
|
|
197
|
-
"ios/LBRNFatalRecordStore.m",
|
|
198
210
|
"ios/LBRNFatalStoreModule.h",
|
|
199
211
|
"ios/LBRNFatalStoreModule.mm",
|
|
200
212
|
"ios/LBRNPrivateStorage.h",
|
|
@@ -251,6 +263,6 @@
|
|
|
251
263
|
}
|
|
252
264
|
},
|
|
253
265
|
"scripts": {
|
|
254
|
-
"test": "node scripts/sync-apple-native-sources.mjs --check && node --check index.js && node --check index.cjs && node --check index.native.js && node --check apple-native-diagnostics.js && node --check expo.js && node --check expo.cjs && node --check apollo.js && node --check apollo.cjs && node --check instrumentation.js && node --check instrumentation.cjs && node --check lifecycle.js && node --check lifecycle.cjs && node --check global-errors.js && node --check global-errors.native.js && node --check global-errors.cjs && node --check promise-rejections.cjs && node --check fatal-replay.cjs && node --check metadata.js && node --check metadata.cjs && node --check native-bridge.js && node --check native-bridge.cjs && node --check resource-fetch.js && node --check resource-fetch.cjs && node --check release-artifacts.js && node --check release-artifacts.cjs && node --check metro.js && node --check metro.cjs && node --check examples/index.mjs && node --check examples/apollo-link-spans.mjs && node --check examples/instrumentation-kit.mjs && node --check examples/lifecycle-spans.mjs && node --check examples/native-bridge-scope.mjs && node --check examples/navigation-resource-spans.mjs && node --check examples/readme-example.mjs && node --check examples/real-user-smoke.mjs && node --check examples/resource-fetch-spans.mjs && node --check examples/trace-correlation.mjs && node --test"
|
|
266
|
+
"test": "node scripts/sync-apple-native-sources.mjs --check && node --check index.js && node --check index.cjs && node --check index.native.js && node --check apple-native-diagnostics.js && node --check android-native-diagnostics.js && node --check expo.js && node --check expo.cjs && node --check apollo.js && node --check apollo.cjs && node --check instrumentation.js && node --check instrumentation.cjs && node --check lifecycle.js && node --check lifecycle.cjs && node --check global-errors.js && node --check global-errors.native.js && node --check global-errors.cjs && node --check promise-rejections.cjs && node --check fatal-replay.cjs && node --check metadata.js && node --check metadata.cjs && node --check native-bridge.js && node --check native-bridge.cjs && node --check resource-fetch.js && node --check resource-fetch.cjs && node --check release-artifacts.js && node --check release-artifacts.cjs && node --check metro.js && node --check metro.cjs && node --check examples/index.mjs && node --check examples/apollo-link-spans.mjs && node --check examples/instrumentation-kit.mjs && node --check examples/lifecycle-spans.mjs && node --check examples/native-bridge-scope.mjs && node --check examples/navigation-resource-spans.mjs && node --check examples/readme-example.mjs && node --check examples/real-user-smoke.mjs && node --check examples/resource-fetch-spans.mjs && node --check examples/trace-correlation.mjs && node --test"
|
|
255
267
|
}
|
|
256
268
|
}
|
|
@@ -29,10 +29,10 @@ export function resolveReactNativePersistentEventStore({
|
|
|
29
29
|
"eventStore and persistentQueue are mutually exclusive"
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
|
-
return { eventStore, abort() {}, release() {} };
|
|
32
|
+
return { eventStore, durable: false, abort() {}, release() {} };
|
|
33
33
|
}
|
|
34
34
|
if (persistentQueue === "disabled") {
|
|
35
|
-
return { eventStore: undefined, abort() {}, release() {} };
|
|
35
|
+
return { eventStore: undefined, durable: false, abort() {}, release() {} };
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
const nativeStore = defaultNativeStore();
|
|
@@ -43,7 +43,7 @@ export function resolveReactNativePersistentEventStore({
|
|
|
43
43
|
"React Native persistent queue requires the linked LogBrew native module"
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
|
-
return { eventStore: undefined, abort() {}, release() {} };
|
|
46
|
+
return { eventStore: undefined, durable: false, abort() {}, release() {} };
|
|
47
47
|
}
|
|
48
48
|
validateNativeQueueLimits({ maxQueueBytes, maxQueueSize });
|
|
49
49
|
if (ACTIVE_QUEUE_KEYS.has(authKey)) {
|
|
@@ -63,6 +63,7 @@ export function resolveReactNativePersistentEventStore({
|
|
|
63
63
|
};
|
|
64
64
|
const nativeEventStore = createNativeEventStore(nativeStore, authKey, release);
|
|
65
65
|
return {
|
|
66
|
+
durable: true,
|
|
66
67
|
eventStore: nativeEventStore,
|
|
67
68
|
abort() {
|
|
68
69
|
try {
|