Skip to content

Update KQL queries in Application Insights#458

Merged
JoeProgrammer88 merged 3 commits intomainfrom
UpdateAppInsightsSDK
Jan 14, 2026
Merged

Update KQL queries in Application Insights#458
JoeProgrammer88 merged 3 commits intomainfrom
UpdateAppInsightsSDK

Conversation

@JoeProgrammer88
Copy link
Copy Markdown
Member

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:

  • Added a new TotalUniqueUsers property to AnalyticsViewModel, 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]
  • Updated the logic in AdminController.Analytics to show the "no data" message only if all metrics, including unique users, are zero.

Analytics Query Improvements:

  • Refactored Kusto queries to use new tables and fields (AppPageViews, AppEvents, Properties) for page views, downloads, and searches, ensuring more accurate and consistent analytics data. [1] [2] [3]

Newsletter Download Tracking:

  • Replaced client-side Application Insights tracking with a server-side endpoint (TrackNewsletterDownload) in ResourcesController for newsletter downloads, improving reliability and security of event logging. [1] [2]

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.
@JoeProgrammer88 JoeProgrammer88 merged commit a8a95ef into main Jan 14, 2026
1 check passed
@JoeProgrammer88 JoeProgrammer88 deleted the UpdateAppInsightsSDK branch January 14, 2026 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant