@bugsee/react-native 7.0.0-beta2 → 7.0.0-beta4
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 +264 -9
- package/android/build.gradle +9 -0
- package/android/consumer-rules.pro +3 -0
- package/android/src/main/java/com/bugsee/reactnative/BreadcrumbFilterBridge.java +224 -20
- package/android/src/main/java/com/bugsee/reactnative/BugseeModule.java +44 -21
- package/android/src/main/java/com/bugsee/reactnative/BugseeOptionEnums.java +15 -0
- package/android/src/main/java/com/bugsee/reactnative/LogFilterBridge.java +119 -5
- package/android/src/main/java/com/bugsee/reactnative/NetworkCaptureProbe.java +107 -0
- package/android/src/main/java/com/bugsee/reactnative/NetworkFilterBridge.java +129 -14
- package/android/src/main/java/com/bugsee/reactnative/ReactNativeWrapperInitProvider.java +48 -0
- package/android/src/main/java/com/bugsee/reactnative/SpanHandles.java +64 -8
- package/android/src/main/java/com/bugsee/reactnative/StartupHold.java +237 -0
- package/ios/BugseeModule.mm +293 -155
- package/ios/Support/Package.resolved +2 -2
- package/ios/Support/Package.swift +1 -1
- package/ios/Support/Sources/BugseeRNSupport/BGSRNBlackout.m +14 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNDeleteCollectedData.m +33 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNFilterArming.m +22 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNFilterDeadline.m +110 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSpanHandles.m +40 -6
- package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapper.m +1 -1
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNBlackout.h +23 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReportOps.h +2 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNDeleteCollectedData.h +29 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNFilterArming.h +26 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNFilterDeadline.h +68 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportHandlerBridge.h +5 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportOps.h +5 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSpanHandles.h +16 -2
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapperChannelHolder.h +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNBlackoutTests.m +38 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNDeleteCollectedDataTests.m +135 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.h +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFilterArmingTests.m +48 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFilterDeadlineTests.m +230 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportHandlerBridgeTests.m +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSpanHandlesTests.m +86 -6
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperChannelHolderTests.m +5 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperTests.m +1 -1
- package/native-versions.json +2 -2
- package/package.json +2 -2
- package/plugin/build/dsym-script.d.ts +11 -0
- package/plugin/build/dsym-script.js +26 -3
- package/plugin/build/dsym-script.js.map +1 -1
- package/plugin/build/index.d.ts +27 -0
- package/plugin/build/index.js +33 -21
- package/plugin/build/index.js.map +1 -1
- package/plugin/build/manifest.d.ts +37 -0
- package/plugin/build/manifest.js +67 -1
- package/plugin/build/manifest.js.map +1 -1
- package/plugin/build/native-versions.baked.json +1 -1
- package/scripts/bugsee-xcode.sh +0 -0
- package/scripts/compose-then-inject.js +4 -2
- package/scripts/hermes-sourcemaps.js +40 -3
- package/scripts/hermesc-preserve-js.js +0 -0
- package/scripts/hermesc-preserve-js.sh +0 -0
- package/src/NativeBugsee.ts +39 -22
- package/src/apm/span.ts +42 -7
- package/src/breadcrumbs/filter.ts +104 -13
- package/src/breadcrumbs/types.ts +6 -4
- package/src/breadcrumbs/url-scrub.ts +75 -0
- package/src/exceptions/ErrorBoundary.tsx +4 -1
- package/src/exceptions/RootErrorReporter.tsx +1 -1
- package/src/exceptions/handlers.ts +17 -1
- package/src/exceptions/report.ts +30 -8
- package/src/index.ts +125 -33
- package/src/logs/filter.ts +19 -8
- package/src/network/filter.ts +17 -5
- package/src/options/AndroidLaunchOptions.ts +310 -24
- package/src/options/BugseeLaunchOptions.ts +463 -18
- package/src/options/IOSLaunchOptions.ts +164 -8
- package/src/options/android-options-manifest.json +63 -6
- package/src/options/enums.ts +28 -0
- package/src/options/ios-enums.json +6 -5
- package/src/options/ios-options-manifest.json +594 -0
- package/src/options/keys.ts +19 -1
- package/src/options/noAccessor.ts +16 -0
- package/src/options/option-keys.json +9 -3
- package/src/options/unknownKeys.ts +198 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
package com.bugsee.reactnative;
|
|
2
|
+
|
|
3
|
+
import android.os.Handler;
|
|
4
|
+
import android.os.Looper;
|
|
5
|
+
import android.util.Log;
|
|
6
|
+
|
|
7
|
+
import androidx.annotation.NonNull;
|
|
8
|
+
import androidx.annotation.Nullable;
|
|
9
|
+
|
|
10
|
+
import java.util.Collections;
|
|
11
|
+
import java.util.LinkedHashSet;
|
|
12
|
+
import java.util.Locale;
|
|
13
|
+
import java.util.Set;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The opt-in that closes the window in which an auto-launched SDK records
|
|
17
|
+
* before JavaScript has installed the app's filters.
|
|
18
|
+
*
|
|
19
|
+
* <p>Under manifest auto-launch the SDK starts at process start, long before a
|
|
20
|
+
* JS runtime exists. The JS log, network and breadcrumb filters are installed
|
|
21
|
+
* natively only when {@code setLogFilter} / {@code setNetworkFilter} /
|
|
22
|
+
* {@code setBreadcrumbFilter} run, so everything captured until then is
|
|
23
|
+
* recorded unfiltered. The Android SDK keeps a filter set before launch and
|
|
24
|
+
* applies it to the providers when they are created, so the wrapper's init
|
|
25
|
+
* provider can install the bridge filters first. Each bridge's filter drops an
|
|
26
|
+
* event while no module (or a module whose JS has not answered) is there to
|
|
27
|
+
* ask: fail closed.
|
|
28
|
+
*
|
|
29
|
+
* <p>Opt-in, per filter, by the {@value #META_DATA} manifest meta-data (the
|
|
30
|
+
* Expo plugin's {@code holdFilters} option): a held filter also drops
|
|
31
|
+
* everything for an app that never calls its {@code setXFilter}, so the
|
|
32
|
+
* default is not to hold. JS releases a hold by calling the setter, with a
|
|
33
|
+
* function or with {@code null} (no filter, pass-through).
|
|
34
|
+
*/
|
|
35
|
+
final class StartupHold {
|
|
36
|
+
|
|
37
|
+
static final String META_DATA = "com.bugsee.reactnative.hold-filters";
|
|
38
|
+
static final String NETWORK = "network";
|
|
39
|
+
static final String LOG = "log";
|
|
40
|
+
static final String BREADCRUMB = "breadcrumb";
|
|
41
|
+
|
|
42
|
+
private static final String TAG = "BugseeRN";
|
|
43
|
+
|
|
44
|
+
private StartupHold() {
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** How long after a module attaches a hold may wait for JS before the watchdog says so. */
|
|
48
|
+
static final long WATCHDOG_MS = 30_000L;
|
|
49
|
+
|
|
50
|
+
/** Which holds JS has not released yet. */
|
|
51
|
+
interface Probe {
|
|
52
|
+
boolean networkHeld();
|
|
53
|
+
|
|
54
|
+
boolean logHeld();
|
|
55
|
+
|
|
56
|
+
boolean breadcrumbHeld();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Runs a task once, after a delay. Injectable so tests control time. */
|
|
60
|
+
interface Delayer {
|
|
61
|
+
void runAfter(long delayMs, @NonNull Runnable task);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The holds {@code apply} puts in place. */
|
|
65
|
+
interface Targets {
|
|
66
|
+
void holdNetwork();
|
|
67
|
+
|
|
68
|
+
void holdLog();
|
|
69
|
+
|
|
70
|
+
void holdBreadcrumb();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The real probe. */
|
|
74
|
+
static final Probe PROBE = new Probe() {
|
|
75
|
+
@Override
|
|
76
|
+
public boolean networkHeld() {
|
|
77
|
+
return NetworkFilterBridge.shared().isHeld();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Override
|
|
81
|
+
public boolean logHeld() {
|
|
82
|
+
return LogFilterBridge.shared().isHeld();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@Override
|
|
86
|
+
public boolean breadcrumbHeld() {
|
|
87
|
+
return BreadcrumbFilterBridge.shared().isHeld();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
private static final java.util.concurrent.atomic.AtomicBoolean WATCHING =
|
|
92
|
+
new java.util.concurrent.atomic.AtomicBoolean();
|
|
93
|
+
|
|
94
|
+
/** The real bridges. */
|
|
95
|
+
static final Targets BRIDGES = new Targets() {
|
|
96
|
+
@Override
|
|
97
|
+
public void holdNetwork() {
|
|
98
|
+
NetworkFilterBridge.shared().holdUntilJs();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@Override
|
|
102
|
+
public void holdLog() {
|
|
103
|
+
LogFilterBridge.shared().holdUntilJs();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@Override
|
|
107
|
+
public void holdBreadcrumb() {
|
|
108
|
+
BreadcrumbFilterBridge.shared().holdUntilJs();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The filters {@code raw} names: a comma list of {@link #NETWORK},
|
|
114
|
+
* {@link #LOG} and {@link #BREADCRUMB}, or {@code all} / {@code true} for
|
|
115
|
+
* all three. Case and spaces do not matter. A name that is not one of
|
|
116
|
+
* them is ignored, since a typo that held nothing is no worse than the
|
|
117
|
+
* default, but one that threw would kill the process at start.
|
|
118
|
+
*/
|
|
119
|
+
@NonNull
|
|
120
|
+
static Set<String> parse(@Nullable final Object raw) {
|
|
121
|
+
if (raw == null) {
|
|
122
|
+
return Collections.emptySet();
|
|
123
|
+
}
|
|
124
|
+
final Set<String> held = new LinkedHashSet<>();
|
|
125
|
+
for (final String part : raw.toString().split(",")) {
|
|
126
|
+
final String name = part.trim().toLowerCase(Locale.ROOT);
|
|
127
|
+
if (name.equals("all") || name.equals("true")) {
|
|
128
|
+
held.add(NETWORK);
|
|
129
|
+
held.add(LOG);
|
|
130
|
+
held.add(BREADCRUMB);
|
|
131
|
+
} else if (name.equals(NETWORK) || name.equals(LOG) || name.equals(BREADCRUMB)) {
|
|
132
|
+
held.add(name);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return held;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Holds each filter {@code raw} names. One that fails to hold does not
|
|
140
|
+
* stop the others: the rest still close their window. Returns what was
|
|
141
|
+
* held. Never throws, errors included; see
|
|
142
|
+
* {@link ReactNativeWrapperInitProvider#registerEarly}.
|
|
143
|
+
*/
|
|
144
|
+
@NonNull
|
|
145
|
+
static Set<String> apply(@Nullable final Object raw, @NonNull final Targets targets) {
|
|
146
|
+
final Set<String> held = new LinkedHashSet<>();
|
|
147
|
+
for (final String name : parse(raw)) {
|
|
148
|
+
try {
|
|
149
|
+
if (name.equals(NETWORK)) {
|
|
150
|
+
targets.holdNetwork();
|
|
151
|
+
} else if (name.equals(LOG)) {
|
|
152
|
+
targets.holdLog();
|
|
153
|
+
} else {
|
|
154
|
+
targets.holdBreadcrumb();
|
|
155
|
+
}
|
|
156
|
+
held.add(name);
|
|
157
|
+
} catch (Throwable t) {
|
|
158
|
+
Log.e(TAG, "could not hold the " + name + " filter at process start: "
|
|
159
|
+
+ t.getClass().getName());
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!held.isEmpty()) {
|
|
163
|
+
Log.i(TAG, "holding the " + held + " filter(s) from process start: events are dropped until JS calls "
|
|
164
|
+
+ "setNetworkFilter / setLogFilter / setBreadcrumbFilter (a function, or null for none)");
|
|
165
|
+
}
|
|
166
|
+
return held;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The filters {@code probe} says JS has not released, in a fixed order.
|
|
171
|
+
*/
|
|
172
|
+
@NonNull
|
|
173
|
+
static Set<String> stillHeld(@NonNull final Probe probe) {
|
|
174
|
+
final Set<String> waiting = new LinkedHashSet<>();
|
|
175
|
+
if (probe.networkHeld()) {
|
|
176
|
+
waiting.add(NETWORK);
|
|
177
|
+
}
|
|
178
|
+
if (probe.logHeld()) {
|
|
179
|
+
waiting.add(LOG);
|
|
180
|
+
}
|
|
181
|
+
if (probe.breadcrumbHeld()) {
|
|
182
|
+
waiting.add(BREADCRUMB);
|
|
183
|
+
}
|
|
184
|
+
return waiting;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Once per process, {@code delayMs} after the first module attaches: says so
|
|
189
|
+
* (and returns what, to the log) if a filter is still held, because an
|
|
190
|
+
* app that lists a filter and never calls its setter records none of that
|
|
191
|
+
* kind. A log line only; it changes no behaviour.
|
|
192
|
+
*
|
|
193
|
+
* @return whether this call scheduled the watchdog
|
|
194
|
+
*/
|
|
195
|
+
static boolean watch(
|
|
196
|
+
@NonNull final Probe probe,
|
|
197
|
+
@NonNull final Delayer delayer,
|
|
198
|
+
@NonNull final java.util.function.Consumer<String> warn,
|
|
199
|
+
final long delayMs
|
|
200
|
+
) {
|
|
201
|
+
if (!WATCHING.compareAndSet(false, true)) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
delayer.runAfter(delayMs, () -> {
|
|
205
|
+
final Set<String> waiting = stillHeld(probe);
|
|
206
|
+
if (!waiting.isEmpty()) {
|
|
207
|
+
warn.accept("the " + waiting + " filter(s) are still held " + (delayMs / 1000L)
|
|
208
|
+
+ " s after process start: events of that kind are being dropped. If JS runs, call "
|
|
209
|
+
+ "setNetworkFilter / setLogFilter / setBreadcrumbFilter at startup (null for no filter), "
|
|
210
|
+
+ "or remove it from holdFilters; a process that never starts React Native holds them for its whole life");
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Starts the watchdog from the init provider, so it runs in a process that
|
|
218
|
+
* never starts React Native too ("still held 30 s after process start").
|
|
219
|
+
* A no-op when nothing was held.
|
|
220
|
+
*/
|
|
221
|
+
static void watchFromProvider(@NonNull final Set<String> held) {
|
|
222
|
+
try {
|
|
223
|
+
if (held.isEmpty()) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
final Handler main = new Handler(Looper.getMainLooper());
|
|
227
|
+
watch(PROBE, (delayMs, task) -> main.postDelayed(task, delayMs), message -> Log.w(TAG, message), WATCHDOG_MS);
|
|
228
|
+
} catch (Throwable t) {
|
|
229
|
+
Log.e(TAG, "could not start the startup hold watchdog: " + t.getClass().getName());
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Test seam: lets another test start a fresh watchdog. */
|
|
234
|
+
static void resetWatchForTest() {
|
|
235
|
+
WATCHING.set(false);
|
|
236
|
+
}
|
|
237
|
+
}
|