@oneuptime/react-native-replay 17.0.0 → 17.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/README.md CHANGED
@@ -128,8 +128,8 @@ await OneUptimeReplay.revokeConsent();
128
128
  ```
129
129
 
130
130
  Revocation stops capture and clears the in-memory buffer, session identifier,
131
- anonymous visitor identifier, and AsyncStorage outbox. A later grant starts a
132
- new visit.
131
+ anonymous visitor identifier, AsyncStorage outbox, and the product analytics
132
+ events kept unsent. A later grant starts a new visit.
133
133
 
134
134
  ## Identity, tags, events, and routes
135
135
 
@@ -160,7 +160,11 @@ Identity and traits are sent only when the RUM application's policy enables
160
160
  user-identity capture. Under mobile's mandatory `MaskAllText`, trait values,
161
161
  custom-event property values, and manual-capture reasons use the same coarse
162
162
  text masks as the browser recorder. Event names and the explicitly supplied
163
- user reference stay readable. Tag values deliberately stay readable and
163
+ user reference stay readable. So does a custom-event property or metric
164
+ attribute whose key the application lists under **Readable event
165
+ properties** on its Replay Policy page, while its value is a short token
166
+ (letters, digits and `_ . : / -`, at most 32 characters); any other value
167
+ under that key is still masked, and traits always are. Tag values deliberately stay readable and
164
168
  searchable, matching the browser contract; do not use tags for secrets. All
165
169
  maps remain count/length bounded. Routes always drop query strings and
166
170
  fragments and are stored as `app://com.example.checkout/checkout`. The
@@ -195,22 +199,39 @@ in `src/ProductAnalyticsContract.ts` and held to it by `ContractParity`):
195
199
  session the grant opens; `revokeConsent()` drops them.
196
200
  - **Masked as the recording is.** The SDK always masks text, so property,
197
201
  attribute and trait values arrive masked; event names, keys and metric
198
- values are sent as written. A screen is its scrubbed route.
202
+ values are sent as written. A screen is its scrubbed route. A property or
203
+ attribute whose key the application lists as a readable event property
204
+ keeps a short token value as written, as the recording's marker does.
199
205
  - **Small batches.** Every 5 seconds and as the app leaves the foreground,
200
206
  at most 100 events and 100 metric points each, one session's and one
201
207
  person's per batch. A failed batch is retried with backoff up to 5 minutes
202
208
  (a `Retry-After` is honoured up to 300 seconds), at once when the app
203
209
  returns to the foreground or a `connectivity` source says the device is
204
210
  back online, and nothing is tried while it says the device is offline.
205
- Events are held in memory: an app killed while offline loses the ones it
206
- had not sent. A 204, 400 or 403 stops them until the next `start()`.
211
+ A batch sent again says when it was sent again, so its events are filed
212
+ when they happened. A 204, 400 or 403 stops them until the next `start()`,
213
+ and drops what was held.
214
+ - **Kept across a relaunch.** What has not been sent is also kept in
215
+ AsyncStorage, under its own key: an app used offline (on a plane, in a
216
+ tunnel) and then killed, or stopped by the system in the background, sends
217
+ those events and metric points after its next `start()`, under the session
218
+ and the person they happened under, and the batch that was on its way
219
+ under its own id. It is written a second after a change and at once as the
220
+ app leaves the foreground, holds at most 500 events and 500 metric points
221
+ in at most 512 KB (the oldest left out first), and drops what is older
222
+ than the server's 3 days before sending. Nothing held before a required
223
+ consent is written, and `revokeConsent()` - or a policy that starts
224
+ requiring consent - deletes it.
207
225
  - **The context** is the one recorded sessions are filed under: `mobile`,
208
226
  or `tablet` from a shorter side of 600 points; the system the native
209
227
  module names; and the `appVersion` start option, or the binary's own.
210
228
  - **Diagnostics.** `getDiagnostics().productAnalytics` reports `state`
211
- (`off`, `on`, or why they stopped), `pending` and `dropped`; the codes
212
- `analytics-started`, `analytics-stopped`, `metric-analytics-off`,
213
- `metric-name-refused` and `metric-value-refused` say what happened.
229
+ (`off`, `on`, or why they stopped), `pending` (what waits to be sent,
230
+ what a relaunch brought back included) and `dropped` (events dropped
231
+ because too many waited, or they waited longer than 3 days); the codes
232
+ `analytics-started`, `analytics-restored`, `analytics-store-unreadable`,
233
+ `analytics-stopped`, `metric-analytics-off`, `metric-name-refused` and
234
+ `metric-value-refused` say what happened.
214
235
 
215
236
  `metric()` sends nothing while the events are off for the application.
216
237
 
@@ -235,20 +256,33 @@ pre-roll is uploaded after a manual or JavaScript error trigger.
235
256
  ## Frustration signals of your own
236
257
 
237
258
  A RUM application can name signals of its own on its **Frustration Signals**
238
- page in OneUptime, and this SDK detects three kinds of them with no code change:
259
+ page in OneUptime, and this SDK detects four kinds of them with no code change:
239
260
 
240
- | signal | fires when |
241
- | ------ | ---------------------------------------------------------------------------------------------------------------------------------- |
242
- | page | `setRoute()` moves to a route whose path matches the pattern (`*` stands for any characters; case, query and fragment are ignored) |
243
- | event | `track()` is called with that event name (case is ignored) |
244
- | error | a JavaScript error or `captureError()` carries a message containing the given words (case is ignored) |
261
+ | signal | fires when |
262
+ | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
263
+ | tap | a tap lands on a view whose `testID` is the one named, or starts with it when the pattern ends in `*` (`product-card-*`), or on anything inside it (case is ignored) |
264
+ | page | `setRoute()` moves to a route whose path matches the pattern (`*` stands for any characters; case, query and fragment are ignored) |
265
+ | event | `track()` is called with that event name (case is ignored) |
266
+ | error | a JavaScript error or `captureError()` carries a message containing the given words (case is ignored) |
245
267
 
246
268
  A hit is recorded as a marker carrying the signal's **name** only - never the
247
- route, the event's properties or the error's text, which are only compared on
248
- the device - and counted on the chunk. A signal that counts as frustration
249
- starts the upload in error-triggered mode, like an error. The same name fires
250
- at most once a second, and a chunk holds at most 50 markers. Nothing is
251
- detected while capture is paused because nobody is using the app.
269
+ route, the event's properties, the error's text or a view's `testID`, which
270
+ are only compared on the device - and counted on the chunk. A tap signal's
271
+ marker also says where on the screen the tap was, as the recorded touch does,
272
+ except on a view inside a `ReplayMask`, an image, a web view or another view
273
+ the replay never records. A signal that counts as frustration starts the
274
+ upload in error-triggered mode, like an error. The same name fires at most
275
+ once a second, and a chunk holds at most 50 markers. Nothing is detected while
276
+ capture is paused because nobody is using the app.
277
+
278
+ A tap is a touch that ends within 10 points of where it started, on the view
279
+ it started on: a finger that slides further was scrolling. Give the views you
280
+ want to name a `testID` (`<Pressable testID="pay-button">`): the SDK reads the
281
+ touched view's `testID` and those of the views around it from the native
282
+ module, so a tap on a label inside a named button is a tap on the button. A
283
+ binary built with an older version of this SDK's native code (a JavaScript-only
284
+ over-the-air update) detects no tap signal and records everything else as
285
+ before.
252
286
 
253
287
  Signals that react to a click on an element are CSS selectors on a web page,
254
288
  and the built-in rage, dead and error clicks and refresh rage are about a mouse
@@ -35,6 +35,9 @@ public final class OneUptimeReplayViewTreeModule extends ReactContextBaseJavaMod
35
35
  private static final String REPLAY_MASK_TEST_ID = "oneuptime-replay-mask";
36
36
  private static final int MAX_TREE_DEPTH = 64;
37
37
  private static final int MAX_TREE_NODES = 5000;
38
+ /* A tap signal's match is at most 200 characters; a longer testID never matches. */
39
+ private static final int MAX_TAP_TEST_ID_LENGTH = 200;
40
+ private static final int MAX_TAP_TEST_IDS = 32;
38
41
 
39
42
  private static final class TraversalState {
40
43
  int visited = 0;
@@ -166,6 +169,69 @@ public final class OneUptimeReplayViewTreeModule extends ReactContextBaseJavaMod
166
169
  });
167
170
  }
168
171
 
172
+ /*
173
+ * The testIDs of the touched view and of the views around it, out to the
174
+ * replay root, the touched one first: what the application's tap signals
175
+ * are matched against in JavaScript, on the device, and never recorded.
176
+ * Only the testID tag React Native sets is read - no text, content or
177
+ * accessibility label - and nothing is offered for a target outside the
178
+ * replay root or a tag that no longer resolves.
179
+ */
180
+ @ReactMethod
181
+ public void touchTargetTestIds(
182
+ double targetTagValue,
183
+ double replayRootTagValue,
184
+ Promise promise
185
+ ) {
186
+ if (!isReactTag(targetTagValue) || !isReactTag(replayRootTagValue)) {
187
+ promise.resolve(Arguments.createArray());
188
+ return;
189
+ }
190
+
191
+ final int targetTag = (int) targetTagValue;
192
+ final int replayRootTag = (int) replayRootTagValue;
193
+ UiThreadUtil.runOnUiThread(() -> {
194
+ try {
195
+ View target = resolveView(targetTag);
196
+ View replayRoot = resolveView(replayRootTag);
197
+ if (target == null || replayRoot == null) {
198
+ promise.resolve(Arguments.createArray());
199
+ return;
200
+ }
201
+
202
+ WritableArray testIds = Arguments.createArray();
203
+ int found = 0;
204
+ int depth = 0;
205
+ View current = target;
206
+ while (current != null && depth <= MAX_TREE_DEPTH) {
207
+ Object testId = current.getTag(com.facebook.react.R.id.react_test_id);
208
+ if (testId instanceof String && found < MAX_TAP_TEST_IDS) {
209
+ String value = (String) testId;
210
+ if (!value.isEmpty() && value.length() <= MAX_TAP_TEST_ID_LENGTH
211
+ && !REPLAY_MASK_TEST_ID.equals(value)) {
212
+ testIds.pushString(value);
213
+ found += 1;
214
+ }
215
+ }
216
+ if (current == replayRoot) {
217
+ promise.resolve(testIds);
218
+ return;
219
+ }
220
+
221
+ android.view.ViewParent parent = current.getParent();
222
+ current = parent instanceof View ? (View) parent : null;
223
+ depth += 1;
224
+ }
225
+
226
+ /* The event target was not a descendant of this replay root. */
227
+ promise.resolve(Arguments.createArray());
228
+ } catch (Throwable ignored) {
229
+ /* A stale tag or a renderer error matches no tap signal. */
230
+ promise.resolve(Arguments.createArray());
231
+ }
232
+ });
233
+ }
234
+
169
235
  private WritableMap serializeView(
170
236
  View view,
171
237
  int rootX,