@goliapkg/sentori-react-native 0.6.1 → 0.7.1

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/trail.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { TrailBuffer, type TrailStep } from '@goliapkg/sentori-core';
2
+ /**
3
+ * Phase 46 — record a step into the session-trail buffer. The buffer
4
+ * is a fixed-size FIFO (default 30 steps); pushing past capacity
5
+ * drops the oldest entry. Steps are only uploaded if
6
+ * `init({ capture: { sessionTrail: true } })` is on AND a
7
+ * `captureException` follows.
8
+ */
9
+ export declare const captureStep: (label: string, opts?: Partial<TrailStep>) => void;
10
+ export declare const getTrailBuffer: () => TrailBuffer;
11
+ export declare const __resetTrailForTests: () => void;
12
+ //# sourceMappingURL=trail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trail.d.ts","sourceRoot":"","sources":["../src/trail.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAIrE;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,EAAE,OAAO,OAAO,CAAC,SAAS,CAAC,KAAG,IAMtE,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,WAAqB,CAAC;AAExD,eAAO,MAAM,oBAAoB,QAAO,IAEvC,CAAC"}
package/lib/trail.js ADDED
@@ -0,0 +1,28 @@
1
+ // Phase 46 — singleton TrailBuffer for the RN SDK.
2
+ //
3
+ // Kept in its own module so callers (including navigation.ts, which
4
+ // is intentionally lightweight) can record steps without pulling in
5
+ // capture.ts → handlers/screenshot.ts → react-native. The buffer is
6
+ // drained inside capture.ts when an event captures and
7
+ // `sessionTrailEnabled` is on.
8
+ import { TrailBuffer } from '@goliapkg/sentori-core';
9
+ const _trail = new TrailBuffer(30);
10
+ /**
11
+ * Phase 46 — record a step into the session-trail buffer. The buffer
12
+ * is a fixed-size FIFO (default 30 steps); pushing past capacity
13
+ * drops the oldest entry. Steps are only uploaded if
14
+ * `init({ capture: { sessionTrail: true } })` is on AND a
15
+ * `captureException` follows.
16
+ */
17
+ export const captureStep = (label, opts) => {
18
+ _trail.push({
19
+ ts: Date.now(),
20
+ label,
21
+ ...(opts ?? {}),
22
+ });
23
+ };
24
+ export const getTrailBuffer = () => _trail;
25
+ export const __resetTrailForTests = () => {
26
+ _trail.clear();
27
+ };
28
+ //# sourceMappingURL=trail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trail.js","sourceRoot":"","sources":["../src/trail.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,oEAAoE;AACpE,oEAAoE;AACpE,oEAAoE;AACpE,uDAAuD;AACvD,+BAA+B;AAE/B,OAAO,EAAE,WAAW,EAAkB,MAAM,wBAAwB,CAAC;AAErE,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;AAEnC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,IAAyB,EAAQ,EAAE;IAC5E,MAAM,CAAC,IAAI,CAAC;QACV,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;QACd,KAAK;QACL,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;KAChB,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,GAAgB,EAAE,CAAC,MAAM,CAAC;AAExD,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAS,EAAE;IAC7C,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAqBrC,eAAO,MAAM,OAAO,GAAI,OAAO,KAAK,KAAG,IAUtC,CAAC;AAEF,eAAO,MA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O,MAAM,eAAe,QAAO,IAOlC,CAAC;AAEF,eAAO,MAAM,WAAW,QAAO,SAAS,KAAK,EAAY,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC1B,WAAW,MAAM,EACjB,OAAO,MAAM,EACb,MAAM,OAAO,KACZ,OAAO,CAAC,IAAI,CAcd,CAAC;AAMF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,MAAM,EACf,MAAM,OAAO,SAAS,EAAE,cAAc,CAAC,MAAM,CAAC,EAC9C,MAAM;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAC3C,OAAM;IAAE,MAAM,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,IAAI,CAAA;CAAO,KAC/C,OAAO,CAAC,OAAO,SAAS,EAAE,cAAc,GAAG,IAAI,CAmDjD,CAAC"}
package/lib/transport.js CHANGED
@@ -256,9 +256,16 @@ export const uploadAttachment = async (eventId, kind, blob, opts = {}) => {
256
256
  },
257
257
  method: 'POST',
258
258
  });
259
- if (resp.status !== 201)
259
+ // Phase 48 sub-A: accept any 2xx instead of strict 201. Reverse
260
+ // proxies in front of ingest occasionally rewrite 201 → 202 (the
261
+ // exact symptom Insight observed), and a 200 is also a valid
262
+ // "stored" response. We still require a JSON body shaped like
263
+ // UploadResponse; non-JSON bodies fall through to null.
264
+ if (resp.status < 200 || resp.status >= 300)
265
+ return null;
266
+ const j = (await resp.json().catch(() => null));
267
+ if (!j || !j.refId)
260
268
  return null;
261
- const j = (await resp.json());
262
269
  return {
263
270
  kind,
264
271
  mediaType: j.mediaType,
@@ -1 +1 @@
1
- {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAGrC,MAAM,iBAAiB,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ACf,CAAC,CAAC;QACH,gEAAgE;QAChE,iEAAiE;QACjE,6DAA6D;QAC7D,8DAA8D;QAC9D,wDAAwD;QACxD,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG;YAAE,OAAO,IAAI,CAAC;QACzD,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAK7C,CAAC;QACF,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;YAAE,OAAO,IAAI,CAAC;QAChC,OAAO;YACL,IAAI;YACJ,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,GAAG,EAAE,CAAC,CAAC,KAAK;YACZ,SAAS,EAAE,CAAC,CAAC,SAAS;YACtB,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI;SAC5B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAEF,SAAS,WAAW,CAAC,IAAY,EAAE,SAAiB;IAClD,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC;IAC7C,OAAO,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@goliapkg/sentori-react-native",
3
- "version": "0.6.1",
4
- "description": "Sentori SDK for React Native JS-layer error capture, native crash handlers (iOS / Android), batched transport, fetch + react-navigation tracing.",
3
+ "version": "0.7.1",
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",
7
7
  "repository": {
@@ -69,6 +69,6 @@
69
69
  "access": "public"
70
70
  },
71
71
  "dependencies": {
72
- "@goliapkg/sentori-core": "0.5.0"
72
+ "@goliapkg/sentori-core": "0.6.0"
73
73
  }
74
74
  }
package/src/capture.ts CHANGED
@@ -1,13 +1,18 @@
1
+ import { sealTrail, shouldSample } from '@goliapkg/sentori-core';
2
+
1
3
  import { addBreadcrumb, getBreadcrumbs } from './breadcrumbs';
2
4
  import { getConfig, isInitialized } from './config';
3
5
  import { symbolicateErrorViaMetro } from './handlers/dev-symbolicate';
4
6
  import { captureScreenshot } from './handlers/screenshot';
5
7
  import { markSessionErrored } from './session-tracker';
6
8
  import { parseStack } from './stack';
9
+ import { getTrailBuffer } from './trail';
7
10
  import { enqueue, uploadAttachment } from './transport';
8
11
  import { uuidV7 } from './uuid';
9
12
  import type { App, AttachmentMeta, Device, Event, SentoriError, Tags, User } from './types';
10
13
 
14
+ export { captureStep, __resetTrailForTests } from './trail';
15
+
11
16
  declare const __DEV__: boolean | undefined;
12
17
 
13
18
  let _user: User | null = null;
@@ -60,6 +65,14 @@ export const captureError = (error: Error, extras?: CaptureExtras): void => {
60
65
  const config = getConfig();
61
66
  if (!config) return;
62
67
 
68
+ // Phase 44 sub-B: client-side sampling. Skip the whole pipeline
69
+ // (no screenshot capture either) when the sample dice come up
70
+ // wrong. Default rate = null = keep, so existing callers unaffected.
71
+ if (!shouldSample(config.errorSampleRate)) {
72
+ addBreadcrumb({ type: 'custom', data: { reason: 'sampled-out', kind: 'error' } });
73
+ return;
74
+ }
75
+
63
76
  const event: Event = {
64
77
  id: uuidV7(),
65
78
  timestamp: new Date().toISOString(),
@@ -97,11 +110,49 @@ export const captureError = (error: Error, extras?: CaptureExtras): void => {
97
110
  if (wantScreenshot) {
98
111
  await captureAndAttachScreenshot(event);
99
112
  }
113
+ const trail = getTrailBuffer();
114
+ if (config.sessionTrailEnabled && trail.size() > 0) {
115
+ await captureAndAttachSessionTrail(event);
116
+ }
100
117
  enqueue(event);
101
118
  };
102
119
  void pipeline();
103
120
  };
104
121
 
122
+ /**
123
+ * Phase 46 — seal the trail buffer, upload it as a `sessionTrail`
124
+ * attachment, attach the ref. Best-effort: any failure leaves a
125
+ * breadcrumb and lets the event ship without the trail.
126
+ *
127
+ * The trail is **always cleared** after `captureException`, even if
128
+ * upload fails — we don't want a stale 30-step buffer leaking into
129
+ * the next crash's trail.
130
+ */
131
+ async function captureAndAttachSessionTrail(event: Event): Promise<void> {
132
+ const trail = getTrailBuffer();
133
+ const payload = sealTrail(trail);
134
+ trail.clear();
135
+ const json = JSON.stringify(payload);
136
+ // base64 the JSON for the `data:` URI multipart bridge (same
137
+ // trick the screenshot path uses).
138
+ const base64 =
139
+ typeof globalThis.btoa === 'function'
140
+ ? globalThis.btoa(unescape(encodeURIComponent(json)))
141
+ : Buffer.from(json, 'utf-8').toString('base64');
142
+ const attachment = await uploadAttachment(
143
+ event.id,
144
+ 'sessionTrail',
145
+ { base64, mediaType: 'application/json' },
146
+ { source: 'js' },
147
+ );
148
+ if (!attachment) {
149
+ addBreadcrumb({ type: 'custom', data: { reason: 'session-trail-upload-failed' } });
150
+ return;
151
+ }
152
+ if (!event.attachments) event.attachments = [];
153
+ event.attachments.push(attachment);
154
+ }
155
+
105
156
  export const captureException = captureError;
106
157
 
107
158
  /** Phase 42 sub-D.08: per-session screenshot quota gate. */
package/src/config.ts CHANGED
@@ -6,6 +6,14 @@ export type Config = {
6
6
  enabled: boolean;
7
7
  /** Phase 42 sub-D.07: opt-in screenshot capture on captureException. */
8
8
  screenshotsEnabled: boolean;
9
+ /** Phase 44 sub-B: per-event-class sampling rates 0..1.
10
+ * `null` = keep everything (default). */
11
+ errorSampleRate: null | number;
12
+ traceSampleRate: null | number;
13
+ /** Phase 46: when true, every `captureException` seals the
14
+ * session-trail buffer and uploads it as a `sessionTrail`
15
+ * attachment. Defaults to false. */
16
+ sessionTrailEnabled: boolean;
9
17
  };
10
18
 
11
19
  let _config: Config | null = null;
@@ -20,6 +20,8 @@
20
20
 
21
21
  import { InteractionManager } from 'react-native';
22
22
 
23
+ import { engageMasks } from '../mask';
24
+
23
25
  type CaptureRef = (
24
26
  // Phase 42: the lib accepts a React ref or — when we pass `undefined` —
25
27
  // shoots the root window. We always go for the root (no per-component
@@ -75,6 +77,19 @@ export async function captureScreenshot(): Promise<ScreenshotBlob | null> {
75
77
  requestAnimationFrame(() => resolve());
76
78
  });
77
79
 
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
+
78
93
  try {
79
94
  const base64 = await withTimeout(
80
95
  captureRef(undefined, {
@@ -87,6 +102,7 @@ export async function captureScreenshot(): Promise<ScreenshotBlob | null> {
87
102
  }),
88
103
  CAPTURE_TIMEOUT_MS,
89
104
  );
105
+ restoreMasks();
90
106
  if (!base64) return null;
91
107
  // view-shot doesn't ship a WebP encoder on every RN version.
92
108
  // JPEG q=70 fits the budget too (typical 40-100 KB) and every
@@ -94,6 +110,7 @@ export async function captureScreenshot(): Promise<ScreenshotBlob | null> {
94
110
  // RN minimum we support has it everywhere.
95
111
  return { base64, mediaType: 'image/jpeg' };
96
112
  } catch {
113
+ restoreMasks();
97
114
  return null;
98
115
  }
99
116
  }
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { init } from './init';
2
2
  import { addBreadcrumb } from './breadcrumbs';
3
- import { setUser, getUser, captureError, captureException } from './capture';
3
+ import { setUser, getUser, captureError, captureException, captureStep } from './capture';
4
4
  import { ErrorBoundary } from './error-boundary';
5
5
  import { MaskRegion, setMaskedNode, unsetMaskedNode } from './mask';
6
6
  import {
@@ -16,6 +16,7 @@ export const sentori = {
16
16
  getUser,
17
17
  captureError,
18
18
  captureException,
19
+ captureStep,
19
20
  ErrorBoundary,
20
21
  MaskRegion,
21
22
  setMaskedNode,
@@ -29,7 +30,13 @@ export default sentori;
29
30
 
30
31
  export { init, init as initSentori } from './init';
31
32
  export { addBreadcrumb } from './breadcrumbs';
32
- export { setUser, getUser, captureError, captureException } from './capture';
33
+ export {
34
+ captureError,
35
+ captureException,
36
+ captureStep,
37
+ getUser,
38
+ setUser,
39
+ } from './capture';
33
40
  export { ErrorBoundary } from './error-boundary';
34
41
  export { MaskRegion, setMaskedNode, unsetMaskedNode } from './mask';
35
42
  export {
package/src/init.ts CHANGED
@@ -38,6 +38,21 @@ export type InitOptions = {
38
38
  * installed and `<MaskRegion>` placed over any sensitive UI. The
39
39
  * image is webp q=70 480 px max, < 100 KB typical. */
40
40
  screenshot?: boolean;
41
+ /** Phase 46: record the last N steps (route changes, custom
42
+ * breadcrumbs) leading up to a crash. On `captureException`
43
+ * the buffer is sealed and uploaded as a `sessionTrail`
44
+ * attachment. Defaults to false. */
45
+ sessionTrail?: boolean;
46
+ };
47
+ /** Phase 44 sub-B: client-side sampling. Each rate is `[0, 1]`;
48
+ * absent / null keeps everything. Defaults to 1.0 for both
49
+ * (no drop). Set traces to e.g. 0.1 once the app's at user
50
+ * volume to keep ingest budget under control without changing
51
+ * the server-side quota. Decisions are made per-event for
52
+ * errors and per-trace (all spans together) for traces. */
53
+ sampling?: {
54
+ errors?: null | number;
55
+ traces?: null | number;
41
56
  };
42
57
  };
43
58
 
@@ -62,6 +77,9 @@ export const init = (options: InitOptions): void => {
62
77
  ingestUrl: options.ingestUrl ?? DEFAULT_INGEST_URL,
63
78
  enabled: true,
64
79
  screenshotsEnabled: options.capture?.screenshot === true,
80
+ errorSampleRate: options.sampling?.errors ?? null,
81
+ traceSampleRate: options.sampling?.traces ?? null,
82
+ sessionTrailEnabled: options.capture?.sessionTrail === true,
65
83
  });
66
84
 
67
85
  // Tell the native crash handler about the config so the JSON it writes
package/src/mask.tsx CHANGED
@@ -1,89 +1,143 @@
1
- // Phase 42 sub-D.09/10 — mark UI regions as "do not screenshot".
1
+ // Phase 42 sub-D.09/10 + Phase 48 sub-B — mark UI regions as "do not
2
+ // screenshot" AND actually redact them at capture time.
2
3
  //
3
- // `<MaskRegion>` wraps any subtree the SDK should redact before
4
- // shipping a crash screenshot. It's purely declarative the
5
- // component renders its children as-is in normal flight, but its
6
- // `View` is tagged with `collapsable={false}` + a sentinel
7
- // `nativeID` so the platform-level screenshotters
8
- // (`react-native-view-shot`, the iOS / Android native crash
9
- // capturers we add in sub-E / sub-F) can find it and paint over.
4
+ // `<MaskRegion>` renders its children normally, plus a black overlay
5
+ // `<View>` that sits on top of them with `opacity: 0`. Right before
6
+ // `captureScreenshot()` calls into react-native-view-shot, the SDK
7
+ // flips every registered overlay to `opacity: 1` (black square covers
8
+ // the children), captures, then flips back to `opacity: 0` so the
9
+ // user never sees the overlay. The overlay uses `pointerEvents="none"`
10
+ // so it never intercepts touches.
10
11
  //
11
- // `setMaskedNode(ref)` is the imperative escape hatch: useful
12
- // when the sensitive view isn't yours to wrap (a third-party
13
- // modal, a video player, etc.). Pass a React ref obtained via
14
- // `createRef()` / `useRef()` and the SDK will redact that
15
- // subtree the next time it captures.
16
- //
17
- // `getMaskedRegions()` returns the current set of native tags;
18
- // `captureScreenshot()` would consult this list, but
19
- // `react-native-view-shot` doesn't expose a "redact these rects"
20
- // hook — so this iteration ships the registration API only and
21
- // the rendered overlay lives behind a default-on
22
- // `<View style={{ backgroundColor: '#000' }}>` you can wrap
23
- // yourself. The iOS / Android crash-time screenshotters in
24
- // sub-E / sub-F will read this list before drawing.
12
+ // `setMaskedNode(ref)` is the imperative escape hatch for views you
13
+ // can't wrap. We can't inject an overlay into a foreign view, so the
14
+ // imperative path falls back to setting the registered view's own
15
+ // `opacity: 0` for the capture window content underneath may show
16
+ // through, but that beats sending the sensitive content to the server.
17
+ // Prefer `<MaskRegion>` when you control the subtree.
25
18
 
26
19
  import React, { type ReactNode, useEffect, useRef } from 'react';
27
- import { View, type ViewProps } from 'react-native';
20
+ import { StyleSheet, View, type ViewProps } from 'react-native';
21
+
22
+ /** What we drive in the capture window: any handle with
23
+ * `setNativeProps({ opacity })`. RN's View instance satisfies this. */
24
+ type Maskable = {
25
+ setNativeProps?: (props: { style?: { opacity?: number } }) => void;
26
+ };
28
27
 
29
- /** Component-level node identifiers we've been asked to redact. */
30
- const _maskedRefs = new Set<React.Component | View | unknown>();
28
+ const _maskedRefs = new Set<Maskable>();
29
+ const _maskedOverlays = new Set<Maskable>();
31
30
  const _maskedNativeIds = new Set<string>();
32
31
 
33
32
  /**
34
- * Imperative registration: when you can't wrap the sensitive view
35
- * in `<MaskRegion>`, drop a ref on it and call `setMaskedNode(ref)`.
36
- * Future captures will mask the subtree.
33
+ * Imperative registration: pass a ref obtained via `useRef()` /
34
+ * `createRef()` to a `<View>` you want hidden from screenshots.
37
35
  */
38
- export function setMaskedNode(node: React.Component | View | null | unknown): void {
39
- if (!node) return;
40
- _maskedRefs.add(node);
36
+ export function setMaskedNode(node: null | Maskable | unknown): void {
37
+ if (!node || typeof (node as Maskable).setNativeProps !== 'function') return;
38
+ _maskedRefs.add(node as Maskable);
41
39
  }
42
40
 
43
- /** Removes a previously registered ref. Pair this with mount/unmount
44
- * lifecycle hooks if the node is short-lived. */
45
- export function unsetMaskedNode(node: React.Component | View | null | unknown): void {
41
+ export function unsetMaskedNode(node: null | Maskable | unknown): void {
46
42
  if (!node) return;
47
- _maskedRefs.delete(node);
43
+ _maskedRefs.delete(node as Maskable);
48
44
  }
49
45
 
50
46
  /** Returns the current set of registered masked nodes + nativeIDs.
51
- * Read by the native screenshotter layer in sub-E / sub-F. */
47
+ * Read by the native screenshotter layer (iOS / Android sub-E / F). */
52
48
  export function getMaskedRegions(): {
53
- refs: Set<unknown>;
54
49
  nativeIds: Set<string>;
50
+ overlays: Set<Maskable>;
51
+ refs: Set<Maskable>;
55
52
  } {
56
- return { nativeIds: _maskedNativeIds, refs: _maskedRefs };
53
+ return { nativeIds: _maskedNativeIds, overlays: _maskedOverlays, refs: _maskedRefs };
54
+ }
55
+
56
+ /**
57
+ * Phase 48 sub-B — engage masking right before screenshot capture.
58
+ * Returns a function the caller must invoke once capture is done so
59
+ * the user never sees the black overlays.
60
+ *
61
+ * Two paths:
62
+ * - Overlays from `<MaskRegion>`: flip opacity 0 → 1 (cover children).
63
+ * - Imperative refs from `setMaskedNode`: flip opacity 1 → 0 on the
64
+ * view itself (whole subtree disappears for one frame).
65
+ *
66
+ * All `setNativeProps` calls are best-effort — a failure on one
67
+ * doesn't block the others or the capture.
68
+ */
69
+ export function engageMasks(): () => void {
70
+ const overlaysEngaged: Maskable[] = [];
71
+ for (const o of _maskedOverlays) {
72
+ try {
73
+ o.setNativeProps?.({ style: { opacity: 1 } });
74
+ overlaysEngaged.push(o);
75
+ } catch {
76
+ // skip
77
+ }
78
+ }
79
+ const refsEngaged: Maskable[] = [];
80
+ for (const r of _maskedRefs) {
81
+ try {
82
+ r.setNativeProps?.({ style: { opacity: 0 } });
83
+ refsEngaged.push(r);
84
+ } catch {
85
+ // skip
86
+ }
87
+ }
88
+ return () => {
89
+ for (const o of overlaysEngaged) {
90
+ try {
91
+ o.setNativeProps?.({ style: { opacity: 0 } });
92
+ } catch {
93
+ // skip
94
+ }
95
+ }
96
+ for (const r of refsEngaged) {
97
+ try {
98
+ r.setNativeProps?.({ style: { opacity: 1 } });
99
+ } catch {
100
+ // skip
101
+ }
102
+ }
103
+ };
57
104
  }
58
105
 
59
106
  /**
60
107
  * Declarative redaction. `<MaskRegion>{children}</MaskRegion>` keeps
61
- * the children visible in normal flight; under capture, the wrapping
62
- * view is repainted black so the rendered screenshot doesn't leak
63
- * the underlying pixels.
108
+ * the children visible in normal flight; under capture the overlay's
109
+ * opacity is flipped to 1 and the children are hidden behind a black
110
+ * square in the rendered screenshot.
64
111
  */
65
112
  export function MaskRegion({
66
113
  children,
67
114
  nativeID,
68
115
  ...rest
69
116
  }: { children: ReactNode; nativeID?: string } & ViewProps): React.JSX.Element {
70
- // Auto-generate a stable nativeID per mount so the native
71
- // screenshotter can find this view by ID at capture time.
72
117
  const idRef = useRef<string>(
73
118
  nativeID ?? `sentori-mask-${Math.random().toString(36).slice(2, 10)}`,
74
119
  );
120
+ const overlayRef = useRef<null | View>(null);
75
121
 
76
122
  useEffect(() => {
77
123
  const id = idRef.current;
78
124
  _maskedNativeIds.add(id);
125
+ const overlay = overlayRef.current as null | Maskable;
126
+ if (overlay) _maskedOverlays.add(overlay);
79
127
  return () => {
80
128
  _maskedNativeIds.delete(id);
129
+ if (overlay) _maskedOverlays.delete(overlay);
81
130
  };
82
131
  }, []);
83
132
 
84
133
  return (
85
134
  <View collapsable={false} nativeID={idRef.current} {...rest}>
86
135
  {children}
136
+ <View
137
+ pointerEvents="none"
138
+ ref={overlayRef}
139
+ style={[StyleSheet.absoluteFill, { backgroundColor: '#000', opacity: 0 }]}
140
+ />
87
141
  </View>
88
142
  );
89
143
  }
@@ -91,5 +145,6 @@ export function MaskRegion({
91
145
  /** Test-only — flush registration tables. */
92
146
  export function __resetMaskedRegionsForTests(): void {
93
147
  _maskedRefs.clear();
148
+ _maskedOverlays.clear();
94
149
  _maskedNativeIds.clear();
95
150
  }
package/src/navigation.ts CHANGED
@@ -24,6 +24,8 @@ import { useEffect, useRef } from 'react';
24
24
 
25
25
  import { setActiveSpan, startSpan, type SpanHandle } from '@goliapkg/sentori-core';
26
26
 
27
+ import { captureStep } from './trail';
28
+
27
29
  /** Minimal contract: anything with `addListener('state', cb)` and
28
30
  * `getCurrentRoute()` works. The real @react-navigation/native
29
31
  * NavigationContainer ref matches this shape. */
@@ -72,6 +74,12 @@ export function useTraceNavigation(navigationRef: NavigationRefLike): void {
72
74
  openSpanRef.current = span;
73
75
  setActiveSpan(span);
74
76
  lastRouteRef.current = to;
77
+ // Phase 46 — record the screen transition into the session trail.
78
+ // No-op when sessionTrail isn't enabled (the buffer just grows
79
+ // unbounded until cleared by captureException, but stays cheap).
80
+ captureStep(`screen:${to}`, {
81
+ breadcrumb: { type: 'navigation', message: from ? `${from} → ${to}` : to },
82
+ });
75
83
  };
76
84
 
77
85
  // Open a span for the initial screen so its requests are grouped
package/src/trail.ts ADDED
@@ -0,0 +1,32 @@
1
+ // Phase 46 — singleton TrailBuffer for the RN SDK.
2
+ //
3
+ // Kept in its own module so callers (including navigation.ts, which
4
+ // is intentionally lightweight) can record steps without pulling in
5
+ // capture.ts → handlers/screenshot.ts → react-native. The buffer is
6
+ // drained inside capture.ts when an event captures and
7
+ // `sessionTrailEnabled` is on.
8
+
9
+ import { TrailBuffer, type TrailStep } from '@goliapkg/sentori-core';
10
+
11
+ const _trail = new TrailBuffer(30);
12
+
13
+ /**
14
+ * Phase 46 — record a step into the session-trail buffer. The buffer
15
+ * is a fixed-size FIFO (default 30 steps); pushing past capacity
16
+ * drops the oldest entry. Steps are only uploaded if
17
+ * `init({ capture: { sessionTrail: true } })` is on AND a
18
+ * `captureException` follows.
19
+ */
20
+ export const captureStep = (label: string, opts?: Partial<TrailStep>): void => {
21
+ _trail.push({
22
+ ts: Date.now(),
23
+ label,
24
+ ...(opts ?? {}),
25
+ });
26
+ };
27
+
28
+ export const getTrailBuffer = (): TrailBuffer => _trail;
29
+
30
+ export const __resetTrailForTests = (): void => {
31
+ _trail.clear();
32
+ };
package/src/transport.ts CHANGED
@@ -295,13 +295,19 @@ export const uploadAttachment = async (
295
295
  },
296
296
  method: 'POST',
297
297
  });
298
- if (resp.status !== 201) return null;
299
- const j = (await resp.json()) as {
298
+ // Phase 48 sub-A: accept any 2xx instead of strict 201. Reverse
299
+ // proxies in front of ingest occasionally rewrite 201 → 202 (the
300
+ // exact symptom Insight observed), and a 200 is also a valid
301
+ // "stored" response. We still require a JSON body shaped like
302
+ // UploadResponse; non-JSON bodies fall through to null.
303
+ if (resp.status < 200 || resp.status >= 300) return null;
304
+ const j = (await resp.json().catch(() => null)) as null | {
300
305
  refId: string;
301
306
  sizeBytes: number;
302
307
  mediaType: string;
303
308
  kind: string;
304
309
  };
310
+ if (!j || !j.refId) return null;
305
311
  return {
306
312
  kind,
307
313
  mediaType: j.mediaType,