File tree Expand file tree Collapse file tree 4 files changed +201
-168
lines changed Expand file tree Collapse file tree 4 files changed +201
-168
lines changed Original file line number Diff line number Diff line change 1+ import * as applicationinsights from 'applicationinsights'
2+
13export default function ( ctx , inject ) {
24 // 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 || { } )
412}
Original file line number Diff line number Diff line change @@ -60,22 +60,28 @@ module.exports = function appInsights (moduleOptions) {
6060 const optionsServer = deepMerge . all ( [ options , privateRuntimeConfig ] )
6161
6262 const appInsightsServer = AppInsights . setup ( optionsServer . instrumentationKey )
63+ const config = { ...AppInsights . defaultClient . config , ...optionsServer . serverConfig }
6364
64- AppInsights . defaultClient . config = { ... AppInsights . defaultClient . config , ... optionsServer . serverConfig }
65+ AppInsights . defaultClient . config = config
6566 // Initialize AppInsights
6667 if ( optionsServer . initialize ) {
6768 appInsightsServer . start ( )
6869 }
6970 const appInsightsClient = AppInsights . defaultClient
7071
71- process . appInsights = appInsightsClient
7272 logger . success ( 'Started logging errors to AppInsights' )
7373
7474 this . addPlugin ( {
7575 src : path . resolve ( __dirname , 'appinsights.server.js' ) ,
7676 fileName : 'appinsights.server.js' ,
77- mode : 'server'
77+ mode : 'server' ,
78+ options : {
79+ instrumentationKey : optionsServer . instrumentationKey ,
80+ config,
81+ initialize : optionsServer . initialize
82+ }
7883 } )
84+
7985 this . nuxt . hook ( 'render:setupMiddleware' , app => app . use ( requestHandler ( appInsightsClient ) ) )
8086 this . nuxt . hook ( 'render:errorMiddleware' , app => app . use ( errorHandler ( appInsightsClient ) ) )
8187 this . nuxt . hook ( 'generate:routeFailed' , ( { errors } ) => {
Original file line number Diff line number Diff line change 2222 "nuxt" : " node --inspect=0.0.0.0 node_modules/nuxt-edge/bin/nuxt test/fixture"
2323 },
2424 "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 " ,
2727 "consola" : " ^2.15.0" ,
2828 "deepmerge" : " ^4.2.2"
2929 },
You can’t perform that action at this time.
0 commit comments