@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
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { SdkError } = require("@logbrew/sdk");
|
|
4
|
+
const {
|
|
5
|
+
defaultRouteTemplateFactory,
|
|
6
|
+
isCallable,
|
|
7
|
+
isWritableRecord,
|
|
8
|
+
readField,
|
|
9
|
+
toText
|
|
10
|
+
} = require("./instrumentation-values.cjs");
|
|
11
|
+
const { XhrRequestState } = require("./instrumentation-xhr-request.cjs");
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @import { LogBrewClient, Metadata } from "@logbrew/sdk"
|
|
15
|
+
* @import { TracePropagationTarget } from "./index.cjs"
|
|
16
|
+
* @import { AppStateInput, Callable, PlatformInput, TraceInput } from "./instrumentation-values.cjs"
|
|
17
|
+
* @import { XhrMethods, XhrWrapperSettings } from "./instrumentation-xhr-request.cjs"
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {{
|
|
22
|
+
* readonly appState: AppStateInput | undefined,
|
|
23
|
+
* readonly globalObject: unknown,
|
|
24
|
+
* readonly measureXhrResponseBodySize: boolean,
|
|
25
|
+
* readonly metadata: Readonly<Metadata>,
|
|
26
|
+
* readonly metadataFactory: unknown,
|
|
27
|
+
* readonly now: () => string,
|
|
28
|
+
* readonly nowMs: () => number,
|
|
29
|
+
* readonly platform: PlatformInput | undefined,
|
|
30
|
+
* readonly routeTemplate: string | undefined,
|
|
31
|
+
* readonly routeTemplateFactory: unknown,
|
|
32
|
+
* readonly screen: string | undefined,
|
|
33
|
+
* readonly sessionId: string | undefined,
|
|
34
|
+
* readonly trace: TraceInput,
|
|
35
|
+
* readonly tracePropagationTargets: readonly TracePropagationTarget[]
|
|
36
|
+
* }} XhrInstallOptions
|
|
37
|
+
* @typedef {{ readonly open: Callable, readonly send: Callable }} XhrWrappers
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
const HEADERS_RECEIVED = 2;
|
|
41
|
+
const DONE = 4;
|
|
42
|
+
const OPEN_LENGTH = 2;
|
|
43
|
+
const SEND_LENGTH = 1;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @param {unknown} method
|
|
47
|
+
* @returns {string}
|
|
48
|
+
*/
|
|
49
|
+
function normalizeXhrMethod(method) {
|
|
50
|
+
return toText(method ?? "GET").toUpperCase();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {unknown} url
|
|
55
|
+
* @returns {unknown}
|
|
56
|
+
*/
|
|
57
|
+
function xhrUrl(url) {
|
|
58
|
+
if (typeof url === "string") {
|
|
59
|
+
return url;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
const toStringMethod = readField(url, "toString");
|
|
63
|
+
return isCallable(toStringMethod) ? Reflect.apply(toStringMethod, url, []) : toText(url);
|
|
64
|
+
} catch {
|
|
65
|
+
return toText(url);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* @param {unknown} value
|
|
71
|
+
* @param {number} fallback
|
|
72
|
+
* @returns {unknown}
|
|
73
|
+
*/
|
|
74
|
+
function readyState(value, fallback) {
|
|
75
|
+
return typeof value === "number" ? value : fallback;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @param {unknown} prototype
|
|
80
|
+
* @returns {XhrMethods}
|
|
81
|
+
*/
|
|
82
|
+
function readXhrMethods(prototype) {
|
|
83
|
+
const open = readField(prototype, "open");
|
|
84
|
+
const send = readField(prototype, "send");
|
|
85
|
+
const setRequestHeader = readField(prototype, "setRequestHeader");
|
|
86
|
+
if (!isCallable(open) || !isCallable(send) || !isCallable(setRequestHeader)) {
|
|
87
|
+
throw new SdkError("configuration_error", "instrumentGlobalXMLHttpRequest requires open, send, and setRequestHeader");
|
|
88
|
+
}
|
|
89
|
+
return { open, send, setRequestHeader };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {unknown} xhrType
|
|
94
|
+
* @returns {unknown}
|
|
95
|
+
*/
|
|
96
|
+
function xhrPrototype(xhrType) {
|
|
97
|
+
const prototype = isCallable(xhrType) ? readField(xhrType, "prototype") : undefined;
|
|
98
|
+
const hasPrototype = Boolean(prototype);
|
|
99
|
+
if (!isCallable(xhrType) || !hasPrototype) {
|
|
100
|
+
throw new SdkError("configuration_error", "instrumentGlobalXMLHttpRequest requires globalObject.XMLHttpRequest");
|
|
101
|
+
}
|
|
102
|
+
return prototype;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {unknown} globalObject
|
|
107
|
+
* @returns {{ readonly methods: XhrMethods, readonly prototype: Record<PropertyKey, unknown>, readonly xhrType: unknown }}
|
|
108
|
+
*/
|
|
109
|
+
function requireXhrTarget(globalObject) {
|
|
110
|
+
if (!isWritableRecord(globalObject)) {
|
|
111
|
+
throw new SdkError("configuration_error", "instrumentGlobalXMLHttpRequest requires a globalObject");
|
|
112
|
+
}
|
|
113
|
+
const xhrType = globalObject["XMLHttpRequest"];
|
|
114
|
+
const prototype = xhrPrototype(xhrType);
|
|
115
|
+
const methods = readXhrMethods(prototype);
|
|
116
|
+
if (!isWritableRecord(prototype)) {
|
|
117
|
+
throw new SdkError("configuration_error", "instrumentGlobalXMLHttpRequest requires open, send, and setRequestHeader");
|
|
118
|
+
}
|
|
119
|
+
return { methods, prototype, xhrType };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {LogBrewClient} client
|
|
124
|
+
* @param {XhrInstallOptions} options
|
|
125
|
+
* @param {unknown} xhrType
|
|
126
|
+
* @returns {XhrWrapperSettings}
|
|
127
|
+
*/
|
|
128
|
+
function xhrWrapperSettings(client, options, xhrType) {
|
|
129
|
+
return {
|
|
130
|
+
capture: {
|
|
131
|
+
appState: options.appState,
|
|
132
|
+
client,
|
|
133
|
+
doneState: readyState(readField(xhrType, "DONE"), DONE),
|
|
134
|
+
headersReceivedState: readyState(readField(xhrType, "HEADERS_RECEIVED"), HEADERS_RECEIVED),
|
|
135
|
+
measureXhrResponseBodySize: options.measureXhrResponseBodySize,
|
|
136
|
+
metadata: options.metadata,
|
|
137
|
+
metadataFactory: options.metadataFactory,
|
|
138
|
+
nowMs: options.nowMs,
|
|
139
|
+
platform: options.platform,
|
|
140
|
+
routeTemplate: options.routeTemplate,
|
|
141
|
+
routeTemplateFactory: isCallable(options.routeTemplateFactory) ? options.routeTemplateFactory : defaultRouteTemplateFactory,
|
|
142
|
+
screen: options.screen,
|
|
143
|
+
sessionId: options.sessionId,
|
|
144
|
+
status: undefined,
|
|
145
|
+
trace: options.trace
|
|
146
|
+
},
|
|
147
|
+
now: options.now,
|
|
148
|
+
tracePropagationTargets: options.tracePropagationTargets
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* @param {XhrMethods} methods
|
|
154
|
+
* @param {XhrWrapperSettings} settings
|
|
155
|
+
* @returns {XhrWrappers}
|
|
156
|
+
*/
|
|
157
|
+
function createXhrWrappers(methods, settings) {
|
|
158
|
+
const contextKey = Symbol("logbrew.xhr");
|
|
159
|
+
/**
|
|
160
|
+
* @this {unknown}
|
|
161
|
+
* @param {readonly unknown[]} args
|
|
162
|
+
* @returns {unknown}
|
|
163
|
+
*/
|
|
164
|
+
function wrappedOpen(...args) {
|
|
165
|
+
const [method, url] = args;
|
|
166
|
+
const context = new XhrRequestState(normalizeXhrMethod(method), xhrUrl(url));
|
|
167
|
+
if (!isWritableRecord(this)) {
|
|
168
|
+
throw new TypeError("XMLHttpRequest.open requires an XMLHttpRequest");
|
|
169
|
+
}
|
|
170
|
+
this[contextKey] = context;
|
|
171
|
+
return Reflect.apply(methods.open, this, args);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* @this {unknown}
|
|
175
|
+
* @param {readonly unknown[]} args
|
|
176
|
+
* @returns {unknown}
|
|
177
|
+
*/
|
|
178
|
+
function wrappedSend(...args) {
|
|
179
|
+
const context = readField(this, contextKey);
|
|
180
|
+
if (!(context instanceof XhrRequestState)) {
|
|
181
|
+
return Reflect.apply(methods.send, this, args);
|
|
182
|
+
}
|
|
183
|
+
return context.send(this, { args, methods, settings });
|
|
184
|
+
}
|
|
185
|
+
Object.defineProperty(wrappedOpen, "length", { value: OPEN_LENGTH });
|
|
186
|
+
Object.defineProperty(wrappedSend, "length", { value: SEND_LENGTH });
|
|
187
|
+
return { open: wrappedOpen, send: wrappedSend };
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @param {unknown} prototype
|
|
192
|
+
* @param {XhrWrappers} wrappers
|
|
193
|
+
* @returns {void}
|
|
194
|
+
*/
|
|
195
|
+
function requirePatched(prototype, wrappers) {
|
|
196
|
+
if (readField(prototype, "open") !== wrappers.open || readField(prototype, "send") !== wrappers.send) {
|
|
197
|
+
throw new SdkError("configuration_error", "instrumentGlobalXMLHttpRequest could not patch XMLHttpRequest");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @param {LogBrewClient} client
|
|
203
|
+
* @param {XhrInstallOptions} options
|
|
204
|
+
* @returns {Readonly<{ remove: () => void, stop: () => void }>}
|
|
205
|
+
*/
|
|
206
|
+
function installGlobalXMLHttpRequestInstrumentation(client, options) {
|
|
207
|
+
const { methods, prototype, xhrType } = requireXhrTarget(options.globalObject);
|
|
208
|
+
const wrappers = createXhrWrappers(methods, xhrWrapperSettings(client, options, xhrType));
|
|
209
|
+
prototype["open"] = wrappers.open;
|
|
210
|
+
prototype["send"] = wrappers.send;
|
|
211
|
+
requirePatched(prototype, wrappers);
|
|
212
|
+
let removed = false;
|
|
213
|
+
const { remove } = {
|
|
214
|
+
remove: () => {
|
|
215
|
+
if (removed) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
removed = true;
|
|
219
|
+
if (prototype["open"] === wrappers.open) {
|
|
220
|
+
prototype["open"] = methods.open;
|
|
221
|
+
}
|
|
222
|
+
if (prototype["send"] === wrappers.send) {
|
|
223
|
+
prototype["send"] = methods.send;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return Object.freeze({
|
|
228
|
+
remove,
|
|
229
|
+
stop: remove
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
module.exports = { installGlobalXMLHttpRequestInstrumentation };
|