@goliapkg/sentori-react-native 0.7.1 → 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.d.ts CHANGED
@@ -1,52 +1,16 @@
1
- import React, { type ReactNode } from 'react';
2
- import { type ViewProps } from 'react-native';
3
- /** What we drive in the capture window: any handle with
4
- * `setNativeProps({ opacity })`. RN's View instance satisfies this. */
5
- type Maskable = {
6
- setNativeProps?: (props: {
7
- style?: {
8
- opacity?: number;
9
- };
10
- }) => void;
11
- };
1
+ type MaskQuery = () => string[];
12
2
  /**
13
- * Imperative registration: pass a ref obtained via `useRef()` /
14
- * `createRef()` to a `<View>` you want hidden from screenshots.
15
- */
16
- export declare function setMaskedNode(node: null | Maskable | unknown): void;
17
- export declare function unsetMaskedNode(node: null | Maskable | unknown): void;
18
- /** Returns the current set of registered masked nodes + nativeIDs.
19
- * Read by the native screenshotter layer (iOS / Android sub-E / F). */
20
- export declare function getMaskedRegions(): {
21
- nativeIds: Set<string>;
22
- overlays: Set<Maskable>;
23
- refs: Set<Maskable>;
24
- };
25
- /**
26
- * Phase 48 sub-B — engage masking right before screenshot capture.
27
- * Returns a function the caller must invoke once capture is done so
28
- * the user never sees the black overlays.
29
- *
30
- * Two paths:
31
- * - Overlays from `<MaskRegion>`: flip opacity 0 → 1 (cover children).
32
- * - Imperative refs from `setMaskedNode`: flip opacity 1 → 0 on the
33
- * view itself (whole subtree disappears for one frame).
3
+ * Register a callback the SDK calls right before each screenshot
4
+ * capture. Return the native-IDs (the `nativeID` prop on the RN
5
+ * `<View>`) that should be blacked-out in the captured image.
34
6
  *
35
- * All `setNativeProps` calls are best-effort a failure on one
36
- * doesn't block the others or the capture.
37
- */
38
- export declare function engageMasks(): () => void;
39
- /**
40
- * Declarative redaction. `<MaskRegion>{children}</MaskRegion>` keeps
41
- * the children visible in normal flight; under capture the overlay's
42
- * opacity is flipped to 1 and the children are hidden behind a black
43
- * square in the rendered screenshot.
7
+ * Idempotent: a second call replaces the first. Pass `null` (or
8
+ * call `clearMaskQuery`) to detach.
44
9
  */
45
- export declare function MaskRegion({ children, nativeID, ...rest }: {
46
- children: ReactNode;
47
- nativeID?: string;
48
- } & ViewProps): React.JSX.Element;
49
- /** Test-only flush registration tables. */
50
- export declare function __resetMaskedRegionsForTests(): void;
10
+ export declare function registerMaskQuery(query: MaskQuery): void;
11
+ /** Unregister. Mostly for tests / teardown. */
12
+ export declare function clearMaskQuery(): void;
13
+ /** Internal read by `handlers/screenshot.ts` at capture time. */
14
+ export declare function getRegisteredMaskQuery(): MaskQuery | null;
51
15
  export {};
52
16
  //# sourceMappingURL=mask.d.ts.map
package/lib/mask.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../src/mask.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AACjE,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEhE;wEACwE;AACxE,KAAK,QAAQ,GAAG;IACd,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,KAAK,IAAI,CAAC;CACpE,CAAC;AAMF;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAGnE;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,GAAG,IAAI,CAGrE;AAED;wEACwE;AACxE,wBAAgB,gBAAgB,IAAI;IAClC,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,QAAQ,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,IAAI,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;CACrB,CAEA;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,IAAI,MAAM,IAAI,CAmCxC;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAQ,EACR,GAAG,IAAI,EACR,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA2B5E;AAED,6CAA6C;AAC7C,wBAAgB,4BAA4B,IAAI,IAAI,CAInD"}
1
+ {"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../src/mask.ts"],"names":[],"mappings":"AAgBA,KAAK,SAAS,GAAG,MAAM,MAAM,EAAE,CAAC;AAIhC;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAExD;AAED,+CAA+C;AAC/C,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,mEAAmE;AACnE,wBAAgB,sBAAsB,IAAI,SAAS,GAAG,IAAI,CAEzD"}
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;AACnE,sEAAsE;AACtE,kEAAkE;AAClE,uEAAuE;AACvE,kCAAkC;AAClC,EAAE;AACF,oEAAoE;AACpE,qEAAqE;AACrE,kEAAkE;AAClE,oEAAoE;AACpE,uEAAuE;AACvE,sDAAsD;AAEtD,OAAc,EAAkB,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,cAAc,CAAC;AAQhE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAY,CAAC;AACxC,MAAM,eAAe,GAAG,IAAI,GAAG,EAAY,CAAC;AAC5C,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;AAE3C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAA+B;IAC3D,IAAI,CAAC,IAAI,IAAI,OAAQ,IAAiB,CAAC,cAAc,KAAK,UAAU;QAAE,OAAO;IAC7E,WAAW,CAAC,GAAG,CAAC,IAAgB,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAA+B;IAC7D,IAAI,C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,EAAE,CAAC,GACzE,IACG,CACR,CAAC;AACJ,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,4BAA4B;IAC1C,WAAW,CAAC,KAAK,EAAE,CAAC;IACpB,eAAe,CAAC,KAAK,EAAE,CAAC;IACxB,gBAAgB,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"mask.js","sourceRoot":"","sources":["../src/mask.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,EAAE;AACF,kEAAkE;AAClE,8DAA8D;AAC9D,mEAAmE;AACnE,oEAAoE;AACpE,qEAAqE;AACrE,EAAE;AACF,gEAAgE;AAChE,qEAAqE;AACrE,kEAAkE;AAClE,iEAAiE;AACjE,qEAAqE;AACrE,mEAAmE;AACnE,oBAAoB;AAIpB,IAAI,MAAM,GAAqB,IAAI,CAAC;AAEpC;;;;;;;GAOG;AACH,MAAM,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,C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A;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.1",
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",
@@ -69,6 +64,6 @@
69
64
  "access": "public"
70
65
  },
71
66
  "dependencies": {
72
- "@goliapkg/sentori-core": "0.6.0"
67
+ "@goliapkg/sentori-core": "0.7.0"
73
68
  }
74
69
  }
@@ -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,3 +1,5 @@
1
+ import { coerceError } from '@goliapkg/sentori-core';
2
+
1
3
  import { captureError } from '../capture';
2
4
 
3
5
  type RejectionTracker = (opts: {
@@ -22,9 +24,11 @@ export const installPromiseHandler = (): void => {
22
24
  allRejections: true,
23
25
  onUnhandled: (_id, rejection) => {
24
26
  try {
25
- const err =
26
- rejection instanceof Error ? rejection : new Error(String(rejection));
27
- captureError(err);
27
+ // `coerceError` keeps the actual rejection visible. JS code
28
+ // routinely rejects with plain objects (`Promise.reject({code})`),
29
+ // which would otherwise collapse to the literal text
30
+ // `[object Object]` in the dashboard.
31
+ captureError(coerceError(rejection));
28
32
  } catch {
29
33
  // never throw
30
34
  }
@@ -1,56 +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
- // - Wait for the in-flight RN interaction batch to drain before
6
- // touching the view shot (`InteractionManager.runAfterInteractions`)
7
- // so we never extend the active gesture / animation by a frame.
8
- // - Yield one paint by chaining a `requestAnimationFrame` so the
9
- // screenshot reflects post-error UI state, not the frame that
10
- // was already half-laid-out.
11
- // - Capped output: 480 px on the longest edge, WebP q=70. Typical
12
- // payload 30-80 KB; multipart hard cap is 500 KB.
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.
10
+ //
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.
18
+ //
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.
13
25
  // - On any failure we silently return null. The error event still
14
26
  // goes to the server; the user just doesn't see a thumbnail.
15
- //
16
- // `react-native-view-shot` is an OPTIONAL peer. We `require()` it
17
- // lazily so apps that don't install it never pay the bundle cost
18
- // or fail at import time. Without it, `captureScreenshot()` returns
19
- // `null` immediately.
20
-
21
- import { InteractionManager } from 'react-native';
22
-
23
- import { engageMasks } from '../mask';
24
-
25
- type CaptureRef = (
26
- // Phase 42: the lib accepts a React ref or — when we pass `undefined` —
27
- // shoots the root window. We always go for the root (no per-component
28
- // ref) so the screenshot lines up with what the user just saw.
29
- refOrUndefined: undefined,
30
- opts: {
31
- format?: 'jpg' | 'png' | 'webm';
32
- quality?: number;
33
- result?: 'base64' | 'data-uri' | 'tmpfile';
34
- width?: number;
35
- height?: number;
36
- },
37
- ) => Promise<string>;
38
-
39
- type ViewShotModule = { captureRef?: CaptureRef; default?: { captureRef?: CaptureRef } };
40
-
41
- function loadCaptureRef(): CaptureRef | null {
42
- try {
43
- // eslint-disable-next-line @typescript-eslint/no-require-imports
44
- const mod = require('react-native-view-shot') as ViewShotModule;
45
- return mod.captureRef ?? mod.default?.captureRef ?? null;
46
- } catch {
47
- return null;
48
- }
49
- }
50
27
 
51
- const MAX_LONG_EDGE_PX = 480;
52
- const WEBP_QUALITY = 0.7;
53
- const CAPTURE_TIMEOUT_MS = 1500;
28
+ import { getRegisteredMaskQuery } from '../mask';
29
+ import { captureNativeScreenshotWithMask } from '../native';
54
30
 
55
31
  /** What `captureScreenshot()` hands back when it succeeds. */
56
32
  export type ScreenshotBlob = {
@@ -60,73 +36,34 @@ export type ScreenshotBlob = {
60
36
 
61
37
  /**
62
38
  * Take one screenshot, yielding the JS thread first. Returns null on
63
- * any error (missing peer dep, native side refused, timeout, etc.).
64
- * 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`).
65
42
  */
66
43
  export async function captureScreenshot(): Promise<ScreenshotBlob | null> {
67
- const captureRef = loadCaptureRef();
68
- if (!captureRef) return null;
69
-
70
- // Wait for the in-flight RN interaction batch to drain. This is
71
- // why screenshot capture doesn't visibly stall the user's last
72
- // action — we let React commit before we ask the OS to render.
73
- await new Promise<void>((resolve) => {
74
- InteractionManager.runAfterInteractions(() => resolve());
75
- });
44
+ // Yield one paint frame so the post-error UI has committed before
45
+ // we ask the OS to snapshot it.
76
46
  await new Promise<void>((resolve) => {
77
47
  requestAnimationFrame(() => resolve());
78
48
  });
79
49
 
80
- // Phase 48 sub-B flip every registered MaskRegion overlay to
81
- // opacity 1 (black covers the children) and every imperative
82
- // setMaskedNode ref to opacity 0 (subtree disappears). Held for
83
- // exactly one frame's worth of capture, then restored.
84
- const restoreMasks = engageMasks();
85
- // Yield one more frame so the overlay paint reaches the screen
86
- // before captureRef snapshots. Without this the overlay opacity
87
- // change is queued but the screenshotter may see the previous
88
- // frame.
89
- await new Promise<void>((resolve) => {
90
- requestAnimationFrame(() => resolve());
91
- });
92
-
93
- try {
94
- const base64 = await withTimeout(
95
- captureRef(undefined, {
96
- format: 'jpg',
97
- quality: WEBP_QUALITY,
98
- result: 'base64',
99
- // Long-edge cap. RN view-shot scales preserving aspect ratio
100
- // when only one dimension is set.
101
- width: MAX_LONG_EDGE_PX,
102
- }),
103
- CAPTURE_TIMEOUT_MS,
104
- );
105
- restoreMasks();
106
- if (!base64) return null;
107
- // view-shot doesn't ship a WebP encoder on every RN version.
108
- // JPEG q=70 fits the budget too (typical 40-100 KB) and every
109
- // version handles it identically. We can swap to WebP once the
110
- // RN minimum we support has it everywhere.
111
- return { base64, mediaType: 'image/jpeg' };
112
- } catch {
113
- restoreMasks();
114
- 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
+ }
115
64
  }
116
- }
117
65
 
118
- function withTimeout<T>(p: Promise<T>, ms: number): Promise<T | null> {
119
- return new Promise((resolve) => {
120
- const t = setTimeout(() => resolve(null as unknown as T), ms);
121
- p.then(
122
- (v) => {
123
- clearTimeout(t);
124
- resolve(v);
125
- },
126
- () => {
127
- clearTimeout(t);
128
- resolve(null as unknown as T);
129
- },
130
- );
131
- });
66
+ const result = await captureNativeScreenshotWithMask(maskedIds);
67
+ if (!result) return null;
68
+ return { base64: result.base64, mediaType: result.mediaType };
132
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`