File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import type { Client } from '@sentry/core' ;
22import { applySdkMetadata } from '@sentry/core' ;
3- import { init as reactInit , setRouteProvider } from '@sentry/react' ;
3+ import { init as reactInit } from '@sentry/react' ;
44import type { RemixOptions } from '../utils/remixOptions' ;
55import { createRemixRouteProvider } from './routeProvider' ;
66
@@ -11,18 +11,14 @@ import { createRemixRouteProvider } from './routeProvider';
1111 */
1212export function init ( options : RemixOptions ) : Client | undefined {
1313 const opts = {
14+ // The manifest is injected at build time, so route parameterization works from `init` on, even with
15+ // tracing disabled.
16+ routeProvider : createRemixRouteProvider ( ) ,
1417 ...options ,
1518 environment : options . environment || process . env . NODE_ENV ,
1619 } ;
1720
1821 applySdkMetadata ( opts , 'remix' , [ 'remix' , 'react' ] ) ;
1922
20- const client = reactInit ( opts ) ;
21-
22- // Registered here rather than from the tracing integration so route parameterization does not
23- // depend on tracing: the manifest is injected at build time, so anything that needs a route name
24- // (bfcache metrics, web vitals) can resolve one even with tracing disabled.
25- setRouteProvider ( createRemixRouteProvider ( ) , client ) ;
26-
27- return client ;
23+ return reactInit ( opts ) ;
2824}
Original file line number Diff line number Diff line change @@ -43,6 +43,17 @@ describe('Client init()', () => {
4343 ) ;
4444 } ) ;
4545
46+ it ( 'passes the Remix route provider unless the user passed one' , ( ) => {
47+ init ( { } ) ;
48+ expect ( reactInit ) . toHaveBeenLastCalledWith (
49+ expect . objectContaining ( { routeProvider : expect . objectContaining ( { resolveRoute : expect . any ( Function ) } ) } ) ,
50+ ) ;
51+
52+ const routeProvider = { resolveRoute : ( ) => '/custom' , resolveCurrentRoute : ( ) => '/custom' } ;
53+ init ( { routeProvider } ) ;
54+ expect ( reactInit ) . toHaveBeenLastCalledWith ( expect . objectContaining ( { routeProvider } ) ) ;
55+ } ) ;
56+
4657 it ( 'returns client from init' , ( ) => {
4758 expect ( init ( { } ) ) . not . toBeUndefined ( ) ;
4859 } ) ;
You can’t perform that action at this time.
0 commit comments