@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
@@ -1,60 +1 @@
1
- import type { LogBrewClient, Metadata } from "@logbrew/sdk";
2
- import type {
3
- ReactNativeAppStateLike,
4
- ReactNativePlatformLike,
5
- ReactNativeTraceInput,
6
- TracePropagationTarget
7
- } from "./index.cjs";
8
-
9
- export type ReactNativeResourceFetchOptions<TInput = unknown, TInit = unknown, TResponse = unknown> = {
10
- appState?: ReactNativeAppStateLike;
11
- fetchImpl?: (input: TInput, init?: TInit) => Promise<TResponse> | TResponse;
12
- measureResponseBodySize?: boolean;
13
- metadata?: Metadata;
14
- metadataFactory?: (context: ReactNativeResourceFetchMetadataContext<TInput, TInit, TResponse>) => Metadata | undefined;
15
- now?: () => string;
16
- nowMs?: () => number;
17
- platform?: ReactNativePlatformLike;
18
- randomValues?: (length: number) => ArrayLike<number>;
19
- routeTemplate?: string;
20
- routeTemplateFactory?: (context: { input: TInput; init?: TInit; url: string }) => string | undefined;
21
- screen?: string;
22
- sessionId?: string;
23
- trace?: ReactNativeTraceInput;
24
- traceFlags?: string;
25
- tracePropagationTargets?: TracePropagationTarget[];
26
- };
27
-
28
- export type ReactNativeResourceFetchMetadataContext<TInput = unknown, TInit = unknown, TResponse = unknown> = {
29
- readonly durationMs?: number;
30
- readonly error?: unknown;
31
- readonly init?: TInit;
32
- readonly input: TInput;
33
- readonly method: string;
34
- readonly response?: TResponse;
35
- readonly responseSizeBytes?: number;
36
- readonly responseStartDurationMs?: number;
37
- readonly routeTemplate?: string;
38
- readonly status?: string;
39
- readonly statusCode?: number;
40
- readonly url: string;
41
- };
42
-
43
- export type ReactNativeGraphQLMetadataFactoryOptions<TInput = unknown, TInit = unknown, TResponse = unknown> = {
44
- endpoint?: ReactNativeGraphQLEndpointMatcher<TInput, TInit, TResponse> | ReactNativeGraphQLEndpointMatcher<TInput, TInit, TResponse>[];
45
- metadataFactory?: (context: ReactNativeResourceFetchMetadataContext<TInput, TInit, TResponse>) => Metadata | undefined;
46
- };
47
-
48
- export type ReactNativeGraphQLEndpointMatcher<TInput = unknown, TInit = unknown, TResponse = unknown> =
49
- | string
50
- | RegExp
51
- | ((context: ReactNativeResourceFetchMetadataContext<TInput, TInit, TResponse>) => boolean);
52
-
53
- export declare function createReactNativeGraphQLMetadataFactory<TInput = unknown, TInit = unknown, TResponse = unknown>(
54
- options?: ReactNativeGraphQLMetadataFactoryOptions<TInput, TInit, TResponse>
55
- ): (context: ReactNativeResourceFetchMetadataContext<TInput, TInit, TResponse>) => Metadata;
56
-
57
- export declare function createReactNativeResourceFetch<TInput = unknown, TInit = unknown, TResponse = unknown>(
58
- client: LogBrewClient,
59
- options?: ReactNativeResourceFetchOptions<TInput, TInit, TResponse>
60
- ): (input: TInput, init?: TInit) => Promise<TResponse>;
1
+ export * from "./resource-fetch.js";
@@ -6,7 +6,7 @@ import type {
6
6
  TracePropagationTarget
7
7
  } from "./index.js";
8
8
 
9
- export type ReactNativeResourceFetchOptions<TInput = unknown, TInit = unknown, TResponse = unknown> = {
9
+ type ReactNativeResourceFetchOptions<TInput = unknown, TInit = unknown, TResponse = unknown> = {
10
10
  appState?: ReactNativeAppStateLike;
11
11
  fetchImpl?: (input: TInput, init?: TInit) => Promise<TResponse> | TResponse;
12
12
  measureResponseBodySize?: boolean;
@@ -25,7 +25,7 @@ export type ReactNativeResourceFetchOptions<TInput = unknown, TInit = unknown, T
25
25
  tracePropagationTargets?: TracePropagationTarget[];
26
26
  };
27
27
 
28
- export type ReactNativeResourceFetchMetadataContext<TInput = unknown, TInit = unknown, TResponse = unknown> = {
28
+ type ReactNativeResourceFetchMetadataContext<TInput = unknown, TInit = unknown, TResponse = unknown> = {
29
29
  readonly durationMs?: number;
30
30
  readonly error?: unknown;
31
31
  readonly init?: TInit;
@@ -40,21 +40,32 @@ export type ReactNativeResourceFetchMetadataContext<TInput = unknown, TInit = un
40
40
  readonly url: string;
41
41
  };
42
42
 
43
- export type ReactNativeGraphQLMetadataFactoryOptions<TInput = unknown, TInit = unknown, TResponse = unknown> = {
43
+ type ReactNativeGraphQLMetadataFactoryOptions<TInput = unknown, TInit = unknown, TResponse = unknown> = {
44
44
  endpoint?: ReactNativeGraphQLEndpointMatcher<TInput, TInit, TResponse> | ReactNativeGraphQLEndpointMatcher<TInput, TInit, TResponse>[];
45
45
  metadataFactory?: (context: ReactNativeResourceFetchMetadataContext<TInput, TInit, TResponse>) => Metadata | undefined;
46
46
  };
47
47
 
48
- export type ReactNativeGraphQLEndpointMatcher<TInput = unknown, TInit = unknown, TResponse = unknown> =
48
+ type ReactNativeGraphQLEndpointMatcher<TInput = unknown, TInit = unknown, TResponse = unknown> =
49
49
  | string
50
50
  | RegExp
51
51
  | ((context: ReactNativeResourceFetchMetadataContext<TInput, TInit, TResponse>) => boolean);
52
52
 
53
- export declare function createReactNativeGraphQLMetadataFactory<TInput = unknown, TInit = unknown, TResponse = unknown>(
53
+ declare function createReactNativeGraphQLMetadataFactory<TInput = unknown, TInit = unknown, TResponse = unknown>(
54
54
  options?: ReactNativeGraphQLMetadataFactoryOptions<TInput, TInit, TResponse>
55
55
  ): (context: ReactNativeResourceFetchMetadataContext<TInput, TInit, TResponse>) => Metadata;
56
56
 
57
- export declare function createReactNativeResourceFetch<TInput = unknown, TInit = unknown, TResponse = unknown>(
57
+ declare function createReactNativeResourceFetch<TInput = unknown, TInit = unknown, TResponse = unknown>(
58
58
  client: LogBrewClient,
59
59
  options?: ReactNativeResourceFetchOptions<TInput, TInit, TResponse>
60
60
  ): (input: TInput, init?: TInit) => Promise<TResponse>;
61
+
62
+ export type {
63
+ ReactNativeGraphQLEndpointMatcher,
64
+ ReactNativeGraphQLMetadataFactoryOptions,
65
+ ReactNativeResourceFetchMetadataContext,
66
+ ReactNativeResourceFetchOptions
67
+ };
68
+ export {
69
+ createReactNativeGraphQLMetadataFactory,
70
+ createReactNativeResourceFetch
71
+ };
@@ -1,8 +1,8 @@
1
1
  import assert from "node:assert/strict";
2
2
  import crypto from "node:crypto";
3
+ import { fileURLToPath } from "node:url";
3
4
  import fs from "node:fs";
4
5
  import path from "node:path";
5
- import { fileURLToPath } from "node:url";
6
6
 
7
7
  const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
8
8
  const packageRoot = path.resolve(scriptDirectory, "..");
@@ -15,16 +15,89 @@ const generatedHeader = [
15
15
  "// Edit the canonical Swift source, then regenerate this package boundary.",
16
16
  ""
17
17
  ].join("\n");
18
- const mode = process.argv[2] ?? "--check";
18
+ const MODE_ARGUMENT = 2;
19
+ const JSON_INDENT = 2;
20
+ const mode = process.argv[MODE_ARGUMENT] ?? "--check";
19
21
 
20
- assert.ok(
21
- generatedRoot.startsWith(`${packageRoot}${path.sep}`)
22
- && path.basename(generatedRoot) === "GeneratedAppleDiagnostics",
23
- "refusing to operate outside the package-generated source directory"
24
- );
22
+ /**
23
+ * @param {string} root
24
+ * @returns {string[]}
25
+ */
26
+ function listFiles(root) {
27
+ if (!fs.existsSync(root)) {
28
+ return [];
29
+ }
30
+ /** @type {string[]} */
31
+ const files = [];
32
+ for (const entry of fs.readdirSync(root, { withFileTypes: true })) {
33
+ const entryPath = path.join(root, entry.name);
34
+ files.push(...(entry.isDirectory() ? listFiles(entryPath) : [entryPath]));
35
+ }
36
+ files.sort();
37
+ return files;
38
+ }
25
39
 
26
- const expected = expectedFiles();
27
- if (mode === "--write") {
40
+ /**
41
+ * @param {string} canonical
42
+ * @returns {string}
43
+ */
44
+ function transformCanonicalSource(canonical) {
45
+ return canonical
46
+ .replaceAll("@_spi(CrashReplay) import LogBrew\n", "")
47
+ .replaceAll("@objc(LBW", "@objc(LBRNApple")
48
+ .replaceAll("@preconcurrency import KSCrashRecording\n", "@preconcurrency import KSCrash\n")
49
+ .replaceAll("@preconcurrency import KSCrashRecordingCore\n", "@preconcurrency import KSCrash\n");
50
+ }
51
+
52
+ /**
53
+ * @param {string} moduleName
54
+ * @returns {Readonly<{ contents: string, digest: string, manifestPath: string, relativePath: string }>[]}
55
+ */
56
+ function moduleEntries(moduleName) {
57
+ const moduleRoot = path.join(sourceRoot, moduleName);
58
+ return listFiles(moduleRoot).filter(filePath => filePath.endsWith(".swift")).map(sourcePath => {
59
+ const moduleRelativePath = path.relative(moduleRoot, sourcePath);
60
+ const relativePath = path.join(moduleName, moduleRelativePath);
61
+ const canonical = fs.readFileSync(sourcePath, "utf8");
62
+ const transformed = transformCanonicalSource(canonical);
63
+ return {
64
+ contents: `${generatedHeader}${transformed}`,
65
+ digest: crypto.createHash("sha256").update(canonical).digest("hex"),
66
+ manifestPath: path.join("swift", "logbrew-swift", "Sources", relativePath),
67
+ relativePath
68
+ };
69
+ });
70
+ }
71
+
72
+ /**
73
+ * @param {readonly [string, string]} left
74
+ * @param {readonly [string, string]} right
75
+ * @returns {number}
76
+ */
77
+ function byPath([leftPath], [rightPath]) {
78
+ return leftPath.localeCompare(rightPath);
79
+ }
80
+
81
+ /**
82
+ * @returns {Map<string, string>}
83
+ */
84
+ function expectedFiles() {
85
+ const entries = sourceModules.flatMap(moduleName => moduleEntries(moduleName));
86
+ const manifest = Object.fromEntries(entries.map(entry => [entry.manifestPath, entry.digest]));
87
+ /** @type {[string, string][]} */
88
+ const files = entries.map(entry => [entry.relativePath, entry.contents]);
89
+ files.push([
90
+ "SOURCE-MANIFEST.json",
91
+ `${JSON.stringify({ schemaVersion: 1, sources: manifest }, undefined, JSON_INDENT)}\n`
92
+ ]);
93
+ files.sort(byPath);
94
+ return new Map(files);
95
+ }
96
+
97
+ /**
98
+ * @param {Readonly<ReadonlyMap<string, string>>} expected
99
+ */
100
+ function writeExpected(expected) {
28
101
  fs.rmSync(generatedRoot, { force: true, recursive: true });
29
102
  for (const [relativePath, contents] of expected) {
30
103
  const destination = path.join(generatedRoot, relativePath);
@@ -32,8 +105,13 @@ if (mode === "--write") {
32
105
  fs.writeFileSync(destination, contents, "utf8");
33
106
  }
34
107
  process.stdout.write(`generated ${expected.size} Apple diagnostics source files\n`);
35
- } else if (mode === "--check") {
36
- const actualPaths = listFiles(generatedRoot).map((filePath) =>
108
+ }
109
+
110
+ /**
111
+ * @param {Readonly<ReadonlyMap<string, string>>} expected
112
+ */
113
+ function checkExpected(expected) {
114
+ const actualPaths = listFiles(generatedRoot).map(filePath =>
37
115
  path.relative(generatedRoot, filePath)
38
116
  );
39
117
  assert.deepEqual(actualPaths, [...expected.keys()]);
@@ -45,49 +123,19 @@ if (mode === "--write") {
45
123
  );
46
124
  }
47
125
  process.stdout.write(`verified ${expected.size} Apple diagnostics source files\n`);
48
- } else {
49
- throw new Error("usage: sync-apple-native-sources.mjs [--check|--write]");
50
- }
51
-
52
- function expectedFiles() {
53
- const files = new Map();
54
- const manifest = {};
55
- for (const moduleName of sourceModules) {
56
- const moduleRoot = path.join(sourceRoot, moduleName);
57
- for (const sourcePath of listFiles(moduleRoot).filter((filePath) => filePath.endsWith(".swift"))) {
58
- const moduleRelativePath = path.relative(moduleRoot, sourcePath);
59
- const relativePath = path.join(moduleName, moduleRelativePath);
60
- const canonical = fs.readFileSync(sourcePath, "utf8");
61
- const transformed = transformCanonicalSource(canonical);
62
- const contents = `${generatedHeader}${transformed}`;
63
- files.set(relativePath, contents);
64
- manifest[path.join("swift", "logbrew-swift", "Sources", relativePath)] =
65
- crypto.createHash("sha256").update(canonical).digest("hex");
66
- }
67
- }
68
- files.set(
69
- "SOURCE-MANIFEST.json",
70
- `${JSON.stringify({ schemaVersion: 1, sources: manifest }, null, 2)}\n`
71
- );
72
- return new Map([...files].sort(([left], [right]) => left.localeCompare(right)));
73
126
  }
74
127
 
75
- function transformCanonicalSource(canonical) {
76
- return canonical
77
- .replaceAll("@_spi(CrashReplay) import LogBrew\n", "")
78
- .replaceAll("@objc(LBW", "@objc(LBRNApple")
79
- .replaceAll("@preconcurrency import KSCrashRecording\n", "@preconcurrency import KSCrash\n")
80
- .replaceAll("@preconcurrency import KSCrashRecordingCore\n", "@preconcurrency import KSCrash\n");
81
- }
128
+ assert.ok(
129
+ generatedRoot.startsWith(`${packageRoot}${path.sep}`)
130
+ && path.basename(generatedRoot) === "GeneratedAppleDiagnostics",
131
+ "refusing to operate outside the package-generated source directory"
132
+ );
82
133
 
83
- function listFiles(root) {
84
- if (!fs.existsSync(root)) {
85
- return [];
86
- }
87
- return fs.readdirSync(root, { withFileTypes: true })
88
- .flatMap((entry) => {
89
- const entryPath = path.join(root, entry.name);
90
- return entry.isDirectory() ? listFiles(entryPath) : [entryPath];
91
- })
92
- .sort();
134
+ const expected = expectedFiles();
135
+ if (mode === "--write") {
136
+ writeExpected(expected);
137
+ } else if (mode === "--check") {
138
+ checkExpected(expected);
139
+ } else {
140
+ throw new Error("usage: sync-apple-native-sources.mjs [--check|--write]");
93
141
  }
@@ -0,0 +1,95 @@
1
+ import type {
2
+ CaptureAppStateChangeOptions,
3
+ CaptureReactNativeErrorOptions,
4
+ CaptureScreenViewOptions,
5
+ CreateAppStateListenerOptions,
6
+ ReactNativeActionEvent,
7
+ ReactNativeActionInput,
8
+ ReactNativeContextOptions,
9
+ ReactNativeErrorEvent,
10
+ ReactNativeNavigationSpanInput,
11
+ ReactNativeNetworkInput,
12
+ ReactNativeResourceSpanInput,
13
+ ReactNativeSpanEvent,
14
+ ReactNavigationContainerLike,
15
+ ReactNavigationSpanListenerOptions
16
+ } from "./events.js";
17
+ import type { LogBrewClient, Metadata } from "@logbrew/sdk";
18
+ import type { ReactNativeAppStateLike } from "./config.js";
19
+
20
+ declare function getReactNativeContext(options?: ReactNativeContextOptions): Metadata;
21
+ declare function captureScreenView(
22
+ client: LogBrewClient,
23
+ screenName: string,
24
+ options?: CaptureScreenViewOptions
25
+ ): void;
26
+ declare function captureAppStateChange(
27
+ client: LogBrewClient,
28
+ state: string,
29
+ options?: CaptureAppStateChangeOptions
30
+ ): void;
31
+ declare function createReactNativeActionEvent(
32
+ input?: ReactNativeActionInput
33
+ ): ReactNativeActionEvent;
34
+ declare function captureReactNativeAction(
35
+ client: LogBrewClient,
36
+ input?: ReactNativeActionInput
37
+ ): ReactNativeActionEvent;
38
+ declare function createReactNativeNetworkEvent(
39
+ input?: ReactNativeNetworkInput
40
+ ): ReactNativeActionEvent;
41
+ declare function captureReactNativeNetwork(
42
+ client: LogBrewClient,
43
+ input?: ReactNativeNetworkInput
44
+ ): ReactNativeActionEvent;
45
+ declare function createReactNativeNavigationSpanEvent(
46
+ input?: ReactNativeNavigationSpanInput
47
+ ): ReactNativeSpanEvent;
48
+ declare function captureReactNativeNavigationSpan(
49
+ client: LogBrewClient,
50
+ input?: ReactNativeNavigationSpanInput
51
+ ): ReactNativeSpanEvent;
52
+ declare function createReactNativeResourceSpanEvent(
53
+ input?: ReactNativeResourceSpanInput
54
+ ): ReactNativeSpanEvent;
55
+ declare function captureReactNativeResourceSpan(
56
+ client: LogBrewClient,
57
+ input?: ReactNativeResourceSpanInput
58
+ ): ReactNativeSpanEvent;
59
+ declare function createReactNavigationSpanListener(
60
+ client: LogBrewClient,
61
+ navigationContainer: ReactNavigationContainerLike,
62
+ options?: ReactNavigationSpanListenerOptions
63
+ ): () => void;
64
+ declare function createReactNativeErrorEvent(
65
+ error: unknown,
66
+ options?: CaptureReactNativeErrorOptions
67
+ ): ReactNativeErrorEvent;
68
+ declare function captureReactNativeError(
69
+ client: LogBrewClient,
70
+ error: unknown,
71
+ options?: CaptureReactNativeErrorOptions
72
+ ): ReactNativeErrorEvent;
73
+ declare function createAppStateListener(
74
+ client: LogBrewClient,
75
+ appState: ReactNativeAppStateLike,
76
+ options?: CreateAppStateListenerOptions
77
+ ): () => void;
78
+
79
+ export {
80
+ captureAppStateChange,
81
+ captureReactNativeAction,
82
+ captureReactNativeError,
83
+ captureReactNativeNavigationSpan,
84
+ captureReactNativeNetwork,
85
+ captureReactNativeResourceSpan,
86
+ captureScreenView,
87
+ createAppStateListener,
88
+ createReactNativeActionEvent,
89
+ createReactNativeErrorEvent,
90
+ createReactNativeNavigationSpanEvent,
91
+ createReactNativeNetworkEvent,
92
+ createReactNativeResourceSpanEvent,
93
+ createReactNavigationSpanListener,
94
+ getReactNativeContext
95
+ };
@@ -0,0 +1,85 @@
1
+ import type {
2
+ DroppedEvent,
3
+ EventStore,
4
+ LogBrewClient,
5
+ TelemetryContext,
6
+ Transport
7
+ } from "@logbrew/sdk";
8
+
9
+ type ReactNativePlatformLike = {
10
+ OS?: string;
11
+ Version?: string | number;
12
+ isPad?: boolean;
13
+ constants?: { isTesting?: boolean; [key: string]: unknown };
14
+ };
15
+
16
+ type ReactNativeAppStateLike = {
17
+ currentState?: string | null | undefined;
18
+ addEventListener?: (
19
+ type: "change",
20
+ listener: (state: string) => void
21
+ ) => { remove(): void } | (() => void);
22
+ };
23
+
24
+ type CreateLogBrewReactNativeClientConfig = {
25
+ automaticDelivery?: boolean;
26
+ apiKey?: string;
27
+ clientKey?: string;
28
+ context?: TelemetryContext;
29
+ /** Automatic delivery interval in milliseconds. Defaults to 5000 on mobile to save battery. */
30
+ deliveryIntervalMs?: number;
31
+ deliveryQueueThreshold?: number;
32
+ /** Advanced synchronous persistence seam. React Native apps normally use the native entry's persistentQueue mode. */
33
+ eventStore?: EventStore;
34
+ maxBatchBytes?: number;
35
+ maxBatchEvents?: number;
36
+ maxQueueBytes?: number;
37
+ maxQueueSize?: number;
38
+ maxRetries?: number;
39
+ onEventDropped?: (drop: DroppedEvent) => void;
40
+ sdkName?: string;
41
+ sdkVersion?: string;
42
+ transport?: Transport;
43
+ };
44
+
45
+ type ReactNativeFetchResponseLike = {
46
+ status: number;
47
+ headers?: {
48
+ get(name: string): string | null | undefined;
49
+ };
50
+ };
51
+
52
+ type ReactNativeFetchLike = (
53
+ endpoint: string,
54
+ init: {
55
+ body: string;
56
+ headers: Record<string, string>;
57
+ method: "POST";
58
+ }
59
+ ) => Promise<ReactNativeFetchResponseLike> | ReactNativeFetchResponseLike;
60
+
61
+ type ReactNativeFetchTransportConfig = {
62
+ endpoint?: string;
63
+ fetchImpl?: ReactNativeFetchLike;
64
+ headers?: Record<string, string>;
65
+ };
66
+
67
+ declare function createLogBrewReactNativeClient(
68
+ config: CreateLogBrewReactNativeClientConfig
69
+ ): LogBrewClient;
70
+ declare function createReactNativeFetchTransport(
71
+ config?: ReactNativeFetchTransportConfig
72
+ ): Transport;
73
+
74
+ export type {
75
+ CreateLogBrewReactNativeClientConfig,
76
+ ReactNativeAppStateLike,
77
+ ReactNativeFetchLike,
78
+ ReactNativeFetchResponseLike,
79
+ ReactNativeFetchTransportConfig,
80
+ ReactNativePlatformLike
81
+ };
82
+ export {
83
+ createLogBrewReactNativeClient,
84
+ createReactNativeFetchTransport
85
+ };
@@ -0,0 +1,55 @@
1
+ import type {
2
+ CaptureAppStateChangeOptions,
3
+ CaptureReactNativeErrorOptions,
4
+ CaptureScreenViewOptions,
5
+ CreateAppStateListenerOptions,
6
+ ReactNativeActionEvent,
7
+ ReactNativeActionInput,
8
+ ReactNativeErrorEvent,
9
+ ReactNativeNetworkInput
10
+ } from "./events.js";
11
+ import type { LogBrewClient, Metadata } from "@logbrew/sdk";
12
+ import type { CreateLogBrewReactNativeClientConfig } from "./config.js";
13
+
14
+ declare function createDefaultLogBrewReactNativeClient(
15
+ config: CreateLogBrewReactNativeClientConfig
16
+ ): LogBrewClient;
17
+ declare function getDefaultReactNativeContext(options?: { metadata?: Metadata }): Metadata;
18
+ declare function captureDefaultScreenView(
19
+ client: LogBrewClient,
20
+ screenName: string,
21
+ options?: Omit<CaptureScreenViewOptions, "platform" | "appState">
22
+ ): void;
23
+ declare function captureDefaultAppStateChange(
24
+ client: LogBrewClient,
25
+ state: string,
26
+ options?: Omit<CaptureAppStateChangeOptions, "platform" | "appState">
27
+ ): void;
28
+ declare function captureDefaultReactNativeAction(
29
+ client: LogBrewClient,
30
+ input?: Omit<ReactNativeActionInput, "platform" | "appState">
31
+ ): ReactNativeActionEvent;
32
+ declare function captureDefaultReactNativeNetwork(
33
+ client: LogBrewClient,
34
+ input?: Omit<ReactNativeNetworkInput, "platform" | "appState">
35
+ ): ReactNativeActionEvent;
36
+ declare function captureDefaultReactNativeError(
37
+ client: LogBrewClient,
38
+ error: unknown,
39
+ options?: Omit<CaptureReactNativeErrorOptions, "platform" | "appState">
40
+ ): ReactNativeErrorEvent;
41
+ declare function createDefaultAppStateListener(
42
+ client: LogBrewClient,
43
+ options?: Omit<CreateAppStateListenerOptions, "appState">
44
+ ): () => void;
45
+
46
+ export {
47
+ captureDefaultAppStateChange,
48
+ captureDefaultReactNativeAction,
49
+ captureDefaultReactNativeError,
50
+ captureDefaultReactNativeNetwork,
51
+ captureDefaultScreenView,
52
+ createDefaultAppStateListener,
53
+ createDefaultLogBrewReactNativeClient,
54
+ getDefaultReactNativeContext
55
+ };