@logbrew/react-native 0.1.38 → 0.1.40
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 -1
- package/README.md +17 -15
- package/android-native-diagnostics.d.ts +15 -5
- package/android-native-diagnostics.js +170 -94
- package/apollo.cjs +435 -226
- package/apollo.d.cts +2 -70
- package/apollo.d.ts +24 -12
- package/apollo.js +438 -221
- package/apple-native-diagnostics-config.js +176 -0
- package/apple-native-diagnostics-context.js +232 -0
- package/apple-native-diagnostics-module.js +229 -0
- package/apple-native-diagnostics.d.ts +42 -11
- package/apple-native-diagnostics.js +60 -389
- package/expo.cjs +29 -16
- package/expo.d.ts +10 -9
- package/expo.js +4 -3
- package/fatal-admission.cjs +113 -0
- package/fatal-record.cjs +317 -0
- package/fatal-replay.cjs +297 -508
- package/global-errors-capture.cjs +369 -0
- package/global-errors-event.cjs +174 -0
- package/global-errors-support.cjs +128 -0
- package/global-errors.cjs +75 -351
- package/global-errors.d.cts +29 -278
- package/global-errors.d.ts +57 -27
- package/global-errors.js +7 -2
- package/global-errors.native.js +83 -48
- package/index-breadcrumbs.cjs +139 -0
- package/index-errors.cjs +167 -0
- package/index-events.cjs +365 -0
- package/index-navigation.cjs +327 -0
- package/index-random.cjs +120 -0
- package/index-react.cjs +189 -0
- package/index-spans.cjs +190 -0
- package/index-trace-fetch.cjs +322 -0
- package/index-trace.cjs +335 -0
- package/index-transport.cjs +201 -0
- package/index-values.cjs +232 -0
- package/index.cjs +95 -1220
- package/index.d.cts +2 -505
- package/index.d.ts +130 -469
- package/index.native.d.ts +146 -22
- package/index.native.js +184 -159
- package/instrumentation-fetch.cjs +113 -0
- package/instrumentation-install.cjs +241 -0
- package/instrumentation-runtime.cjs +65 -0
- package/instrumentation-teardown.cjs +93 -0
- package/instrumentation-values.cjs +282 -0
- package/instrumentation-xhr-request.cjs +298 -0
- package/instrumentation-xhr.cjs +233 -0
- package/instrumentation.cjs +110 -599
- package/instrumentation.d.cts +2 -84
- package/instrumentation.d.ts +22 -8
- package/ios/AppleDiagnostics/LBRNAppleNativeDiagnostics.swift +1 -1
- package/ios/GeneratedAppleDiagnostics/LogBrew/DeliveryEngine.swift +7 -1
- package/ios/GeneratedAppleDiagnostics/LogBrew/DeliveryEngineAutomatic.swift +36 -4
- package/ios/GeneratedAppleDiagnostics/LogBrew/DeliveryEngineQueue.swift +17 -0
- package/ios/GeneratedAppleDiagnostics/LogBrew/DeliveryLifecycle.swift +2 -0
- package/ios/GeneratedAppleDiagnostics/LogBrew/Transport.swift +41 -6
- package/ios/GeneratedAppleDiagnostics/SOURCE-MANIFEST.json +5 -5
- package/lifecycle.cjs +181 -78
- package/lifecycle.d.cts +1 -50
- package/lifecycle.d.ts +17 -6
- package/metadata.cjs +279 -114
- package/metro-debug-id.cjs +296 -0
- package/metro-serializer.cjs +219 -0
- package/metro.cjs +153 -297
- package/metro.d.cts +2 -57
- package/metro.d.ts +27 -13
- package/metro.js +2 -3
- package/native-bridge-async.cjs +165 -0
- package/native-bridge-scope.cjs +148 -0
- package/native-bridge.cjs +83 -186
- package/native-bridge.d.cts +2 -94
- package/native-bridge.d.ts +28 -15
- package/native-client-bindings.js +230 -0
- package/native-diagnostics-values.js +120 -0
- package/native-module-lookup.js +31 -0
- package/native-null.js +3 -0
- package/null-value.cjs +4 -0
- package/package.json +44 -2
- package/persistent-delivery-store.js +247 -0
- package/persistent-delivery.native.js +183 -261
- package/promise-rejection-handlers.cjs +368 -0
- package/promise-rejections.cjs +169 -361
- package/react-native.config.js +3 -1
- package/release-artifacts-files.cjs +94 -0
- package/release-artifacts-options.cjs +182 -0
- package/release-artifacts.cjs +278 -207
- package/release-artifacts.d.cts +2 -55
- package/release-artifacts.d.ts +18 -7
- package/release-artifacts.js +2 -4
- package/resource-fetch-graphql.cjs +265 -0
- package/resource-fetch-size.cjs +156 -0
- package/resource-fetch.cjs +227 -428
- package/resource-fetch.d.cts +1 -60
- package/resource-fetch.d.ts +17 -6
- package/scripts/sync-apple-native-sources.mjs +101 -53
- package/types/capture.d.ts +95 -0
- package/types/config.d.ts +85 -0
- package/types/defaults.d.ts +55 -0
- package/types/events.d.ts +203 -0
- package/types/provider.d.ts +81 -0
- package/types/trace.d.ts +104 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { isRecord, nativeMethod, readField } from "./native-diagnostics-values.js";
|
|
2
|
+
import { SdkError } from "@logbrew/sdk";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {{ event: unknown, eventBytes: number, serializedEvent: string }} NativeStoredEvent
|
|
6
|
+
* @typedef {Readonly<{ eventBytes: unknown, serializedEvent: unknown }>} NativeAppendRecord
|
|
7
|
+
* @typedef {{
|
|
8
|
+
* load: () => NativeStoredEvent[],
|
|
9
|
+
* append: (record: NativeAppendRecord) => void,
|
|
10
|
+
* acknowledge: (count: unknown) => void,
|
|
11
|
+
* purge: () => void,
|
|
12
|
+
* loadClientReport: () => unknown,
|
|
13
|
+
* saveClientReport: (state: unknown) => void,
|
|
14
|
+
* close: () => void,
|
|
15
|
+
* remove?: (indexes: unknown) => Readonly<Record<string, unknown>>
|
|
16
|
+
* }} NativeEventStore
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** @type {ReadonlyMap<string, string>} */
|
|
20
|
+
const METHOD_OPERATIONS = new Map([
|
|
21
|
+
["acknowledgeEventRecords", "acknowledge"],
|
|
22
|
+
["appendEventRecord", "append"],
|
|
23
|
+
["closeEventStore", "close"],
|
|
24
|
+
["loadEventRecords", "load"],
|
|
25
|
+
["purgeEventRecords", "purge"],
|
|
26
|
+
["removeEventRecords", "remove"]
|
|
27
|
+
]);
|
|
28
|
+
const CLIENT_REPORT_QUEUE_SUFFIX = ":client-report";
|
|
29
|
+
const MIN_EVENT_BYTES = 0;
|
|
30
|
+
const NO_RECORDS = 0;
|
|
31
|
+
const LAST_RECORD = -1;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {string} operation
|
|
35
|
+
* @returns {SdkError}
|
|
36
|
+
*/
|
|
37
|
+
function persistenceFailure(operation) {
|
|
38
|
+
return new SdkError(
|
|
39
|
+
"persistence_error",
|
|
40
|
+
`React Native persistent queue ${operation} failed`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param {unknown} nativeStore
|
|
46
|
+
* @param {string} method
|
|
47
|
+
* @param {readonly unknown[]} args
|
|
48
|
+
* @returns {unknown}
|
|
49
|
+
*/
|
|
50
|
+
function callNative(nativeStore, method, ...args) {
|
|
51
|
+
const native = nativeMethod(nativeStore, method, args);
|
|
52
|
+
const operation = METHOD_OPERATIONS.get(method) ?? "operation";
|
|
53
|
+
if (!native.found) {
|
|
54
|
+
throw persistenceFailure(operation);
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
return native.call();
|
|
58
|
+
} catch {
|
|
59
|
+
throw persistenceFailure(operation);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @param {string} operation
|
|
65
|
+
* @param {unknown} result
|
|
66
|
+
* @param {string} expected
|
|
67
|
+
* @returns {Readonly<Record<string, unknown>>}
|
|
68
|
+
*/
|
|
69
|
+
function requireStatus(operation, result, expected) {
|
|
70
|
+
if (!isRecord(result) || result["status"] !== expected) {
|
|
71
|
+
throw persistenceFailure(operation);
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} serializedEvent
|
|
78
|
+
* @returns {unknown}
|
|
79
|
+
*/
|
|
80
|
+
function parseStoredEvent(serializedEvent) {
|
|
81
|
+
try {
|
|
82
|
+
/** @type {unknown} */
|
|
83
|
+
const event = JSON.parse(serializedEvent);
|
|
84
|
+
return event;
|
|
85
|
+
} catch {
|
|
86
|
+
throw persistenceFailure("load");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* @param {unknown} record
|
|
92
|
+
* @returns {NativeStoredEvent}
|
|
93
|
+
*/
|
|
94
|
+
function storedEvent(record) {
|
|
95
|
+
if (!isRecord(record)) {
|
|
96
|
+
throw persistenceFailure("load");
|
|
97
|
+
}
|
|
98
|
+
const { eventBytes, serializedEvent } = record;
|
|
99
|
+
if (typeof serializedEvent !== "string"
|
|
100
|
+
|| typeof eventBytes !== "number"
|
|
101
|
+
|| !Number.isSafeInteger(eventBytes)
|
|
102
|
+
|| eventBytes <= MIN_EVENT_BYTES) {
|
|
103
|
+
throw persistenceFailure("load");
|
|
104
|
+
}
|
|
105
|
+
return { event: parseStoredEvent(serializedEvent), eventBytes, serializedEvent };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @param {unknown} nativeStore
|
|
110
|
+
* @param {string} queueKey
|
|
111
|
+
* @returns {NativeStoredEvent[]}
|
|
112
|
+
*/
|
|
113
|
+
function loadEvents(nativeStore, queueKey) {
|
|
114
|
+
const { records } = requireStatus("load", callNative(nativeStore, "loadEventRecords", queueKey), "loaded");
|
|
115
|
+
if (!Array.isArray(records)) {
|
|
116
|
+
throw persistenceFailure("load");
|
|
117
|
+
}
|
|
118
|
+
return records.map(record => storedEvent(record));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @param {unknown} nativeStore
|
|
123
|
+
* @param {string} reportKey
|
|
124
|
+
* @returns {unknown}
|
|
125
|
+
*/
|
|
126
|
+
function loadClientReport(nativeStore, reportKey) {
|
|
127
|
+
const { records } = requireStatus("load", callNative(nativeStore, "loadEventRecords", reportKey), "loaded");
|
|
128
|
+
const latest = Array.isArray(records) ? readField(records.at(LAST_RECORD), "serializedEvent") : undefined;
|
|
129
|
+
if (typeof latest !== "string") {
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|
|
132
|
+
/** @type {unknown} */
|
|
133
|
+
const state = JSON.parse(latest);
|
|
134
|
+
return state;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @param {unknown} nativeStore
|
|
139
|
+
* @param {string} reportKey
|
|
140
|
+
* @param {unknown} state
|
|
141
|
+
*/
|
|
142
|
+
function saveClientReport(nativeStore, reportKey, state) {
|
|
143
|
+
const { records } = requireStatus("load", callNative(nativeStore, "loadEventRecords", reportKey), "loaded");
|
|
144
|
+
const serialized = JSON.stringify(state);
|
|
145
|
+
requireStatus(
|
|
146
|
+
"append",
|
|
147
|
+
callNative(nativeStore, "appendEventRecord", reportKey, serialized, serialized.length),
|
|
148
|
+
"appended"
|
|
149
|
+
);
|
|
150
|
+
if (Array.isArray(records) && records.length > NO_RECORDS) {
|
|
151
|
+
requireStatus(
|
|
152
|
+
"acknowledge",
|
|
153
|
+
callNative(nativeStore, "acknowledgeEventRecords", reportKey, records.length),
|
|
154
|
+
"acknowledged"
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* @param {unknown} nativeStore
|
|
161
|
+
* @param {string} queueKey
|
|
162
|
+
* @returns {boolean}
|
|
163
|
+
*/
|
|
164
|
+
function closeQuietly(nativeStore, queueKey) {
|
|
165
|
+
try {
|
|
166
|
+
callNative(nativeStore, "closeEventStore", queueKey);
|
|
167
|
+
return true;
|
|
168
|
+
} catch {
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* @param {unknown} nativeStore
|
|
175
|
+
* @param {string} authKey
|
|
176
|
+
* @param {string} reportKey
|
|
177
|
+
* @returns {NativeEventStore}
|
|
178
|
+
*/
|
|
179
|
+
function baseEventStore(nativeStore, authKey, reportKey) {
|
|
180
|
+
return {
|
|
181
|
+
load() {
|
|
182
|
+
return loadEvents(nativeStore, authKey);
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
append(record) {
|
|
186
|
+
requireStatus(
|
|
187
|
+
"append",
|
|
188
|
+
callNative(nativeStore, "appendEventRecord", authKey, record.serializedEvent, record.eventBytes),
|
|
189
|
+
"appended"
|
|
190
|
+
);
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
acknowledge(count) {
|
|
194
|
+
requireStatus("acknowledge", callNative(nativeStore, "acknowledgeEventRecords", authKey, count), "acknowledged");
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
purge() {
|
|
198
|
+
requireStatus("purge", callNative(nativeStore, "purgeEventRecords", authKey), "purged");
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
loadClientReport() {
|
|
202
|
+
return loadClientReport(nativeStore, reportKey);
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
saveClientReport(state) {
|
|
206
|
+
saveClientReport(nativeStore, reportKey, state);
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
close() {
|
|
210
|
+
closeQuietly(nativeStore, reportKey);
|
|
211
|
+
requireStatus("close", callNative(nativeStore, "closeEventStore", authKey), "closed");
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* @param {unknown} nativeStore
|
|
218
|
+
* @param {string} authKey
|
|
219
|
+
* @param {() => void} release
|
|
220
|
+
* @returns {NativeEventStore}
|
|
221
|
+
*/
|
|
222
|
+
function createNativeEventStore(nativeStore, authKey, release) {
|
|
223
|
+
const reportKey = `${authKey}${CLIENT_REPORT_QUEUE_SUFFIX}`;
|
|
224
|
+
const eventStore = baseEventStore(nativeStore, authKey, reportKey);
|
|
225
|
+
const closeStore = eventStore.close;
|
|
226
|
+
eventStore.close = function close() {
|
|
227
|
+
try {
|
|
228
|
+
closeStore();
|
|
229
|
+
} finally {
|
|
230
|
+
release();
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
if (typeof readField(nativeStore, "removeEventRecords") === "function") {
|
|
234
|
+
/**
|
|
235
|
+
* @param {unknown} indexes
|
|
236
|
+
* @returns {Readonly<Record<string, unknown>>}
|
|
237
|
+
*/
|
|
238
|
+
eventStore.remove = indexes => requireStatus(
|
|
239
|
+
"remove",
|
|
240
|
+
callNative(nativeStore, "removeEventRecords", authKey, indexes),
|
|
241
|
+
"removed"
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
return eventStore;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export { callNative, createNativeEventStore, requireStatus };
|