Skip to content

Commit

Permalink
fix: don't initiate DeviceContext if enableNative is false (#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzach authored Jul 24, 2020
1 parent b706722 commit 93dfe79
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
## Unreleased

- fix: Use `LogBox` instead of `YellowBox` if possible. #989
- fix: Don't add `DeviceContext` default integration if `enableNative` is set to `false`. #993
- fix: Don't log "Native Sentry SDK is disabled" if `enableNativeNagger` is set to `false`. #993

## 1.6.3

Expand Down
30 changes: 18 additions & 12 deletions src/js/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,15 @@ export function init(
}
}
return frame;
}
}),
new DeviceContext()
},
})
);
if (options.enableNative) {
options.defaultIntegrations.push(new DeviceContext());
}
options = assignDefaultOptions(options);
}
if (options.enableNative === undefined) {
options.enableNative = true;
}
if (options.enableNativeCrashHandling === undefined) {
options.enableNativeCrashHandling = true;
}
if (options.enableNativeNagger === undefined) {
options.enableNativeNagger = true;
}

// tslint:enable: strict-comparisons
initAndBind(ReactNativeClient, options);

Expand Down Expand Up @@ -125,3 +120,14 @@ export function nativeCrash(): void {
client.nativeCrash();
}
}

function assignDefaultOptions(
providedOptions: ReactNativeOptions
): ReactNativeOptions {
const defaultOptions: ReactNativeOptions = {
enableNative: true,
enableNativeCrashHandling: true,
enableNativeNagger: true,
};
return { ...defaultOptions, ...providedOptions };
}
8 changes: 6 additions & 2 deletions src/js/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@ export const NATIVE = {
* Starts native with the provided options.
* @param options ReactNativeOptions
*/
async startWithOptions(options: ReactNativeOptions = {}): Promise<boolean> {
async startWithOptions(
options: ReactNativeOptions = { enableNative: true }
): Promise<boolean> {
if (!options.dsn) {
logger.warn(
"Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized."
);
return false;
}
if (!options.enableNative) {
if (!options.enableNativeNagger) {
logger.warn("Note: Native Sentry SDK is disabled.");
}
this.enableNative = false;
logger.warn("Note: Native Sentry SDK is disabled.");
return false;
}

Expand Down

0 comments on commit 93dfe79

Please sign in to comment.