diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/src/application-insights.js b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/src/application-insights.js new file mode 100644 index 000000000..a786f777d --- /dev/null +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/src/application-insights.js @@ -0,0 +1,16 @@ +// App Insights frontend +import { ApplicationInsights } from '@microsoft/applicationinsights-web' + +const clickPluginInstance = new Microsoft.ApplicationInsights.ClickAnalyticsPlugin(); +const appInsights = new ApplicationInsights({ config: { + connectionString: window.appInsights.connectionString, + extensions: [ clickPluginInstance ], + extensionConfig: { [clickPluginInstance.identifier] : { + autoCapture : true, + dataTags: { useDefaultContentNameOrId: true } + } }, +} }); + +appInsights.loadAppInsights(); +appInsights.setAuthenticatedUserContext(window.appInsights.authenticatedUserId, null, true); +appInsights.trackPageView(); diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/webpack.appinsights.config.js b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/webpack.appinsights.config.js new file mode 100644 index 000000000..d872596f9 --- /dev/null +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/webpack.appinsights.config.js @@ -0,0 +1,9 @@ +const path = require('path'); + +module.exports = { + entry: ['./src/application-insights.js', './node_modules/@microsoft/applicationinsights-web/dist/es5/applicationinsights-web.min.js'], + output: { + path: path.resolve(__dirname, 'dist'), + filename: 'application-insights.min.js', + } +};