Skip to content

Commit

Permalink
Rename to withSentry and deprecate withSentryRouteTracing.
Browse files Browse the repository at this point in the history
  • Loading branch information
onurtemizkan committed Jul 6, 2022
1 parent fc33554 commit 0a59239
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
12 changes: 6 additions & 6 deletions packages/remix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Sentry.init({
});
```

Also, wrap your Remix root with `withSentryRouteTracing` to catch React component errors and to get parameterized router transactions.
Also, wrap your Remix root with `withSentry` to catch React component errors and to get parameterized router transactions.

```ts
// root.tsx
Expand All @@ -71,7 +71,7 @@ import {
ScrollRestoration,
} from "@remix-run/react";

import { withSentryRouteTracing } from "@sentry/remix";
import { withSentry } from "@sentry/remix";

function App() {
return (
Expand All @@ -90,20 +90,20 @@ function App() {
);
}

export default withSentryRouteTracing(App);
export default withSentry(App);
```

You can disable or configure `ErrorBoundary` using a second parameter to `withSentryRouteTracing`.
You can disable or configure `ErrorBoundary` using a second parameter to `withSentry`.

```ts

withSentryRouteTracing(App, {
withSentry(App, {
wrapWithErrorBoundary: false
});

// or

withSentryRouteTracing(App, {
withSentry(App, {
errorBoundaryOptions: {
fallback: <p>An error has occurred</p>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/remix/src/index.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { configureScope, init as reactInit, Integrations } from '@sentry/react';

import { buildMetadata } from './utils/metadata';
import { RemixOptions } from './utils/remixOptions';
export { remixRouterInstrumentation, withSentryRouteTracing } from './performance/client';
export { remixRouterInstrumentation, withSentry, withSentryRouteTracing } from './performance/client';
export { BrowserTracing } from '@sentry/tracing';
export * from '@sentry/react';

Expand Down
2 changes: 1 addition & 1 deletion packages/remix/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { buildMetadata } from './utils/metadata';
import { RemixOptions } from './utils/remixOptions';

export { ErrorBoundary, withErrorBoundary } from '@sentry/react';
export { remixRouterInstrumentation, withSentryRouteTracing } from './performance/client';
export { remixRouterInstrumentation, withSentry, withSentryRouteTracing } from './performance/client';
export { BrowserTracing, Integrations } from '@sentry/tracing';
export * from '@sentry/node';

Expand Down
18 changes: 17 additions & 1 deletion packages/remix/src/performance/client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,27 @@ export function remixRouterInstrumentation(useEffect: UseEffect, useLocation: Us
};
}

/**
* @deprecated Please use `withSentry` instead.
*
* Wraps a remix `root` (see: https://remix.run/docs/en/v1/guides/migrating-react-router-app#creating-the-root-route)
* To enable pageload/navigation tracing on every route.
*/
export function withSentryRouteTracing<P extends Record<string, unknown>, R extends React.FC<P>>(App: R): R {
// @ts-ignore Setting more specific React Component typing for `R` generic above
// will break advanced type inference done by react router params
return withSentry(App);
}

/**
* Wraps a remix `root` (see: https://remix.run/docs/en/v1/guides/migrating-react-router-app#creating-the-root-route)
* To enable pageload/navigation tracing on every route.
* Also wraps the application with `ErrorBoundary`.
*
* @param OrigApp The Remix root to wrap
* @param options The options for ErrorBoundary wrapper.
*/
export function withSentryRouteTracing<P extends Record<string, unknown>, R extends React.FC<P>>(
export function withSentry<P extends Record<string, unknown>, R extends React.FC<P>>(
OrigApp: R,
options: {
wrapWithErrorBoundary?: boolean;
Expand Down

0 comments on commit 0a59239

Please sign in to comment.