@goliapkg/sentori-react-native 5.0.0 → 5.1.0
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/MIGRATION.md +131 -0
- package/README.md +40 -30
- package/android/src/main/java/com/sentori/SentoriModule.kt +8 -0
- package/android/src/main/java/com/sentori/SentoriScreenshotCapture.kt +36 -4
- package/ios/SentoriCrashHandler.swift +48 -4
- package/ios/SentoriModule.swift +12 -0
- package/ios/SentoriScreenshotCapture.swift +34 -3
- package/lib/config.d.ts +1 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/lib/init.d.ts.map +1 -1
- package/lib/init.js +18 -6
- package/lib/init.js.map +1 -1
- package/lib/mask.d.ts +8 -0
- package/lib/mask.d.ts.map +1 -0
- package/lib/mask.js +35 -0
- package/lib/mask.js.map +1 -0
- package/lib/native.d.ts +4 -11
- package/lib/native.d.ts.map +1 -1
- package/lib/native.js +23 -0
- package/lib/native.js.map +1 -1
- package/lib/rage-tap.d.ts.map +1 -1
- package/lib/rage-tap.js +30 -2
- package/lib/rage-tap.js.map +1 -1
- package/lib/replay-screens.d.ts +15 -0
- package/lib/replay-screens.d.ts.map +1 -0
- package/lib/replay-screens.js +87 -0
- package/lib/replay-screens.js.map +1 -0
- package/lib/responsiveness-detector.d.ts +18 -0
- package/lib/responsiveness-detector.d.ts.map +1 -0
- package/lib/responsiveness-detector.js +55 -0
- package/lib/responsiveness-detector.js.map +1 -0
- package/package.json +3 -2
- package/src/__tests__/replay-screens.test.ts +63 -0
- package/src/__tests__/responsiveness-detector.test.ts +74 -0
- package/src/config.ts +1 -0
- package/src/index.ts +3 -0
- package/src/init.ts +27 -9
- package/src/mask.ts +39 -0
- package/src/native.ts +33 -0
- package/src/rage-tap.tsx +46 -2
- package/src/replay-screens.ts +95 -0
- package/src/responsiveness-detector.ts +66 -0
package/lib/mask.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Screen masking — the privacy half of visual replay.
|
|
2
|
+
//
|
|
3
|
+
// The host registers a query returning the `nativeID`s of views
|
|
4
|
+
// that must never appear in a screenshot (camera feeds, user
|
|
5
|
+
// identity, payment fields). Native paints black rectangles over
|
|
6
|
+
// those subtrees in the same render pass, so the pixels never
|
|
7
|
+
// leave the device.
|
|
8
|
+
//
|
|
9
|
+
// The query runs on every frame tick; keep it cheap (return a
|
|
10
|
+
// cached array). A throwing query is swallowed and masks NOTHING
|
|
11
|
+
// that tick — so a broken query fails visible-in-review rather
|
|
12
|
+
// than silently, and can never take the capture path down.
|
|
13
|
+
import { reportInternal } from '@goliapkg/sentori-core';
|
|
14
|
+
let _query = null;
|
|
15
|
+
/** Register (or with `null`, clear) the mask query. */
|
|
16
|
+
export const registerMaskQuery = (query) => {
|
|
17
|
+
_query = query;
|
|
18
|
+
};
|
|
19
|
+
/** The current mask list; empty when unregistered or throwing. */
|
|
20
|
+
export const maskedNativeIds = () => {
|
|
21
|
+
if (!_query)
|
|
22
|
+
return [];
|
|
23
|
+
try {
|
|
24
|
+
const ids = _query();
|
|
25
|
+
return Array.isArray(ids) ? ids.filter((x) => typeof x === 'string') : [];
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
reportInternal('mask-query', e);
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const __resetForTests = () => {
|
|
33
|
+
_query = null;
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=mask.js.map
|
package/lib/mask.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mask.js","sourceRoot":"","sources":["../src/mask.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,EAAE;AACF,gEAAgE;AAChE,6DAA6D;AAC7D,iEAAiE;AACjE,8DAA8D;AAC9D,oBAAoB;AACpB,EAAE;AACF,8DAA8D;AAC9D,iEAAiE;AACjE,+DAA+D;AAC/D,2DAA2D;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD,IAAI,MAAM,GAAqB,IAAI,CAAC;AAEpC,uDAAuD;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAuB,EAAQ,EAAE;IACjE,MAAM,GAAG,KAAK,CAAC;AACjB,CAAC,CAAC;AAEF,kEAAkE;AAClE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAa,EAAE;IAC5C,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5E,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAS,EAAE;IACxC,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC,CAAC"}
|
package/lib/native.d.ts
CHANGED
|
@@ -74,17 +74,10 @@ export declare function getRecentNativeException(): null | {
|
|
|
74
74
|
reason: string;
|
|
75
75
|
stack: string[];
|
|
76
76
|
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
* Returns `null` on every failure mode: no native module bound
|
|
83
|
-
* (jest, bun test, web), method missing (older native build still
|
|
84
|
-
* deployed), capture failed (no key window, timed out, etc.).
|
|
85
|
-
* Callers must treat `null` as "no screenshot this round" — the
|
|
86
|
-
* error event still ships, just without a thumbnail.
|
|
87
|
-
*/
|
|
77
|
+
export declare function captureNativeReplayFrame(maskedIds: string[], longEdgePx: number, quality: number): Promise<null | {
|
|
78
|
+
base64: string;
|
|
79
|
+
mediaType: string;
|
|
80
|
+
}>;
|
|
88
81
|
export declare function captureNativeScreenshotWithMask(maskedIds: string[]): Promise<null | {
|
|
89
82
|
base64: string;
|
|
90
83
|
mediaType: string;
|
package/lib/native.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkMH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;CACd,GAAG,IAAI,CAMP;AAED,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAQ5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAMzC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IACzC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,GAAG,IAAI,CAMP;AAID;gEACgE;AAChE,wBAAsB,aAAa,IAAI,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAQ5D;AAED;yCACyC;AACzC,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,GAAG,MAAM,CAAC,CAQpE;AAED,wBAAgB,YAAY,IAAI,IAAI,CAMnC;AAED,wBAAgB,cAAc,IAAI,IAAI,CAMrC;AAED,MAAM,MAAM,cAAc,GAAG;IAC3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E;AACtE,wBAAgB,uBAAuB,IAAI;IACzC,KAAK,EAAE,OAAO,CAAA;IACd,mBAAmB,EAAE,OAAO,CAAA;IAC5B,iBAAiB,EAAE,OAAO,CAAA;CAC3B,CAOA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,IAAI;IACtC,SAAS,EAAE,OAAO,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB;;+DAE2D;IAC3D,YAAY,EAAE,MAAM,CAAA;IACpB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAA;IACrB;2CACuC;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B,CA+CA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,qBAAqB,IAAI;IACvC,SAAS,EAAE,OAAO,CAAA;IAClB,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7B,CAeA"}
|
package/lib/native.js
CHANGED
|
@@ -207,6 +207,29 @@ export function getRecentNativeException() {
|
|
|
207
207
|
* Callers must treat `null` as "no screenshot this round" — the
|
|
208
208
|
* error event still ships, just without a thumbnail.
|
|
209
209
|
*/
|
|
210
|
+
/** v5.1 — one low-bitrate frame for the screens replay ring.
|
|
211
|
+
* Null on every failure mode (module unbound, method missing on an
|
|
212
|
+
* older native build, capture failed); the ring just skips a beat. */
|
|
213
|
+
let warnedNoReplayFrame = false;
|
|
214
|
+
export async function captureNativeReplayFrame(maskedIds, longEdgePx, quality) {
|
|
215
|
+
const n = native();
|
|
216
|
+
if (!n)
|
|
217
|
+
return null;
|
|
218
|
+
if (!n.captureReplayFrame) {
|
|
219
|
+
if (!warnedNoReplayFrame) {
|
|
220
|
+
warnedNoReplayFrame = true;
|
|
221
|
+
logger.warn('native', 'captureReplayFrame missing — rebuild the native app for visual replay');
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
return (await n.captureReplayFrame(maskedIds, longEdgePx, quality)) ?? null;
|
|
227
|
+
}
|
|
228
|
+
catch (e) {
|
|
229
|
+
logger.warn('native', 'captureReplayFrame threw', e);
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
210
233
|
export async function captureNativeScreenshotWithMask(maskedIds) {
|
|
211
234
|
const n = native();
|
|
212
235
|
if (!n) {
|
package/lib/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAuK/C,IAAI,OAA+C,CAAA;AAEnD,SAAS,MAAM;IACb,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,OAAO,CAAA;IACzC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,OAAO,CAAC,mBAAmB,CAEvC,CAAA;QACD,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAsB,SAAS,CAAC,CAAA;QAClE,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YAClE,8DAA8D;YAC9D,8DAA8D;YAC9D,8DAA8D;YAC9D,4DAA4D;YAC5D,+BAA+B;YAC/B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAiB,CAAC,CAAC,IAAI,E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AA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"rage-tap.d.ts","sourceRoot":"","sources":["../src/rage-tap.tsx"],"names":[],"mappings":"AAYA,OAAO,KAA8B,MAAM,OAAO,CAAC;AACnD,OAAO,EAAoC,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAgBhF,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,SAAS,GAAG;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA8DhE"}
|
package/lib/rage-tap.js
CHANGED
|
@@ -12,20 +12,48 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
12
12
|
// after firing so a frustrated 10-tap burst is one event, not four.
|
|
13
13
|
import { useCallback, useRef } from 'react';
|
|
14
14
|
import { View } from 'react-native';
|
|
15
|
-
import { pushSignal } from '@goliapkg/sentori-core';
|
|
15
|
+
import { pushSignal, snapshotSignals } from '@goliapkg/sentori-core';
|
|
16
16
|
import { getConfig } from './config';
|
|
17
17
|
import { currentScreen } from './navigation';
|
|
18
18
|
import { RAGE_THRESHOLD, RAGE_WINDOW_MS, recordTap } from './rage-tap-detector';
|
|
19
|
+
import { RESPONSE_WINDOW_MS, SLUGGISH_MS, classifyTap, recordDeadTap, recordSluggish, } from './responsiveness-detector';
|
|
19
20
|
import { warnDetected } from './verbs';
|
|
20
21
|
export function RageTapCapture({ children, ...rest }) {
|
|
21
22
|
const recent = useRef(new Map());
|
|
23
|
+
const deadBuckets = useRef(new Map());
|
|
24
|
+
const sluggishWarns = useRef(new Map());
|
|
22
25
|
const onTouchEnd = useCallback((e) => {
|
|
23
26
|
try {
|
|
24
27
|
const target = e.nativeEvent?.target;
|
|
25
28
|
if (typeof target !== 'number')
|
|
26
29
|
return;
|
|
30
|
+
const tapAt = Date.now();
|
|
27
31
|
pushSignal('tap', { target });
|
|
28
|
-
|
|
32
|
+
// Responsiveness verdict lands after the window closes: the
|
|
33
|
+
// ring tells us whether the app reacted to this tap at all.
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
try {
|
|
36
|
+
const screen = currentScreen();
|
|
37
|
+
// Ring snapshots carry event-relative seconds (one decimal);
|
|
38
|
+
// rebase them onto the epoch for the classifier.
|
|
39
|
+
const nowMs = Date.now();
|
|
40
|
+
const times = snapshotSignals(nowMs)
|
|
41
|
+
.filter((s) => s.kind !== 'tap')
|
|
42
|
+
.map((s) => nowMs + s.t * 1000);
|
|
43
|
+
const outcome = classifyTap(tapAt, times);
|
|
44
|
+
if (outcome === 'dead' && recordDeadTap(deadBuckets.current, target, Date.now())) {
|
|
45
|
+
warnDetected('dead_button', { screen, element: String(target) }, { windowMs: RESPONSE_WINDOW_MS });
|
|
46
|
+
}
|
|
47
|
+
else if (outcome === 'sluggish' &&
|
|
48
|
+
recordSluggish(sluggishWarns.current, target, Date.now())) {
|
|
49
|
+
warnDetected('sluggish_button', { screen, element: String(target) }, { thresholdMs: SLUGGISH_MS });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// detector bug must never surface
|
|
54
|
+
}
|
|
55
|
+
}, RESPONSE_WINDOW_MS + 50);
|
|
56
|
+
if (!recordTap(recent.current, target, tapAt))
|
|
29
57
|
return;
|
|
30
58
|
if (getConfig()?.detect.rageTap === false)
|
|
31
59
|
return;
|
package/lib/rage-tap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rage-tap.js","sourceRoot":"","sources":["../src/rage-tap.tsx"],"names":[],"mappings":";AAAA,6DAA6D;AAC7D,6BAA6B;AAC7B,EAAE;AACF,iDAAiD;AACjD,8DAA8D;AAC9D,iEAAiE;AACjE,EAAE;AACF,mEAAmE;AACnE,gEAAgE;AAChE,kEAAkE;AAClE,oEAAoE;AAEpE,OAAc,EAA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EAAE,EACnC,EAAE,WAAW,EAAE,WAAW,EAAE,CAC7B,CAAC;oBACJ,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,kCAAkC;gBACpC,CAAC;YACH,CAAC,EAAE,kBAAkB,GAAG,EAAE,CAAC,CAAC;YAE5B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC;gBAAE,OAAO;YACtD,IAAI,SAAS,EAAE,EAAE,MAAM,CAAC,OAAO,KAAK,KAAK;gBAAE,OAAO;YAClD,YAAY,CACV,UAAU,EACV,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EACpD,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,CACnD,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,6DAA6D;QAC/D,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CACL,KAAC,IAAI,OAAK,IAAI,EAAE,UAAU,EAAE,UAAU,YACnC,QAAQ,GACJ,CACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { captureNativeReplayFrame } from './native';
|
|
2
|
+
type CaptureFn = typeof captureNativeReplayFrame;
|
|
3
|
+
/** Start the ring. `windowSeconds` is how far back the replay
|
|
4
|
+
* reaches when an event fires. */
|
|
5
|
+
export declare const startScreenReplay: (windowSeconds: number) => void;
|
|
6
|
+
/** Drain the ring into the wire form: NDJSON, one frame per line,
|
|
7
|
+
* `t` rewritten to seconds-before-now (negative, so the player
|
|
8
|
+
* reads "-42.5s → 0s"). Returns null when empty. The ring is NOT
|
|
9
|
+
* cleared — a second error two seconds later should still see
|
|
10
|
+
* the minute before it. */
|
|
11
|
+
export declare const drainScreenReplay: () => null | string;
|
|
12
|
+
export declare const __resetForTests: () => void;
|
|
13
|
+
export declare const __setCaptureForTests: (fn: CaptureFn) => void;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=replay-screens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay-screens.d.ts","sourceRoot":"","sources":["../src/replay-screens.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAEpD,KAAK,SAAS,GAAG,OAAO,wBAAwB,CAAC;AAoBjD;mCACmC;AACnC,eAAO,MAAM,iBAAiB,kBAAmB,MAAM,KAAG,IAOzD,CAAC;AAkBF;;;;4BAI4B;AAC5B,eAAO,MAAM,iBAAiB,QAAO,IAAI,GAAG,MAY3C,CAAC;AAEF,eAAO,MAAM,eAAe,QAAO,IAOlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,OAAQ,SAAS,KAAG,IAEpD,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// B-type visual replay — a rolling ring of low-bitrate screenshots.
|
|
2
|
+
//
|
|
3
|
+
// OFF by default (privacy + the client-zero-cost rule): enable
|
|
4
|
+
// with `init({ replayScreens: true })`. One frame every 2.5 s at
|
|
5
|
+
// 360 px / q≈0.35 runs 10-20 KB, so the 60 s window a triage
|
|
6
|
+
// actually wants is ~24 frames and a few hundred KB — and those
|
|
7
|
+
// bytes only ever leave the device when an error/warn fires,
|
|
8
|
+
// stapled to that event as a `screens` attachment.
|
|
9
|
+
//
|
|
10
|
+
// Older native builds have no `captureReplayFrame`; the ring then
|
|
11
|
+
// simply stays empty (one warn) — wireframe replay still works.
|
|
12
|
+
import { logger } from '@goliapkg/sentori-core';
|
|
13
|
+
import { maskedNativeIds } from './mask';
|
|
14
|
+
import { captureNativeReplayFrame } from './native';
|
|
15
|
+
let _capture = captureNativeReplayFrame;
|
|
16
|
+
/** Frame cadence. 2.5 s keeps the main-thread cost of a capture
|
|
17
|
+
* (~1-3 ms) far under the 1 % occupancy budget. */
|
|
18
|
+
const TICK_INTERVAL_MS = 2_500;
|
|
19
|
+
/** Long edge of a replay frame, px. Enough to read a screen's
|
|
20
|
+
* layout and large text; deliberately not enough to read a
|
|
21
|
+
* document over someone's shoulder. */
|
|
22
|
+
const FRAME_LONG_EDGE_PX = 360;
|
|
23
|
+
/** JPEG/WebP quality for replay frames. */
|
|
24
|
+
const FRAME_QUALITY = 0.35;
|
|
25
|
+
let _ring = [];
|
|
26
|
+
let _capacity = 0;
|
|
27
|
+
let _timer = null;
|
|
28
|
+
let _capturing = false;
|
|
29
|
+
/** Start the ring. `windowSeconds` is how far back the replay
|
|
30
|
+
* reaches when an event fires. */
|
|
31
|
+
export const startScreenReplay = (windowSeconds) => {
|
|
32
|
+
if (_timer !== null || windowSeconds <= 0)
|
|
33
|
+
return;
|
|
34
|
+
_capacity = Math.max(1, Math.ceil((windowSeconds * 1000) / TICK_INTERVAL_MS));
|
|
35
|
+
_timer = setInterval(() => {
|
|
36
|
+
void tick();
|
|
37
|
+
}, TICK_INTERVAL_MS);
|
|
38
|
+
logger.debug('replay-screens', `ring started: ${_capacity} slots / ${windowSeconds}s`);
|
|
39
|
+
};
|
|
40
|
+
const tick = async () => {
|
|
41
|
+
// Never overlap captures: a slow frame skips a beat instead of
|
|
42
|
+
// queueing main-thread work.
|
|
43
|
+
if (_capturing)
|
|
44
|
+
return;
|
|
45
|
+
_capturing = true;
|
|
46
|
+
try {
|
|
47
|
+
const frame = await _capture(maskedNativeIds(), FRAME_LONG_EDGE_PX, FRAME_QUALITY);
|
|
48
|
+
if (frame) {
|
|
49
|
+
_ring.push({ t: Date.now(), ...frame });
|
|
50
|
+
if (_ring.length > _capacity)
|
|
51
|
+
_ring.splice(0, _ring.length - _capacity);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
_capturing = false;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/** Drain the ring into the wire form: NDJSON, one frame per line,
|
|
59
|
+
* `t` rewritten to seconds-before-now (negative, so the player
|
|
60
|
+
* reads "-42.5s → 0s"). Returns null when empty. The ring is NOT
|
|
61
|
+
* cleared — a second error two seconds later should still see
|
|
62
|
+
* the minute before it. */
|
|
63
|
+
export const drainScreenReplay = () => {
|
|
64
|
+
if (_ring.length === 0)
|
|
65
|
+
return null;
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
return _ring
|
|
68
|
+
.map((f) => JSON.stringify({
|
|
69
|
+
t: Number(((f.t - now) / 1000).toFixed(1)),
|
|
70
|
+
mediaType: f.mediaType,
|
|
71
|
+
base64: f.base64,
|
|
72
|
+
}))
|
|
73
|
+
.join('\n');
|
|
74
|
+
};
|
|
75
|
+
export const __resetForTests = () => {
|
|
76
|
+
if (_timer !== null)
|
|
77
|
+
clearInterval(_timer);
|
|
78
|
+
_timer = null;
|
|
79
|
+
_ring = [];
|
|
80
|
+
_capacity = 0;
|
|
81
|
+
_capturing = false;
|
|
82
|
+
_capture = captureNativeReplayFrame;
|
|
83
|
+
};
|
|
84
|
+
export const __setCaptureForTests = (fn) => {
|
|
85
|
+
_capture = fn;
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=replay-screens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay-screens.js","sourceRoot":"","sources":["../src/replay-screens.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,EAAE;AACF,+DAA+D;AAC/D,iEAAiE;AACjE,6DAA6D;AAC7D,gEAAgE;AAChE,6DAA6D;AAC7D,mDAAmD;AACnD,EAAE;AACF,kEAAkE;AAClE,gEAAgE;AAEhE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAGpD,IAAI,QAAQ,GAAc,wBAAwB,CAAC;AAEnD;oDACoD;AACpD,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B;;wCAEwC;AACxC,MAAM,kBAAk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CAAC;QAC1E,CAAC;IACH,CAAC;YAAS,CAAC;QACT,UAAU,GAAG,KAAK,CAAC;IACrB,CAAC;AACH,CAAC,CAAC;AAEF;;;;4BAI4B;AAC5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAkB,EAAE;IACnD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACT,IAAI,CAAC,SAAS,CAAC;QACb,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1C,SAAS,EAAE,CAAC,CAAC,SAAS;QACtB,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB,CAAC,CACH;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,GAAS,EAAE;IACxC,IAAI,MAAM,KAAK,IAAI;QAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,GAAG,IAAI,CAAC;IACd,KAAK,GAAG,EAAE,CAAC;IACX,SAAS,GAAG,CAAC,CAAC;IACd,UAAU,GAAG,KAAK,CAAC;IACnB,QAAQ,GAAG,wBAAwB,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAa,EAAQ,EAAE;IAC1D,QAAQ,GAAG,EAAE,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const RESPONSE_WINDOW_MS = 1500;
|
|
2
|
+
export declare const SLUGGISH_MS = 1000;
|
|
3
|
+
export declare const DEAD_THRESHOLD = 3;
|
|
4
|
+
export declare const DEAD_WINDOW_MS = 30000;
|
|
5
|
+
export declare const SLUGGISH_COOLDOWN_MS = 60000;
|
|
6
|
+
export type TapOutcome = 'dead' | 'responsive' | 'sluggish';
|
|
7
|
+
/** Judge one tap by the ring signals that followed it.
|
|
8
|
+
* `signalTimes` are the timestamps (ms) of every non-tap signal
|
|
9
|
+
* recorded after `tapAt`. */
|
|
10
|
+
export declare function classifyTap(tapAt: number, signalTimes: number[]): TapOutcome;
|
|
11
|
+
/** Per-target dead-tap bookkeeping. Returns true when this dead tap
|
|
12
|
+
* crosses the warn threshold (and clears the bucket so the next
|
|
13
|
+
* warn needs a fresh run of dead taps). */
|
|
14
|
+
export declare function recordDeadTap(buckets: Map<number, number[]>, target: number, now: number): boolean;
|
|
15
|
+
/** Per-target sluggish cooldown. Returns true when a warn should
|
|
16
|
+
* fire (and stamps the cooldown). */
|
|
17
|
+
export declare function recordSluggish(lastWarnAt: Map<number, number>, target: number, now: number): boolean;
|
|
18
|
+
//# sourceMappingURL=responsiveness-detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsiveness-detector.d.ts","sourceRoot":"","sources":["../src/responsiveness-detector.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AACxC,eAAO,MAAM,WAAW,OAAQ,CAAC;AACjC,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,cAAc,QAAS,CAAC;AACrC,eAAO,MAAM,oBAAoB,QAAS,CAAC;AAE3C,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,CAAC;AAE5D;;8BAE8B;AAC9B,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,UAAU,CAM5E;AAED;;4CAE4C;AAC5C,wBAAgB,aAAa,CAC3B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAC9B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAST;AAED;sCACsC;AACtC,wBAAgB,cAAc,CAC5B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAKT"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// dead_button / sluggish_button — pure detection logic.
|
|
2
|
+
//
|
|
3
|
+
// A tap is judged by what the signal ring records after it: any
|
|
4
|
+
// non-tap signal (navigation, network, a trace point) inside the
|
|
5
|
+
// response window counts as the app reacting.
|
|
6
|
+
//
|
|
7
|
+
// - responsive: a reaction within SLUGGISH_MS.
|
|
8
|
+
// - sluggish: a reaction, but slower than SLUGGISH_MS.
|
|
9
|
+
// - dead: no reaction at all inside RESPONSE_WINDOW_MS.
|
|
10
|
+
//
|
|
11
|
+
// One dead tap is usually decoration (backgrounds, labels), so a
|
|
12
|
+
// dead_button warn needs DEAD_THRESHOLD dead taps on the SAME
|
|
13
|
+
// target inside DEAD_WINDOW_MS — a user repeatedly poking one
|
|
14
|
+
// unresponsive control, at a slower cadence than a rage tap.
|
|
15
|
+
// Sluggish warns are per-target cooldown-limited so one slow
|
|
16
|
+
// button files one issue, not one per tap.
|
|
17
|
+
export const RESPONSE_WINDOW_MS = 1_500;
|
|
18
|
+
export const SLUGGISH_MS = 1_000;
|
|
19
|
+
export const DEAD_THRESHOLD = 3;
|
|
20
|
+
export const DEAD_WINDOW_MS = 30_000;
|
|
21
|
+
export const SLUGGISH_COOLDOWN_MS = 60_000;
|
|
22
|
+
/** Judge one tap by the ring signals that followed it.
|
|
23
|
+
* `signalTimes` are the timestamps (ms) of every non-tap signal
|
|
24
|
+
* recorded after `tapAt`. */
|
|
25
|
+
export function classifyTap(tapAt, signalTimes) {
|
|
26
|
+
const first = signalTimes
|
|
27
|
+
.filter((t) => t > tapAt && t - tapAt <= RESPONSE_WINDOW_MS)
|
|
28
|
+
.sort((a, b) => a - b)[0];
|
|
29
|
+
if (first === undefined)
|
|
30
|
+
return 'dead';
|
|
31
|
+
return first - tapAt > SLUGGISH_MS ? 'sluggish' : 'responsive';
|
|
32
|
+
}
|
|
33
|
+
/** Per-target dead-tap bookkeeping. Returns true when this dead tap
|
|
34
|
+
* crosses the warn threshold (and clears the bucket so the next
|
|
35
|
+
* warn needs a fresh run of dead taps). */
|
|
36
|
+
export function recordDeadTap(buckets, target, now) {
|
|
37
|
+
const fresh = (buckets.get(target) ?? []).filter((t) => now - t <= DEAD_WINDOW_MS);
|
|
38
|
+
fresh.push(now);
|
|
39
|
+
if (fresh.length >= DEAD_THRESHOLD) {
|
|
40
|
+
buckets.delete(target);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
buckets.set(target, fresh);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
/** Per-target sluggish cooldown. Returns true when a warn should
|
|
47
|
+
* fire (and stamps the cooldown). */
|
|
48
|
+
export function recordSluggish(lastWarnAt, target, now) {
|
|
49
|
+
const last = lastWarnAt.get(target);
|
|
50
|
+
if (last !== undefined && now - last < SLUGGISH_COOLDOWN_MS)
|
|
51
|
+
return false;
|
|
52
|
+
lastWarnAt.set(target, now);
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=responsiveness-detector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responsiveness-detector.js","sourceRoot":"","sources":["../src/responsiveness-detector.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,gEAAgE;AAChE,iEAAiE;AACjE,8CAA8C;AAC9C,EAAE;AACF,iDAAiD;AACjD,2DAA2D;AAC3D,gEAAgE;AAChE,EAAE;AACF,iEAAiE;AACjE,8DAA8D;AAC9D,8DAA8D;AAC9D,6DAA6D;AAC7D,6DAA6D;AAC7D,2CAA2C;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AACxC,MAAM,CAAC,M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B,UAA+B,EAC/B,MAAc,EACd,GAAW;IAEX,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACpC,IAAI,IAAI,KAAK,SAAS,IAAI,GAAG,GAAG,IAAI,GAAG,oBAAoB;QAAE,OAAO,KAAK,CAAC;IAC1E,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goliapkg/sentori-react-native",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Sentori SDK for React Native — JS-layer error capture, native crash handlers (iOS / Android), batched transport, fetch + react-navigation tracing.",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"author": "GOLIA K.K. <takagi@golia.jp> (https://golia.jp)",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"sentori-rn-upload-source-bundle": "bin/sentori-rn-upload-source-bundle.cjs"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
|
+
"MIGRATION.md",
|
|
49
50
|
"lib/",
|
|
50
51
|
"src/",
|
|
51
52
|
"bin/",
|
|
@@ -96,6 +97,6 @@
|
|
|
96
97
|
"access": "public"
|
|
97
98
|
},
|
|
98
99
|
"dependencies": {
|
|
99
|
-
"@goliapkg/sentori-core": "^2.
|
|
100
|
+
"@goliapkg/sentori-core": "^2.1.0"
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The screens ring: capacity, drain shape, mask-query isolation,
|
|
2
|
+
// and graceful absence on an old native build.
|
|
3
|
+
|
|
4
|
+
import { afterEach, describe, expect, mock, test } from 'bun:test';
|
|
5
|
+
|
|
6
|
+
import { __resetForTests as resetMask, maskedNativeIds, registerMaskQuery } from '../mask';
|
|
7
|
+
import {
|
|
8
|
+
__resetForTests as resetRing,
|
|
9
|
+
__setCaptureForTests,
|
|
10
|
+
drainScreenReplay,
|
|
11
|
+
startScreenReplay,
|
|
12
|
+
} from '../replay-screens';
|
|
13
|
+
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
resetRing();
|
|
16
|
+
resetMask();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('mask query', () => {
|
|
20
|
+
test('unregistered → empty', () => {
|
|
21
|
+
expect(maskedNativeIds()).toEqual([]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('registered query flows through and filters junk', () => {
|
|
25
|
+
registerMaskQuery(() => ['camera-feed', 42 as unknown as string, 'user-email']);
|
|
26
|
+
expect(maskedNativeIds()).toEqual(['camera-feed', 'user-email']);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('a throwing query masks nothing and never throws', () => {
|
|
30
|
+
registerMaskQuery(() => {
|
|
31
|
+
throw new Error('boom');
|
|
32
|
+
});
|
|
33
|
+
expect(maskedNativeIds()).toEqual([]);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('screens ring', () => {
|
|
38
|
+
test('drain on an empty ring is null (old native builds)', () => {
|
|
39
|
+
startScreenReplay(60);
|
|
40
|
+
expect(drainScreenReplay()).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('drain emits NDJSON with negative relative timestamps', async () => {
|
|
44
|
+
let n = 0;
|
|
45
|
+
__setCaptureForTests(
|
|
46
|
+
mock(async () => ({ base64: `frame${(n += 1)}`, mediaType: 'image/jpeg' })),
|
|
47
|
+
);
|
|
48
|
+
startScreenReplay(60);
|
|
49
|
+
await new Promise((r) => setTimeout(r, 2_600));
|
|
50
|
+
const out = drainScreenReplay();
|
|
51
|
+
expect(out).not.toBeNull();
|
|
52
|
+
const lines = (out ?? '')
|
|
53
|
+
.split('\n')
|
|
54
|
+
.map((l) => JSON.parse(l) as { t: number; base64: string });
|
|
55
|
+
expect(lines.length).toBeGreaterThanOrEqual(1);
|
|
56
|
+
for (const l of lines) {
|
|
57
|
+
expect(l.t).toBeLessThanOrEqual(0);
|
|
58
|
+
expect(l.base64.startsWith('frame')).toBe(true);
|
|
59
|
+
}
|
|
60
|
+
// drain does not clear: a second error still sees the window
|
|
61
|
+
expect(drainScreenReplay()).not.toBeNull();
|
|
62
|
+
}, 10_000);
|
|
63
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// dead_button / sluggish_button verdict logic.
|
|
2
|
+
|
|
3
|
+
import { describe, expect, test } from 'bun:test';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
DEAD_THRESHOLD,
|
|
7
|
+
DEAD_WINDOW_MS,
|
|
8
|
+
RESPONSE_WINDOW_MS,
|
|
9
|
+
SLUGGISH_COOLDOWN_MS,
|
|
10
|
+
SLUGGISH_MS,
|
|
11
|
+
classifyTap,
|
|
12
|
+
recordDeadTap,
|
|
13
|
+
recordSluggish,
|
|
14
|
+
} from '../responsiveness-detector';
|
|
15
|
+
|
|
16
|
+
describe('classifyTap', () => {
|
|
17
|
+
test('a fast reaction is responsive', () => {
|
|
18
|
+
expect(classifyTap(1000, [1300])).toBe('responsive');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('a slow reaction is sluggish', () => {
|
|
22
|
+
expect(classifyTap(1000, [1000 + SLUGGISH_MS + 200])).toBe('sluggish');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('no reaction inside the window is dead', () => {
|
|
26
|
+
expect(classifyTap(1000, [])).toBe('dead');
|
|
27
|
+
expect(classifyTap(1000, [1000 + RESPONSE_WINDOW_MS + 500])).toBe('dead');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('signals from before the tap do not count', () => {
|
|
31
|
+
expect(classifyTap(1000, [900, 500])).toBe('dead');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('the earliest reaction decides', () => {
|
|
35
|
+
expect(classifyTap(1000, [1000 + SLUGGISH_MS + 400, 1200])).toBe('responsive');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('recordDeadTap', () => {
|
|
40
|
+
test('warns only at the threshold, then resets', () => {
|
|
41
|
+
const buckets = new Map<number, number[]>();
|
|
42
|
+
let warned = 0;
|
|
43
|
+
for (let i = 0; i < DEAD_THRESHOLD * 2; i++) {
|
|
44
|
+
if (recordDeadTap(buckets, 7, 1000 + i * 100)) warned += 1;
|
|
45
|
+
}
|
|
46
|
+
expect(warned).toBe(2);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('stale dead taps age out of the window', () => {
|
|
50
|
+
const buckets = new Map<number, number[]>();
|
|
51
|
+
recordDeadTap(buckets, 7, 0);
|
|
52
|
+
recordDeadTap(buckets, 7, 100);
|
|
53
|
+
// Third tap arrives after the window: the old two are gone.
|
|
54
|
+
expect(recordDeadTap(buckets, 7, DEAD_WINDOW_MS + 200)).toBe(false);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('targets are independent', () => {
|
|
58
|
+
const buckets = new Map<number, number[]>();
|
|
59
|
+
recordDeadTap(buckets, 1, 0);
|
|
60
|
+
recordDeadTap(buckets, 1, 10);
|
|
61
|
+
expect(recordDeadTap(buckets, 2, 20)).toBe(false);
|
|
62
|
+
expect(recordDeadTap(buckets, 1, 30)).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('recordSluggish', () => {
|
|
67
|
+
test('cooldown gates repeat warns per target', () => {
|
|
68
|
+
const warns = new Map<number, number>();
|
|
69
|
+
expect(recordSluggish(warns, 7, 1000)).toBe(true);
|
|
70
|
+
expect(recordSluggish(warns, 7, 2000)).toBe(false);
|
|
71
|
+
expect(recordSluggish(warns, 7, 1000 + SLUGGISH_COOLDOWN_MS + 1)).toBe(true);
|
|
72
|
+
expect(recordSluggish(warns, 8, 2000)).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
});
|
package/src/config.ts
CHANGED
|
@@ -19,6 +19,7 @@ export type Config = {
|
|
|
19
19
|
};
|
|
20
20
|
/** B-type replay rolling buffer, seconds. 0 disables. */
|
|
21
21
|
replaySeconds: number;
|
|
22
|
+
replayScreens: boolean;
|
|
22
23
|
/** Sentori console output gate. Default `warn`: silent on the
|
|
23
24
|
* host's console unless something is genuinely broken. */
|
|
24
25
|
logLevel?: LogLevel;
|
package/src/index.ts
CHANGED
|
@@ -62,6 +62,9 @@ export default sentori;
|
|
|
62
62
|
export { init } from './init';
|
|
63
63
|
export { ErrorBoundary } from './error-boundary';
|
|
64
64
|
export { RageTapCapture } from './rage-tap';
|
|
65
|
+
// Privacy: register a query returning nativeIDs that must be
|
|
66
|
+
// blacked out in every captured frame (visual replay, screenshots).
|
|
67
|
+
export { registerMaskQuery } from './mask';
|
|
65
68
|
// Dev-panel helper: crash the native layer on purpose to exercise
|
|
66
69
|
// the pending-crash upload pipeline. Not part of the 8-verb surface.
|
|
67
70
|
export { triggerNativeCrash } from './native';
|