File tree 4 files changed +201
-168
lines changed
4 files changed +201
-168
lines changed Original file line number Diff line number Diff line change
1
+ import * as applicationinsights from 'applicationinsights'
2
+
1
3
export default function ( ctx , inject ) {
2
4
// Inject AppInsights to the context as $appInsights
3
- inject ( 'appInsights' , process . appInsights || { } )
5
+ const config = < %= serialize ( options . config ) % >
6
+ const appInsightsServer = applicationinsights . setup ( < %= serialize ( options . instrumentationKey ) % > )
7
+ applicationinsights . defaultClient . config = config
8
+ if ( optionsServer . initialize ) {
9
+ appInsightsServer . start ( )
10
+ }
11
+ inject ( 'appInsights' , applicationinsights || { } )
4
12
}
Original file line number Diff line number Diff line change @@ -60,22 +60,28 @@ module.exports = function appInsights (moduleOptions) {
60
60
const optionsServer = deepMerge . all ( [ options , privateRuntimeConfig ] )
61
61
62
62
const appInsightsServer = AppInsights . setup ( optionsServer . instrumentationKey )
63
+ const config = { ...AppInsights . defaultClient . config , ...optionsServer . serverConfig }
63
64
64
- AppInsights . defaultClient . config = { ... AppInsights . defaultClient . config , ... optionsServer . serverConfig }
65
+ AppInsights . defaultClient . config = config
65
66
// Initialize AppInsights
66
67
if ( optionsServer . initialize ) {
67
68
appInsightsServer . start ( )
68
69
}
69
70
const appInsightsClient = AppInsights . defaultClient
70
71
71
- process . appInsights = appInsightsClient
72
72
logger . success ( 'Started logging errors to AppInsights' )
73
73
74
74
this . addPlugin ( {
75
75
src : path . resolve ( __dirname , 'appinsights.server.js' ) ,
76
76
fileName : 'appinsights.server.js' ,
77
- mode : 'server'
77
+ mode : 'server' ,
78
+ options : {
79
+ instrumentationKey : optionsServer . instrumentationKey ,
80
+ config,
81
+ initialize : optionsServer . initialize
82
+ }
78
83
} )
84
+
79
85
this . nuxt . hook ( 'render:setupMiddleware' , app => app . use ( requestHandler ( appInsightsClient ) ) )
80
86
this . nuxt . hook ( 'render:errorMiddleware' , app => app . use ( errorHandler ( appInsightsClient ) ) )
81
87
this . nuxt . hook ( 'generate:routeFailed' , ( { errors } ) => {
Original file line number Diff line number Diff line change 22
22
"nuxt" : " node --inspect=0.0.0.0 node_modules/nuxt-edge/bin/nuxt test/fixture"
23
23
},
24
24
"dependencies" : {
25
- "applicationinsights" : " ^2.1.2 " ,
26
- "@microsoft/applicationinsights-web" : " ^2.6.3 " ,
25
+ "applicationinsights" : " ^2.3.3 " ,
26
+ "@microsoft/applicationinsights-web" : " ^2.8.5 " ,
27
27
"consola" : " ^2.15.0" ,
28
28
"deepmerge" : " ^4.2.2"
29
29
},
You can’t perform that action at this time.
0 commit comments