@@ -83,13 +83,10 @@ async function attemptLoadSentry (ctx, inject) {
8383 if ( ! window . < %= globals . nuxt % > ) {
8484 < % if ( options . dev ) { % >
8585 console . warn ( '$sentryLoad was called but window.<%= globals.nuxt %> is not available, delaying sentry loading until onNuxtReady callback. Do you really need to use lazy loading for Sentry?' )
86- < % } % >
87- < % if ( options . lazy . injectLoadHook ) { % >
88- window . < %= globals . readyCallback % > ( ( ) => loadSentry ( ctx , inject ) )
89- < % } else { % >
90- // Wait for onNuxtReady hook to trigger.
91- < % } % >
92- return
86+ < % }
87+ if ( options . lazy . injectLoadHook ) { % > window . < %= globals . readyCallback % > ( ( ) => loadSentry ( ctx , inject ) )
88+ < % } else { % > // Wait for onNuxtReady hook to trigger.
89+ < % } % > return
9390 }
9491
9592 await loadSentry ( ctx , inject )
@@ -109,86 +106,10 @@ async function loadSentry (ctx, inject) {
109106 magicComments . push ( 'webpackPreload: true' )
110107 }
111108 % >
112- const Sentry = await import ( /* <%= magicComments.join(', ') %> */ '~@sentry/vue' )
113- < % if ( options . tracing ) { % > const { BrowserTracing } = await import ( /* <%= magicComments.join(', ') %> */ '~@sentry/tracing' ) < % } % >
114- < %
115- if ( options . initialize ) {
116- let integrations = options . BROWSER_PLUGGABLE_INTEGRATIONS . filter ( key => key in options . integrations )
117- if ( integrations . length ) { % > const { < %= integrations . join ( ', ' ) % > } = await import ( /* <%= magicComments.join(', ') %> */ '~@sentry/integrations' )
118- < % }
119- integrations = options . BROWSER_INTEGRATIONS . filter ( key => key in options . integrations )
120- if ( integrations . length ) { % > const { < %= integrations . join ( ', ' ) % > } = Sentry . Integrations
121- < % }
122-
123- const serializedConfig = Object
124- . entries ( {
125- ...options . config ,
126- ...( options . tracing ? options . tracing . vueOptions : { } ) ,
127- } )
128- . map ( ( [ key , option ] ) => {
129- const value = typeof option === 'function' ? serializeFunction ( option ) : serialize ( option )
130- return `${ key } : ${ value } `
131- } )
132- . join ( ',\n ' )
133- % >
134- /* eslint-disable quotes, key-spacing */
135- const config = {
136- Vue,
137- < %= serializedConfig % > ,
138- }
139-
140- const runtimeConfigKey = < %= serialize ( options . runtimeConfigKey ) % >
141- if ( ctx . $config && runtimeConfigKey && ctx . $config [ runtimeConfigKey ] ) {
142- const { default : merge } = await import ( /* <%= magicComments.join(', ') %> */ '~lodash.mergewith' )
143- merge ( config , ctx . $config [ runtimeConfigKey ] . config , ctx . $config [ runtimeConfigKey ] . clientConfig )
144- }
145-
146- config . integrations = [
147- < %= Object
148- . entries ( options . integrations )
149- . filter ( ( [ name ] ) => name !== 'Vue' )
150- . map ( ( [ name , integration ] ) => {
151- const integrationOptions = Object
152- . entries ( integration )
153- . map ( ( [ key , option ] ) => {
154- const value = typeof option === 'function' ? serializeFunction ( option ) : serialize ( option )
155- return `${ key } :${ value } `
156- } )
157-
158- return `new ${ name } (${ integrationOptions . length ? '{ ' + integrationOptions . join ( ',' ) + ' }' : '' } )`
159- } ) . join ( ',\n ' )
160- % > ,
161- ]
162- < % if ( options . tracing ) {
163- const serializedTracingConfig = Object
164- . entries ( options . tracing . browserTracing )
165- . map ( ( [ key , option ] ) => {
166- const value = typeof option === 'function' ? serializeFunction ( option ) : serialize ( option )
167- return `${ key } : ${ value } `
168- } )
169- . join ( ',\n ' )
170- % >
171- config . integrations . push ( new BrowserTracing ( {
172- ...( ctx . app . router ? { routingInstrumentation : Sentry . vueRouterInstrumentation ( ctx . app . router ) } : { } ) ,
173- < %= serializedTracingConfig % >
174- } ) )
175- < % } % >
176-
177- < % if ( options . clientConfigPath ) { % >
178- const clientConfig = ( await import ( /* <%= magicComments.join(', ') %> */ '<%= options.clientConfigPath %>' ) . then ( m => m . default || m ) ) ( ctx )
179- const { default : merge } = await import ( /* <%= magicComments.join(', ') %> */ '~lodash.mergewith' )
180- clientConfig ? merge ( config , clientConfig ) : console . error ( `[@nuxtjs/sentry] Invalid value returned from the clientConfig plugin.` )
181- < % } % >
182-
183- < % if ( options . customClientIntegrations ) { % >
184- const customIntegrations = ( await import ( /* <%= magicComments.join(', ') %> */ '<%= options.customClientIntegrations %>' ) . then ( m => m . default || m ) ) ( ctx )
185- if ( Array . isArray ( customIntegrations ) ) {
186- config . integrations . push ( ...customIntegrations )
187- } else {
188- console . error ( `[@nuxtjs/sentry] Invalid value returned from customClientIntegrations plugin. Expected an array, got "${ typeof customIntegrations } ".` )
189- }
190- < % } % >
191- Sentry . init ( config )
109+ const { getConfig, init, SentrySdk } = await import ( /* <%= magicComments.join(', ') %> */ './sentry.client.shared' )
110+ < % if ( options . initialize ) { % >
111+ const config = await getConfig ( ctx )
112+ init ( { Vue, ...config } )
192113 < % } % >
193114
194115 loadCompleted = true
@@ -213,12 +134,10 @@ async function loadSentry (ctx, inject) {
213134 }
214135 delayedUnhandledRejections = [ ]
215136 }
216- delayedCalls . forEach ( ( [ methodName , args ] ) => Sentry [ methodName ] . apply ( Sentry , args ) )
137+ delayedCalls . forEach ( ( [ methodName , args ] ) => SentrySdk [ methodName ] . apply ( SentrySdk , args ) )
217138 < % } % >
218-
219- forceInject ( ctx , inject , 'sentry' , Sentry )
220-
221- sentryReadyResolve ( Sentry )
139+ forceInject ( ctx , inject , 'sentry' , SentrySdk )
140+ sentryReadyResolve ( SentrySdk )
222141
223142 // help gc
224143 < % if ( options . lazy . injectMock ) { % >
@@ -234,7 +153,6 @@ async function loadSentry (ctx, inject) {
234153 sentryReadyResolve = undefined
235154}
236155
237-
238156// Custom inject function that is able to overwrite previously injected values,
239157// which original inject doesn't allow to do.
240158// This method is adapted from the inject method in nuxt/vue-app/template/index.js
0 commit comments