@logbrew/react-native 0.1.42 → 0.1.43

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
@@ -860,7 +860,7 @@ await resourceFetch("https://api.example.com/graphql?email=hidden", {
860
860
  });
861
861
  ```
862
862
 
863
- `createReactNativeResourceFetch()` wraps the fetch function your app supplies, or the runtime `fetch` when available. It records status, method, duration, response-start timing, sanitized route template, screen, session, primitive metadata, response size when `Content-Length` is available, and trace correlation. `metadataFactory` is called after each fetch completes or fails so apps can add low-cardinality request metadata such as `graphqlOperationName` or `graphqlOperationType`; by default LogBrew does not parse GraphQL payloads. If you set `measureResponseBodySize: true`, LogBrew can fall back to measuring a cloned response body's byte length when the response omits `Content-Length`; it returns the original response untouched and does not store the response content. Metadata returned from the factory keeps only primitive values and drops sensitive request fields. It does not patch global `fetch` or XHR, inspect request or response bodies by default, capture arbitrary headers, or attach `traceparent` outside `tracePropagationTargets`. Pass `trace` explicitly after `await` boundaries or build the wrapper from provider/hook state so async resource spans stay correlated.
863
+ `createReactNativeResourceFetch()` wraps the fetch function your app supplies, or the runtime `fetch` when available. It records status, method, duration, response-start timing, sanitized route template, screen, session, primitive metadata, response size when `Content-Length` is available, and trace correlation. Without `routeTemplate` or `routeTemplateFactory`, the route template is the URL path with each numeric, UUID, or long hex (16 or more characters) segment replaced by `:id`, so `/orders/8412/items/77` becomes `/orders/:id/items/:id`. Pass `routeTemplateFactory: ({ url }) => name` to name requests yourself, or `routeTemplate` for one fixed name. `metadataFactory` is called after each fetch completes or fails so apps can add low-cardinality request metadata such as `graphqlOperationName` or `graphqlOperationType`; by default LogBrew does not parse GraphQL payloads. If you set `measureResponseBodySize: true`, LogBrew can fall back to measuring a cloned response body's byte length when the response omits `Content-Length`; it returns the original response untouched and does not store the response content. Metadata returned from the factory keeps only primitive values and drops sensitive request fields. It does not patch global `fetch` or XHR, inspect request or response bodies by default, capture arbitrary headers, or attach `traceparent` outside `tracePropagationTargets`. Pass `trace` explicitly after `await` boundaries or build the wrapper from provider/hook state so async resource spans stay correlated.
864
864
  `createReactNativeGraphQLMetadataFactory()` is an explicit helper for GraphQL requests your app already owns. Pass `endpoint` as a route template, absolute URL without query/hash, `RegExp`, predicate, or an array of those when you use it with broader fetch/XHR instrumentation; LogBrew compares route templates and query-stripped URL paths before parsing. It reads only a JSON string request body to derive `graphqlOperationName` and `graphqlOperationType`, drops variables/query text/body fields, ignores large or non-JSON bodies, and can compose an existing primitive metadata factory. Do not use it on unrelated endpoints without an endpoint matcher.
865
865
 
866
866
  If your app uses Apollo Client, use the optional Apollo subpath with the `ApolloLink` constructor your app already imports:
package/index.cjs CHANGED
@@ -36,7 +36,7 @@ const { getReactNativeContext } = require("./index-values.cjs");
36
36
  */
37
37
 
38
38
  const DEFAULT_SDK_NAME = "logbrew-react-native";
39
- const DEFAULT_SDK_VERSION = "0.1.42";
39
+ const DEFAULT_SDK_VERSION = "0.1.43";
40
40
  const DEFAULT_REACT_NATIVE_DELIVERY_INTERVAL_MS = 1000;
41
41
  const DEFAULT_MAX_RETRIES = 2;
42
42
 
@@ -253,13 +253,21 @@ function toText(value) {
253
253
  return typeof value === "string" ? value : String(value);
254
254
  }
255
255
 
256
+ const RECORD_ID_SEGMENT = /^(?:\d+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}|[0-9a-f]{16,})$/iu;
257
+
256
258
  /**
259
+ * Names a request by its path with numeric, UUID, and long hex segments replaced by `:id`, so the
260
+ * name holds no record ID and stays low-cardinality.
257
261
  * @param {{ readonly url: unknown }} context
258
262
  * @returns {string}
259
263
  */
260
264
  function defaultRouteTemplateFactory({ url }) {
261
265
  const parsedUrl = parseUrl(url);
262
- return parsedUrl === undefined ? stripQueryAndHash(toText(url)) : parsedUrl.pathname;
266
+ const pathname = parsedUrl === undefined ? stripQueryAndHash(toText(url)) : parsedUrl.pathname;
267
+ return pathname
268
+ .split("/")
269
+ .map((segment) => (RECORD_ID_SEGMENT.test(segment) ? ":id" : segment))
270
+ .join("/");
263
271
  }
264
272
 
265
273
  module.exports = {
@@ -3,7 +3,7 @@ import Foundation
3
3
  @objc(LBRNAppleNativeDiagnostics)
4
4
  public final class LBRNAppleNativeDiagnostics: NSObject, @unchecked Sendable {
5
5
  private static let shared = LBRNAppleNativeDiagnostics()
6
- private static let sdkVersion = "0.1.42"
6
+ private static let sdkVersion = "0.1.43"
7
7
 
8
8
  private let lock = NSLock()
9
9
  private let replayQueue = DispatchQueue(label: "co.logbrew.react-native.apple-diagnostics-replay")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logbrew/react-native",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "description": "React Native offline delivery, native diagnostics, screen, error, trace, action, and network timeline helpers for LogBrew.",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",