@goliapkg/sentori-react-native 0.7.2 → 0.7.3

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/lib/mask.js CHANGED
@@ -1,125 +1,36 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // Phase 42 sub-D.09/10 + Phase 48 sub-B — mark UI regions as "do not
3
- // screenshot" AND actually redact them at capture time.
1
+ // v0.7.3 mask discovery via consumer-supplied query callback.
4
2
  //
5
- // `<MaskRegion>` renders its children normally, plus a black overlay
6
- // `<View>` that sits on top of them with `opacity: 0`. Right before
7
- // `captureScreenshot()` calls into react-native-view-shot, the SDK
8
- // flips every registered overlay to `opacity: 1` (black square covers
9
- // the children), captures, then flips back to `opacity: 0` so the
10
- // user never sees the overlay. The overlay uses `pointerEvents="none"`
11
- // so it never intercepts touches.
3
+ // The SDK does not own a registry of masked regions. The host app
4
+ // keeps its own (e.g. a `Set<string>` updated as `<Maskable>`
5
+ // components mount/unmount) and hands the SDK a thunk that returns
6
+ // the current list of native-IDs to redact. The SDK calls the thunk
7
+ // once per screenshot capture cheap, called rarely, only on error.
12
8
  //
13
- // `setMaskedNode(ref)` is the imperative escape hatch for views you
14
- // can't wrap. We can't inject an overlay into a foreign view, so the
15
- // imperative path falls back to setting the registered view's own
16
- // `opacity: 0` for the capture window content underneath may show
17
- // through, but that beats sending the sensitive content to the server.
18
- // Prefer `<MaskRegion>` when you control the subtree.
19
- import { useEffect, useRef } from 'react';
20
- import { StyleSheet, View } from 'react-native';
21
- const _maskedRefs = new Set();
22
- const _maskedOverlays = new Set();
23
- const _maskedNativeIds = new Set();
9
+ // Why this shape: a logging SDK should never live on the render
10
+ // path. Earlier iterations exported `<MaskRegion>` (React component)
11
+ // and `setMaskedNode` (imperative ref helper), which forced every
12
+ // PII-bearing UI file to import from the SDK and put SDK bugs in
13
+ // the user's render tree. This module is JS-only no React, no JSX,
14
+ // no native module touch so swapping or removing the SDK doesn't
15
+ // affect rendering.
16
+ let _query = null;
24
17
  /**
25
- * Imperative registration: pass a ref obtained via `useRef()` /
26
- * `createRef()` to a `<View>` you want hidden from screenshots.
27
- */
28
- export function setMaskedNode(node) {
29
- if (!node || typeof node.setNativeProps !== 'function')
30
- return;
31
- _maskedRefs.add(node);
32
- }
33
- export function unsetMaskedNode(node) {
34
- if (!node)
35
- return;
36
- _maskedRefs.delete(node);
37
- }
38
- /** Returns the current set of registered masked nodes + nativeIDs.
39
- * Read by the native screenshotter layer (iOS / Android sub-E / F). */
40
- export function getMaskedRegions() {
41
- return { nativeIds: _maskedNativeIds, overlays: _maskedOverlays, refs: _maskedRefs };
42
- }
43
- /**
44
- * Phase 48 sub-B — engage masking right before screenshot capture.
45
- * Returns a function the caller must invoke once capture is done so
46
- * the user never sees the black overlays.
47
- *
48
- * Two paths:
49
- * - Overlays from `<MaskRegion>`: flip opacity 0 → 1 (cover children).
50
- * - Imperative refs from `setMaskedNode`: flip opacity 1 → 0 on the
51
- * view itself (whole subtree disappears for one frame).
18
+ * Register a callback the SDK calls right before each screenshot
19
+ * capture. Return the native-IDs (the `nativeID` prop on the RN
20
+ * `<View>`) that should be blacked-out in the captured image.
52
21
  *
53
- * All `setNativeProps` calls are best-effort a failure on one
54
- * doesn't block the others or the capture.
22
+ * Idempotent: a second call replaces the first. Pass `null` (or
23
+ * call `clearMaskQuery`) to detach.
55
24
  */
56
- export function engageMasks() {
57
- const overlaysEngaged = [];
58
- for (const o of _maskedOverlays) {
59
- try {
60
- o.setNativeProps?.({ style: { opacity: 1 } });
61
- overlaysEngaged.push(o);
62
- }
63
- catch {
64
- // skip
65
- }
66
- }
67
- const refsEngaged = [];
68
- for (const r of _maskedRefs) {
69
- try {
70
- r.setNativeProps?.({ style: { opacity: 0 } });
71
- refsEngaged.push(r);
72
- }
73
- catch {
74
- // skip
75
- }
76
- }
77
- return () => {
78
- for (const o of overlaysEngaged) {
79
- try {
80
- o.setNativeProps?.({ style: { opacity: 0 } });
81
- }
82
- catch {
83
- // skip
84
- }
85
- }
86
- for (const r of refsEngaged) {
87
- try {
88
- r.setNativeProps?.({ style: { opacity: 1 } });
89
- }
90
- catch {
91
- // skip
92
- }
93
- }
94
- };
25
+ export function registerMaskQuery(query) {
26
+ _query = query;
95
27
  }
96
- /**
97
- * Declarative redaction. `<MaskRegion>{children}</MaskRegion>` keeps
98
- * the children visible in normal flight; under capture the overlay's
99
- * opacity is flipped to 1 and the children are hidden behind a black
100
- * square in the rendered screenshot.
101
- */
102
- export function MaskRegion({ children, nativeID, ...rest }) {
103
- const idRef = useRef(nativeID ?? `sentori-mask-${Math.random().toString(36).slice(2, 10)}`);
104
- const overlayRef = useRef(null);
105
- useEffect(() => {
106
- const id = idRef.current;
107
- _maskedNativeIds.add(id);
108
- const overlay = overlayRef.current;
109
- if (overlay)
110
- _maskedOverlays.add(overlay);
111
- return () => {
112
- _maskedNativeIds.delete(id);
113
- if (overlay)
114
- _maskedOverlays.delete(overlay);
115
- };
116
- }, []);
117
- return (_jsxs(View, { collapsable: false, nativeID: idRef.current, ...rest, children: [children, _jsx(View, { pointerEvents: "none", ref: overlayRef, style: [StyleSheet.absoluteFill, { backgroundColor: '#000', opacity: 0 }] })] }));
28
+ /** Unregister. Mostly for tests / teardown. */
29
+ export function clearMaskQuery() {
30
+ _query = null;
118
31
  }
119
- /** Test-onlyflush registration tables. */
120
- export function __resetMaskedRegionsForTests() {
121
- _maskedRefs.clear();
122
- _maskedOverlays.clear();
123
- _maskedNativeIds.clear();
32
+ /** Internalread by `handlers/screenshot.ts` at capture time. */
33
+ export function getRegisteredMaskQuery() {
34
+ return _query;
124
35
  }
125
36
  //# sourceMappingURL=mask.js.map
package/lib/mask.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mask.js","sourceRoot":"","sources":["../src/mask.tsx"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,wDAAwD;AACxD,EAAE;AACF,qEAAqE;AACrE,oEAAoE;AACpE,mEAAmE;AAC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UAAU,iBAAiB,CAAC,KAAgB;IAChD,MAAM,GAAG,KAAK,CAAC;AACjB,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,cAAc;IAC5B,MAAM,GAAG,IAAI,CAAC;AAChB,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,sBAAsB;IACpC,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/lib/native.d.ts CHANGED
@@ -37,4 +37,19 @@ export declare function startAnrWatchdog(options?: {
37
37
  timeoutMs?: number;
38
38
  }): void;
39
39
  export declare function stopAnrWatchdog(): void;
40
+ /**
41
+ * v0.7.3 — drives the native screenshot path. JS side passes the
42
+ * current list of mask `nativeID`s (read from the consumer's
43
+ * registered mask query); native renders + redacts.
44
+ *
45
+ * Returns `null` on every failure mode: no native module bound
46
+ * (jest, bun test, web), method missing (older native build still
47
+ * deployed), capture failed (no key window, timed out, etc.).
48
+ * Callers must treat `null` as "no screenshot this round" — the
49
+ * error event still ships, just without a thumbnail.
50
+ */
51
+ export declare function captureNativeScreenshotWithMask(maskedIds: string[]): Promise<null | {
52
+ base64: string;
53
+ mediaType: string;
54
+ }>;
40
55
  //# sourceMappingURL=native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0CH,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;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC"}
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAsDH,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;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,+BAA+B,CACnD,SAAS,EAAE,MAAM,EAAE,GAClB,OAAO,CAAC,IAAI,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAQvD"}
package/lib/native.js CHANGED
@@ -80,4 +80,26 @@ export function stopAnrWatchdog() {
80
80
  // ignore
81
81
  }
82
82
  }
83
+ /**
84
+ * v0.7.3 — drives the native screenshot path. JS side passes the
85
+ * current list of mask `nativeID`s (read from the consumer's
86
+ * registered mask query); native renders + redacts.
87
+ *
88
+ * Returns `null` on every failure mode: no native module bound
89
+ * (jest, bun test, web), method missing (older native build still
90
+ * deployed), capture failed (no key window, timed out, etc.).
91
+ * Callers must treat `null` as "no screenshot this round" — the
92
+ * error event still ships, just without a thumbnail.
93
+ */
94
+ export async function captureNativeScreenshotWithMask(maskedIds) {
95
+ const n = native();
96
+ if (!n?.captureScreenshotWithMask)
97
+ return null;
98
+ try {
99
+ return await n.captureScreenshotWithMask(maskedIds);
100
+ }
101
+ catch {
102
+ return null;
103
+ }
104
+ }
83
105
  //# sourceMappingURL=native.js.map
package/lib/native.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"native.js","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH,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;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,MAI/B;IACC,IAAI,CAAC;QACH,MAAM,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,MAAM,CAAC,GAAG,MAAM,EAAE,CAAA;IAClB,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAA;IACjB,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,CAAC,YAAY,EAAE,CAAA;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAA;IACX,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC;QACH,MAAM,EAAE,EAAE,sBAAsB,EAAE,EAAE,CAAA;IACtC,CAAC;IAAC,MAAM,CAAC;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A;IACX,CAAC;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC;QACH,MAAM,EAAE,EAAE,sBAAsB,EAAE,EAAE,CAAA;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,sCAAsC;IACxC,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAIhC;IACC,IAAI,CAAC;QACH,MAAM,EAAE,EAAE,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,gCAAgC;IAClC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC;QACH,MAAM,EAAE,EAAE,eAAe,EAAE,EAAE,CAAA;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,SAAmB;IAEnB,MAAM,CAAC,GAAG,MAAM,EAAE,CAAA;IAClB,IAAI,CAAC,CAAC,EAAE,yBAAyB;QAAE,OAAO,IAAI,CAAA;IAC9C,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,CAAC,yBAAyB,CAAC,SAAS,CAAC,CAAA;IACrD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goliapkg/sentori-react-native",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Sentori SDK for React Native \u2014 JS-layer error capture, native crash handlers (iOS / Android), batched transport, fetch + react-navigation tracing.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://sentori.golia.jp",
@@ -41,8 +41,7 @@
41
41
  "peerDependencies": {
42
42
  "expo-modules-core": ">=2.0",
43
43
  "react": ">=18",
44
- "react-native": ">=0.74",
45
- "react-native-view-shot": ">=3.8"
44
+ "react-native": ">=0.74"
46
45
  },
47
46
  "peerDependenciesMeta": {
48
47
  "@react-native-async-storage/async-storage": {
@@ -50,15 +49,11 @@
50
49
  },
51
50
  "expo-modules-core": {
52
51
  "optional": true
53
- },
54
- "react-native-view-shot": {
55
- "optional": true
56
52
  }
57
53
  },
58
54
  "optionalDependencies": {
59
55
  "@react-native-async-storage/async-storage": ">=1.23",
60
- "expo-modules-core": ">=2.0",
61
- "react-native-view-shot": ">=3.8"
56
+ "expo-modules-core": ">=2.0"
62
57
  },
63
58
  "devDependencies": {
64
59
  "@types/bun": "latest",
@@ -3,15 +3,13 @@ import { afterEach, beforeEach, describe, expect, mock, test } from 'bun:test';
3
3
  import { setConfig, __resetForTests as resetConfig } from '../config';
4
4
  import { uploadAttachment } from '../transport';
5
5
 
6
- // Phase 42 sub-D.13 — unit coverage for the upload pipeline.
6
+ // Unit coverage for the upload pipeline.
7
7
  //
8
- // `captureScreenshot()` itself goes through react-native-view-shot
9
- // + RN's InteractionManager, neither of which exist in the bun:test
10
- // runtime, so we test it indirectly: `uploadAttachment` is the
11
- // non-RN-API surface and that's what we hit hardest. The
12
- // `requestAnimationFrame` / InteractionManager perf gating is a
13
- // runtime concern asserted via manual smoke + the iOS / Android
14
- // XCTest / instrumentation tests in sub-E / sub-F.
8
+ // `captureScreenshot()` itself goes through the native module
9
+ // (v0.7.3+) which doesn't exist in the bun:test runtime, so we
10
+ // test it indirectly: `uploadAttachment` is the non-RN-API surface
11
+ // and that's what we hit hardest. The native render + mask redaction
12
+ // is exercised by the iOS XCTest / Android instrumentation tests.
15
13
 
16
14
  const origFetch = globalThis.fetch;
17
15
  afterEach(() => {
@@ -1,63 +1,32 @@
1
- // Phase 42 sub-D.03/04 — capture a screenshot of the current view tree
2
- // on `captureException`. Off-main-thread, best-effort, opt-in.
1
+ // v0.7.3 — capture a screenshot of the current view tree on
2
+ // `captureException`. Off-main-thread, best-effort, opt-in.
3
3
  //
4
- // Performance contract (sub-D.04):
5
- // - Yield one paint via `requestAnimationFrame` before snapshotting
6
- // so the screenshot reflects post-error UI state, not the frame
7
- // that was already half-laid-out.
8
- // - Capped output: 480 px on the longest edge, JPEG q=70. Typical
9
- // payload 30-80 KB; multipart hard cap is 500 KB.
10
- // - On any failure we silently return null. The error event still
11
- // goes to the server; the user just doesn't see a thumbnail.
4
+ // JS owns the registry of which regions to redact: the host app
5
+ // passes a thunk via `sentori.registerMaskQuery(() => string[])` that
6
+ // returns the `nativeID`s currently mounted as masked. We call it
7
+ // once per capture and forward the list to the native module, which
8
+ // renders the bitmap and paints black rectangles over the matching
9
+ // subviews in a single pass.
12
10
  //
13
- // `react-native-view-shot` is an OPTIONAL peer. We `require()` it
14
- // lazily so apps that don't install it never pay the bundle cost
15
- // or fail at import time. Without it, `captureScreenshot()` returns
16
- // `null` immediately.
11
+ // History: pre-v0.7.3 went through `react-native-view-shot` (peer
12
+ // dep) and used a JS-side overlay-opacity trick (`<MaskRegion>` /
13
+ // `setMaskedNode`) to hide PII before snapshotting. That design put
14
+ // the SDK on the render path; a single SDK bug could break the host
15
+ // app's UI. v0.7.3 cuts that coupling — the SDK no longer ships
16
+ // React components, and the screenshot path runs entirely through
17
+ // the native module already used for native-crash captures.
17
18
  //
18
- // 2026-05-15 — dropped `InteractionManager.runAfterInteractions`.
19
- // RN's docs mark `InteractionManager` as deprecated and recommend
20
- // `requestIdleCallback`, but `requestIdleCallback` doesn't actually
21
- // exist in RN (it's a web API), so the deprecation print is
22
- // unactionable for SDK consumers. The defensive "wait for the active
23
- // gesture batch to drain" semantics it provided is not reachable
24
- // from a screenshot triggered on captureException by the time an
25
- // error fires, the user is between actions, not mid-gesture — so
26
- // removing it has no observable effect except silencing the warning.
27
- // The `requestAnimationFrame` calls below still guarantee one paint
28
- // commit before captureRef snapshots.
29
-
30
- import { engageMasks } from '../mask';
31
-
32
- type CaptureRef = (
33
- // Phase 42: the lib accepts a React ref or — when we pass `undefined` —
34
- // shoots the root window. We always go for the root (no per-component
35
- // ref) so the screenshot lines up with what the user just saw.
36
- refOrUndefined: undefined,
37
- opts: {
38
- format?: 'jpg' | 'png' | 'webm';
39
- quality?: number;
40
- result?: 'base64' | 'data-uri' | 'tmpfile';
41
- width?: number;
42
- height?: number;
43
- },
44
- ) => Promise<string>;
45
-
46
- type ViewShotModule = { captureRef?: CaptureRef; default?: { captureRef?: CaptureRef } };
47
-
48
- function loadCaptureRef(): CaptureRef | null {
49
- try {
50
- // eslint-disable-next-line @typescript-eslint/no-require-imports
51
- const mod = require('react-native-view-shot') as ViewShotModule;
52
- return mod.captureRef ?? mod.default?.captureRef ?? null;
53
- } catch {
54
- return null;
55
- }
56
- }
19
+ // Performance:
20
+ // - Yield one paint via `requestAnimationFrame` before the native
21
+ // call so post-error UI state has committed.
22
+ // - 480 px on the longest edge, JPEG q=70 (iOS) / WEBP_LOSSY q=70
23
+ // (Android 11+). Typical payload 30-80 KB; multipart hard cap
24
+ // is 500 KB.
25
+ // - On any failure we silently return null. The error event still
26
+ // goes to the server; the user just doesn't see a thumbnail.
57
27
 
58
- const MAX_LONG_EDGE_PX = 480;
59
- const WEBP_QUALITY = 0.7;
60
- const CAPTURE_TIMEOUT_MS = 1500;
28
+ import { getRegisteredMaskQuery } from '../mask';
29
+ import { captureNativeScreenshotWithMask } from '../native';
61
30
 
62
31
  /** What `captureScreenshot()` hands back when it succeeds. */
63
32
  export type ScreenshotBlob = {
@@ -67,74 +36,34 @@ export type ScreenshotBlob = {
67
36
 
68
37
  /**
69
38
  * Take one screenshot, yielding the JS thread first. Returns null on
70
- * any error (missing peer dep, native side refused, timeout, etc.).
71
- * Caller is responsible for opt-in checks (`config.screenshotsEnabled`).
39
+ * any error (no native module bound, native side refused, capture
40
+ * timed out, etc.). Caller is responsible for opt-in checks
41
+ * (`config.screenshotsEnabled`).
72
42
  */
73
43
  export async function captureScreenshot(): Promise<ScreenshotBlob | null> {
74
- const captureRef = loadCaptureRef();
75
- if (!captureRef) return null;
76
-
77
44
  // Yield one paint frame so the post-error UI has committed before
78
- // we ask the OS to snapshot it. The previous
79
- // `InteractionManager.runAfterInteractions` step was removed: see
80
- // file header — its replacement (`requestIdleCallback`) doesn't
81
- // exist in RN, and on captureException the user is between actions
82
- // anyway, so the gesture-batch-drain semantics never came into
83
- // play in practice.
84
- await new Promise<void>((resolve) => {
85
- requestAnimationFrame(() => resolve());
86
- });
87
-
88
- // Phase 48 sub-B — flip every registered MaskRegion overlay to
89
- // opacity 1 (black covers the children) and every imperative
90
- // setMaskedNode ref to opacity 0 (subtree disappears). Held for
91
- // exactly one frame's worth of capture, then restored.
92
- const restoreMasks = engageMasks();
93
- // Yield one more frame so the overlay paint reaches the screen
94
- // before captureRef snapshots. Without this the overlay opacity
95
- // change is queued but the screenshotter may see the previous
96
- // frame.
45
+ // we ask the OS to snapshot it.
97
46
  await new Promise<void>((resolve) => {
98
47
  requestAnimationFrame(() => resolve());
99
48
  });
100
49
 
101
- try {
102
- const base64 = await withTimeout(
103
- captureRef(undefined, {
104
- format: 'jpg',
105
- quality: WEBP_QUALITY,
106
- result: 'base64',
107
- // Long-edge cap. RN view-shot scales preserving aspect ratio
108
- // when only one dimension is set.
109
- width: MAX_LONG_EDGE_PX,
110
- }),
111
- CAPTURE_TIMEOUT_MS,
112
- );
113
- restoreMasks();
114
- if (!base64) return null;
115
- // view-shot doesn't ship a WebP encoder on every RN version.
116
- // JPEG q=70 fits the budget too (typical 40-100 KB) and every
117
- // version handles it identically. We can swap to WebP once the
118
- // RN minimum we support has it everywhere.
119
- return { base64, mediaType: 'image/jpeg' };
120
- } catch {
121
- restoreMasks();
122
- return null;
50
+ // Read the consumer-supplied mask query once per capture. If
51
+ // the host never called `registerMaskQuery`, no mask is applied
52
+ // and the full screenshot ships — sane default: SDK does nothing
53
+ // unless told to.
54
+ const query = getRegisteredMaskQuery();
55
+ let maskedIds: string[] = [];
56
+ if (query) {
57
+ try {
58
+ maskedIds = query();
59
+ } catch {
60
+ // A throwing query is the host's bug, not ours; skip mask
61
+ // rather than skip the screenshot.
62
+ maskedIds = [];
63
+ }
123
64
  }
124
- }
125
65
 
126
- function withTimeout<T>(p: Promise<T>, ms: number): Promise<T | null> {
127
- return new Promise((resolve) => {
128
- const t = setTimeout(() => resolve(null as unknown as T), ms);
129
- p.then(
130
- (v) => {
131
- clearTimeout(t);
132
- resolve(v);
133
- },
134
- () => {
135
- clearTimeout(t);
136
- resolve(null as unknown as T);
137
- },
138
- );
139
- });
66
+ const result = await captureNativeScreenshotWithMask(maskedIds);
67
+ if (!result) return null;
68
+ return { base64: result.base64, mediaType: result.mediaType };
140
69
  }
package/src/index.ts CHANGED
@@ -2,7 +2,7 @@ import { init } from './init';
2
2
  import { addBreadcrumb } from './breadcrumbs';
3
3
  import { setUser, getUser, captureError, captureException, captureStep } from './capture';
4
4
  import { ErrorBoundary } from './error-boundary';
5
- import { MaskRegion, setMaskedNode, unsetMaskedNode } from './mask';
5
+ import { clearMaskQuery, registerMaskQuery } from './mask';
6
6
  import {
7
7
  endSession,
8
8
  markSessionCrashed,
@@ -18,9 +18,8 @@ export const sentori = {
18
18
  captureException,
19
19
  captureStep,
20
20
  ErrorBoundary,
21
- MaskRegion,
22
- setMaskedNode,
23
- unsetMaskedNode,
21
+ registerMaskQuery,
22
+ clearMaskQuery,
24
23
  startSession,
25
24
  endSession,
26
25
  markSessionCrashed,
@@ -38,7 +37,7 @@ export {
38
37
  setUser,
39
38
  } from './capture';
40
39
  export { ErrorBoundary } from './error-boundary';
41
- export { MaskRegion, setMaskedNode, unsetMaskedNode } from './mask';
40
+ export { clearMaskQuery, registerMaskQuery } from './mask';
42
41
  export {
43
42
  startAnrWatchdog,
44
43
  stopAnrWatchdog,
package/src/init.ts CHANGED
@@ -33,10 +33,14 @@ export type InitOptions = {
33
33
  * foreground (`AppState` → `active`), ends it on background.
34
34
  * Drives crash-free rate. Set `false` to opt out. */
35
35
  sessions?: boolean;
36
- /** Phase 42 sub-D.07: capture a screenshot of the current screen
37
- * on `captureException`. Opt-in requires `react-native-view-shot`
38
- * installed and `<MaskRegion>` placed over any sensitive UI. The
39
- * image is webp q=70 480 px max, < 100 KB typical. */
36
+ /** Capture a screenshot of the current screen on
37
+ * `captureException`. Opt-in. The capture runs through the
38
+ * bundled native module no extra peer dep required since
39
+ * v0.7.3. To redact PII regions, register a mask query via
40
+ * `sentori.registerMaskQuery(() => string[])` and put
41
+ * `nativeID="..."` on the `<View>`s the SDK should black out.
42
+ * The image is webp q=70 / jpeg q=70 at 480 px max, < 100 KB
43
+ * typical. */
40
44
  screenshot?: boolean;
41
45
  /** Phase 46: record the last N steps (route changes, custom
42
46
  * breadcrumbs) leading up to a crash. On `captureException`
package/src/mask.ts ADDED
@@ -0,0 +1,41 @@
1
+ // v0.7.3 — mask discovery via consumer-supplied query callback.
2
+ //
3
+ // The SDK does not own a registry of masked regions. The host app
4
+ // keeps its own (e.g. a `Set<string>` updated as `<Maskable>`
5
+ // components mount/unmount) and hands the SDK a thunk that returns
6
+ // the current list of native-IDs to redact. The SDK calls the thunk
7
+ // once per screenshot capture — cheap, called rarely, only on error.
8
+ //
9
+ // Why this shape: a logging SDK should never live on the render
10
+ // path. Earlier iterations exported `<MaskRegion>` (React component)
11
+ // and `setMaskedNode` (imperative ref helper), which forced every
12
+ // PII-bearing UI file to import from the SDK and put SDK bugs in
13
+ // the user's render tree. This module is JS-only — no React, no JSX,
14
+ // no native module touch — so swapping or removing the SDK doesn't
15
+ // affect rendering.
16
+
17
+ type MaskQuery = () => string[];
18
+
19
+ let _query: MaskQuery | null = null;
20
+
21
+ /**
22
+ * Register a callback the SDK calls right before each screenshot
23
+ * capture. Return the native-IDs (the `nativeID` prop on the RN
24
+ * `<View>`) that should be blacked-out in the captured image.
25
+ *
26
+ * Idempotent: a second call replaces the first. Pass `null` (or
27
+ * call `clearMaskQuery`) to detach.
28
+ */
29
+ export function registerMaskQuery(query: MaskQuery): void {
30
+ _query = query;
31
+ }
32
+
33
+ /** Unregister. Mostly for tests / teardown. */
34
+ export function clearMaskQuery(): void {
35
+ _query = null;
36
+ }
37
+
38
+ /** Internal — read by `handlers/screenshot.ts` at capture time. */
39
+ export function getRegisteredMaskQuery(): MaskQuery | null {
40
+ return _query;
41
+ }
package/src/native.ts CHANGED
@@ -11,6 +11,18 @@ type SentoriNativeModule = {
11
11
  release: string
12
12
  token: string
13
13
  }) => void
14
+ /**
15
+ * v0.7.3 — JS-triggered screenshot with consumer-supplied mask IDs.
16
+ * `maskedIds` are RN `nativeID` strings; native walks the view
17
+ * tree, finds each subview by identifier, and paints a black
18
+ * rectangle over its frame in the captured bitmap. Resolves to
19
+ * `null` if there's no key window / API < 24 (Android) / render
20
+ * timed out. Replaced the previous `react-native-view-shot`
21
+ * peer-dep path.
22
+ */
23
+ captureScreenshotWithMask?: (
24
+ maskedIds: string[],
25
+ ) => Promise<null | { base64: string; mediaType: string }>
14
26
  /**
15
27
  * Phase 22 sub-D / sub-E: cross-platform main-thread watchdog.
16
28
  * Android: 5 s / 1 s defaults (matches the OS ANR threshold).
@@ -114,3 +126,26 @@ export function stopAnrWatchdog(): void {
114
126
  // ignore
115
127
  }
116
128
  }
129
+
130
+ /**
131
+ * v0.7.3 — drives the native screenshot path. JS side passes the
132
+ * current list of mask `nativeID`s (read from the consumer's
133
+ * registered mask query); native renders + redacts.
134
+ *
135
+ * Returns `null` on every failure mode: no native module bound
136
+ * (jest, bun test, web), method missing (older native build still
137
+ * deployed), capture failed (no key window, timed out, etc.).
138
+ * Callers must treat `null` as "no screenshot this round" — the
139
+ * error event still ships, just without a thumbnail.
140
+ */
141
+ export async function captureNativeScreenshotWithMask(
142
+ maskedIds: string[],
143
+ ): Promise<null | { base64: string; mediaType: string }> {
144
+ const n = native()
145
+ if (!n?.captureScreenshotWithMask) return null
146
+ try {
147
+ return await n.captureScreenshotWithMask(maskedIds)
148
+ } catch {
149
+ return null
150
+ }
151
+ }