Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't initiate DeviceContext if enableNative is false #993

Merged
merged 2 commits into from
Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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