Repository navigation
fix(telemetry): Re-enable XAML generator telemetry - #25846
Conversation
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]>
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]>
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
Xiaoy312
left a comment
There was a problem hiding this comment.
The diagnosis checks out: the library treats the provider's result as an opt-out flag, and InitTelemetry ran before _isDesignTimeBuild was set. The new gate is correct for what it claims, and the browser check is worth keeping, since Flush's task.Wait is a hazard on single-threaded WebAssembly.
Before merging, I'd want two things settled: the 93e435f intent question you raised, and opting hot reload out (inline). The rest are suggestions.
FYI: TelemetryEnvironment in the library documents an explicit UNO_PLATFORM_TELEMETRY_OPTOUT=false as forcing telemetry on over the provider. With this PR the generator no longer honours that when UnoPlatformTelemetryOptOut is set. That's the more privacy-friendly direction and you call it out, but the library's docs will now disagree with the generator.
- 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]>
|
@Mergifyio backport release/stable/6.7 |
✅ Backports have been createdDetails
Cherry-pick of 9d47558 has failed: 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 |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
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. |
…6.7/pr-25846 fix(telemetry): Re-enable XAML generator telemetry (backport #25846)
GitHub Issue: related to unoplatform/uno-private#2477 (kept open until the
release/stable/6.7backport 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 behindisTelemetryOptout() is true. ButUno.DevTools.TelemetryreadsenabledProvideras 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
IsTelemetryDisabledis false. It returns true in five cases:UnoPlatformTelemetryOptOutis1ortrue. This is the root-cause fix.UNO_PLATFORM_TELEMETRY_OPTOUTis1ortrue, read through the build as aCompilerVisibleProperty.bool.TryParse, so onlytrueworked, and 6.6 sent telemetry for users who had set1._isDesignTimeBuildused to be read before it was set, so every design-time build, 6.6 included, started an enabled client, even though theTrack*methods then skipped sending. It's now set first.UnoIsHotReloadHost. The dev server's hot-reload workspace already evaluates as design-time, becauseMSBuildWorkspacedefaults toDesignTimeBuild=trueandBuildingProject=false. The explicit check keeps hot reload silent if that changes.Flushblocks onTask.Wait, which most likely broke the in-browser build that 93e435f fixed.The generator test assembly sets
UNO_PLATFORM_TELEMETRY_OPTOUT=truein 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=falsecan no longer re-enable a build that setUnoPlatformTelemetryOptOut.Reviewer's guide
XamlCodeGeneration.Telemetry.cs: the gate (InitTelemetry,IsTelemetryDisabled).XamlCodeGeneration.cs:_isDesignTimeBuildmoved ahead ofInitTelemetry.Uno.UI.SourceGenerators.props: two newCompilerVisiblePropertyentries.Given_XamlTelemetryholds the tests.AssemlyInfo.csholds the test-run opt-out.Validation
Given_XamlTelemetrycoversIsTelemetryDisabled, not howInitTelemetrywires it up.true,True,1), opt-outs by the variable (true,TRUE,1, including with the property set tofalse), design-time builds and hot-reload builds."",falseor0in either place, andUnoIsHotReloadHost=False.Uno.UI.SourceGenerators.propsgetsbuild_property.UNO_PLATFORM_TELEMETRY_OPTOUTandbuild_property.UnoIsHotReloadHost. A design-time compile writesDesignTimeBuild = trueandBuildingProject = falseinto the generator's config.Uno.UI.SourceGenerators.Testsrun: 222 passed, 7 skipped, 403 failed, all withUnable to find Uno.UI.dllbecauseUno.UIwasn't built. That run was on the first commit and hasn't been repeated, and it was built againstnet10.0locally because I don't have a .NET 11 SDK. CI runs the full suite.Open questions before merge or backport
Follow-up
release/stable/6.7after merge. That branch usesUno.DevTools.Telemetry1.3.3 and has noGiven_XamlTelemetry, so the backport needs adapting.servicing/6.8has the same check.Uno.DevTools.Telemetry:1and0for the variable;Dispose's drain, which can block a build for up to about 100s on a network that silently drops traffic (as in 6.6);Disposerace that leaves a channel undisposed in long-lived processes;TelemetryEnvironment's docs that a host may opt out before creating a client.PR Checklist ✅
Given_XamlTelemetrydoc/articles/uno-toolchain-telemetry.mdalready documents1ortrue, and the generator now matches itScreenshots Compare Test Runresults.🤖 Generated with Claude Code