Update KQL queries in Application Insights#458
Merged
JoeProgrammer88 merged 3 commits intomainfrom Jan 14, 2026
Merged
Conversation
Replaced references to the pageViews and customEvents tables with AppPageViews and AppEvents in the AnalyticsService class. This ensures analytics queries for page views, newsletter downloads, and resource guide searches use the updated table names. No other query logic was changed.
Added a TrackNewsletterDownload endpoint to ResourcesController to log newsletter download events using Application Insights. Introduced NewsletterDownloadRequest model for AJAX payload. Updated FocusNewsletters.cshtml to send download tracking data to the server via AJAX with anti-forgery token, replacing direct client-side telemetry calls. PDF still opens in a new window after tracking.
Adds a new "Unique Visitors" metric to the admin analytics dashboard, displaying the total number of unique users for the selected date range. Updates AnalyticsViewModel and AnalyticsService to calculate and retrieve this value from Application Insights using a new GetUniqueUsersAsync method. Adjusts Kusto queries to use the latest schema and ensure accurate user counting. Updates the UI to show the unique visitors count and includes it in the analyticsData JavaScript object. Also updates the "no data" message logic to consider unique users. Minor schema and formatting improvements included.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
KQL queries for analytics data needed to be updated to pull info from the log analytics workspace. This involved a few identifier name changes in the queries themselves. Number of unique users has also been added. Queries should only look at human generated data and not bot data
Copilot Summary
This pull request introduces a new unique user analytics metric, refines how analytics data is queried and displayed, and improves newsletter download tracking. The changes enhance the accuracy and usefulness of analytics reporting, especially around user engagement and event logging.
Analytics Enhancements:
TotalUniqueUsersproperty toAnalyticsViewModel, and implemented logic to calculate and display the number of unique visitors in the specified date range on the analytics dashboard. [1] [2] [3] [4] [5] [6]AdminController.Analyticsto show the "no data" message only if all metrics, including unique users, are zero.Analytics Query Improvements:
AppPageViews,AppEvents,Properties) for page views, downloads, and searches, ensuring more accurate and consistent analytics data. [1] [2] [3]Newsletter Download Tracking:
TrackNewsletterDownload) inResourcesControllerfor newsletter downloads, improving reliability and security of event logging. [1] [2]