Skip to content

Conversation

@sbroenne
Copy link
Owner

@sbroenne sbroenne commented Dec 1, 2025

Summary

Simplifies telemetry architecture by making it always enabled and embedding the AppInsights connection string at build time.

Changes

Telemetry Simplification

  • Remove opt-out functionality (EXCELMCP_TELEMETRY_OPTOUT environment variable)
  • Simplify IsEnabled to always return true
  • Remove IsOptedOut() method

Build-Time Connection String

  • Embed AppInsights connection string at build time via MSBuild GenerateTelemetryConfig target
  • Add custom WriteTextFile inline task to handle semicolons in connection strings
  • Generate TelemetryConfig.g.cs with embedded connection string
  • Remove runtime environment variable lookup

Local Development

  • Add Directory.Build.props.user.template for local dev setup
  • Directory.Build.props.user (gitignored) contains local connection string
  • MSBuild reads AppInsightsConnectionString property at build time

Release Workflows

  • Update release-mcp-server.yml to pass connection string via MSBuild property
  • Update release-vscode-extension.yml similarly
  • Remove manual string replacement steps

Cleanup

  • Remove obsolete test.runsettings and test.runsettings.local files
  • Remove RunSettingsFilePath from tests/Directory.Build.props
  • Update documentation in docs/DEVELOPMENT.md

Testing

  • All 36 telemetry tests pass
  • Build succeeds with 0 warnings

…string

- Remove opt-out functionality (EXCELMCP_TELEMETRY_OPTOUT)
- Embed AppInsights connection string at build time via MSBuild
- Add Directory.Build.props.user for local dev connection string
- Remove runtime environment variable lookup for connection string
- Update release workflows to pass connection string to build
- Remove obsolete test.runsettings file
- Simplify IsEnabled to always return true
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
nuget/Microsoft.ApplicationInsights.WorkerService >= 0 UnknownUnknown

Scanned Files

  • src/ExcelMcp.McpServer/ExcelMcp.McpServer.csproj

Stefan Broenner added 5 commits December 1, 2025 11:29
- Reduce prompts from 14 to 2 (keep only high-value guides)
- Remove 13 orphaned .md content files
- Fix ExcelWorksheetTool incorrect 'save' action reference
- Improve ExcelRangeTool and ExcelNamedRangeTool descriptions
- Slim ServerInstructions to essential info only
- Remove redundant telemetry flush (SDK handles automatically)
- Set Component.Version explicitly to override SDK auto-detection
  (was picking up Excel COM interop 15.0.0.0 instead of app 1.0.0)
- Anonymize cloud_RoleInstance (was exposing machine name)
- Now all telemetry context values are privacy-safe:
  - application_Version: from assembly metadata
  - cloud_RoleName: fixed 'ExcelMcp.McpServer'
  - cloud_RoleInstance: anonymous hash 'instance-xxxx'
  - user_Id: anonymous hash of machine identity
  - session_Id: random per session
- Remove debug mode from telemetry (simplify code)
- Fix PageView tracking to include duration (required for User Flows)
- Always override application_Version (SDK picks up Excel 15.0.0.0)
- Add explicit Flush() call in smoke tests for reliable telemetry delivery
- Fix smoke test shutdown to use graceful shutdown before cancellation

Telemetry now correctly populates:
- requests table (with duration, success, resultCode)
- pageViews table (with duration for User Flows)
- user_Id and session_Id (for Users/Sessions blades)
- application_Version (MCP Server version, not Excel)
@sbroenne sbroenne merged commit 073f254 into main Dec 1, 2025
4 checks passed
@sbroenne sbroenne deleted the feature/telemetry-simplification branch December 1, 2025 13:34
string.Equals(optOut, "1", StringComparison.OrdinalIgnoreCase);
// Connection string is embedded at build time from Directory.Build.props.user
// Returns null if not set (placeholder value starts with __)
if (string.IsNullOrEmpty(TelemetryConfig.ConnectionString) ||

Check warning

Code scanning / CodeQL

Constant condition Warning

Condition always evaluates to 'true'.

Copilot Autofix

AI about 6 hours ago

Copilot could not generate an autofix suggestion

Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.

if (string.IsNullOrEmpty(TelemetryConfig.ConnectionString) ||
TelemetryConfig.ConnectionString.StartsWith("__", StringComparison.Ordinal))
{
Console.Error.WriteLine($"[TELEMETRY DIAG] GetConnectionString returning null. Raw value: '{TelemetryConfig.ConnectionString ?? "(null)"}'");

Check warning

Code scanning / CodeQL

Constant condition Warning

Expression is never 'null'.

Copilot Autofix

AI about 6 hours ago

The best way to fix this is to simplify the logging line (line 79) so that it does not redundantly use the null-coalescing operator on TelemetryConfig.ConnectionString. Since the function returns early if TelemetryConfig.ConnectionString is either null or a placeholder, we can be certain it is not null at this log point, making the ?? "(null)" clause unnecessary.

Specifically, modify line 79 in src/ExcelMcp.McpServer/Telemetry/ExcelMcpTelemetry.cs to use TelemetryConfig.ConnectionString directly in the string interpolation, removing the unnecessary null check.

No imports or additional definitions are required for this change.


Suggested changeset 1
src/ExcelMcp.McpServer/Telemetry/ExcelMcpTelemetry.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/ExcelMcp.McpServer/Telemetry/ExcelMcpTelemetry.cs b/src/ExcelMcp.McpServer/Telemetry/ExcelMcpTelemetry.cs
--- a/src/ExcelMcp.McpServer/Telemetry/ExcelMcpTelemetry.cs
+++ b/src/ExcelMcp.McpServer/Telemetry/ExcelMcpTelemetry.cs
@@ -76,7 +76,7 @@
         if (string.IsNullOrEmpty(TelemetryConfig.ConnectionString) ||
             TelemetryConfig.ConnectionString.StartsWith("__", StringComparison.Ordinal))
         {
-            Console.Error.WriteLine($"[TELEMETRY DIAG] GetConnectionString returning null. Raw value: '{TelemetryConfig.ConnectionString ?? "(null)"}'");
+            Console.Error.WriteLine($"[TELEMETRY DIAG] GetConnectionString returning null. Raw value: '{TelemetryConfig.ConnectionString}'");
             return null;
         }
         Console.Error.WriteLine($"[TELEMETRY DIAG] GetConnectionString returning valid connection string (length={TelemetryConfig.ConnectionString.Length})");
EOF
@@ -76,7 +76,7 @@
if (string.IsNullOrEmpty(TelemetryConfig.ConnectionString) ||
TelemetryConfig.ConnectionString.StartsWith("__", StringComparison.Ordinal))
{
Console.Error.WriteLine($"[TELEMETRY DIAG] GetConnectionString returning null. Raw value: '{TelemetryConfig.ConnectionString ?? "(null)"}'");
Console.Error.WriteLine($"[TELEMETRY DIAG] GetConnectionString returning null. Raw value: '{TelemetryConfig.ConnectionString}'");
return null;
}
Console.Error.WriteLine($"[TELEMETRY DIAG] GetConnectionString returning valid connection string (length={TelemetryConfig.ConnectionString.Length})");
Copilot is powered by AI and may make mistakes. Always verify output.
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.

2 participants