Skip to content

fix(telemetry): Re-enable XAML generator telemetry (backport #25846) - #25850

Merged
agneszitte merged 4 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-25846
Nov 2, 2026
Merged

agneszitte merged 4 commits into
release/stable/6.7from
mergify/bp/release/stable/6.7/pr-25846

Conversation

@mergify

@mergify mergify Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

GitHub Issue: related to unoplatform/uno-private#2477 (kept open until the release/stable/6.7 backport ships)

PR Type:

🐞 Bugfix

What changed? 🚀

Since 6.7, the XAML generator sends no build telemetry (uno/generation/generate-xaml, -done, -failed), whether or not the build opted out. 93e435f put the client behind isTelemetryOptout() is true. But Uno.DevTools.Telemetry reads enabledProvider as the opt-out flag (Enabled = !enabledProvider()). So an opted-out build got a disabled client, and every other build got none.

The generator now creates a client only when IsTelemetryDisabled is false. It returns true in five cases:

  • The build opts out: UnoPlatformTelemetryOptOut is 1 or true. This is the root-cause fix.
  • The environment opts out: UNO_PLATFORM_TELEMETRY_OPTOUT is 1 or true, read through the build as a CompilerVisibleProperty.
    • The library parses the variable with bool.TryParse, so only true worked, and 6.6 sent telemetry for users who had set 1.
    • A reused compiler server can also predate the variable.
  • It's a design-time build. _isDesignTimeBuild used to be read before it was set, so every design-time build, 6.6 included, started an enabled client, even though the Track* methods then skipped sending. It's now set first.
  • It's a hot-reload build: UnoIsHotReloadHost. The dev server's hot-reload workspace already evaluates as design-time, because MSBuildWorkspace defaults to DesignTimeBuild=true and BuildingProject=false. The explicit check keeps hot reload silent if that changes.
  • The generator itself runs in a browser. This is defensive hardening for single-threaded WebAssembly hosts.
    • With an enabled client, Flush blocks on Task.Wait, which most likely broke the in-browser build that 93e435f fixed.
    • That host has opted out by MSBuild property since February. This check is a second layer and easy to drop.

The generator test assembly sets UNO_PLATFORM_TELEMETRY_OPTOUT=true in an [AssemblyInitialize]. The test harness doesn't pass that variable as a build property, so the generator's own check never sees it. The clients these tests create stay disabled through the library instead.

Builds that haven't opted out send the same events as 6.6. Because an opted-out build has no client, UNO_PLATFORM_TELEMETRY_OPTOUT=false can no longer re-enable a build that set UnoPlatformTelemetryOptOut.

Reviewer's guide

  • XamlCodeGeneration.Telemetry.cs: the gate (InitTelemetry, IsTelemetryDisabled).
  • XamlCodeGeneration.cs: _isDesignTimeBuild moved ahead of InitTelemetry.
  • Uno.UI.SourceGenerators.props: two new CompilerVisibleProperty entries.
  • Given_XamlTelemetry holds the tests. AssemlyInfo.cs holds the test-run opt-out.

Validation

  • Runtime (unit tests): Given_XamlTelemetry covers IsTelemetryDisabled, not how InitTelemetry wires it up.
    • Disabled: opt-outs by the property (true, True, 1), opt-outs by the variable (true, TRUE, 1, including with the property set to false), design-time builds and hot-reload builds.
    • Enabled: "", false or 0 in either place, and UnoIsHotReloadHost=False.
    • Results: 34 of 34 pass.
    • Mutation checks: inverting the predicate fails all 15 new tests. Removing the variable check fails 4. Removing the design-time or hot-reload check fails 1 each.
  • Build wiring: a probe project importing Uno.UI.SourceGenerators.props gets build_property.UNO_PLATFORM_TELEMETRY_OPTOUT and build_property.UnoIsHotReloadHost. A design-time compile writes DesignTimeBuild = true and BuildingProject = false into the generator's config.
  • Full Uno.UI.SourceGenerators.Tests run: 222 passed, 7 skipped, 403 failed, all with Unable to find Uno.UI.dll because Uno.UI wasn't built. That run was on the first commit and hasn't been repeated, and it was built against net10.0 locally because I don't have a .NET 11 SDK. CI runs the full suite.
  • Not validated: an in-browser build, events arriving in Application Insights, and build time against a blocked telemetry endpoint.

Open questions before merge or backport

  • Confirmation from 93e435f's author that skipping the client for opted-out builds was the intent, and team agreement that a 6.7 servicing release resumes collection.
  • Uno's own CI builds don't opt out. Do the dashboards filter them?

Follow-up

  • Backport to release/stable/6.7 after merge. That branch uses Uno.DevTools.Telemetry 1.3.3 and has no Given_XamlTelemetry, so the backport needs adapting. servicing/6.8 has the same check.
  • In Uno.DevTools.Telemetry:
    • accept 1 and 0 for the variable;
    • cap Dispose's drain, which can block a build for up to about 100s on a network that silently drops traffic (as in 6.6);
    • fix the init/Dispose race that leaves a channel undisposed in long-lived processes;
    • note in TelemetryEnvironment's docs that a host may opt out before creating a client.

PR Checklist ✅

  • 🧪 Added Runtime tests, UI tests, or a manual test sample (for bug fixes / features, if applicable): unit tests in Given_XamlTelemetry
  • 📚 Docs have been added/updated following the documentation template (for bug fixes / features): not needed. doc/articles/uno-toolchain-telemetry.md already documents 1 or true, and the generator now matches it
  • 🖼️ Validated PR Screenshots Compare Test Run results.
  • ❗ Contains NO breaking changes
  • 👀 Reviewed 2 other open pull requests (optional but appreciated!)

🤖 Generated with Claude Code


This is an automatic backport of pull request #25846 done by [Mergify](https://mergify.com).

rajamatt and others added 3 commits October 30, 2026 18:52
Since 6.7 the generator created its telemetry client only when the
build had opted out, so no build sent generate-xaml events. It now
creates one only when the build hasn't opted out, isn't a design-time
build and isn't running in the browser.

InitTelemetry runs before _isDesignTimeBuild is set, so the design-time
check now reads the context directly.

The generator tests opt out through UNO_PLATFORM_TELEMETRY_OPTOUT, so
running them doesn't send build telemetry.

Related to unoplatform/uno-private#2477

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 9d47558)

# Conflicts:
#	src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_XamlTelemetry.cs
The documented UNO_PLATFORM_TELEMETRY_OPTOUT=1 didn't stop the
generator: the telemetry library parses the variable with
bool.TryParse, so only "true" worked, and a reused compiler server can
predate the variable. The generator now reads it through the build and
creates no client when it's "1" or "true".

An MSBuild opt-out also wins over UNO_PLATFORM_TELEMETRY_OPTOUT=false
now, since an opted-out build has no client to enable.

Related to unoplatform/uno-private#2477

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit d080127)
- The dev server's hot-reload workspace flags its builds with
  UnoIsHotReloadHost; the generator now creates no client for them.
  That workspace already evaluates as a design-time build, so this
  keeps hot reload silent if that ever changes.
- Replace the CreateTelemetry factory with an IsTelemetryDisabled
  predicate.
- Set _isDesignTimeBuild before InitTelemetry, and drop the Track*
  checks that a design-time build no longer reaches.
- Comment the environment-variable property and the test hook.

Related to unoplatform/uno-private#2477

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2089192)
@mergify mergify Bot added the conflicts Automated merge hit conflicts label Oct 30, 2026
@mergify

mergify Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 9d47558 has failed:

On branch mergify/bp/release/stable/6.7/pr-25846
Your branch is up to date with 'origin/release/stable/6.7'.

You are currently cherry-picking commit 9d47558.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   src/SourceGenerators/Uno.UI.SourceGenerators.Tests/AssemlyInfo.cs
	modified:   src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlCodeGeneration.Telemetry.cs

Unmerged paths:
  (use "git add/rm <file>..." as appropriate to mark resolution)
	deleted by us:   src/SourceGenerators/Uno.UI.SourceGenerators.Tests/XamlCodeGeneratorTests/Given_XamlTelemetry.cs

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@github-actions github-actions Bot added the area/code-generation Categorizes an issue or PR as relevant to code generation label Oct 30, 2026
@rajamatt rajamatt self-assigned this Oct 30, 2026
Given_XamlTelemetry doesn't exist on 6.7, so the cherry-pick brought
in master's whole file, including the GetUnoRuntime tests. 6.7 has no
GetUnoRuntime, so only the telemetry gate tests are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@rajamatt
rajamatt enabled auto-merge October 30, 2026 19:31
@rajamatt
rajamatt disabled auto-merge October 30, 2026 20:57
@mergify

mergify Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@Jen-Uno
Jen-Uno enabled auto-merge November 2, 2026 15:20
@kazo0
kazo0 disabled auto-merge November 2, 2026 15:39
@agneszitte
agneszitte merged commit 2605ace into release/stable/6.7 Nov 2, 2026
64 checks passed
@agneszitte
agneszitte deleted the mergify/bp/release/stable/6.7/pr-25846 branch November 2, 2026 16:44
@agneszitte

Copy link
Copy Markdown
Member

@Mergifyio backport servicing/6.8

@mergify

mergify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

backport servicing/6.8

✅ Backports have been created

Details

agneszitte added a commit that referenced this pull request Nov 3, 2026
…r-25850

fix(telemetry): Re-enable XAML generator telemetry (backport #25846) (backport #25850)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/code-generation Categorizes an issue or PR as relevant to code generation conflicts Automated merge hit conflicts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants