@logbrew/react-native 0.1.36 → 0.1.37
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
CHANGED
|
@@ -166,6 +166,9 @@ delivery. When the queue is full, a fatal JavaScript report removes the oldest
|
|
|
166
166
|
events that are not fatal and are not being sent, and counts each one as
|
|
167
167
|
`evicted_for_fatal` in `deliveryHealth().droppedByReason`. The fatal is dropped
|
|
168
168
|
only when the rest of the queue is fatal reports or a batch being sent.
|
|
169
|
+
Drop counts not yet reported to LogBrew are kept in a separate native queue,
|
|
170
|
+
so the next app start sends them, and a report that was already sent keeps
|
|
171
|
+
its `report_id` so LogBrew counts it once.
|
|
169
172
|
|
|
170
173
|
A successful `shutdown()` drains and closes the queue. A failed flush or
|
|
171
174
|
shutdown leaves the exact remainder available to the same client and the next
|
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.37";
|
|
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.37"
|
|
7
7
|
|
|
8
8
|
private let lock = NSLock()
|
|
9
9
|
private let replayQueue = DispatchQueue(label: "co.logbrew.react-native.apple-diagnostics-replay")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logbrew/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
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.33",
|
|
256
256
|
"expo": ">=49",
|
|
257
257
|
"react": ">=18",
|
|
258
258
|
"react-native": ">=0.72"
|
|
@@ -12,6 +12,8 @@ const NATIVE_STORE_METHODS = [
|
|
|
12
12
|
"purgeEventRecords"
|
|
13
13
|
];
|
|
14
14
|
const PERSISTENT_QUEUE_MODES = new Set(["auto", "disabled", "required"]);
|
|
15
|
+
// Drop counts live in a separate native queue, so existing native binaries keep them without changes.
|
|
16
|
+
const CLIENT_REPORT_QUEUE_SUFFIX = ":client-report";
|
|
15
17
|
|
|
16
18
|
export function resolveReactNativePersistentEventStore({
|
|
17
19
|
authKey,
|
|
@@ -122,6 +124,7 @@ export function purgeReactNativePersistentQueue({ apiKey, clientKey } = {}) {
|
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
function createNativeEventStore(nativeStore, authKey, release) {
|
|
127
|
+
const reportKey = `${authKey}${CLIENT_REPORT_QUEUE_SUFFIX}`;
|
|
125
128
|
const eventStore = {
|
|
126
129
|
load() {
|
|
127
130
|
const result = requireStatus(
|
|
@@ -181,7 +184,42 @@ function createNativeEventStore(nativeStore, authKey, release) {
|
|
|
181
184
|
"purged"
|
|
182
185
|
);
|
|
183
186
|
},
|
|
187
|
+
// Appends the new state before acknowledging the old one, so a crash keeps one of them.
|
|
188
|
+
loadClientReport() {
|
|
189
|
+
const { records } = requireStatus(
|
|
190
|
+
"load",
|
|
191
|
+
callNative(nativeStore, "loadEventRecords", reportKey),
|
|
192
|
+
"loaded"
|
|
193
|
+
);
|
|
194
|
+
const latest = Array.isArray(records) ? records.at(-1)?.serializedEvent : undefined;
|
|
195
|
+
return typeof latest === "string" ? JSON.parse(latest) : undefined;
|
|
196
|
+
},
|
|
197
|
+
saveClientReport(state) {
|
|
198
|
+
const { records } = requireStatus(
|
|
199
|
+
"load",
|
|
200
|
+
callNative(nativeStore, "loadEventRecords", reportKey),
|
|
201
|
+
"loaded"
|
|
202
|
+
);
|
|
203
|
+
const serialized = JSON.stringify(state);
|
|
204
|
+
requireStatus(
|
|
205
|
+
"append",
|
|
206
|
+
callNative(nativeStore, "appendEventRecord", reportKey, serialized, serialized.length),
|
|
207
|
+
"appended"
|
|
208
|
+
);
|
|
209
|
+
if (Array.isArray(records) && records.length > 0) {
|
|
210
|
+
requireStatus(
|
|
211
|
+
"acknowledge",
|
|
212
|
+
callNative(nativeStore, "acknowledgeEventRecords", reportKey, records.length),
|
|
213
|
+
"acknowledged"
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
184
217
|
close() {
|
|
218
|
+
try {
|
|
219
|
+
callNative(nativeStore, "closeEventStore", reportKey);
|
|
220
|
+
} catch {
|
|
221
|
+
// The drop-count queue is advisory; closing the event queue decides the outcome.
|
|
222
|
+
}
|
|
185
223
|
try {
|
|
186
224
|
requireStatus(
|
|
187
225
|
"close",
|