@logbrew/react-native 0.1.29 → 0.1.31
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 +1 -1
- package/android/src/main/java/co/logbrew/reactnative/AndroidDiagnosticsRuntime.java +3 -2
- package/android/src/main/java/co/logbrew/reactnative/AndroidNativeDiagnostics.java +11 -17
- package/index.cjs +1 -1
- package/ios/AppleDiagnostics/LBRNAppleNativeDiagnostics.swift +1 -1
- package/metro.cjs +4 -2
- package/package.json +1 -1
- package/release-artifacts.cjs +14 -1
package/README.md
CHANGED
|
@@ -978,7 +978,7 @@ uploadLogBrewReactNativeReleaseArtifacts({
|
|
|
978
978
|
});
|
|
979
979
|
```
|
|
980
980
|
|
|
981
|
-
The helper requires explicit `release`, `environment`, `service`, and `platform` metadata. Hosted uploads also require a UUID `projectId`; local preparation and loopback upload remain valid without it. It defaults minified bundle URLs to `app:///react-native/<platform>/...`, removes query strings and hashes from manifest URLs, and strips source paths under `root` or `stripSourcePrefix`. Hosted endpoints must use HTTPS and must not include embedded auth values, query strings, or fragments. The helper never uses normal SDK ingest keys or account/session API auth values.
|
|
981
|
+
The helper requires explicit `release`, `environment`, `service`, and `platform` metadata. Hosted uploads also require a UUID `projectId`; local preparation and loopback upload remain valid without it. It defaults minified bundle URLs to `app:///react-native/<platform>/...`, removes query strings and hashes from manifest URLs, and strips source paths under `root` or `stripSourcePrefix`. Hosted endpoints must use HTTPS and must not include embedded auth values, query strings, or fragments. The helper never uses normal SDK ingest keys or account/session API auth values. For text bundles, `sourcemap` can name another file inside `buildDir` and the helper updates the bundle's `sourceMappingURL`. Final Hermes bytecode is never rewritten; stage its final composed map as `<bundle>.map`, as in the example above. The explicit Metro wrapper changes only app-owned serialization and one bounded runtime Debug-ID registry; neither helper patches Gradle, Xcode, global fetch/XHR, request payloads, or transport behavior.
|
|
982
982
|
|
|
983
983
|
React Native native symbols are release artifacts, not runtime telemetry. Use
|
|
984
984
|
the repository release-artifact tooling for local dry-run checks of app-owned
|
|
@@ -39,7 +39,8 @@ final class AndroidDiagnosticsRuntime implements Thread.UncaughtExceptionHandler
|
|
|
39
39
|
scheduler,
|
|
40
40
|
afterPersist,
|
|
41
41
|
this::chain,
|
|
42
|
-
scheduler.mainThread::getStackTrace
|
|
42
|
+
scheduler.mainThread::getStackTrace,
|
|
43
|
+
context.getPackageName());
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
synchronized String install() {
|
|
@@ -92,7 +93,7 @@ final class AndroidDiagnosticsRuntime implements Thread.UncaughtExceptionHandler
|
|
|
92
93
|
|
|
93
94
|
synchronized boolean matches(
|
|
94
95
|
EventRecordStore eventStore, AndroidNativeDiagnostics.Configuration configuration) {
|
|
95
|
-
return diagnostics.eventStore == eventStore && diagnostics.
|
|
96
|
+
return diagnostics.eventStore == eventStore && diagnostics.configuration.matches(configuration);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
@Override
|
|
@@ -45,7 +45,7 @@ final class AndroidNativeDiagnostics {
|
|
|
45
45
|
|| !bounded(service, 128)
|
|
46
46
|
|| !bounded(operatingSystemVersion, 128)
|
|
47
47
|
|| !bounded(deviceModel, 128)
|
|
48
|
-
|| !
|
|
48
|
+
|| !Pattern.matches("^(?:arm|arm64|x86|x86_64)$", architecture)
|
|
49
49
|
|| anrThresholdMs < 2_000
|
|
50
50
|
|| anrThresholdMs > 60_000) {
|
|
51
51
|
throw new IllegalArgumentException("invalid Android diagnostics configuration");
|
|
@@ -69,13 +69,6 @@ final class AndroidNativeDiagnostics {
|
|
|
69
69
|
character -> character <= 31 || character >= 127 && character <= 159);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
private static boolean isArchitecture(String value) {
|
|
73
|
-
return "arm".equals(value)
|
|
74
|
-
|| "arm64".equals(value)
|
|
75
|
-
|| "x86".equals(value)
|
|
76
|
-
|| "x86_64".equals(value);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
72
|
boolean matches(Configuration other) {
|
|
80
73
|
return other != null
|
|
81
74
|
&& projectId.equals(other.projectId)
|
|
@@ -95,12 +88,13 @@ final class AndroidNativeDiagnostics {
|
|
|
95
88
|
|
|
96
89
|
final EventRecordStore eventStore;
|
|
97
90
|
final AndroidNativeSignalStore signalStore;
|
|
98
|
-
|
|
91
|
+
final Configuration configuration;
|
|
99
92
|
private final Scheduler scheduler;
|
|
100
93
|
private final Runnable afterPersist;
|
|
101
94
|
private final Thread.UncaughtExceptionHandler previousHandler;
|
|
102
95
|
private final Supplier<StackTraceElement[]> mainFrames;
|
|
103
96
|
private final String processNonce;
|
|
97
|
+
private final String applicationPackage;
|
|
104
98
|
boolean installed;
|
|
105
99
|
|
|
106
100
|
AndroidNativeDiagnostics(
|
|
@@ -110,7 +104,8 @@ final class AndroidNativeDiagnostics {
|
|
|
110
104
|
Scheduler scheduler,
|
|
111
105
|
Runnable afterPersist,
|
|
112
106
|
Thread.UncaughtExceptionHandler previousHandler,
|
|
113
|
-
Supplier<StackTraceElement[]> mainFrames
|
|
107
|
+
Supplier<StackTraceElement[]> mainFrames,
|
|
108
|
+
String applicationPackage) {
|
|
114
109
|
this.eventStore = eventStore;
|
|
115
110
|
this.signalStore = signalStore;
|
|
116
111
|
this.configuration = configuration;
|
|
@@ -118,6 +113,7 @@ final class AndroidNativeDiagnostics {
|
|
|
118
113
|
this.afterPersist = afterPersist;
|
|
119
114
|
this.previousHandler = previousHandler;
|
|
120
115
|
this.mainFrames = mainFrames;
|
|
116
|
+
this.applicationPackage = applicationPackage;
|
|
121
117
|
processNonce = randomHex(8);
|
|
122
118
|
}
|
|
123
119
|
|
|
@@ -246,7 +242,7 @@ final class AndroidNativeDiagnostics {
|
|
|
246
242
|
.append("\",\"timestamp\":\"").append(timestamp(timestampMs))
|
|
247
243
|
.append("\",\"attributes\":{\"title\":\"").append(title)
|
|
248
244
|
.append("\",\"level\":\"").append(level).append('"');
|
|
249
|
-
appendJavaFrames(output, frames);
|
|
245
|
+
appendJavaFrames(output, frames, applicationPackage);
|
|
250
246
|
if (nativeFrame != null) {
|
|
251
247
|
output.append(",\"nativeStackFrames\":[{\"imageUuid\":\"")
|
|
252
248
|
.append(nativeFrame.imageUuid).append("\",\"architecture\":\"")
|
|
@@ -273,7 +269,8 @@ final class AndroidNativeDiagnostics {
|
|
|
273
269
|
return output.append("}}").toString();
|
|
274
270
|
}
|
|
275
271
|
|
|
276
|
-
private static void appendJavaFrames(
|
|
272
|
+
private static void appendJavaFrames(
|
|
273
|
+
StringBuilder output, StackTraceElement[] frames, String applicationPackage) {
|
|
277
274
|
int start = output.length();
|
|
278
275
|
output.append(",\"stackFrames\":[");
|
|
279
276
|
int count = 0;
|
|
@@ -293,7 +290,8 @@ final class AndroidNativeDiagnostics {
|
|
|
293
290
|
.append(",\"column\":1,\"function\":\"")
|
|
294
291
|
.append(json(safeSymbol(frame.getMethodName(), 256, "unknown")))
|
|
295
292
|
.append("\",\"module\":\"")
|
|
296
|
-
.append(json(safeSymbol(frame.getClassName(), 512, "unknown"))).append("\"
|
|
293
|
+
.append(json(safeSymbol(frame.getClassName(), 512, "unknown"))).append("\",\"inApp\":")
|
|
294
|
+
.append(frame.getClassName().startsWith(applicationPackage + '.')).append('}');
|
|
297
295
|
count += 1;
|
|
298
296
|
}
|
|
299
297
|
if (count == 0) {
|
|
@@ -321,10 +319,6 @@ final class AndroidNativeDiagnostics {
|
|
|
321
319
|
return nextId("native");
|
|
322
320
|
}
|
|
323
321
|
|
|
324
|
-
boolean configurationMatches(Configuration candidate) {
|
|
325
|
-
return configuration.matches(candidate);
|
|
326
|
-
}
|
|
327
|
-
|
|
328
322
|
private static String safeFilename(String value) {
|
|
329
323
|
String safe = safeSymbol(value, 256, null);
|
|
330
324
|
return safe == null || safe.contains("/") || safe.contains("\\") || safe.contains("?") || safe.contains("#") ? null : safe;
|
package/index.cjs
CHANGED
|
@@ -16,7 +16,7 @@ const {
|
|
|
16
16
|
} = require("./metadata.cjs");
|
|
17
17
|
|
|
18
18
|
const DEFAULT_SDK_NAME = "logbrew-react-native";
|
|
19
|
-
const DEFAULT_SDK_VERSION = "0.1.
|
|
19
|
+
const DEFAULT_SDK_VERSION = "0.1.31";
|
|
20
20
|
const DEFAULT_ENDPOINT = "https://api.logbrew.co/v1/events";
|
|
21
21
|
const NATIVE_RANDOM_HEX = Symbol.for("co.logbrew.react-native.secure-random-hex");
|
|
22
22
|
const MAX_ACTION_NAME_LENGTH = 64;
|
|
@@ -3,7 +3,7 @@ import Foundation
|
|
|
3
3
|
@objc(LBRNAppleNativeDiagnostics)
|
|
4
4
|
public final class LBRNAppleNativeDiagnostics: NSObject, @unchecked Sendable {
|
|
5
5
|
private static let shared = LBRNAppleNativeDiagnostics()
|
|
6
|
-
private static let sdkVersion = "0.1.
|
|
6
|
+
private static let sdkVersion = "0.1.31"
|
|
7
7
|
|
|
8
8
|
private let lock = NSLock()
|
|
9
9
|
private let replayQueue = DispatchQueue(label: "co.logbrew.react-native.apple-diagnostics-replay")
|
package/metro.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const path = require("node:path");
|
|
|
8
8
|
const DEBUG_ID_PLACEHOLDER = "__LOGBREW_REACT_NATIVE_DEBUG_ID__";
|
|
9
9
|
const DEBUG_ID_MODULE_PATH = "__logbrew_debug_id__";
|
|
10
10
|
const DEBUG_ID_REGISTRY_NAME = "@logbrew/react-native/debug-ids";
|
|
11
|
+
const RUNTIME_DEBUG_ID_MARKER = "/*logbrew-runtime-debug-id*/";
|
|
11
12
|
const DEBUG_ID_KEYS = ["debug_id", "debugId", "debugID", "x_debug_id"];
|
|
12
13
|
const DEBUG_ID_COMMENT_RE = /(?:\/\/[#@]|\/\*[#@])\s*debugId=[^\r\n]*/iu;
|
|
13
14
|
const DEBUG_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
@@ -31,7 +32,8 @@ function requireOptions(options) {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
function runtimeDebugIdSnippet(debugId) {
|
|
34
|
-
|
|
35
|
+
const embedded = `${RUNTIME_DEBUG_ID_MARKER}//# debugId=${debugId}`;
|
|
36
|
+
return `;(()=>{try{const d=${JSON.stringify(embedded)}.slice(-36),k=Symbol.for(${JSON.stringify(DEBUG_ID_REGISTRY_NAME)}),g=globalThis,r=g[k]||(g[k]=Object.create(null)),s=(new Error).stack;if(s){r[s]=d;const e=Object.keys(r);if(e.length>64)delete r[e[0]]}}catch{}})();`;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
function countLines(source) {
|
|
@@ -147,7 +149,7 @@ function productionResult(result) {
|
|
|
147
149
|
if (result.code.split(DEBUG_ID_PLACEHOLDER).length !== 2) {
|
|
148
150
|
throw configurationError("LogBrew Metro production serializer must include the injected Debug ID module exactly once");
|
|
149
151
|
}
|
|
150
|
-
if (DEBUG_ID_COMMENT_RE.test(result.code)) {
|
|
152
|
+
if (DEBUG_ID_COMMENT_RE.test(result.code.replace(`${RUNTIME_DEBUG_ID_MARKER}//# debugId=${DEBUG_ID_PLACEHOLDER}`, ""))) {
|
|
151
153
|
throw configurationError("LogBrew Metro production serializer already contains Debug ID metadata");
|
|
152
154
|
}
|
|
153
155
|
const sourceMap = parseSourceMap(result.map);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logbrew/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
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",
|
package/release-artifacts.cjs
CHANGED
|
@@ -7,6 +7,9 @@ const path = require("node:path");
|
|
|
7
7
|
|
|
8
8
|
const PACKAGE_DIR = path.dirname(require.resolve("./package.json"));
|
|
9
9
|
const DEFAULT_MANIFEST_NAME = "logbrew-release-artifacts.json";
|
|
10
|
+
const HERMES_MAGIC = Buffer.from("c61fbc03c103191f", "hex");
|
|
11
|
+
const HERMES_RUNTIME_DEBUG_ID_RE =
|
|
12
|
+
/\/\*logbrew-runtime-debug-id\*\/\/\/# debugId=[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[89ab][0-9a-f]{3}-[0-9a-f]{12}(?![0-9a-f-])/iu;
|
|
10
13
|
const HOSTED_UPLOAD_ENDPOINT = "https://api.logbrew.co/api/release-artifacts";
|
|
11
14
|
const SUPPORTED_PLATFORMS = new Set(["android", "ios"]);
|
|
12
15
|
const SOURCE_MAPPING_COMMENT_RE = /(?:\/\/#|\/\*#)\s*sourceMappingURL=[^\r\n]*/giu;
|
|
@@ -176,8 +179,18 @@ function sourceWithSourceMappingUrl(source, reference) {
|
|
|
176
179
|
}
|
|
177
180
|
|
|
178
181
|
function applyExplicitSourceMapReference(bundlePath, sourcemapPath) {
|
|
182
|
+
const bundle = fs.readFileSync(bundlePath);
|
|
183
|
+
if (bundle.subarray(0, HERMES_MAGIC.length).equals(HERMES_MAGIC)) {
|
|
184
|
+
if (!HERMES_RUNTIME_DEBUG_ID_RE.test(bundle.toString("latin1"))) {
|
|
185
|
+
throw new Error("LogBrew React Native Hermes bytecode requires the LogBrew Metro wrapper");
|
|
186
|
+
}
|
|
187
|
+
if (sourcemapPath !== `${bundlePath}.map`) {
|
|
188
|
+
throw new Error("LogBrew React Native Hermes source map must use the bundle's sibling .map path");
|
|
189
|
+
}
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
179
192
|
const reference = sourceMapReferenceForBundle(bundlePath, sourcemapPath);
|
|
180
|
-
const source =
|
|
193
|
+
const source = bundle.toString("utf8");
|
|
181
194
|
const updated = sourceWithSourceMappingUrl(source, reference);
|
|
182
195
|
if (updated !== source) {
|
|
183
196
|
fs.writeFileSync(bundlePath, updated, "utf8");
|