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

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-beta2`), 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,14 +72,18 @@ 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
@@ -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-beta2",
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-beta2");
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-beta2",
4
4
  "description": "Bugsee SDK for React Native",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.bugsee.com",
@@ -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-beta2');
217
217
  //# sourceMappingURL=index.js.map
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