* Add skills specific telemetry * Remove VisibilityFuture, inline goroutine at call sites The VisibilityFuture/FetchRepoVisibilityAsync/Wait wrapper was an unidiomatic async abstraction built for a single pattern used in exactly two call sites. In Go the channel is already the future; wrapping it in a struct with a Wait(timeout) method adds no value. Delete the abstraction and inline a local visResult struct, buffered channel, goroutine, and select at each call site. Behavior is preserved exactly: err -> "unknown", timeout -> "unknown", success+public -> include skill_names. FetchRepoVisibility (synchronous) is kept as-is. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Fix nonsense copilot tests * Update telemetry tests for public-only dims and search event removal Production telemetry emission changed: - preview: skill_owner/skill_repo/skill_name (renamed from skill_names) are now emitted only when repo_visibility=public. - install: skill_owner/skill_repo/skill_names are now emitted only when repo_visibility=public. - search: the initial skill_search event was removed entirely; the skill_search_install event no longer carries query/owner dims. Update tests to match: rename skill_names -> skill_name in preview, make owner/repo assertions conditional on public visibility in both preview and install, and reduce the search test to a single event with explicit Empty assertions for the removed query/owner dims so a privacy regression cannot pass silently. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Test CategorizeHost and switch telemetry to skill_host_type Add TestCategorizeHost covering all four classification branches (github.com, ghes, tenancy, uncategorized) with cases verified against the real ghauth implementation rather than guessed. Update install and preview unit tests to assert the new skill_host_type dimension name, and fix a typo in the preview acceptance txtar (skill_hos_type -> skill_host_type). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Shrink visibility wait and test unknown visibility The 2s visibilityWaitTimeout was wildly overprovisioned: by the time telemetry emission reaches the select, the command has already done several serial GitHub REST calls (and for install, a git sparse-checkout plus possibly interactive prompts), so the one-call visibility fetch has almost always completed. Drop the timeout to 200ms — a short safety net for a stalled REST call, not a wait budget for a healthy one. Also adds a table-driven case to TestFetchRepoVisibility covering an unknown/future visibility value from the API, addressing @babakks' review nitpick. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
35 lines
898 B
Go
35 lines
898 B
Go
package telemetry
|
|
|
|
import "github.com/cli/cli/v2/internal/gh/ghtelemetry"
|
|
|
|
type EventRecorderSpy struct {
|
|
Events []ghtelemetry.Event
|
|
}
|
|
|
|
func (r *EventRecorderSpy) Record(event ghtelemetry.Event) {
|
|
r.Events = append(r.Events, event)
|
|
}
|
|
|
|
func (r *EventRecorderSpy) Disable() {}
|
|
|
|
func (r *EventRecorderSpy) Flush() {}
|
|
|
|
// CommandRecorderSpy is a test double for ghtelemetry.CommandRecorder.
|
|
// It captures recorded events and the most recent SetSampleRate call so tests can
|
|
// assert on the sampling behavior commands attempt to configure.
|
|
type CommandRecorderSpy struct {
|
|
Events []ghtelemetry.Event
|
|
LastSampleRate int
|
|
}
|
|
|
|
func (r *CommandRecorderSpy) Record(event ghtelemetry.Event) {
|
|
r.Events = append(r.Events, event)
|
|
}
|
|
|
|
func (r *CommandRecorderSpy) Disable() {}
|
|
|
|
func (r *CommandRecorderSpy) SetSampleRate(rate int) {
|
|
r.LastSampleRate = rate
|
|
}
|
|
|
|
func (r *CommandRecorderSpy) Flush() {}
|