@logbrew/react-native 0.1.38 → 0.1.40

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.
Files changed (104) hide show
  1. package/LogBrewReactNative.podspec +1 -1
  2. package/README.md +17 -15
  3. package/android-native-diagnostics.d.ts +15 -5
  4. package/android-native-diagnostics.js +170 -94
  5. package/apollo.cjs +435 -226
  6. package/apollo.d.cts +2 -70
  7. package/apollo.d.ts +24 -12
  8. package/apollo.js +438 -221
  9. package/apple-native-diagnostics-config.js +176 -0
  10. package/apple-native-diagnostics-context.js +232 -0
  11. package/apple-native-diagnostics-module.js +229 -0
  12. package/apple-native-diagnostics.d.ts +42 -11
  13. package/apple-native-diagnostics.js +60 -389
  14. package/expo.cjs +29 -16
  15. package/expo.d.ts +10 -9
  16. package/expo.js +4 -3
  17. package/fatal-admission.cjs +113 -0
  18. package/fatal-record.cjs +317 -0
  19. package/fatal-replay.cjs +297 -508
  20. package/global-errors-capture.cjs +369 -0
  21. package/global-errors-event.cjs +174 -0
  22. package/global-errors-support.cjs +128 -0
  23. package/global-errors.cjs +75 -351
  24. package/global-errors.d.cts +29 -278
  25. package/global-errors.d.ts +57 -27
  26. package/global-errors.js +7 -2
  27. package/global-errors.native.js +83 -48
  28. package/index-breadcrumbs.cjs +139 -0
  29. package/index-errors.cjs +167 -0
  30. package/index-events.cjs +365 -0
  31. package/index-navigation.cjs +327 -0
  32. package/index-random.cjs +120 -0
  33. package/index-react.cjs +189 -0
  34. package/index-spans.cjs +190 -0
  35. package/index-trace-fetch.cjs +322 -0
  36. package/index-trace.cjs +335 -0
  37. package/index-transport.cjs +201 -0
  38. package/index-values.cjs +232 -0
  39. package/index.cjs +95 -1220
  40. package/index.d.cts +2 -505
  41. package/index.d.ts +130 -469
  42. package/index.native.d.ts +146 -22
  43. package/index.native.js +184 -159
  44. package/instrumentation-fetch.cjs +113 -0
  45. package/instrumentation-install.cjs +241 -0
  46. package/instrumentation-runtime.cjs +65 -0
  47. package/instrumentation-teardown.cjs +93 -0
  48. package/instrumentation-values.cjs +282 -0
  49. package/instrumentation-xhr-request.cjs +298 -0
  50. package/instrumentation-xhr.cjs +233 -0
  51. package/instrumentation.cjs +110 -599
  52. package/instrumentation.d.cts +2 -84
  53. package/instrumentation.d.ts +22 -8
  54. package/ios/AppleDiagnostics/LBRNAppleNativeDiagnostics.swift +1 -1
  55. package/ios/GeneratedAppleDiagnostics/LogBrew/DeliveryEngine.swift +7 -1
  56. package/ios/GeneratedAppleDiagnostics/LogBrew/DeliveryEngineAutomatic.swift +36 -4
  57. package/ios/GeneratedAppleDiagnostics/LogBrew/DeliveryEngineQueue.swift +17 -0
  58. package/ios/GeneratedAppleDiagnostics/LogBrew/DeliveryLifecycle.swift +2 -0
  59. package/ios/GeneratedAppleDiagnostics/LogBrew/Transport.swift +41 -6
  60. package/ios/GeneratedAppleDiagnostics/SOURCE-MANIFEST.json +5 -5
  61. package/lifecycle.cjs +181 -78
  62. package/lifecycle.d.cts +1 -50
  63. package/lifecycle.d.ts +17 -6
  64. package/metadata.cjs +279 -114
  65. package/metro-debug-id.cjs +296 -0
  66. package/metro-serializer.cjs +219 -0
  67. package/metro.cjs +153 -297
  68. package/metro.d.cts +2 -57
  69. package/metro.d.ts +27 -13
  70. package/metro.js +2 -3
  71. package/native-bridge-async.cjs +165 -0
  72. package/native-bridge-scope.cjs +148 -0
  73. package/native-bridge.cjs +83 -186
  74. package/native-bridge.d.cts +2 -94
  75. package/native-bridge.d.ts +28 -15
  76. package/native-client-bindings.js +230 -0
  77. package/native-diagnostics-values.js +120 -0
  78. package/native-module-lookup.js +31 -0
  79. package/native-null.js +3 -0
  80. package/null-value.cjs +4 -0
  81. package/package.json +44 -2
  82. package/persistent-delivery-store.js +247 -0
  83. package/persistent-delivery.native.js +183 -261
  84. package/promise-rejection-handlers.cjs +368 -0
  85. package/promise-rejections.cjs +169 -361
  86. package/react-native.config.js +3 -1
  87. package/release-artifacts-files.cjs +94 -0
  88. package/release-artifacts-options.cjs +182 -0
  89. package/release-artifacts.cjs +278 -207
  90. package/release-artifacts.d.cts +2 -55
  91. package/release-artifacts.d.ts +18 -7
  92. package/release-artifacts.js +2 -4
  93. package/resource-fetch-graphql.cjs +265 -0
  94. package/resource-fetch-size.cjs +156 -0
  95. package/resource-fetch.cjs +227 -428
  96. package/resource-fetch.d.cts +1 -60
  97. package/resource-fetch.d.ts +17 -6
  98. package/scripts/sync-apple-native-sources.mjs +101 -53
  99. package/types/capture.d.ts +95 -0
  100. package/types/config.d.ts +85 -0
  101. package/types/defaults.d.ts +55 -0
  102. package/types/events.d.ts +203 -0
  103. package/types/provider.d.ts +81 -0
  104. package/types/trace.d.ts +104 -0
package/index.native.d.ts CHANGED
@@ -1,17 +1,30 @@
1
+ import type {
2
+ CreateLogBrewReactNativeClientConfig,
3
+ captureDefaultAppStateChange,
4
+ captureDefaultReactNativeAction,
5
+ captureDefaultReactNativeError,
6
+ captureDefaultReactNativeNetwork,
7
+ captureDefaultScreenView,
8
+ createDefaultAppStateListener,
9
+ getDefaultReactNativeContext
10
+ } from "./index.js";
1
11
  import type { EventStore, LogBrewClient } from "@logbrew/sdk";
2
- import type { CreateLogBrewReactNativeClientConfig } from "./index.js";
12
+ import type {
13
+ getLogBrewAndroidNativeDiagnosticsStatus,
14
+ installLogBrewAndroidNativeDiagnostics,
15
+ uninstallLogBrewAndroidNativeDiagnostics
16
+ } from "./android-native-diagnostics.js";
17
+ import type {
18
+ getLogBrewAppleNativeDiagnosticsStatus,
19
+ installLogBrewAppleNativeDiagnostics,
20
+ replayLogBrewAppleNativeDiagnostics,
21
+ setLogBrewAppleNativeCrashContext
22
+ } from "./apple-native-diagnostics.js";
23
+ import type indexDefault from "./index.js";
3
24
 
4
- export * from "./index.js";
5
- export * from "./apple-native-diagnostics.js";
6
- export * from "./android-native-diagnostics.js";
7
- export {
8
- installLogBrewReactNativeGlobalErrorHandler,
9
- installLogBrewReactNativePromiseRejectionTracker
10
- } from "./global-errors";
25
+ type ReactNativePersistentQueueMode = "auto" | "required" | "disabled";
11
26
 
12
- export type ReactNativePersistentQueueMode = "auto" | "required" | "disabled";
13
-
14
- export type CreateNativeLogBrewReactNativeClientConfig =
27
+ type CreateNativeLogBrewReactNativeClientConfig =
15
28
  Omit<CreateLogBrewReactNativeClientConfig, "eventStore"> & ({
16
29
  /**
17
30
  * `auto` uses the linked app-private native queue when available and otherwise uses memory.
@@ -25,32 +38,143 @@ export type CreateNativeLogBrewReactNativeClientConfig =
25
38
  persistentQueue?: never;
26
39
  });
27
40
 
28
- export declare function createLogBrewReactNativeClient(
41
+ declare function createLogBrewReactNativeClient(
29
42
  config: CreateNativeLogBrewReactNativeClientConfig
30
43
  ): LogBrewClient;
31
44
 
32
- export declare function createDefaultLogBrewReactNativeClient(
45
+ declare function createDefaultLogBrewReactNativeClient(
33
46
  config: CreateNativeLogBrewReactNativeClientConfig
34
47
  ): LogBrewClient;
35
48
 
36
- export declare function purgeLogBrewReactNativePersistentQueue(
49
+ declare function purgeLogBrewReactNativePersistentQueue(
37
50
  config: { apiKey?: string; clientKey?: string }
38
51
  ): void;
39
52
 
40
53
  declare const defaultExport: Omit<
41
- typeof import("./index.js").default,
54
+ typeof indexDefault,
42
55
  "createLogBrewReactNativeClient" | "createDefaultLogBrewReactNativeClient"
43
56
  > & {
44
57
  createLogBrewReactNativeClient: typeof createLogBrewReactNativeClient;
45
58
  createDefaultLogBrewReactNativeClient: typeof createDefaultLogBrewReactNativeClient;
46
- getLogBrewAppleNativeDiagnosticsStatus: typeof import("./apple-native-diagnostics.js").getLogBrewAppleNativeDiagnosticsStatus;
47
- getLogBrewAndroidNativeDiagnosticsStatus: typeof import("./android-native-diagnostics.js").getLogBrewAndroidNativeDiagnosticsStatus;
48
- installLogBrewAppleNativeDiagnostics: typeof import("./apple-native-diagnostics.js").installLogBrewAppleNativeDiagnostics;
49
- installLogBrewAndroidNativeDiagnostics: typeof import("./android-native-diagnostics.js").installLogBrewAndroidNativeDiagnostics;
59
+ getLogBrewAppleNativeDiagnosticsStatus: typeof getLogBrewAppleNativeDiagnosticsStatus;
60
+ getLogBrewAndroidNativeDiagnosticsStatus: typeof getLogBrewAndroidNativeDiagnosticsStatus;
61
+ installLogBrewAppleNativeDiagnostics: typeof installLogBrewAppleNativeDiagnostics;
62
+ installLogBrewAndroidNativeDiagnostics: typeof installLogBrewAndroidNativeDiagnostics;
50
63
  purgeLogBrewReactNativePersistentQueue: typeof purgeLogBrewReactNativePersistentQueue;
51
- replayLogBrewAppleNativeDiagnostics: typeof import("./apple-native-diagnostics.js").replayLogBrewAppleNativeDiagnostics;
52
- setLogBrewAppleNativeCrashContext: typeof import("./apple-native-diagnostics.js").setLogBrewAppleNativeCrashContext;
53
- uninstallLogBrewAndroidNativeDiagnostics: typeof import("./android-native-diagnostics.js").uninstallLogBrewAndroidNativeDiagnostics;
64
+ replayLogBrewAppleNativeDiagnostics: typeof replayLogBrewAppleNativeDiagnostics;
65
+ setLogBrewAppleNativeCrashContext: typeof setLogBrewAppleNativeCrashContext;
66
+ uninstallLogBrewAndroidNativeDiagnostics: typeof uninstallLogBrewAndroidNativeDiagnostics;
67
+ captureDefaultAppStateChange: typeof captureDefaultAppStateChange;
68
+ captureDefaultReactNativeAction: typeof captureDefaultReactNativeAction;
69
+ captureDefaultReactNativeError: typeof captureDefaultReactNativeError;
70
+ captureDefaultReactNativeNetwork: typeof captureDefaultReactNativeNetwork;
71
+ captureDefaultScreenView: typeof captureDefaultScreenView;
72
+ createDefaultAppStateListener: typeof createDefaultAppStateListener;
73
+ getDefaultReactNativeContext: typeof getDefaultReactNativeContext;
54
74
  };
55
75
 
76
+ export type {
77
+ CaptureAppStateChangeOptions,
78
+ CaptureReactNativeErrorOptions,
79
+ CaptureScreenViewOptions,
80
+ CreateAppStateListenerOptions,
81
+ CreateLogBrewReactNativeClientConfig,
82
+ LogBrewNativeActions,
83
+ LogBrewNativeContextValue,
84
+ LogBrewNativeProviderProps,
85
+ ReactNativeActionEvent,
86
+ ReactNativeActionIdFactoryContext,
87
+ ReactNativeActionInput,
88
+ ReactNativeAppStateLike,
89
+ ReactNativeContextOptions,
90
+ ReactNativeErrorEvent,
91
+ ReactNativeErrorIdFactoryContext,
92
+ ReactNativeFetchLike,
93
+ ReactNativeFetchResponseLike,
94
+ ReactNativeFetchTransportConfig,
95
+ ReactNativeNavigationSpanIdFactoryContext,
96
+ ReactNativeNavigationSpanInput,
97
+ ReactNativeNetworkIdFactoryContext,
98
+ ReactNativeNetworkInput,
99
+ ReactNativePlatformLike,
100
+ ReactNativeResourceSpanIdFactoryContext,
101
+ ReactNativeResourceSpanInput,
102
+ ReactNativeSpanAttributesInput,
103
+ ReactNativeSpanEvent,
104
+ ReactNativeTraceContext,
105
+ ReactNativeTraceContextConfig,
106
+ ReactNativeTraceInput,
107
+ ReactNativeTraceparentConfig,
108
+ ReactNavigationContainerLike,
109
+ ReactNavigationRouteLike,
110
+ ReactNavigationSpanListenerOptions,
111
+ TracePropagationTarget,
112
+ TraceparentFetchConfig,
113
+ TraceparentFetchLike
114
+ } from "./index.js";
115
+ export {
116
+ LogBrewNativeProvider,
117
+ bindLogBrewTrace,
118
+ captureAppStateChange,
119
+ captureDefaultAppStateChange,
120
+ captureDefaultReactNativeAction,
121
+ captureDefaultReactNativeError,
122
+ captureDefaultReactNativeNetwork,
123
+ captureDefaultScreenView,
124
+ captureReactNativeAction,
125
+ captureReactNativeError,
126
+ captureReactNativeNavigationSpan,
127
+ captureReactNativeNetwork,
128
+ captureReactNativeResourceSpan,
129
+ captureScreenView,
130
+ createAppStateListener,
131
+ createDefaultAppStateListener,
132
+ createReactNativeActionEvent,
133
+ createReactNativeErrorEvent,
134
+ createReactNativeFetchTransport,
135
+ createReactNativeNavigationSpanEvent,
136
+ createReactNativeNetworkEvent,
137
+ createReactNativeResourceSpanEvent,
138
+ createReactNativeSpanAttributes,
139
+ createReactNativeTraceContext,
140
+ createReactNativeTraceHeaders,
141
+ createReactNativeTraceparent,
142
+ createReactNavigationSpanListener,
143
+ createTraceparentFetch,
144
+ getActiveLogBrewTrace,
145
+ getDefaultReactNativeContext,
146
+ getReactNativeContext,
147
+ getReactNativeTraceMetadata,
148
+ shouldPropagateTraceparent,
149
+ useLogBrewNative,
150
+ useLogBrewNativeActions,
151
+ withLogBrewTrace
152
+ } from "./index.js";
153
+ export type {
154
+ LogBrewAppleNativeCrashContext,
155
+ LogBrewAppleNativeCrashContextResult,
156
+ LogBrewAppleNativeDiagnosticsConfiguration,
157
+ LogBrewAppleNativeDiagnosticsReplayResult,
158
+ LogBrewAppleNativeDiagnosticsStatus
159
+ } from "./apple-native-diagnostics.js";
160
+ export {
161
+ getLogBrewAppleNativeDiagnosticsStatus,
162
+ installLogBrewAppleNativeDiagnostics,
163
+ replayLogBrewAppleNativeDiagnostics,
164
+ setLogBrewAppleNativeCrashContext
165
+ } from "./apple-native-diagnostics.js";
166
+ export * from "./android-native-diagnostics.js";
167
+ export {
168
+ installLogBrewReactNativeGlobalErrorHandler,
169
+ installLogBrewReactNativePromiseRejectionTracker
170
+ } from "./global-errors.js";
171
+ export type {
172
+ CreateNativeLogBrewReactNativeClientConfig,
173
+ ReactNativePersistentQueueMode
174
+ };
175
+ export {
176
+ createLogBrewReactNativeClient,
177
+ createDefaultLogBrewReactNativeClient,
178
+ purgeLogBrewReactNativePersistentQueue
179
+ };
56
180
  export default defaultExport;
package/index.native.js CHANGED
@@ -1,5 +1,5 @@
1
- import { AppState, DeviceEventEmitter, NativeModules, Platform, TurboModuleRegistry } from "react-native";
2
- import {
1
+ import { AppState, Platform } from "react-native";
2
+ import baseDefault, {
3
3
  captureAppStateChange,
4
4
  captureReactNativeAction,
5
5
  captureReactNativeError,
@@ -9,51 +9,82 @@ import {
9
9
  createLogBrewReactNativeClient as createPlatformNeutralClient,
10
10
  getReactNativeContext
11
11
  } from "./index.js";
12
- import baseDefault from "./index.js";
13
- import {
14
- getLogBrewAppleNativeDiagnosticsStatus,
15
- installLogBrewAppleNativeDiagnostics,
16
- replayLogBrewAppleNativeDiagnostics,
17
- setLogBrewAppleNativeCrashContext,
18
- syncLogBrewAppleNativeCrashBreadcrumbs
19
- } from "./apple-native-diagnostics.js";
12
+ import { bindAndroidNativeDelivery, bindAppleNativeCrashBreadcrumbs } from "./native-client-bindings.js";
20
13
  import {
21
14
  getLogBrewAndroidNativeDiagnosticsStatus,
22
15
  installLogBrewAndroidNativeDiagnostics,
23
16
  uninstallLogBrewAndroidNativeDiagnostics
24
17
  } from "./android-native-diagnostics.js";
25
18
  import {
26
- purgeReactNativePersistentQueue,
27
- resolveReactNativePersistentEventStore
28
- } from "./persistent-delivery.native.js";
29
- export {
30
- installLogBrewReactNativeGlobalErrorHandler,
31
- installLogBrewReactNativePromiseRejectionTracker
32
- } from "./global-errors.native.js";
33
- export {
34
19
  getLogBrewAppleNativeDiagnosticsStatus,
35
20
  installLogBrewAppleNativeDiagnostics,
36
21
  replayLogBrewAppleNativeDiagnostics,
37
22
  setLogBrewAppleNativeCrashContext
38
- };
39
- export {
40
- getLogBrewAndroidNativeDiagnosticsStatus,
41
- installLogBrewAndroidNativeDiagnostics,
42
- uninstallLogBrewAndroidNativeDiagnostics
43
- };
23
+ } from "./apple-native-diagnostics.js";
24
+ import { hasOwnKey, readField } from "./native-diagnostics-values.js";
25
+ import {
26
+ purgeReactNativePersistentQueue,
27
+ resolveReactNativePersistentEventStore
28
+ } from "./persistent-delivery.native.js";
29
+ import { lookupNativeModule } from "./native-module-lookup.js";
44
30
 
45
- export * from "./index.js";
31
+ /**
32
+ * @import { LogBrewClient, Metadata } from "@logbrew/sdk"
33
+ * @import { ReactNativeActionEvent, ReactNativeErrorEvent } from "./index.js"
34
+ * @typedef {(...args: readonly never[]) => unknown} Callable
35
+ * @typedef {{ durable: boolean, eventStore: unknown, abort: () => void, release: () => void }} ResolvedEventStore
36
+ */
46
37
 
47
- const nativeRuntime = TurboModuleRegistry?.get?.("LogBrewFatalStore")
48
- ?? NativeModules?.LogBrewFatalStore;
49
- if (typeof nativeRuntime?.secureRandomHex === "function") {
50
- globalThis[Symbol.for("co.logbrew.react-native.secure-random-hex")] =
51
- nativeRuntime.secureRandomHex.bind(nativeRuntime);
52
- }
53
38
  const DURABLE_QUEUE = Symbol.for("co.logbrew.react-native.durable-event-queue");
54
39
 
55
- export function createLogBrewReactNativeClient(config = {}) {
56
- const input = config !== null && typeof config === "object" ? config : {};
40
+ /**
41
+ * @param {unknown} value
42
+ * @returns {value is Callable}
43
+ */
44
+ function isCallable(value) {
45
+ return typeof value === "function";
46
+ }
47
+
48
+ /**
49
+ * @param {unknown} value
50
+ * @returns {value is Readonly<Record<string, unknown>>}
51
+ */
52
+ function isObjectInput(value) {
53
+ return value !== null && typeof value === "object";
54
+ }
55
+
56
+ const nativeRuntime = lookupNativeModule("LogBrewFatalStore");
57
+ const secureRandomHex = readField(nativeRuntime, "secureRandomHex");
58
+ if (isCallable(secureRandomHex)) {
59
+ Reflect.set(globalThis, Symbol.for("co.logbrew.react-native.secure-random-hex"), secureRandomHex.bind(nativeRuntime));
60
+ }
61
+
62
+ /**
63
+ * @param {Readonly<Record<string, unknown>>} settings
64
+ * @param {Readonly<ResolvedEventStore>} resolved
65
+ * @returns {LogBrewClient}
66
+ */
67
+ function createResolvedClient(settings, resolved) {
68
+ try {
69
+ /** @type {Readonly<Record<string, unknown>>} */
70
+ const clientConfig = { ...settings, eventStore: resolved.eventStore };
71
+ const client = createPlatformNeutralClient(clientConfig);
72
+ if (resolved.durable) {
73
+ Object.defineProperty(client, DURABLE_QUEUE, { value: true });
74
+ }
75
+ return bindAndroidNativeDelivery(bindAppleNativeCrashBreadcrumbs(client), resolved.durable);
76
+ } catch (error) {
77
+ resolved.abort();
78
+ throw error;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * @param {unknown} [config]
84
+ * @returns {LogBrewClient}
85
+ */
86
+ function createLogBrewReactNativeClient(config = {}) {
87
+ const input = isObjectInput(config) ? config : {};
57
88
  const {
58
89
  apiKey,
59
90
  clientKey,
@@ -63,10 +94,7 @@ export function createLogBrewReactNativeClient(config = {}) {
63
94
  persistentQueue = "auto",
64
95
  ...forwarded
65
96
  } = input;
66
- const hasExplicitPersistentQueue = Object.prototype.hasOwnProperty.call(
67
- input,
68
- "persistentQueue"
69
- ) && input.persistentQueue !== undefined;
97
+ const hasExplicitPersistentQueue = hasOwnKey(input, "persistentQueue") && input["persistentQueue"] !== undefined;
70
98
  const authKey = clientKey ?? apiKey;
71
99
  if (typeof authKey !== "string" || authKey.trim() === "") {
72
100
  return bindAppleNativeCrashBreadcrumbs(createPlatformNeutralClient(input));
@@ -74,155 +102,123 @@ export function createLogBrewReactNativeClient(config = {}) {
74
102
  const resolved = resolveReactNativePersistentEventStore({
75
103
  authKey,
76
104
  eventStore,
105
+ hasExplicitPersistentQueue,
77
106
  maxQueueBytes,
78
107
  maxQueueSize,
79
- persistentQueue,
80
- hasExplicitPersistentQueue
81
- });
82
- try {
83
- const client = createPlatformNeutralClient({
84
- ...forwarded,
85
- apiKey,
86
- clientKey,
87
- eventStore: resolved.eventStore,
88
- maxQueueBytes,
89
- maxQueueSize
90
- });
91
- if (resolved.durable) {
92
- Object.defineProperty(client, DURABLE_QUEUE, { value: true });
93
- }
94
- return bindAndroidNativeDelivery(bindAppleNativeCrashBreadcrumbs(client), resolved.durable);
95
- } catch (error) {
96
- resolved.abort();
97
- throw error;
98
- }
99
- }
100
-
101
- function bindAndroidNativeDelivery(client, durable) {
102
- if (!durable || Platform?.OS !== "android" || typeof DeviceEventEmitter?.addListener !== "function") {
103
- return client;
104
- }
105
- const subscription = DeviceEventEmitter.addListener(
106
- "logbrewAndroidDiagnosticPersisted", () => void client.flush().catch(() => {})
107
- );
108
- const shutdown = client.shutdown.bind(client);
109
- client.shutdown = (...args) => shutdown(...args).finally(() => {
110
- if (client.deliveryHealth().lifecycle === "closed") {
111
- subscription?.remove?.();
112
- }
108
+ persistentQueue
113
109
  });
114
- return client;
115
- }
116
-
117
- function bindAppleNativeCrashBreadcrumbs(client) {
118
- if (Platform?.OS !== "ios") {
119
- return client;
120
- }
121
- const addBreadcrumb = client.addBreadcrumb.bind(client);
122
- const clearBreadcrumbs = client.clearBreadcrumbs.bind(client);
123
- client.addBreadcrumb = (...args) => updateAppleNativeBreadcrumbs(
124
- client, () => addBreadcrumb(...args)
125
- );
126
- client.clearBreadcrumbs = () => updateAppleNativeBreadcrumbs(client, clearBreadcrumbs);
127
- syncAppleNativeCrashBreadcrumbs(client);
128
- return client;
129
- }
130
-
131
- function updateAppleNativeBreadcrumbs(client, update) {
132
- const previous = [client.issueBreadcrumbs.slice(), client.issueBreadcrumbsTruncated];
133
- const result = update();
134
- try {
135
- syncAppleNativeCrashBreadcrumbs(client);
136
- } catch (error) {
137
- restoreBreadcrumbs(client, previous);
138
- throw error;
139
- }
140
- return result;
141
- }
142
-
143
- function restoreBreadcrumbs(client, [breadcrumbs, truncated]) {
144
- client.issueBreadcrumbs.splice(0, client.issueBreadcrumbs.length, ...breadcrumbs);
145
- client.issueBreadcrumbsTruncated = truncated;
146
- }
147
-
148
- function syncAppleNativeCrashBreadcrumbs(client) {
149
- const snapshot = client.issueBreadcrumbs.length === 0
150
- ? null
151
- : {
152
- breadcrumbs: client.issueBreadcrumbs.map(({ data, ...breadcrumb }) => ({
153
- ...breadcrumb,
154
- ...(data === undefined ? {} : { data: { ...data } })
155
- })),
156
- schemaVersion: 1,
157
- truncated: client.issueBreadcrumbsTruncated
158
- };
159
- try {
160
- syncLogBrewAppleNativeCrashBreadcrumbs(snapshot);
161
- } catch (error) {
162
- if (error?.code !== "native_diagnostics_unavailable"
163
- && error?.code !== "native_diagnostics_not_installed") {
164
- throw error;
165
- }
166
- }
110
+ return createResolvedClient({ ...forwarded, apiKey, clientKey, maxQueueBytes, maxQueueSize }, resolved);
167
111
  }
168
112
 
169
- export function purgeLogBrewReactNativePersistentQueue(config = {}) {
113
+ /**
114
+ * @param {Readonly<{ apiKey?: unknown, clientKey?: unknown }>} [config]
115
+ */
116
+ function purgeLogBrewReactNativePersistentQueue(config = {}) {
170
117
  purgeReactNativePersistentQueue(config);
171
118
  }
172
119
 
173
- export function createDefaultLogBrewReactNativeClient(config = {}) {
120
+ /**
121
+ * @param {unknown} [config]
122
+ * @returns {LogBrewClient}
123
+ */
124
+ function createDefaultLogBrewReactNativeClient(config = {}) {
174
125
  return createLogBrewReactNativeClient(config);
175
126
  }
176
127
 
177
- export function getDefaultReactNativeContext({ metadata = {} } = {}) {
178
- return getReactNativeContext({ platform: Platform, appState: AppState, metadata });
128
+ /**
129
+ * @param {unknown} value
130
+ * @returns {Readonly<Record<string, unknown>>}
131
+ */
132
+ function objectOptions(value) {
133
+ if (isObjectInput(value)) {
134
+ return value;
135
+ }
136
+ return value === null || value === undefined ? {} : Object.fromEntries(Object.entries(value));
179
137
  }
180
138
 
181
- export function captureDefaultScreenView(client, screenName, options = {}) {
182
- return captureScreenView(client, screenName, {
139
+ /**
140
+ * @param {unknown} options
141
+ * @returns {Readonly<Record<string, unknown>>}
142
+ */
143
+ function withDefaultRuntime(options) {
144
+ return {
183
145
  platform: Platform,
146
+
184
147
  appState: AppState,
185
- ...options
186
- });
148
+ ...objectOptions(options)
149
+ };
187
150
  }
188
151
 
189
- export function captureDefaultAppStateChange(client, state, options = {}) {
190
- return captureAppStateChange(client, state, {
152
+ /**
153
+ * @param {Readonly<{ metadata?: unknown }>} [options]
154
+ * @returns {Metadata}
155
+ */
156
+ function getDefaultReactNativeContext({ metadata = {} } = {}) {
157
+ /** @type {Readonly<Record<string, unknown>>} */
158
+ const contextOptions = {
191
159
  platform: Platform,
160
+
192
161
  appState: AppState,
193
- ...options
194
- });
162
+ metadata
163
+ };
164
+ return getReactNativeContext(contextOptions);
195
165
  }
196
166
 
197
- export function captureDefaultReactNativeAction(client, input = {}) {
198
- return captureReactNativeAction(client, {
199
- platform: Platform,
200
- appState: AppState,
201
- ...input
202
- });
167
+ /**
168
+ * @param {LogBrewClient} client
169
+ * @param {string} screenName
170
+ * @param {unknown} [options]
171
+ */
172
+ function captureDefaultScreenView(client, screenName, options = {}) {
173
+ captureScreenView(client, screenName, withDefaultRuntime(options));
203
174
  }
204
175
 
205
- export function captureDefaultReactNativeNetwork(client, input = {}) {
206
- return captureReactNativeNetwork(client, {
207
- platform: Platform,
208
- appState: AppState,
209
- ...input
210
- });
176
+ /**
177
+ * @param {LogBrewClient} client
178
+ * @param {string} state
179
+ * @param {unknown} [options]
180
+ */
181
+ function captureDefaultAppStateChange(client, state, options = {}) {
182
+ captureAppStateChange(client, state, withDefaultRuntime(options));
211
183
  }
212
184
 
213
- export function captureDefaultReactNativeError(client, error, options = {}) {
214
- return captureReactNativeError(client, error, {
215
- platform: Platform,
216
- appState: AppState,
217
- ...options
218
- });
185
+ /**
186
+ * @param {LogBrewClient} client
187
+ * @param {unknown} [input]
188
+ * @returns {ReactNativeActionEvent}
189
+ */
190
+ function captureDefaultReactNativeAction(client, input = {}) {
191
+ return captureReactNativeAction(client, withDefaultRuntime(input));
219
192
  }
220
193
 
221
- export function createDefaultAppStateListener(client, options = {}) {
222
- return createAppStateListener(client, AppState, {
223
- platform: Platform,
224
- ...options
225
- });
194
+ /**
195
+ * @param {LogBrewClient} client
196
+ * @param {unknown} [input]
197
+ * @returns {ReactNativeActionEvent}
198
+ */
199
+ function captureDefaultReactNativeNetwork(client, input = {}) {
200
+ return captureReactNativeNetwork(client, withDefaultRuntime(input));
201
+ }
202
+
203
+ /**
204
+ * @param {LogBrewClient} client
205
+ * @param {unknown} error
206
+ * @param {unknown} [options]
207
+ * @returns {ReactNativeErrorEvent}
208
+ */
209
+ function captureDefaultReactNativeError(client, error, options = {}) {
210
+ return captureReactNativeError(client, error, withDefaultRuntime(options));
211
+ }
212
+
213
+ /**
214
+ * @param {LogBrewClient} client
215
+ * @param {unknown} [options]
216
+ * @returns {() => void}
217
+ */
218
+ function createDefaultAppStateListener(client, options = {}) {
219
+ /** @type {Readonly<Record<string, unknown>>} */
220
+ const listenerOptions = { platform: Platform, ...objectOptions(options) };
221
+ return createAppStateListener(client, AppState, listenerOptions);
226
222
  }
227
223
 
228
224
  const defaultExport = {
@@ -239,6 +235,7 @@ const defaultExport = {
239
235
  getLogBrewAndroidNativeDiagnosticsStatus,
240
236
  getLogBrewAppleNativeDiagnosticsStatus,
241
237
  installLogBrewAppleNativeDiagnostics,
238
+
242
239
  installLogBrewAndroidNativeDiagnostics,
243
240
  purgeLogBrewReactNativePersistentQueue,
244
241
  replayLogBrewAppleNativeDiagnostics,
@@ -246,4 +243,32 @@ const defaultExport = {
246
243
  uninstallLogBrewAndroidNativeDiagnostics
247
244
  };
248
245
 
246
+ export * from "./index.js";
247
+ export {
248
+ getLogBrewAndroidNativeDiagnosticsStatus,
249
+ installLogBrewAndroidNativeDiagnostics,
250
+ uninstallLogBrewAndroidNativeDiagnostics
251
+ } from "./android-native-diagnostics.js";
252
+ export {
253
+ getLogBrewAppleNativeDiagnosticsStatus,
254
+ installLogBrewAppleNativeDiagnostics,
255
+ replayLogBrewAppleNativeDiagnostics,
256
+ setLogBrewAppleNativeCrashContext
257
+ } from "./apple-native-diagnostics.js";
258
+ export {
259
+ installLogBrewReactNativeGlobalErrorHandler,
260
+ installLogBrewReactNativePromiseRejectionTracker
261
+ } from "./global-errors.native.js";
262
+ export {
263
+ captureDefaultAppStateChange,
264
+ captureDefaultReactNativeAction,
265
+ captureDefaultReactNativeError,
266
+ captureDefaultReactNativeNetwork,
267
+ captureDefaultScreenView,
268
+ createDefaultAppStateListener,
269
+ createDefaultLogBrewReactNativeClient,
270
+ createLogBrewReactNativeClient,
271
+ getDefaultReactNativeContext,
272
+ purgeLogBrewReactNativePersistentQueue
273
+ };
249
274
  export default defaultExport;