@logbrew/react-native 0.1.28 → 0.1.30
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 +2 -0
- 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/apollo.cjs +0 -14
- package/apollo.js +0 -14
- package/index.cjs +13 -23
- package/ios/AppleDiagnostics/LBRNAppleNativeDiagnostics.swift +1 -1
- package/lifecycle.cjs +2 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -86,6 +86,8 @@ batches, and pauses repeated automatic sends after authentication, rate-limit,
|
|
|
86
86
|
or non-retryable failures. Do not add a second app-owned flush interval.
|
|
87
87
|
`flushOnBackground: true` requests one final flush when AppState becomes
|
|
88
88
|
`inactive` or `background`; a failure never escapes the AppState callback.
|
|
89
|
+
Helpers generate a fresh opaque event ID by default. Explicit `id` and
|
|
90
|
+
`idFactory` values remain available for app-owned idempotency.
|
|
89
91
|
|
|
90
92
|
## Confirm Hosted Delivery And Event Visibility
|
|
91
93
|
|
|
@@ -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/apollo.cjs
CHANGED
|
@@ -176,7 +176,6 @@ function captureApolloSpan(client, {
|
|
|
176
176
|
captureReactNativeResourceSpan(client, {
|
|
177
177
|
appState,
|
|
178
178
|
durationMs,
|
|
179
|
-
id: defaultApolloSpanId({ operationName: details.operationName, operationType: details.operationType, screen }),
|
|
180
179
|
kind: "graphql",
|
|
181
180
|
metadata: {
|
|
182
181
|
...metadata,
|
|
@@ -280,19 +279,6 @@ function errorName(error) {
|
|
|
280
279
|
return undefined;
|
|
281
280
|
}
|
|
282
281
|
|
|
283
|
-
function defaultApolloSpanId({ operationName, operationType, screen }) {
|
|
284
|
-
return `evt_native_apollo_${slugify([screen, operationType, operationName].filter(Boolean).join("_") || "operation")}`;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function slugify(value) {
|
|
288
|
-
return String(value)
|
|
289
|
-
.trim()
|
|
290
|
-
.toLowerCase()
|
|
291
|
-
.replace(/[^a-z0-9]+/gu, "_")
|
|
292
|
-
.replace(/^_+|_+$/gu, "")
|
|
293
|
-
.slice(0, 96) || "event";
|
|
294
|
-
}
|
|
295
|
-
|
|
296
282
|
module.exports = {
|
|
297
283
|
createReactNativeApolloLink,
|
|
298
284
|
default: {
|
package/apollo.js
CHANGED
|
@@ -172,7 +172,6 @@ function captureApolloSpan(client, {
|
|
|
172
172
|
captureReactNativeResourceSpan(client, {
|
|
173
173
|
appState,
|
|
174
174
|
durationMs,
|
|
175
|
-
id: defaultApolloSpanId({ operationName: details.operationName, operationType: details.operationType, screen }),
|
|
176
175
|
kind: "graphql",
|
|
177
176
|
metadata: {
|
|
178
177
|
...metadata,
|
|
@@ -276,19 +275,6 @@ function errorName(error) {
|
|
|
276
275
|
return undefined;
|
|
277
276
|
}
|
|
278
277
|
|
|
279
|
-
function defaultApolloSpanId({ operationName, operationType, screen }) {
|
|
280
|
-
return `evt_native_apollo_${slugify([screen, operationType, operationName].filter(Boolean).join("_") || "operation")}`;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function slugify(value) {
|
|
284
|
-
return String(value)
|
|
285
|
-
.trim()
|
|
286
|
-
.toLowerCase()
|
|
287
|
-
.replace(/[^a-z0-9]+/gu, "_")
|
|
288
|
-
.replace(/^_+|_+$/gu, "")
|
|
289
|
-
.slice(0, 96) || "event";
|
|
290
|
-
}
|
|
291
|
-
|
|
292
278
|
export default {
|
|
293
279
|
createReactNativeApolloLink
|
|
294
280
|
};
|
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.30";
|
|
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;
|
|
@@ -293,7 +293,7 @@ function getReactNativeContext({ platform, appState, metadata = {} } = {}) {
|
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
function captureScreenView(client, screenName, {
|
|
296
|
-
id
|
|
296
|
+
id,
|
|
297
297
|
timestamp = new Date().toISOString(),
|
|
298
298
|
status = "success",
|
|
299
299
|
platform,
|
|
@@ -303,7 +303,7 @@ function captureScreenView(client, screenName, {
|
|
|
303
303
|
} = {}) {
|
|
304
304
|
requireClient(client);
|
|
305
305
|
requireNonEmpty("screen name", screenName);
|
|
306
|
-
client.action(id, timestamp, {
|
|
306
|
+
client.action(id ?? defaultEventId("screen"), timestamp, {
|
|
307
307
|
name: screenActionName(screenName),
|
|
308
308
|
status,
|
|
309
309
|
metadata: {
|
|
@@ -321,7 +321,7 @@ function captureScreenView(client, screenName, {
|
|
|
321
321
|
}
|
|
322
322
|
|
|
323
323
|
function captureAppStateChange(client, state, {
|
|
324
|
-
id
|
|
324
|
+
id,
|
|
325
325
|
timestamp = new Date().toISOString(),
|
|
326
326
|
platform,
|
|
327
327
|
appState,
|
|
@@ -330,7 +330,7 @@ function captureAppStateChange(client, state, {
|
|
|
330
330
|
} = {}) {
|
|
331
331
|
requireClient(client);
|
|
332
332
|
requireNonEmpty("app state", state);
|
|
333
|
-
client.action(id, timestamp, {
|
|
333
|
+
client.action(id ?? defaultEventId("app_state"), timestamp, {
|
|
334
334
|
name: "app_state_change",
|
|
335
335
|
status: "success",
|
|
336
336
|
metadata: {
|
|
@@ -855,25 +855,15 @@ function retryAfterMsFromHeader(value, now = Date.now()) {
|
|
|
855
855
|
return Number.isFinite(timestamp) ? Math.max(0, timestamp - now) : undefined;
|
|
856
856
|
}
|
|
857
857
|
|
|
858
|
-
function
|
|
859
|
-
return `
|
|
858
|
+
function defaultEventId(kind) {
|
|
859
|
+
return `evt_native_${kind}_${randomHex(16, defaultRandomValues)}`;
|
|
860
860
|
}
|
|
861
861
|
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
return `evt_native_network_${slugify([screen, method, routeTemplate].filter(Boolean).join("_") || "request")}`;
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
function defaultNavigationSpanEventId({ routeName, routePath, screen }) {
|
|
871
|
-
return `evt_native_navigation_${slugify([screen, routeName, routePath].filter(Boolean).join("_") || "route")}`;
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
function defaultResourceSpanEventId({ method, routeTemplate, screen }) {
|
|
875
|
-
return `evt_native_resource_${slugify([screen, method, routeTemplate].filter(Boolean).join("_") || "request")}`;
|
|
876
|
-
}
|
|
862
|
+
const defaultErrorEventId = () => defaultEventId("error");
|
|
863
|
+
const defaultActionEventId = () => defaultEventId("action");
|
|
864
|
+
const defaultNetworkEventId = () => defaultEventId("network");
|
|
865
|
+
const defaultNavigationSpanEventId = () => defaultEventId("navigation");
|
|
866
|
+
const defaultResourceSpanEventId = () => defaultEventId("resource");
|
|
877
867
|
|
|
878
868
|
function defaultFetch() {
|
|
879
869
|
return typeof globalThis.fetch === "function" ? globalThis.fetch.bind(globalThis) : undefined;
|
|
@@ -939,7 +929,7 @@ function defaultRandomValues(length) {
|
|
|
939
929
|
}
|
|
940
930
|
|
|
941
931
|
function secureRandomError() {
|
|
942
|
-
return new SdkError("configuration_error", "
|
|
932
|
+
return new SdkError("configuration_error", "React Native secure random values are unavailable");
|
|
943
933
|
}
|
|
944
934
|
|
|
945
935
|
function headersWithTraceparent(headers, traceparent) {
|
|
@@ -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.30"
|
|
7
7
|
|
|
8
8
|
private let lock = NSLock()
|
|
9
9
|
private let replayQueue = DispatchQueue(label: "co.logbrew.react-native.apple-diagnostics-replay")
|
package/lifecycle.cjs
CHANGED
|
@@ -97,8 +97,8 @@ function requireClient(client) {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function defaultLifecycleSpanEventId(
|
|
101
|
-
return `evt_native_lifecycle_${
|
|
100
|
+
function defaultLifecycleSpanEventId() {
|
|
101
|
+
return `evt_native_lifecycle_${createReactNativeTraceContext().traceId}`;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
function normalizeLifecycleState(state) {
|
|
@@ -115,13 +115,6 @@ function subscriptionRemover(subscription) {
|
|
|
115
115
|
return () => {};
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
function slugify(value) {
|
|
119
|
-
return String(value)
|
|
120
|
-
.toLowerCase()
|
|
121
|
-
.replace(/[^a-z0-9]+/g, "_")
|
|
122
|
-
.replace(/^_+|_+$/g, "") || "event";
|
|
123
|
-
}
|
|
124
|
-
|
|
125
118
|
module.exports = {
|
|
126
119
|
captureReactNativeLifecycleSpan,
|
|
127
120
|
createAppStateLifecycleSpanListener,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logbrew/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
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",
|
|
@@ -252,7 +252,7 @@
|
|
|
252
252
|
"url": "git+https://github.com/LogBrewCo/sdk.git"
|
|
253
253
|
},
|
|
254
254
|
"peerDependencies": {
|
|
255
|
-
"@logbrew/sdk": "^0.1.
|
|
255
|
+
"@logbrew/sdk": "^0.1.24",
|
|
256
256
|
"expo": ">=49",
|
|
257
257
|
"react": ">=18",
|
|
258
258
|
"react-native": ">=0.72"
|