@bugsee/react-native 7.0.0-beta1 → 7.0.0-beta3

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
@@ -9,10 +9,11 @@ added.
9
9
 
10
10
  ## Status: beta
11
11
 
12
- This is a beta (`7.0.0-beta1`), built on the 7.x native SDKs, and the iOS SDK it
13
- bundles is itself a beta. It is published under the `beta` npm dist-tag only, so
14
- a plain `yarn add @bugsee/react-native` finds nothing: ask for the tag, as in
15
- [Install](#install). The API can still change between betas.
12
+ This is a beta (`7.0.0-beta3`), built on the 7.x native SDKs, and the iOS SDK it
13
+ bundles is itself a beta. `latest` and `beta` both point at it for now, so a plain
14
+ `yarn add @bugsee/react-native` installs it; the `@beta` form in [Install](#install)
15
+ keeps following betas once a stable release exists. The API can still change
16
+ between betas.
16
17
 
17
18
  It replaces `react-native-bugsee` (6.x), which stays on its own line. The two
18
19
  are different packages with different APIs, not an upgrade in place: remove the
@@ -71,19 +72,60 @@ React Native itself also needs `nodeLinker: hoisted` under pnpm.
71
72
  ## Use
72
73
 
73
74
  ```ts
74
- import Bugsee, { BugseeLaunchOptions, createDefaultLaunchOptions } from '@bugsee/react-native';
75
+ import Bugsee, { createDefaultLaunchOptions } from '@bugsee/react-native';
75
76
 
76
77
  const options = createDefaultLaunchOptions();
77
78
  options.captureLogs = true;
78
79
 
79
- await Bugsee.launch('<your app token>', BugseeLaunchOptions.serialize(options));
80
+ await Bugsee.launch('<your app token>', options);
80
81
  ```
81
82
 
83
+ `launch` and `relaunch` take the options object as is. They also accept the plain
84
+ `com.bugsee.option.*` map, for options you build or merge yourself; the object's
85
+ `BugseeLaunchOptions.serialize(options)` returns exactly that map.
86
+
82
87
  `launch` resolves to whether the SDK started. It can decline — already
83
88
  running, or a token the backend rejects — without that being an error worth
84
89
  throwing on. Capture comes up asynchronously, so poll `getStatus()` rather
85
90
  than assuming a resolved `launch` means recording has begun.
86
91
 
92
+ ### Reporting render errors
93
+
94
+ Wrap part of the tree (or the whole app) in `<ErrorBoundary>` to report an error thrown while rendering
95
+ and show a fallback instead of an empty screen:
96
+
97
+ ```tsx
98
+ import { ErrorBoundary } from '@bugsee/react-native';
99
+
100
+ <ErrorBoundary
101
+ fallback={({ error, componentStack, resetError }) => (
102
+ <ErrorScreen onRetry={resetError} />
103
+ )}
104
+ onError={(error, componentStack) => console.warn('render failed', error)}
105
+ options={{ domain: 'checkout' }}
106
+ >
107
+ <App />
108
+ </ErrorBoundary>
109
+ ```
110
+
111
+ | Prop | |
112
+ |---|---|
113
+ | `fallback` | What to render after an error: an element, or a function that receives `error`, `componentStack` and `resetError()`. Without it the boundary renders nothing, so give it one. |
114
+ | `onError(error, componentStack)` | Called after the boundary has caught the error, and after it has reported it unless the error was already reported (see the list below). |
115
+ | `onReset(error, componentStack)` | Called when `resetError()` is called, just before the children render again. |
116
+ | `options` | Handled-exception options for the report. `{ domain }` only, as for `Bugsee.logException`. An invalid value logs a warning and the error is reported without options. |
117
+
118
+ What it does and does not do:
119
+
120
+ - The error is reported as a **handled** exception, with the React component stack attached as an extra
121
+ (not as the error's `cause`).
122
+ - An error object the SDK has already reported is not reported again, so a boundary and
123
+ `Bugsee.logException` (or the global handler) do not file the same error twice.
124
+ - `children` is a plain React node. The function-as-children form from 6.x is not supported.
125
+ - Like any React error boundary it only catches errors thrown while **rendering**. Errors in event
126
+ handlers, timers and promises are not caught by it; the global handlers `launch` installs report the
127
+ uncaught ones.
128
+
87
129
  ### Hiding a view from recordings
88
130
 
89
131
  Wrap anything that must never be recorded in `<BugseeSecure>`:
@@ -46,7 +46,7 @@ static NSString *BGSRNStringOr(NSDictionary *source, NSString *key, NSString *fa
46
46
  // test compares the three so they cannot drift.
47
47
  return [self wrapperWithIdentity:@{
48
48
  @"type" : @"react_native",
49
- @"version" : @"7.0.0-beta1",
49
+ @"version" : @"7.0.0-beta3",
50
50
  @"context" : @{},
51
51
  }];
52
52
  }
@@ -58,7 +58,7 @@
58
58
  - (void)testWithoutJsRuntimeCarriesOnlyTypeAndVersion {
59
59
  BGSRNWrapper *wrapper = [BGSRNWrapper wrapperWithoutJsRuntime];
60
60
  XCTAssertEqualObjects(wrapper.wrapperType, @"react_native");
61
- XCTAssertEqualObjects(wrapper.wrapperVersion, @"7.0.0-beta1");
61
+ XCTAssertEqualObjects(wrapper.wrapperVersion, @"7.0.0-beta3");
62
62
  XCTAssertNil(wrapper.wrapperBuild);
63
63
  XCTAssertEqual(wrapper.context.count, (NSUInteger)0);
64
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bugsee/react-native",
3
- "version": "7.0.0-beta1",
3
+ "version": "7.0.0-beta3",
4
4
  "description": "Bugsee SDK for React Native",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.bugsee.com",
@@ -62,4 +62,4 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  }
65
- }
65
+ }
@@ -213,5 +213,5 @@ function listSchemes(iosRoot) {
213
213
  }
214
214
  return schemes;
215
215
  }
216
- exports.default = (0, config_plugins_1.createRunOncePlugin)(withBugsee, '@bugsee/react-native', '7.0.0-beta1');
216
+ exports.default = (0, config_plugins_1.createRunOncePlugin)(withBugsee, '@bugsee/react-native', '7.0.0-beta3');
217
217
  //# sourceMappingURL=index.js.map
File without changes
File without changes
File without changes
File without changes
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ import type { NetworkFilter } from './network/filter';
27
27
  import { addNetworkEvent as recordNetworkEvent } from './network/add';
28
28
  import type { AddedNetworkEvent } from './network/add';
29
29
  import { type IssueSeverity, LogLevel } from './options/enums';
30
+ import { BugseeLaunchOptions } from './options/BugseeLaunchOptions';
30
31
  import { labelsArgument, severityArgument } from './report/fields';
31
32
  import {
32
33
  assertEventOrTraceName,
@@ -104,9 +105,24 @@ function toAttributeError(error: unknown): unknown {
104
105
 
105
106
  export type LaunchOptions = Record<string, unknown>;
106
107
 
108
+ /**
109
+ * What `launch` and `relaunch` take: the options object (`createDefaultLaunchOptions()` and its
110
+ * accessors), or the plain `com.bugsee.option.*` map it serialises to. Both are the same payload.
111
+ */
112
+ export type LaunchOptionsInput = BugseeLaunchOptions | LaunchOptions;
113
+
114
+ /** The native payload for either form. An options object is serialised here, once, so callers never have to. */
115
+ function nativeOptionsOf(options: LaunchOptionsInput): LaunchOptions {
116
+ return options instanceof BugseeLaunchOptions
117
+ ? BugseeLaunchOptions.serialize(options)
118
+ : options;
119
+ }
120
+
107
121
  class Bugsee {
108
122
  /**
109
- * Starts the SDK. Resolves to whether the native side actually launched —
123
+ * Starts the SDK. `options` is the options object from `createDefaultLaunchOptions()` as is, or
124
+ * the plain option map; there is no serialise step to call. Resolves to whether the native side
125
+ * actually launched —
110
126
  * it can decline (already running, token rejected) without that being an
111
127
  * error the caller should throw on.
112
128
  *
@@ -120,16 +136,17 @@ class Bugsee {
120
136
  * does not install the patch. A later call does not wrap the functions
121
137
  * again; it does re-read `com.bugsee.option.capture.logs`.
122
138
  */
123
- async launch(token: string, options: LaunchOptions = {}): Promise<boolean> {
139
+ async launch(token: string, options: LaunchOptionsInput = {}): Promise<boolean> {
124
140
  assertUsableToken(token);
141
+ const nativeOptions = nativeOptionsOf(options);
125
142
  // Registered before launching, not after: the SDK reads the wrapper while
126
143
  // composing a report's environment, and a crash during start-up would
127
144
  // otherwise produce a report that does not say what wrapper it came from.
128
145
  this.registerWrapper();
129
146
  installExceptionHandlers();
130
- applyExceptionCaptureFromOptions(options);
131
- const launched = await NativeBugsee.launch(token, options);
132
- installConsoleCapture(options);
147
+ applyExceptionCaptureFromOptions(nativeOptions);
148
+ const launched = await NativeBugsee.launch(token, nativeOptions);
149
+ installConsoleCapture(nativeOptions);
133
150
  return launched;
134
151
  }
135
152
 
@@ -151,12 +168,13 @@ class Bugsee {
151
168
  * Installs the console patch after the native call resolves, same as
152
169
  * {@link launch}. A second install does not wrap again.
153
170
  */
154
- async relaunch(options: LaunchOptions = {}): Promise<boolean> {
171
+ async relaunch(options: LaunchOptionsInput = {}): Promise<boolean> {
172
+ const nativeOptions = nativeOptionsOf(options);
155
173
  this.registerWrapper();
156
174
  installExceptionHandlers();
157
- applyExceptionCaptureFromOptions(options);
158
- const relaunched = await NativeBugsee.relaunch(options);
159
- installConsoleCapture(options);
175
+ applyExceptionCaptureFromOptions(nativeOptions);
176
+ const relaunched = await NativeBugsee.relaunch(nativeOptions);
177
+ installConsoleCapture(nativeOptions);
160
178
  return relaunched;
161
179
  }
162
180