From 7707a1af010b697de2143721d78d7e6c38ad2f6c Mon Sep 17 00:00:00 2001 From: Ash Davies <3853061+DrizzlyOwl@users.noreply.github.com> Date: Tue, 18 Jun 2024 17:21:14 +0100 Subject: [PATCH] Asset build workflow --- .../wwwroot/package-lock.json | 85 ++++++++++--------- .../wwwroot/src/application-insights.js | 16 ++++ .../wwwroot/webpack.appinsights.config.js | 9 ++ 3 files changed, 70 insertions(+), 40 deletions(-) create mode 100644 Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/src/application-insights.js create mode 100644 Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/webpack.appinsights.config.js diff --git a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/package-lock.json b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/package-lock.json index 7e291d8bb..f74a0436e 100644 --- a/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/package-lock.json +++ b/Dfe.ManageFreeSchoolProjects/Dfe.ManageFreeSchoolProjects/wwwroot/package-lock.json @@ -5,10 +5,10 @@ "packages": { "": { "dependencies": { + "@microsoft/applicationinsights-web": "^3.2.2", "accessible-autocomplete": "^3.0.0", "dfe-frontend": "2.0.1", "govuk-frontend": "5.4.1", - "@microsoft/applicationinsights-web": "^3.2.2", "jquery": "^3.6.1" }, "devDependencies": { @@ -46,15 +46,6 @@ "node": ">=6.0.0" } }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/@jridgewell/set-array": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", @@ -90,6 +81,23 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/trace-mapping/node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true, + "license": "MIT" + }, "node_modules/@microsoft/applicationinsights-analytics-js": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/@microsoft/applicationinsights-analytics-js/-/applicationinsights-analytics-js-3.2.2.tgz", @@ -233,21 +241,6 @@ "@nevware21/ts-utils": ">= 0.10.4 < 2.x" } }, - "node_modules/@ministryofjustice/frontend": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@ministryofjustice/frontend/-/frontend-1.8.0.tgz", - "integrity": "sha512-N4791HcFoqJNLNrK6EN4oMaTJjeFp9ileavCpXkda3qvpEWQByxZUsOd6sDA69FuLRpB6jBFL2C2bqfYbcTdqg==", - "dependencies": { - "govuk-frontend": "^3.0.0 || ^4.0.0", - "moment": "^2.27.0" - }, - "engines": { - "node": ">= 4.2.0" - }, - "peerDependencies": { - "jquery": "^3.6.0" - } - }, "node_modules/@nevware21/ts-async": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.5.1.tgz", @@ -2323,6 +2316,13 @@ "node": ">=8.0" } }, + "node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "license": "0BSD", + "peer": true + }, "node_modules/unicorn-magic": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", @@ -2562,12 +2562,6 @@ "@jridgewell/trace-mapping": "^0.3.24" } }, - "@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true - }, "@jridgewell/set-array": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", @@ -2598,6 +2592,20 @@ "requires": { "@jridgewell/resolve-uri": "3.1.0", "@jridgewell/sourcemap-codec": "1.4.14" + }, + "dependencies": { + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + } } }, "@microsoft/applicationinsights-analytics-js": { @@ -2719,15 +2727,6 @@ "@nevware21/ts-utils": ">= 0.10.4 < 2.x" } }, - "@ministryofjustice/frontend": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@ministryofjustice/frontend/-/frontend-1.8.0.tgz", - "integrity": "sha512-N4791HcFoqJNLNrK6EN4oMaTJjeFp9ileavCpXkda3qvpEWQByxZUsOd6sDA69FuLRpB6jBFL2C2bqfYbcTdqg==", - "requires": { - "govuk-frontend": "^3.0.0 || ^4.0.0", - "moment": "^2.27.0" - } - }, "@nevware21/ts-async": { "version": "0.5.1", "resolved": "https://registry.npmjs.org/@nevware21/ts-async/-/ts-async-0.5.1.tgz", @@ -4164,6 +4163,12 @@ "is-number": "^7.0.0" } }, + "tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "peer": true + }, "unicorn-magic": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz", 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', + } +};