@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
package/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
2
3
|
import NativeBugsee from './NativeBugsee';
|
|
3
4
|
import { PACKAGE_VERSION } from './version';
|
|
4
5
|
import { wrap } from './viewtree/anchor';
|
|
@@ -20,7 +21,11 @@ import { installConsoleCapture } from './console/capture';
|
|
|
20
21
|
import { setLogFilter as installLogFilter } from './logs/filter';
|
|
21
22
|
import type { LogFilter } from './logs/filter';
|
|
22
23
|
import { addBreadcrumb as recordBreadcrumb } from './breadcrumbs/add';
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
setBreadcrumbFilter as installBreadcrumbFilter,
|
|
26
|
+
setBreadcrumbUrlScrubber as installBreadcrumbUrlScrubber,
|
|
27
|
+
} from './breadcrumbs/filter';
|
|
28
|
+
import type { BreadcrumbUrlScrubber } from './breadcrumbs/url-scrub';
|
|
24
29
|
import type { Breadcrumb, BreadcrumbFilter } from './breadcrumbs/types';
|
|
25
30
|
import { setNetworkFilter as installNetworkFilter } from './network/filter';
|
|
26
31
|
import type { NetworkFilter } from './network/filter';
|
|
@@ -28,6 +33,7 @@ import { addNetworkEvent as recordNetworkEvent } from './network/add';
|
|
|
28
33
|
import type { AddedNetworkEvent } from './network/add';
|
|
29
34
|
import { type IssueSeverity, LogLevel } from './options/enums';
|
|
30
35
|
import { BugseeLaunchOptions } from './options/BugseeLaunchOptions';
|
|
36
|
+
import { warnUnknownOptions } from './options/unknownKeys';
|
|
31
37
|
import { labelsArgument, severityArgument } from './report/fields';
|
|
32
38
|
import {
|
|
33
39
|
assertEventOrTraceName,
|
|
@@ -50,6 +56,7 @@ import { encodeExceptionOptions } from './exceptions/options';
|
|
|
50
56
|
import type { ExceptionOptions } from './exceptions/options';
|
|
51
57
|
import {
|
|
52
58
|
installExceptionHandlers,
|
|
59
|
+
setCrashDetectionOptedOut,
|
|
53
60
|
setExceptionCaptureEnabled,
|
|
54
61
|
} from './exceptions/handlers';
|
|
55
62
|
import {
|
|
@@ -71,7 +78,9 @@ import type { ReportAppearance } from './appearance/report';
|
|
|
71
78
|
const DETECT_CRASH_OPTION = 'com.bugsee.option.detect.crash';
|
|
72
79
|
|
|
73
80
|
function applyExceptionCaptureFromOptions(options: LaunchOptions): void {
|
|
74
|
-
|
|
81
|
+
const enabled = options[DETECT_CRASH_OPTION] !== false;
|
|
82
|
+
setExceptionCaptureEnabled(enabled);
|
|
83
|
+
setCrashDetectionOptedOut(!enabled);
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
export { Status } from './status';
|
|
@@ -111,20 +120,30 @@ export type LaunchOptions = Record<string, unknown>;
|
|
|
111
120
|
*/
|
|
112
121
|
export type LaunchOptionsInput = BugseeLaunchOptions | LaunchOptions;
|
|
113
122
|
|
|
114
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* The native payload for either form. An options object is serialised here, once, so callers never have to.
|
|
125
|
+
*
|
|
126
|
+
* Also warns about keys the running platform's SDK would silently drop. Both SDKs ignore an unknown key
|
|
127
|
+
* without any error, so a misspelt or 6.x-style name (`ShakeToReport`) otherwise leaves the setting
|
|
128
|
+
* unapplied with nothing to say so. The launch itself is unchanged.
|
|
129
|
+
*/
|
|
115
130
|
function nativeOptionsOf(options: LaunchOptionsInput): LaunchOptions {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
131
|
+
const native =
|
|
132
|
+
options instanceof BugseeLaunchOptions
|
|
133
|
+
? BugseeLaunchOptions.serialize(options)
|
|
134
|
+
: options;
|
|
135
|
+
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
136
|
+
warnUnknownOptions(Platform.OS, native);
|
|
137
|
+
}
|
|
138
|
+
return native;
|
|
119
139
|
}
|
|
120
140
|
|
|
121
141
|
class Bugsee {
|
|
122
142
|
/**
|
|
123
143
|
* Starts the SDK. `options` is the options object from `createDefaultLaunchOptions()` as is, or
|
|
124
144
|
* the plain option map; there is no serialise step to call. Resolves to whether the native side
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* error the caller should throw on.
|
|
145
|
+
* launched. It can decline (token rejected) without that being an error the caller should
|
|
146
|
+
* throw on. When the SDK is already running it resolves `true` and new native SDK options are ignored.
|
|
128
147
|
*
|
|
129
148
|
* Installs the global JS exception handlers (ErrorUtils and unhandled
|
|
130
149
|
* promise rejections). On Hermes, the last caller of
|
|
@@ -153,7 +172,7 @@ class Bugsee {
|
|
|
153
172
|
/**
|
|
154
173
|
* Tells the SDK what wrapper it is running under.
|
|
155
174
|
*
|
|
156
|
-
* Idempotent and cheap, so `launch` and `
|
|
175
|
+
* Idempotent and cheap, so `launch`, `relaunch` and `attach` can all call it; the
|
|
157
176
|
* SDK replaces whatever was registered.
|
|
158
177
|
*/
|
|
159
178
|
private registerWrapper(): void {
|
|
@@ -293,7 +312,13 @@ class Bugsee {
|
|
|
293
312
|
});
|
|
294
313
|
}
|
|
295
314
|
|
|
296
|
-
/**
|
|
315
|
+
/**
|
|
316
|
+
* Stops the current session. A blackout in force ends with it, on both
|
|
317
|
+
* platforms: it lasts until {@link endBlackout} or `stop()`. A
|
|
318
|
+
* {@link startBlackout} made before `launch()` is held until launch, and
|
|
319
|
+
* `stop()` on an SDK that was never launched does not cancel it. What
|
|
320
|
+
* `relaunch()` does to a blackout is platform-defined and unspecified.
|
|
321
|
+
*/
|
|
297
322
|
async stop(): Promise<boolean> {
|
|
298
323
|
return NativeBugsee.stop();
|
|
299
324
|
}
|
|
@@ -447,11 +472,22 @@ class Bugsee {
|
|
|
447
472
|
* stays omitted: setting that key to `null` leaves it out of the reply.
|
|
448
473
|
* `null` and `undefined` drop the event. The native SDK invokes the
|
|
449
474
|
* filter; JS answers on a later turn, and a callback that throws,
|
|
450
|
-
* rejects, or
|
|
475
|
+
* rejects, or does not settle within 9 s drops the event.
|
|
476
|
+
*
|
|
477
|
+
* On Android this package runs the built-in sanitizer on each event
|
|
478
|
+
* before the callback, when
|
|
479
|
+
* `com.bugsee.option.capture.network.default-sanitizer` is on. On iOS the
|
|
480
|
+
* callback replaces the built-in sanitizer, so raw events reach it and
|
|
481
|
+
* what it does not remove is recorded. The built-in rules also differ by
|
|
482
|
+
* platform.
|
|
451
483
|
*
|
|
452
|
-
*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
484
|
+
* This filter sees network events only. It is not applied to URLs in HTTP
|
|
485
|
+
* breadcrumbs (when breadcrumb capture is on) or `http.client` performance
|
|
486
|
+
* spans (on by default), and path segments in the `http_url` attribute of
|
|
487
|
+
* `detect.http-errors` reports (off by default) are not passed through it.
|
|
488
|
+
* Clean breadcrumb URLs with {@link setBreadcrumbUrlScrubber}, redact the
|
|
489
|
+
* rest of a breadcrumb with {@link setBreadcrumbFilter}, or turn the
|
|
490
|
+
* capture off. See "Network privacy" in the package README.
|
|
455
491
|
*/
|
|
456
492
|
setNetworkFilter(callback?: NetworkFilter | null): void {
|
|
457
493
|
installNetworkFilter(callback);
|
|
@@ -484,8 +520,9 @@ class Bugsee {
|
|
|
484
520
|
* replacement string. `null` or `undefined` drops the line. The native SDK
|
|
485
521
|
* is what invokes the filter; the callback runs on a later turn, and this
|
|
486
522
|
* method does not wait for it. A callback that throws, rejects, or does
|
|
487
|
-
* not settle
|
|
488
|
-
*
|
|
523
|
+
* not settle within 9 s drops the line, and a late answer is ignored (iOS:
|
|
524
|
+
* the bridge drops at 9 s; Android: the bridge stops waiting at 9 s and the
|
|
525
|
+
* SDK drops at 10 s). It is not passed through.
|
|
489
526
|
*/
|
|
490
527
|
setLogFilter(callback?: LogFilter | null): void {
|
|
491
528
|
installLogFilter(callback);
|
|
@@ -516,12 +553,13 @@ class Bugsee {
|
|
|
516
553
|
* `undefined`, drops the crumb. A key the snapshot omitted stays omitted.
|
|
517
554
|
* `data: null` clears data. `timestamp` is read-only and is not sent back.
|
|
518
555
|
*
|
|
519
|
-
* The callback runs on a later turn. This method does not wait for it
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
*
|
|
524
|
-
*
|
|
556
|
+
* The callback runs on a later turn. This method does not wait for it. A
|
|
557
|
+
* callback that throws, rejects, or does not settle within 9 s drops the
|
|
558
|
+
* crumb, and a late answer is ignored. On both platforms the bridge
|
|
559
|
+
* supplies that deadline: neither SDK has one. The original is not passed
|
|
560
|
+
* through. A crumb already passed to `addBreadcrumb` is still offered to
|
|
561
|
+
* the callback that was installed for it when this is cleared, or replaced
|
|
562
|
+
* with another function, on that same turn.
|
|
525
563
|
*
|
|
526
564
|
* Capture stays off until launch options set `captureBreadcrumbs: true`,
|
|
527
565
|
* on Android and on iOS. While it is off, `addBreadcrumb` records nothing
|
|
@@ -531,6 +569,33 @@ class Bugsee {
|
|
|
531
569
|
installBreadcrumbFilter(callback);
|
|
532
570
|
}
|
|
533
571
|
|
|
572
|
+
/**
|
|
573
|
+
* Cleans the URL of HTTP breadcrumbs before {@link setBreadcrumbFilter}'s
|
|
574
|
+
* callback sees the crumb. Off by default.
|
|
575
|
+
*
|
|
576
|
+
* `true` drops `user:password@`, the query string and the fragment and
|
|
577
|
+
* keeps the scheme, host, port and path. A function is a custom scrubber:
|
|
578
|
+
* it maps the URL to the URL to record, and a throw or a non-string result
|
|
579
|
+
* drops the crumb. `false`, `null` or `undefined` turns it off.
|
|
580
|
+
*
|
|
581
|
+
* It applies to crumbs whose `type` is `http` and whose `data.url` is a
|
|
582
|
+
* string: the SDK's own HTTP crumbs (when `captureBreadcrumbs` is on) and
|
|
583
|
+
* an `http` crumb passed to {@link addBreadcrumb}. This is the only way to
|
|
584
|
+
* clean those URLs in the wrapper: {@link setNetworkFilter} does not see
|
|
585
|
+
* them. It does not cover `http.client` performance spans or the
|
|
586
|
+
* `http_url` attribute of `detect.http-errors` reports.
|
|
587
|
+
*
|
|
588
|
+
* Cost: with it off, nothing changes. With it on, native asks JS about
|
|
589
|
+
* every breadcrumb (not only `http`), the same round trip an installed
|
|
590
|
+
* breadcrumb filter costs, with the same 9 s deadline and fail-closed
|
|
591
|
+
* rules. Call it on every launch of the JS runtime, as
|
|
592
|
+
* {@link setBreadcrumbFilter}: after a reload, native drops crumbs until it
|
|
593
|
+
* is called again. See "Network privacy" in the package README.
|
|
594
|
+
*/
|
|
595
|
+
setBreadcrumbUrlScrubber(scrubber?: boolean | BreadcrumbUrlScrubber | null): void {
|
|
596
|
+
installBreadcrumbUrlScrubber(scrubber);
|
|
597
|
+
}
|
|
598
|
+
|
|
534
599
|
/**
|
|
535
600
|
* Records a named event, with optional params.
|
|
536
601
|
*
|
|
@@ -681,6 +746,11 @@ class Bugsee {
|
|
|
681
746
|
* from `com.bugsee.app-token` manifest metadata. Deliberately makes no
|
|
682
747
|
* native launch call; doing so would start a second session.
|
|
683
748
|
*
|
|
749
|
+
* Registers the full wrapper identity first, as `launch` and `relaunch`
|
|
750
|
+
* do: the native side registered only the type and version at process
|
|
751
|
+
* start, so without this every report of an auto-launched session lacks
|
|
752
|
+
* the context (React Native version, JS engine, dev build).
|
|
753
|
+
*
|
|
684
754
|
* Reads `com.bugsee.option.detect.crash` from the native launch options and
|
|
685
755
|
* applies it before the global handlers are installed (R7). Capture is held
|
|
686
756
|
* off during that read: the default is on, and the read yields, so a render
|
|
@@ -690,6 +760,7 @@ class Bugsee {
|
|
|
690
760
|
* handlers; a rejected read does not install it either.
|
|
691
761
|
*/
|
|
692
762
|
async attach(): Promise<void> {
|
|
763
|
+
this.registerWrapper();
|
|
693
764
|
setExceptionCaptureEnabled(false);
|
|
694
765
|
const options = await this.getLaunchOptions();
|
|
695
766
|
applyExceptionCaptureFromOptions(options);
|
|
@@ -748,7 +819,7 @@ class Bugsee {
|
|
|
748
819
|
* on iOS, 5 s on Android). iOS surfaces it at the next launch.
|
|
749
820
|
*/
|
|
750
821
|
logUnhandledException(error: unknown): Promise<void> {
|
|
751
|
-
if (!markReported(error)) {
|
|
822
|
+
if (!markReported(error, 'unhandled')) {
|
|
752
823
|
return Promise.resolve();
|
|
753
824
|
}
|
|
754
825
|
const extras =
|
|
@@ -830,17 +901,36 @@ class Bugsee {
|
|
|
830
901
|
}
|
|
831
902
|
|
|
832
903
|
/**
|
|
833
|
-
* Deletes collected data stored on the device.
|
|
904
|
+
* Deletes collected data stored on the device. The SDK must be stopped
|
|
905
|
+
* first: while launched, both platforms refuse (by design) and this
|
|
906
|
+
* resolves `false`. The promise resolves with the SDK's own outcome, however
|
|
907
|
+
* long the deletion takes. On iOS, if the SDK reports nothing for 60 s (with either
|
|
908
|
+
* flag value), it rejects with code `E_DELETE_TIMEOUT`:
|
|
909
|
+
* the outcome is unknown and the deletion may still finish.
|
|
834
910
|
*
|
|
835
|
-
* `includingIntermediate`
|
|
836
|
-
*
|
|
837
|
-
*
|
|
838
|
-
*
|
|
839
|
-
*
|
|
840
|
-
*
|
|
911
|
+
* - `includingIntermediate`: `false` deletes the rolling capture data and
|
|
912
|
+
* keeps finished reports; `true` also deletes the data set aside for
|
|
913
|
+
* reports not yet bundled (report snapshots on both platforms; on Android
|
|
914
|
+
* also exported reports).
|
|
915
|
+
* - `includingFinishedReports` (default `false`): also deletes the finished
|
|
916
|
+
* reports waiting for upload, which are otherwise still uploaded after
|
|
917
|
+
* the data is deleted (use it when a user withdraws consent).
|
|
918
|
+
*
|
|
919
|
+
* Platform difference with `includingFinishedReports: true`: iOS calls the
|
|
920
|
+
* SDK's delete-everything form, which also deletes crashes not yet reported
|
|
921
|
+
* and the learned performance baselines, and cancels pending uploads
|
|
922
|
+
* (`includingIntermediate` is then moot). Android's 3-argument SDK method
|
|
923
|
+
* deletes the finished report bundles only; it does not touch crashes not
|
|
924
|
+
* yet reported. TODO: possible SDK follow-up to align the two.
|
|
841
925
|
*/
|
|
842
|
-
deleteCollectedDataOnDevice(
|
|
843
|
-
|
|
926
|
+
deleteCollectedDataOnDevice(
|
|
927
|
+
includingIntermediate: boolean,
|
|
928
|
+
includingFinishedReports: boolean = false,
|
|
929
|
+
): Promise<boolean> {
|
|
930
|
+
return NativeBugsee.deleteCollectedDataOnDevice(
|
|
931
|
+
includingIntermediate,
|
|
932
|
+
includingFinishedReports,
|
|
933
|
+
);
|
|
844
934
|
}
|
|
845
935
|
}
|
|
846
936
|
|
|
@@ -949,6 +1039,8 @@ export type {
|
|
|
949
1039
|
BreadcrumbLevel,
|
|
950
1040
|
BreadcrumbSnapshot,
|
|
951
1041
|
} from './breadcrumbs/types';
|
|
1042
|
+
export type { BreadcrumbUrlScrubber } from './breadcrumbs/url-scrub';
|
|
1043
|
+
export { defaultBreadcrumbUrlScrubber } from './breadcrumbs/url-scrub';
|
|
952
1044
|
|
|
953
1045
|
export type { ExceptionOptions } from './exceptions/options';
|
|
954
1046
|
export { SpanStatus } from './apm/types';
|
package/src/logs/filter.ts
CHANGED
|
@@ -5,10 +5,11 @@ import NativeBugsee from '../NativeBugsee';
|
|
|
5
5
|
* One log line in, the line to keep out.
|
|
6
6
|
*
|
|
7
7
|
* A string replaces the line. `null` and `undefined` drop it. A promise is
|
|
8
|
-
* waited on
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* waited on, for at most 9 s: an answer after that is ignored. On iOS the
|
|
9
|
+
* bridge drops the line at 9 s (the SDK has no deadline). On Android the
|
|
10
|
+
* bridge stops waiting at 9 s and the SDK drops the line at 10 s. This
|
|
11
|
+
* function does not add a timeout of its own: a timeout here that then passed
|
|
12
|
+
* the original line would leak exactly what the filter exists to remove.
|
|
12
13
|
*/
|
|
13
14
|
export type LogFilter = (
|
|
14
15
|
line: string,
|
|
@@ -23,10 +24,20 @@ let subscribed = false;
|
|
|
23
24
|
* so lines are recorded without one.
|
|
24
25
|
*
|
|
25
26
|
* The JS listener is subscribed before the native filter is installed, so a
|
|
26
|
-
* line filtered on the installing turn still has a listener.
|
|
27
|
-
* emitted in that gap
|
|
27
|
+
* line filtered on the installing turn still has a listener. A request
|
|
28
|
+
* emitted in that gap is dropped when its deadline passes. The
|
|
28
29
|
* subscription stays: clearing the callback stops native from asking, and a
|
|
29
30
|
* later callback must still be able to answer.
|
|
31
|
+
*
|
|
32
|
+
* The native filter lives for the whole process, but the JavaScript side that
|
|
33
|
+
* answers it does not. After a full reload, `DevSettings.reload()`, or an OTA
|
|
34
|
+
* reload (`Updates.reloadAsync()`, CodePush `restartApp()`), the new runtime
|
|
35
|
+
* has not installed a filter yet, so native fails closed: lines are dropped, not recorded unfiltered.
|
|
36
|
+
* That lasts until `setLogFilter` is called again, which can be the rest of the
|
|
37
|
+
* process. Call it unconditionally at startup, on every launch of the JS
|
|
38
|
+
* runtime, not lazily or conditionally (after login or consent), and keep it
|
|
39
|
+
* in every OTA bundle. To opt out, call `setLogFilter(null)`, which restores
|
|
40
|
+
* pass-through.
|
|
30
41
|
*/
|
|
31
42
|
export function setLogFilter(callback?: LogFilter | null): void {
|
|
32
43
|
if (callback != null && typeof callback !== 'function') {
|
|
@@ -52,8 +63,8 @@ export function setLogFilter(callback?: LogFilter | null): void {
|
|
|
52
63
|
* produced the line.
|
|
53
64
|
*
|
|
54
65
|
* A throw, a rejection, or a result that is not a string drops the line.
|
|
55
|
-
* A callback that
|
|
56
|
-
*
|
|
66
|
+
* A callback that does not settle within 9 s drops the line, and its late
|
|
67
|
+
* answer is ignored. Neither path replies with the original line.
|
|
57
68
|
*/
|
|
58
69
|
function onLogFilterRequest(event: { requestId: string; line: string }): void {
|
|
59
70
|
const callback = current;
|
package/src/network/filter.ts
CHANGED
|
@@ -6,9 +6,11 @@ import NativeBugsee from '../NativeBugsee';
|
|
|
6
6
|
* The native keep-value is the event object (`Callback1<NetworkEvent>` on
|
|
7
7
|
* Android, `BugseeNetworkFilterDecisionBlock` on iOS), so a replacement is
|
|
8
8
|
* that object — not a string. `null` and `undefined` drop it. A promise is
|
|
9
|
-
* waited on
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* waited on, for at most 9 s: an answer after that is ignored. On iOS the
|
|
10
|
+
* bridge drops the event at 9 s (the SDK has no deadline). On Android the
|
|
11
|
+
* bridge stops waiting at 9 s and the SDK drops the event at 10 s. This
|
|
12
|
+
* function does not add a timeout of its own: a timeout here that then passed
|
|
13
|
+
* the original event would leak exactly what the filter exists to remove.
|
|
12
14
|
*/
|
|
13
15
|
export interface NetworkFilterEvent {
|
|
14
16
|
id: string | null;
|
|
@@ -61,6 +63,16 @@ let subscribed = false;
|
|
|
61
63
|
* The native request is subscribed to once and stays subscribed: clearing the
|
|
62
64
|
* callback stops native from asking, and a later callback must still be able
|
|
63
65
|
* to answer.
|
|
66
|
+
*
|
|
67
|
+
* The native filter lives for the whole process, but the JavaScript side that
|
|
68
|
+
* answers it does not. After a full reload, `DevSettings.reload()`, or an OTA
|
|
69
|
+
* reload (`Updates.reloadAsync()`, CodePush `restartApp()`), the new runtime
|
|
70
|
+
* has not installed a filter yet, so native fails closed: events are dropped, not recorded.
|
|
71
|
+
* That lasts until `setNetworkFilter` is called again, which can be the rest of the
|
|
72
|
+
* process. Call it unconditionally at startup, on every launch of the JS
|
|
73
|
+
* runtime, not lazily or conditionally (after login or consent), and keep it
|
|
74
|
+
* in every OTA bundle. To opt out, call `setNetworkFilter(null)`, which restores
|
|
75
|
+
* pass-through.
|
|
64
76
|
*/
|
|
65
77
|
export function setNetworkFilter(callback?: NetworkFilter | null): void {
|
|
66
78
|
if (callback != null && typeof callback !== 'function') {
|
|
@@ -95,8 +107,8 @@ export function setNetworkFilter(callback?: NetworkFilter | null): void {
|
|
|
95
107
|
* `null`. A `null` value on a key the snapshot sent is an explicit clear.
|
|
96
108
|
* A key the snapshot omitted stays omitted: a `null` the callback wrote
|
|
97
109
|
* for that key is left out of the reply, so `body: event.body ?? null`
|
|
98
|
-
* does not clear a body the snapshot never had. A callback that
|
|
99
|
-
*
|
|
110
|
+
* does not clear a body the snapshot never had. A callback that does
|
|
111
|
+
* not settle within 9 s drops the event, and its late answer is ignored.
|
|
100
112
|
* Neither path replies with the original event.
|
|
101
113
|
*/
|
|
102
114
|
function onNetworkFilterRequest(event: { requestId: string; eventJson: string }): void {
|