@logbrew/react-native 0.1.39 → 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/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 -1243
- 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/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 +43 -1
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type LogBrewAndroidNativeDiagnosticsConfiguration = Readonly<{
|
|
2
2
|
anrThresholdMs?: number;
|
|
3
3
|
clientKey: string;
|
|
4
4
|
environment: string;
|
|
@@ -8,7 +8,7 @@ export type LogBrewAndroidNativeDiagnosticsConfiguration = Readonly<{
|
|
|
8
8
|
service: string;
|
|
9
9
|
}>;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
type LogBrewAndroidNativeDiagnosticsReceipt = Readonly<{
|
|
12
12
|
pending: number;
|
|
13
13
|
status:
|
|
14
14
|
| "already_installed"
|
|
@@ -18,12 +18,22 @@ export type LogBrewAndroidNativeDiagnosticsReceipt = Readonly<{
|
|
|
18
18
|
| "uninstalled";
|
|
19
19
|
}>;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
declare function installLogBrewAndroidNativeDiagnostics(
|
|
22
22
|
configuration: LogBrewAndroidNativeDiagnosticsConfiguration
|
|
23
23
|
): LogBrewAndroidNativeDiagnosticsReceipt;
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
declare function getLogBrewAndroidNativeDiagnosticsStatus():
|
|
26
26
|
LogBrewAndroidNativeDiagnosticsReceipt;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
declare function uninstallLogBrewAndroidNativeDiagnostics():
|
|
29
29
|
LogBrewAndroidNativeDiagnosticsReceipt;
|
|
30
|
+
|
|
31
|
+
export type {
|
|
32
|
+
LogBrewAndroidNativeDiagnosticsConfiguration,
|
|
33
|
+
LogBrewAndroidNativeDiagnosticsReceipt
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
installLogBrewAndroidNativeDiagnostics,
|
|
37
|
+
getLogBrewAndroidNativeDiagnosticsStatus,
|
|
38
|
+
uninstallLogBrewAndroidNativeDiagnostics
|
|
39
|
+
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import { hasControlCharacter, isCount, isRecord, nativeMethod, utf8Length } from "./native-diagnostics-values.js";
|
|
2
|
+
import { lookupNativeModule, platformOS } from "./native-module-lookup.js";
|
|
1
3
|
import { SdkError } from "@logbrew/sdk";
|
|
2
|
-
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @import { LogBrewAndroidNativeDiagnosticsReceipt } from "./android-native-diagnostics.js"
|
|
7
|
+
* @typedef {LogBrewAndroidNativeDiagnosticsReceipt["status"]} ReceiptStatus
|
|
8
|
+
*/
|
|
3
9
|
|
|
4
10
|
const INSTALL_KEYS = new Set([
|
|
5
11
|
"anrThresholdMs",
|
|
@@ -11,36 +17,85 @@ const INSTALL_KEYS = new Set([
|
|
|
11
17
|
"service"
|
|
12
18
|
]);
|
|
13
19
|
const RECEIPT_KEYS = new Set(["pending", "status"]);
|
|
20
|
+
/** @type {ReadonlySet<string>} */
|
|
21
|
+
const INSTALL_STATUSES = new Set(["already_installed", "installed"]);
|
|
22
|
+
/** @type {ReadonlySet<string>} */
|
|
23
|
+
const STATUS_STATUSES = new Set(["not_installed", "ready"]);
|
|
24
|
+
/** @type {ReadonlySet<string>} */
|
|
25
|
+
const UNINSTALL_STATUSES = new Set(["not_installed", "uninstalled"]);
|
|
26
|
+
const PROJECT_ID_PATTERN = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/u;
|
|
27
|
+
const SCOPE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/u;
|
|
28
|
+
const ERROR_CODE_PATTERN = /^[a-z0-9_]{1,128}$/u;
|
|
29
|
+
const DEFAULT_ANR_THRESHOLD_MS = 5000;
|
|
30
|
+
const MIN_ANR_THRESHOLD_MS = 2000;
|
|
31
|
+
const MAX_ANR_THRESHOLD_MS = 60_000;
|
|
32
|
+
const PROJECT_ID_BYTES = 64;
|
|
33
|
+
const CLIENT_KEY_BYTES = 4096;
|
|
34
|
+
const ENVIRONMENT_BYTES = 128;
|
|
35
|
+
const RELEASE_BYTES = 256;
|
|
36
|
+
const SCOPE_BYTES = 128;
|
|
37
|
+
const EMPTY_LENGTH = 0;
|
|
14
38
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
);
|
|
39
|
+
/**
|
|
40
|
+
* @param {string} message
|
|
41
|
+
* @returns {SdkError}
|
|
42
|
+
*/
|
|
43
|
+
function configurationError(message) {
|
|
44
|
+
return new SdkError("configuration_error", `LogBrew Android native diagnostics ${message}`);
|
|
22
45
|
}
|
|
23
46
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
/**
|
|
48
|
+
* @param {unknown} value
|
|
49
|
+
* @param {number} maximumBytes
|
|
50
|
+
* @param {string} name
|
|
51
|
+
* @returns {string}
|
|
52
|
+
*/
|
|
53
|
+
function exactText(value, maximumBytes, name) {
|
|
54
|
+
if (typeof value !== "string"
|
|
55
|
+
|| value.length === EMPTY_LENGTH
|
|
56
|
+
|| value.trim() !== value
|
|
57
|
+
|| hasControlCharacter(value)
|
|
58
|
+
|| utf8Length(value) > maximumBytes) {
|
|
59
|
+
throw configurationError(`${name} must be a bounded non-empty string`);
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
31
62
|
}
|
|
32
63
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
64
|
+
/**
|
|
65
|
+
* @param {unknown} value
|
|
66
|
+
* @param {string} name
|
|
67
|
+
* @returns {string}
|
|
68
|
+
*/
|
|
69
|
+
function exactScope(value, name) {
|
|
70
|
+
const text = exactText(value, SCOPE_BYTES, name);
|
|
71
|
+
if (!SCOPE_PATTERN.test(text)
|
|
72
|
+
|| text.includes("..")
|
|
73
|
+
|| text.includes("//")) {
|
|
74
|
+
throw configurationError(`${name} must be a bounded deployment identifier`);
|
|
75
|
+
}
|
|
76
|
+
return text;
|
|
40
77
|
}
|
|
41
78
|
|
|
42
|
-
|
|
43
|
-
|
|
79
|
+
/**
|
|
80
|
+
* @param {unknown} threshold
|
|
81
|
+
* @returns {number}
|
|
82
|
+
*/
|
|
83
|
+
function anrThreshold(threshold) {
|
|
84
|
+
if (typeof threshold !== "number"
|
|
85
|
+
|| !Number.isSafeInteger(threshold)
|
|
86
|
+
|| threshold < MIN_ANR_THRESHOLD_MS
|
|
87
|
+
|| threshold > MAX_ANR_THRESHOLD_MS) {
|
|
88
|
+
throw configurationError("anrThresholdMs must be an integer from 2000 through 60000");
|
|
89
|
+
}
|
|
90
|
+
return threshold;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @param {unknown} value
|
|
95
|
+
* @returns {Readonly<Record<string, unknown>>}
|
|
96
|
+
*/
|
|
97
|
+
function knownConfiguration(value) {
|
|
98
|
+
if (!isRecord(value)) {
|
|
44
99
|
throw configurationError("configuration must be an object");
|
|
45
100
|
}
|
|
46
101
|
for (const key of Object.keys(value)) {
|
|
@@ -48,53 +103,38 @@ function normalizeConfiguration(value) {
|
|
|
48
103
|
throw configurationError("configuration contains an unsupported key");
|
|
49
104
|
}
|
|
50
105
|
}
|
|
51
|
-
if (value
|
|
106
|
+
if (value["fatalHandlerOwnership"] !== "logbrew") {
|
|
52
107
|
throw configurationError(
|
|
53
108
|
"fatalHandlerOwnership must be logbrew after removing every other Android fatal handler"
|
|
54
109
|
);
|
|
55
110
|
}
|
|
56
|
-
|
|
57
|
-
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* @param {unknown} configuration
|
|
116
|
+
* @returns {Record<string, unknown>}
|
|
117
|
+
*/
|
|
118
|
+
function normalizeConfiguration(configuration) {
|
|
119
|
+
const value = knownConfiguration(configuration);
|
|
120
|
+
const projectId = exactText(value["projectId"], PROJECT_ID_BYTES, "projectId");
|
|
121
|
+
if (!PROJECT_ID_PATTERN.test(projectId)) {
|
|
58
122
|
throw configurationError("projectId must be a lowercase UUID");
|
|
59
123
|
}
|
|
60
|
-
const threshold = value
|
|
61
|
-
if (!Number.isSafeInteger(threshold) || threshold < 2000 || threshold > 60000) {
|
|
62
|
-
throw configurationError("anrThresholdMs must be an integer from 2000 through 60000");
|
|
63
|
-
}
|
|
124
|
+
const threshold = anrThreshold(value["anrThresholdMs"] ?? DEFAULT_ANR_THRESHOLD_MS);
|
|
64
125
|
return {
|
|
65
126
|
anrThresholdMs: threshold,
|
|
66
|
-
clientKey: exactText(value
|
|
67
|
-
environment: exactText(value
|
|
127
|
+
clientKey: exactText(value["clientKey"], CLIENT_KEY_BYTES, "clientKey"),
|
|
128
|
+
environment: exactText(value["environment"], ENVIRONMENT_BYTES, "environment"),
|
|
68
129
|
fatalHandlerOwnership: "logbrew",
|
|
69
130
|
projectId,
|
|
70
|
-
release: exactText(value
|
|
71
|
-
service: exactScope(value
|
|
131
|
+
release: exactText(value["release"], RELEASE_BYTES, "release"),
|
|
132
|
+
service: exactScope(value["service"], "service")
|
|
72
133
|
};
|
|
73
134
|
}
|
|
74
135
|
|
|
75
|
-
function exactScope(value, name) {
|
|
76
|
-
const text = exactText(value, 128, name);
|
|
77
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._/-]{0,127}$/u.test(text)
|
|
78
|
-
|| text.includes("..")
|
|
79
|
-
|| text.includes("//")) {
|
|
80
|
-
throw configurationError(`${name} must be a bounded deployment identifier`);
|
|
81
|
-
}
|
|
82
|
-
return text;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function exactText(value, maximumBytes, name) {
|
|
86
|
-
if (typeof value !== "string"
|
|
87
|
-
|| value.length === 0
|
|
88
|
-
|| value.trim() !== value
|
|
89
|
-
|| controlCharacter(value)
|
|
90
|
-
|| utf8Length(value) > maximumBytes) {
|
|
91
|
-
throw configurationError(`${name} must be a bounded non-empty string`);
|
|
92
|
-
}
|
|
93
|
-
return value;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
136
|
function requireAndroid() {
|
|
97
|
-
if (
|
|
137
|
+
if (platformOS() !== "android") {
|
|
98
138
|
throw new SdkError(
|
|
99
139
|
"unsupported_platform",
|
|
100
140
|
"LogBrew Android native diagnostics require an Android native build"
|
|
@@ -102,22 +142,32 @@ function requireAndroid() {
|
|
|
102
142
|
}
|
|
103
143
|
}
|
|
104
144
|
|
|
105
|
-
|
|
106
|
-
|
|
145
|
+
/**
|
|
146
|
+
* @returns {unknown}
|
|
147
|
+
*/
|
|
148
|
+
function fatalStoreModule() {
|
|
107
149
|
try {
|
|
108
|
-
|
|
109
|
-
?? NativeModules?.LogBrewFatalStore;
|
|
150
|
+
return lookupNativeModule("LogBrewFatalStore");
|
|
110
151
|
} catch {
|
|
111
|
-
|
|
152
|
+
return undefined;
|
|
112
153
|
}
|
|
113
|
-
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* @param {string} method
|
|
158
|
+
* @param {readonly unknown[]} args
|
|
159
|
+
* @returns {unknown}
|
|
160
|
+
*/
|
|
161
|
+
function call(method, ...args) {
|
|
162
|
+
const native = nativeMethod(fatalStoreModule(), method, args);
|
|
163
|
+
if (!native.found) {
|
|
114
164
|
throw new SdkError(
|
|
115
165
|
"native_diagnostics_unavailable",
|
|
116
166
|
`linked LogBrew Android diagnostics do not implement ${method}`
|
|
117
167
|
);
|
|
118
168
|
}
|
|
119
169
|
try {
|
|
120
|
-
return
|
|
170
|
+
return native.call();
|
|
121
171
|
} catch {
|
|
122
172
|
throw new SdkError(
|
|
123
173
|
"native_diagnostics_failed",
|
|
@@ -126,23 +176,38 @@ function call(method, ...args) {
|
|
|
126
176
|
}
|
|
127
177
|
}
|
|
128
178
|
|
|
179
|
+
/**
|
|
180
|
+
* @param {unknown} value
|
|
181
|
+
* @param {Readonly<ReadonlySet<string>>} statuses
|
|
182
|
+
* @returns {value is Readonly<{ pending: number, status: ReceiptStatus }>}
|
|
183
|
+
*/
|
|
184
|
+
function isReceipt(value, statuses) {
|
|
185
|
+
if (!isRecord(value)) {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
const keys = Object.keys(value);
|
|
189
|
+
return keys.length === RECEIPT_KEYS.size
|
|
190
|
+
&& keys.every(key => RECEIPT_KEYS.has(key))
|
|
191
|
+
&& typeof value["status"] === "string"
|
|
192
|
+
&& statuses.has(value["status"])
|
|
193
|
+
&& isCount(value["pending"]);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @param {string} operation
|
|
198
|
+
* @param {unknown} value
|
|
199
|
+
* @param {Readonly<ReadonlySet<string>>} statuses
|
|
200
|
+
* @returns {LogBrewAndroidNativeDiagnosticsReceipt}
|
|
201
|
+
*/
|
|
129
202
|
function receipt(operation, value, statuses) {
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
&& value.status === "error"
|
|
133
|
-
&& typeof value.code === "string"
|
|
134
|
-
&& /^[a-z0-9_]{1,128}$/u.test(value.code)) {
|
|
203
|
+
const code = isRecord(value) && value["status"] === "error" ? value["code"] : undefined;
|
|
204
|
+
if (typeof code === "string" && ERROR_CODE_PATTERN.test(code)) {
|
|
135
205
|
throw new SdkError(
|
|
136
|
-
|
|
137
|
-
`LogBrew Android native diagnostics ${operation} failed with ${
|
|
206
|
+
code,
|
|
207
|
+
`LogBrew Android native diagnostics ${operation} failed with ${code}`
|
|
138
208
|
);
|
|
139
209
|
}
|
|
140
|
-
if (!
|
|
141
|
-
|| keys.length !== RECEIPT_KEYS.size
|
|
142
|
-
|| !keys.every((key) => RECEIPT_KEYS.has(key))
|
|
143
|
-
|| !statuses.has(value.status)
|
|
144
|
-
|| !Number.isSafeInteger(value.pending)
|
|
145
|
-
|| value.pending < 0) {
|
|
210
|
+
if (!isReceipt(value, statuses)) {
|
|
146
211
|
throw new SdkError(
|
|
147
212
|
"native_diagnostics_invalid_response",
|
|
148
213
|
`LogBrew Android native diagnostics ${operation} returned an invalid response`
|
|
@@ -151,26 +216,37 @@ function receipt(operation, value, statuses) {
|
|
|
151
216
|
return Object.freeze({ pending: value.pending, status: value.status });
|
|
152
217
|
}
|
|
153
218
|
|
|
154
|
-
|
|
155
|
-
|
|
219
|
+
/**
|
|
220
|
+
* @param {unknown} [configuration]
|
|
221
|
+
* @returns {LogBrewAndroidNativeDiagnosticsReceipt}
|
|
222
|
+
*/
|
|
223
|
+
function installLogBrewAndroidNativeDiagnostics(configuration = {}) {
|
|
224
|
+
requireAndroid();
|
|
225
|
+
return receipt(
|
|
226
|
+
"install",
|
|
227
|
+
call("installAndroidDiagnostics", normalizeConfiguration(configuration)),
|
|
228
|
+
INSTALL_STATUSES
|
|
229
|
+
);
|
|
156
230
|
}
|
|
157
231
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
232
|
+
/**
|
|
233
|
+
* @returns {LogBrewAndroidNativeDiagnosticsReceipt}
|
|
234
|
+
*/
|
|
235
|
+
function getLogBrewAndroidNativeDiagnosticsStatus() {
|
|
236
|
+
requireAndroid();
|
|
237
|
+
return receipt("status", call("androidDiagnosticsStatus"), STATUS_STATUSES);
|
|
163
238
|
}
|
|
164
239
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return length;
|
|
240
|
+
/**
|
|
241
|
+
* @returns {LogBrewAndroidNativeDiagnosticsReceipt}
|
|
242
|
+
*/
|
|
243
|
+
function uninstallLogBrewAndroidNativeDiagnostics() {
|
|
244
|
+
requireAndroid();
|
|
245
|
+
return receipt("uninstall", call("uninstallAndroidDiagnostics"), UNINSTALL_STATUSES);
|
|
172
246
|
}
|
|
173
247
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
248
|
+
export {
|
|
249
|
+
getLogBrewAndroidNativeDiagnosticsStatus,
|
|
250
|
+
installLogBrewAndroidNativeDiagnostics,
|
|
251
|
+
uninstallLogBrewAndroidNativeDiagnostics
|
|
252
|
+
};
|