From fabaf93e9d540f42a716c2f18dff4c45e6d7f339 Mon Sep 17 00:00:00 2001 From: Alex Naiman Date: Mon, 26 Oct 2020 18:03:36 +0200 Subject: [PATCH 1/3] - fix: removed circular dependencies --- src/js/backend.ts | 39 +---------------------------------- src/js/client.ts | 5 +++-- src/js/reactNativeOptions.ts | 40 ++++++++++++++++++++++++++++++++++++ src/js/sdk.ts | 2 +- src/js/wrapper.ts | 2 +- 5 files changed, 46 insertions(+), 42 deletions(-) create mode 100644 src/js/reactNativeOptions.ts diff --git a/src/js/backend.ts b/src/js/backend.ts index 17d26921f5..ba438ab6c9 100644 --- a/src/js/backend.ts +++ b/src/js/backend.ts @@ -5,47 +5,10 @@ import { Event, EventHint, Severity, Transport } from "@sentry/types"; // @ts-ignore LogBox introduced in RN 0.63 import { Alert, LogBox, YellowBox } from "react-native"; +import { ReactNativeOptions } from './reactNativeOptions'; import { NativeTransport } from "./transports/native"; import { NATIVE } from "./wrapper"; -/** - * Configuration options for the Sentry ReactNative SDK. - * @see ReactNativeFrontend for more information. - */ -export interface ReactNativeOptions extends BrowserOptions { - /** - * Enables native transport + device info + offline caching. - * Be careful, disabling this also breaks automatic release setting. - * This means you have to manage setting the release yourself. - * Defaults to `true`. - */ - enableNative?: boolean; - - /** - * Enables native crashHandling. This only works if `enableNative` is `true`. - * Defaults to `true`. - */ - enableNativeCrashHandling?: boolean; - - /** Maximum time to wait to drain the request queue, before the process is allowed to exit. */ - shutdownTimeout?: number; - - /** Should the native nagger alert be shown or not. */ - enableNativeNagger?: boolean; - - /** Should sessions be tracked to Sentry Health or not. */ - enableAutoSessionTracking?: boolean; - - /** The interval to end a session if the App goes to the background. */ - sessionTrackingIntervalMillis?: number; - - /** Enable scope sync from Java to NDK on Android */ - enableNdkScopeSync?: boolean; - - /** When enabled, all the threads are automatically attached to all logged events on Android */ - attachThreads?: boolean; -} - /** The Sentry ReactNative SDK Backend. */ export class ReactNativeBackend extends BaseBackend { private readonly _browserBackend: BrowserBackend; diff --git a/src/js/client.ts b/src/js/client.ts index df2f8c550e..46dc9cda7c 100644 --- a/src/js/client.ts +++ b/src/js/client.ts @@ -1,6 +1,7 @@ import { BaseClient } from "@sentry/core"; -import { ReactNativeBackend, ReactNativeOptions } from "./backend"; +import { ReactNativeBackend } from "./backend"; +import { ReactNativeOptions } from "./reactNativeOptions"; /** * The Sentry React Native SDK Client. @@ -11,7 +12,7 @@ import { ReactNativeBackend, ReactNativeOptions } from "./backend"; export class ReactNativeClient extends BaseClient< ReactNativeBackend, ReactNativeOptions -> { + > { /** * Creates a new React Native SDK instance. * @param options Configuration options for this SDK. diff --git a/src/js/reactNativeOptions.ts b/src/js/reactNativeOptions.ts new file mode 100644 index 0000000000..916756679c --- /dev/null +++ b/src/js/reactNativeOptions.ts @@ -0,0 +1,40 @@ +import { BrowserOptions } from "@sentry/react"; + +/** + * Configuration options for the Sentry ReactNative SDK. + * @see ReactNativeFrontend for more information. + */ + +export interface ReactNativeOptions extends BrowserOptions { + /** + * Enables native transport + device info + offline caching. + * Be careful, disabling this also breaks automatic release setting. + * This means you have to manage setting the release yourself. + * Defaults to `true`. + */ + enableNative?: boolean; + + /** + * Enables native crashHandling. This only works if `enableNative` is `true`. + * Defaults to `true`. + */ + enableNativeCrashHandling?: boolean; + + /** Maximum time to wait to drain the request queue, before the process is allowed to exit. */ + shutdownTimeout?: number; + + /** Should the native nagger alert be shown or not. */ + enableNativeNagger?: boolean; + + /** Should sessions be tracked to Sentry Health or not. */ + enableAutoSessionTracking?: boolean; + + /** The interval to end a session if the App goes to the background. */ + sessionTrackingIntervalMillis?: number; + + /** Enable scope sync from Java to NDK on Android */ + enableNdkScopeSync?: boolean; + + /** When enabled, all the threads are automatically attached to all logged events on Android */ + attachThreads?: boolean; +} diff --git a/src/js/sdk.ts b/src/js/sdk.ts index f34a82513b..d4def21f04 100644 --- a/src/js/sdk.ts +++ b/src/js/sdk.ts @@ -5,7 +5,6 @@ import { defaultIntegrations, getCurrentHub } from "@sentry/react"; import { StackFrame } from "@sentry/types"; import { getGlobalObject } from "@sentry/utils"; -import { ReactNativeOptions } from "./backend"; import { ReactNativeClient } from "./client"; import { DebugSymbolicator, @@ -13,6 +12,7 @@ import { ReactNativeErrorHandlers, Release, } from "./integrations"; +import { ReactNativeOptions } from "./reactNativeOptions"; import { ReactNativeScope } from "./scope"; const IGNORED_DEFAULT_INTEGRATIONS = [ diff --git a/src/js/wrapper.ts b/src/js/wrapper.ts index 90441981d9..f2a7c62199 100644 --- a/src/js/wrapper.ts +++ b/src/js/wrapper.ts @@ -3,7 +3,7 @@ import { Breadcrumb, Event, Response, Severity, User } from "@sentry/types"; import { logger, SentryError } from "@sentry/utils"; import { NativeModules, Platform } from "react-native"; -import { ReactNativeOptions } from "./backend"; +import { ReactNativeOptions } from "./reactNativeOptions"; const { RNSentry } = NativeModules; From e37bad2adbd0e547c0c4b828347b1113183de285 Mon Sep 17 00:00:00 2001 From: Alex Naiman Date: Mon, 26 Oct 2020 18:16:11 +0200 Subject: [PATCH 2/3] - small fix --- src/js/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/index.ts b/src/js/index.ts index 20350becd0..09e549558a 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -44,7 +44,8 @@ export { import * as Integrations from "./integrations"; import { SDK_NAME, SDK_VERSION } from "./version"; -export { ReactNativeBackend, ReactNativeOptions } from "./backend"; +export { ReactNativeBackend } from "./backend"; +export { ReactNativeOptions } from './reactNativeOptions'; export { ReactNativeClient } from "./client"; // eslint-disable-next-line deprecation/deprecation export { init, setDist, setRelease, nativeCrash } from "./sdk"; From 1d00a962bd3b9ebc4ee25e05349c33b2142daf37 Mon Sep 17 00:00:00 2001 From: Alex Naiman Date: Mon, 26 Oct 2020 18:23:30 +0200 Subject: [PATCH 3/3] - fix after code review --- src/js/backend.ts | 2 +- src/js/client.ts | 2 +- src/js/index.ts | 2 +- src/js/{reactNativeOptions.ts => options.ts} | 0 src/js/sdk.ts | 2 +- src/js/wrapper.ts | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename src/js/{reactNativeOptions.ts => options.ts} (100%) diff --git a/src/js/backend.ts b/src/js/backend.ts index ba438ab6c9..4db924561e 100644 --- a/src/js/backend.ts +++ b/src/js/backend.ts @@ -5,7 +5,7 @@ import { Event, EventHint, Severity, Transport } from "@sentry/types"; // @ts-ignore LogBox introduced in RN 0.63 import { Alert, LogBox, YellowBox } from "react-native"; -import { ReactNativeOptions } from './reactNativeOptions'; +import { ReactNativeOptions } from "./options"; import { NativeTransport } from "./transports/native"; import { NATIVE } from "./wrapper"; diff --git a/src/js/client.ts b/src/js/client.ts index 46dc9cda7c..5344ae8295 100644 --- a/src/js/client.ts +++ b/src/js/client.ts @@ -1,7 +1,7 @@ import { BaseClient } from "@sentry/core"; import { ReactNativeBackend } from "./backend"; -import { ReactNativeOptions } from "./reactNativeOptions"; +import { ReactNativeOptions } from "./options"; /** * The Sentry React Native SDK Client. diff --git a/src/js/index.ts b/src/js/index.ts index 09e549558a..8fdc0b8716 100644 --- a/src/js/index.ts +++ b/src/js/index.ts @@ -45,7 +45,7 @@ import * as Integrations from "./integrations"; import { SDK_NAME, SDK_VERSION } from "./version"; export { ReactNativeBackend } from "./backend"; -export { ReactNativeOptions } from './reactNativeOptions'; +export { ReactNativeOptions } from "./options"; export { ReactNativeClient } from "./client"; // eslint-disable-next-line deprecation/deprecation export { init, setDist, setRelease, nativeCrash } from "./sdk"; diff --git a/src/js/reactNativeOptions.ts b/src/js/options.ts similarity index 100% rename from src/js/reactNativeOptions.ts rename to src/js/options.ts diff --git a/src/js/sdk.ts b/src/js/sdk.ts index d4def21f04..4f37cd4d06 100644 --- a/src/js/sdk.ts +++ b/src/js/sdk.ts @@ -12,7 +12,7 @@ import { ReactNativeErrorHandlers, Release, } from "./integrations"; -import { ReactNativeOptions } from "./reactNativeOptions"; +import { ReactNativeOptions } from "./options"; import { ReactNativeScope } from "./scope"; const IGNORED_DEFAULT_INTEGRATIONS = [ diff --git a/src/js/wrapper.ts b/src/js/wrapper.ts index f2a7c62199..e8714d182b 100644 --- a/src/js/wrapper.ts +++ b/src/js/wrapper.ts @@ -3,7 +3,7 @@ import { Breadcrumb, Event, Response, Severity, User } from "@sentry/types"; import { logger, SentryError } from "@sentry/utils"; import { NativeModules, Platform } from "react-native"; -import { ReactNativeOptions } from "./reactNativeOptions"; +import { ReactNativeOptions } from "./options"; const { RNSentry } = NativeModules;