Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/auth_connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ func (c AuthConnectionCmd) Timeline(ctx context.Context, in AuthConnectionTimeli
return nil
}

tableData := pterm.TableData{{"Timestamp", "Type", "Status", "Step", "Browser Session", "Details"}}
tableData := pterm.TableData{{"Timestamp", "Type", "Status", "Step", "Browser Session", "Telemetry", "Details"}}
for _, e := range events {
details := e.ErrorMessage
if details == "" {
Expand All @@ -848,12 +848,20 @@ func (c AuthConnectionCmd) Timeline(ctx context.Context, in AuthConnectionTimeli
if details == "" && e.PreviousStatus != "" {
details = fmt.Sprintf("%s -> %s", e.PreviousStatus, e.Status)
}
// Telemetry only means something when the event has a browser session
// whose events `kernel browsers telemetry` could fetch, and when the API
// actually reported the field.
telemetry := "-"
if e.BrowserSessionID != "" && e.JSON.TelemetryCaptured.Valid() {
telemetry = lo.Ternary(e.TelemetryCaptured, "yes", "no")
}
tableData = append(tableData, []string{
util.FormatLocal(e.Timestamp),
string(e.Type),
string(e.Status),
string(e.Step),
util.OrDash(e.BrowserSessionID),
telemetry,
util.OrDash(details),
})
}
Expand Down
15 changes: 14 additions & 1 deletion cmd/auth_connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -690,13 +690,23 @@ func TestSubmit_CanonicalAndLegacyAreMutuallyExclusive(t *testing.T) {
func TestTimeline_RendersEventsAndPagination(t *testing.T) {
buf := capturePtermOutput(t)
var captured kernel.AuthConnectionTimelineParams
// Decoded from JSON so the telemetry_captured field registers as present;
// the CLI distinguishes "reported false" from "not reported at all".
var loginEvent kernel.ManagedAuthTimelineEvent
require.NoError(t, json.Unmarshal([]byte(`{
"id": "e1",
"type": "login",
"status": "SUCCESS",
"browser_session_id": "browser_1",
"telemetry_captured": true
}`), &loginEvent))
fake := &FakeAuthConnectionService{
TimelineFunc: func(ctx context.Context, id string, query kernel.AuthConnectionTimelineParams, opts ...option.RequestOption) (*pagination.OffsetPagination[kernel.ManagedAuthTimelineEvent], error) {
captured = query
// Return perPage+1 events so the CLI reports another page exists.
return &pagination.OffsetPagination[kernel.ManagedAuthTimelineEvent]{
Items: []kernel.ManagedAuthTimelineEvent{
{ID: "e1", Type: "login", Status: "SUCCESS", BrowserSessionID: "browser_1"},
loginEvent,
{ID: "e2", Type: "reauth", Status: "FAILED", ErrorMessage: "boom"},
{ID: "e3", Type: "health_check", Status: "SUCCESS"},
},
Expand All @@ -714,6 +724,9 @@ func TestTimeline_RendersEventsAndPagination(t *testing.T) {
out := buf.String()
assert.Contains(t, out, "browser_1")
assert.Contains(t, out, "boom")
// Telemetry capture is reported for events that have a browser session.
assert.Contains(t, out, "Telemetry")
assert.Regexp(t, `browser_1.*yes`, out)
// The third event is truncated off the page.
assert.NotContains(t, out, "health_check")
assert.Contains(t, out, "Has more: yes")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/charmbracelet/lipgloss/v2 v2.0.0-beta.1
github.com/golang-jwt/jwt/v5 v5.2.2
github.com/joho/godotenv v1.5.1
github.com/kernel/kernel-go-sdk v0.83.1-0.20260724213320-12b3ec62f63e
github.com/kernel/kernel-go-sdk v0.84.0
github.com/klauspost/compress v1.18.5
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/pterm/pterm v0.12.80
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/kernel/kernel-go-sdk v0.83.1-0.20260724213320-12b3ec62f63e h1:Pe1fRnIM4Zf7ddVg/wd+qTD0X4t2NmXRIeXyY98AILI=
github.com/kernel/kernel-go-sdk v0.83.1-0.20260724213320-12b3ec62f63e/go.mod h1:EeZzSuHZVeHKxKCPUzxou2bovNGhXaz0RXrSqKNf1AQ=
github.com/kernel/kernel-go-sdk v0.84.0 h1:EYJC6TMFDiosqsbWbCLlVkVr/B8/hTYfyVAUinb7Hsk=
github.com/kernel/kernel-go-sdk v0.84.0/go.mod h1:EeZzSuHZVeHKxKCPUzxou2bovNGhXaz0RXrSqKNf1AQ=
github.com/klauspost/compress v1.18.5 h1:/h1gH5Ce+VWNLSWqPzOVn6XBO+vJbCNGvjoaGBFW2IE=
github.com/klauspost/compress v1.18.5/go.mod h1:cwPg85FWrGar70rWktvGQj8/hthj3wpl0PGDogxkrSQ=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
Expand Down
Loading