diff --git a/lib/module.js b/lib/module.js index 7f048fd..d1dbe67 100644 --- a/lib/module.js +++ b/lib/module.js @@ -64,11 +64,14 @@ module.exports = function appInsights (moduleOptions) { logger.info('Server errors will not be logged because no serverConnectionString provided') return } + const appInsightsServer = AppInsights.setup(optionsServer.serverConnectionString) - const config = { ...AppInsights.defaultClient.config, ...optionsServer.serverConfig } - AppInsights.defaultClient.config = config // Initialize AppInsights + for (const [key, value] of Object.entries(optionsServer.serverConfig)) { + AppInsights.defaultClient.config[key] = value + } + if (optionsServer.initialize) { appInsightsServer.start() }