Skip to content

Commit

Permalink
Use npm package for app insights web configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Nov 29, 2024
1 parent 440cb9e commit ea82c6c
Show file tree
Hide file tree
Showing 4 changed files with 326 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@
=======
@if (hasConsented && enableAppInsightsBrowserAnalytics)
{
<!-- Application Insights -->
<!-- Application insights -->
<script type="text/javascript" integrity="sha384-g/ZkzetdQypWdY0NBZT5r2L3BR9/hURD8OBcd1rEaBpgX6QC7EaTL+o+mzWrBcXW" crossorigin="anonymous" src="https://js.monitor.azure.com/scripts/b/ext/ai.clck.2.8.18.min.js"></script>
<script type="text/javascript" asp-add-nonce>
@Html.Raw(AIJavaScriptSnippet.ScriptBody)
// Load the Click analytics plugin
var clickPluginInstance = new Microsoft.ApplicationInsights.ClickAnalyticsPlugin();
window.appInsights.setAuthenticatedUserContext("@authenticatedUserId", null, true);
window.appInsights = {
connectionString: '@_configuration["ApplicationInsights:ConnectionString"]',
authenticatedUserId: '@authenticatedUserId'
}
</script>
<script type="text/javascript" src="~/dist/application-insights.min.js" asp-add-nonce></script>
<!-- End Application insights -->
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Dfe.ManageFreeSchoolProjects
@addTagHelper *, NetEscapades.AspNetCore.SecurityHeaders.TagHelpers
@inject Microsoft.ApplicationInsights.AspNetCore.JavaScriptSnippet AIJavaScriptSnippet;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"scripts": {
"build": "npm run build:assets && npm run build:frontend",
"build:frontend": "webpack",
"build:assets": "webpack --config webpack.assets.config.js",
"build:assets": "webpack --config webpack.assets.config.js & npm run build:assets:application-insights",
"build:assets:application-insights": "webpack --config webpack.appinsights.config.js",
"build:watch": "webpack --watch"
},
"devDependencies": {
Expand All @@ -20,6 +21,7 @@
"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"
}
}

0 comments on commit ea82c6c

Please sign in to comment.