Skip to content

Commit a16b946

Browse files
committed
fix: Separate wrapper method
1 parent 1dcae6c commit a16b946

File tree

4 files changed

+11
-22
lines changed

4 files changed

+11
-22
lines changed

sample/src/App.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const reactNavigationV5Instrumentation = new Sentry.ReactNavigationV5Instrumenta
2525
routeChangeTimeoutMs: 500, // How long it will wait for the route change to complete. Default is 1000ms
2626
},
2727
);
28-
const options = {
28+
Sentry.init({
2929
// Replace the example DSN below with your own DSN:
3030
dsn: SENTRY_INTERNAL_DSN,
3131
debug: true,
@@ -62,7 +62,7 @@ const options = {
6262
// otherwise they will not work.
6363
release: packageVersion,
6464
dist: `${packageVersion}.0`,
65-
};
65+
});
6666

6767
const Stack = createStackNavigator();
6868

@@ -94,5 +94,5 @@ const App = () => {
9494
);
9595
};
9696

97-
// We use initWith to wrap your app with more features out of the box such as auto performance monitoring.
98-
export default Sentry.initWith(App, options);
97+
// Wrap your app to get more features out of the box such as auto performance monitoring.
98+
export default Sentry.wrap(App);

src/js/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export { ReactNativeClient } from "./client";
6262

6363
export {
6464
init,
65-
initWith,
65+
wrap,
6666
// eslint-disable-next-line deprecation/deprecation
6767
setDist,
6868
// eslint-disable-next-line deprecation/deprecation

src/js/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface ReactNativeOptions extends BrowserOptions {
7373
enableAutoPerformanceTracking?: boolean;
7474
}
7575

76-
export interface ReactNativeWrapperOptions extends ReactNativeOptions {
76+
export interface ReactNativeWrapperOptions {
7777
/** Props for the root React profiler */
7878
profilerProps?: ProfilerProps;
7979

src/js/sdk.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const DEFAULT_OPTIONS: ReactNativeOptions = {
3333
/**
3434
* Inits the SDK and returns the final options.
3535
*/
36-
function _init<O = ReactNativeOptions>(passedOptions: O): O {
36+
export function init(passedOptions: ReactNativeOptions): void {
3737
const reactNativeHub = new Hub(undefined, new ReactNativeScope());
3838
makeMain(reactNativeHub);
3939

@@ -102,39 +102,28 @@ function _init<O = ReactNativeOptions>(passedOptions: O): O {
102102
if (getGlobalObject<any>().HermesInternal) {
103103
getCurrentHub().setTag("hermes", "true");
104104
}
105-
106-
return options;
107-
}
108-
109-
/**
110-
* Inits the Sentry React Native SDK without any wrapping
111-
*/
112-
export function init(options: ReactNativeOptions): void {
113-
_init(options);
114105
}
115106

116107
/**
117108
* Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.
118109
*/
119-
export function initWith<P>(
110+
export function wrap<P>(
120111
RootComponent: React.ComponentType<P>,
121-
passedOptions: ReactNativeWrapperOptions
112+
options?: ReactNativeWrapperOptions
122113
): React.ComponentType<P> {
123-
const options = _init(passedOptions);
124-
125114
const tracingIntegration = getCurrentHub().getIntegration(ReactNativeTracing);
126115
if (tracingIntegration) {
127116
tracingIntegration.useAppStartWithProfiler = true;
128117
}
129118

130119
const profilerProps = {
131-
...options.profilerProps,
120+
...(options?.profilerProps ?? {}),
132121
name: RootComponent.displayName ?? "Root",
133122
};
134123

135124
const RootApp: React.FC<P> = (appProps) => {
136125
return (
137-
<TouchEventBoundary {...options.touchEventBoundaryProps}>
126+
<TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>
138127
<ReactNativeProfiler {...profilerProps}>
139128
<RootComponent {...appProps} />
140129
</ReactNativeProfiler>

0 commit comments

Comments
 (0)