1
1
/* eslint-disable import/order */
2
2
import Vue from 'vue'
3
3
import merge from '~lodash.mergewith'
4
- import * as Sentry from '~@sentry/vue'
5
- < % if ( options . tracing ) { % > import { BrowserTracing } from '~@sentry/tracing' < % } % >
6
4
< %
7
- if ( options . initialize ) {
8
- let integrations = options . BROWSER_PLUGGABLE_INTEGRATIONS . filter ( key => key in options . integrations )
9
- if ( integrations . length ) { % > import { < %= integrations . join ( ', ' ) % > } from '~@sentry/integrations'
5
+ const vueImports = [ 'getCurrentHub' , 'init' , 'Integrations' , ...( options . tracing ? [ 'vueRouterInstrumentation' ] : [ ] ) ]
6
+ % > import { < %= vueImports . join ( ', ' ) % > } from '~@sentry/vue'
7
+ < %
8
+ if ( options . tracing ) { % > import { BrowserTracing } from '~@sentry/tracing'
10
9
< % }
11
- if ( options . clientConfigPath ) { % > import getClientConfig from '<%= options.clientConfigPath %>'
10
+ let integrations = options . BROWSER_PLUGGABLE_INTEGRATIONS . filter ( key => key in options . integrations )
11
+ if ( integrations . length ) { % > import { < %= integrations . join ( ', ' ) % > } from '~@sentry/integrations'
12
12
< % }
13
- if ( options . customClientIntegrations ) { % > import getCustomIntegrations from '<%= options.customClientIntegrations %>'
13
+ if ( options . clientConfigPath ) { % > import getClientConfig from '<%= options.clientConfigPath %>'
14
14
< % }
15
- integrations = options . BROWSER_INTEGRATIONS . filter ( key => key in options . integrations )
16
- if ( integrations . length ) { % >
17
- const { < %= integrations . join ( ', ' ) % > } = Sentry . Integrations
15
+ if ( options . customClientIntegrations ) { % > import getCustomIntegrations from '<%= options.customClientIntegrations %>'
16
+ < % }
17
+ integrations = options . BROWSER_INTEGRATIONS . filter ( key => key in options . integrations )
18
+ if ( integrations . length ) { % >
19
+ const { < %= integrations . join ( ', ' ) % > } = Integrations
18
20
< % }
19
- }
20
21
% >
21
22
22
23
export default async function ( ctx , inject ) {
23
- < % if ( options . initialize ) { % >
24
24
/* eslint-disable object-curly-spacing, quote-props, quotes, key-spacing, comma-spacing */
25
25
const config = {
26
26
Vue,
@@ -53,7 +53,7 @@ export default async function (ctx, inject) {
53
53
// eslint-disable-next-line prefer-regex-literals
54
54
const { browserTracing, vueOptions, ...tracingOptions } = < %= serialize ( options . tracing ) % >
55
55
config . integrations . push ( new BrowserTracing ( {
56
- ...( ctx . app . router ? { routingInstrumentation : Sentry . vueRouterInstrumentation ( ctx . app . router ) } : { } ) ,
56
+ ...( ctx . app . router ? { routingInstrumentation : vueRouterInstrumentation ( ctx . app . router ) } : { } ) ,
57
57
...browserTracing ,
58
58
} ) )
59
59
merge ( config , vueOptions , tracingOptions )
@@ -79,9 +79,8 @@ export default async function (ctx, inject) {
79
79
}
80
80
81
81
/* eslint-enable object-curly-spacing, quote-props, quotes, key-spacing, comma-spacing */
82
- Sentry . init ( config )
83
- < % } % >
84
-
85
- inject ( 'sentry' , Sentry )
86
- ctx . $sentry = Sentry
82
+ init ( config )
83
+ const sentryClient = getCurrentHub ( ) . getClient ( )
84
+ inject ( 'sentry' , sentryClient )
85
+ ctx . $sentry = sentryClient
87
86
}
0 commit comments