adk-telemetry: show opt-out notice before the first emit (all paths) - #244
Open
amilandi wants to merge 1 commit into
Open
adk-telemetry: show opt-out notice before the first emit (all paths)#244amilandi wants to merge 1 commit into
amilandi wants to merge 1 commit into
Conversation
Fixes a notice-ordering gap discovered while investigating the /setup
capability skew:
Prior flow when a maker runs /setup on a direct-clone install (no installer):
1. fetch_and_setup.py auth + emit_capability_use("setup") FIRES <-- send
2. setup.py subprocess -> maybe_print_notice() prints on stderr <-- notice
3. setup.py emit_agent_create(...) <-- send
The first emit sent an event before the maker was ever shown the opt-out
notice. That doesn't meet the "notice at time of collection" bar (GDPR
Art. 13 / Microsoft privacy review standard for pseudonymous OII on
legitimate-interest basis) for the direct-clone path.
Installer-bootstrapped installs already do this right: the PowerShell /
bash installer telemetry emitter (setup/telemetry/install-telemetry.{ps1,sh})
calls Show-EssTelemetryNotice BEFORE emitting ESSMakerKit.Installer.Start,
and persists ``noticeShown=true`` to ~/.adk/config. So this fix is a no-op
for them (the notice call in _emit finds the flag already set and returns
immediately) and closes the gap for git-cloned installs that bypass the
installer.
Change: route notice through the single ``_emit`` choke point so every ADK
event dispatch (capability_use, session_start, agent_create, agent_deploy,
build_start/complete, api_call, flightcheck_run/result/error) shows the
notice before the network round-trip. New helper ``_notice_before_emit``:
* Idempotent via the existing noticeShown config flag - cheap after 1st call
* Skips notice when telemetry is already opted out (nothing to disclose)
* Best-effort - any IO error is swallowed so a notice-write can never
break a caller's flow
Existing setup.py maybe_print_notice() call at line 786 is preserved as
belt-and-suspenders; after this change it always finds the flag already
set and no-ops.
Regression tests:
* test_emit_shows_notice_before_dispatch - orders "notice" before "post"
by spying on maybe_print_notice + _fc._post on a fresh install.
* test_emit_skips_notice_when_opted_out - opt-out env var suppresses both.
* test_emit_notice_swallows_errors - notice OSError doesn't break emit.
Tests: 69 passed in test_adk_telemetry; 1193 passed in broader touched suite
(tests/test_adk_telemetry.py + tests/flightcheck + tests/scripts/test_auth.py).
ADO: https://o365exchange.visualstudio.com/O365%20Core/_workitems/edit/7764297
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 70ddf006-7f8d-48e7-9afa-3fbae73b3864
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.
Closes a notice-ordering gap discovered while investigating why real-customer
/setupevents dominateadk.capability.use.The gap
For git-cloned installs (no bootstrap installer), the prior /setup flow emitted the first
adk.capability.usebefore the maker had any chance to see the opt-out notice:That doesn't meet the "notice at time of collection" bar (GDPR Art. 13 / Microsoft privacy-review standard for pseudonymous OII on a legitimate-interest basis).
Installer-bootstrapped installs already do this right —
setup/telemetry/install-telemetry.ps1(and the.shmirror) callShow-EssTelemetryNoticebeforeESSMakerKit.Installer.Startand persistnoticeShown=trueto~/.adk/config. So this PR is a no-op for that path and closes the gap only for git-cloned installs that bypass the installer.The fix
Route the notice through the single
_emitchoke point inadk_telemetry.pyso every ADK event dispatch (capability_use, session_start, agent_create, agent_deploy, build_start/complete, api_call, flightcheck_run/result/error) shows the notice before the network round-trip.New helper
_notice_before_emit:noticeShownconfig flag — cheap read after the first callExisting
maybe_print_notice()call inscripts/setup.pyis preserved as belt-and-suspenders; after this change it always finds the flag already set and no-ops.Regression tests
test_emit_shows_notice_before_dispatch— spies onmaybe_print_notice+_fc._poston a fresh install and assertsnoticefires beforepost.test_emit_skips_notice_when_opted_out— the opt-out env var suppresses both.test_emit_notice_swallows_errors— a noticeOSErrordoesn't break the emit.Verification
tests/test_adk_telemetry.py— 69 passedtest_adk_telemetry.py+tests/flightcheck+tests/scripts/test_auth.py) — 1193 passedADO: https://o365exchange.visualstudio.com/O365%20Core/_workitems/edit/7764297