Skip to content
Merged
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
14 changes: 13 additions & 1 deletion internal/devtui/model_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package devtui

import (
"context"
"strconv"
"time"

"charm.land/bubbles/v2/textinput"
Expand All @@ -11,6 +12,7 @@ import (
"github.com/shopware/shopware-cli/internal/envfile"
"github.com/shopware/shopware-cli/internal/executor"
"github.com/shopware/shopware-cli/internal/shop"
"github.com/shopware/shopware-cli/internal/tracking"
)

func (m Model) updateKeyPress(msg tea.KeyPressMsg) (tea.Model, tea.Cmd) {
Expand Down Expand Up @@ -266,7 +268,17 @@ func (m Model) saveSetupGuide() (tea.Model, tea.Cmd) {
m.setupGuide.deploymentHelperAdded = changed

m.setupGuide.step = setupStepDone
return m, nil
duration := time.Since(m.setupGuide.startedAt)
Comment thread
tturkowski marked this conversation as resolved.
phpVersion := m.setupGuide.phpVersions[m.setupGuide.phpCursor]
return m, func() tea.Msg {
ctx, cancel := context.WithTimeout(context.Background(), 300*time.Millisecond)
defer cancel()
tracking.Track(ctx, "migration_wizard_completed", map[string]string{
"took": strconv.FormatInt(int64(duration.Seconds()), 10),
"php_version": phpVersion,
})
return nil
}
}

// mergeLocalProfilerSecrets copies profiler credential fields from the
Expand Down
3 changes: 3 additions & 0 deletions internal/devtui/setup_guide.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package devtui
import (
"path/filepath"
"slices"
"time"

"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
Expand Down Expand Up @@ -31,6 +32,7 @@ type setupGuide struct {
password textinput.Model
passwordErr string
credFocus credFocus
startedAt time.Time

err error
}
Expand Down Expand Up @@ -149,6 +151,7 @@ func (sg *setupGuide) updateWelcome(msg tea.KeyPressMsg) (setupGuide, tea.Cmd) {
sg.confirmYes = !sg.confirmYes
case keyEnter:
if sg.confirmYes {
sg.startedAt = time.Now()
sg.step = setupStepAdminUser
return sg.focusAdminCred(credFocusUsername)
}
Expand Down
14 changes: 14 additions & 0 deletions internal/devtui/setup_guide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"os"
"path/filepath"
"testing"
"time"

"charm.land/bubbles/v2/textinput"
tea "charm.land/bubbletea/v2"
Expand Down Expand Up @@ -407,3 +408,16 @@ func TestSetupGuideStepNumbering(t *testing.T) {
assert.Equal(t, 0, sg.stepNum(setupStepWelcome))
assert.Equal(t, 0, sg.stepNum(setupStepDone))
}

func TestSetupGuideWelcome_EnterSetsStartedAt(t *testing.T) {
sg := newSetupGuide("")
sg.confirmYes = true

before := time.Now()
next, _ := sg.update(tea.KeyPressMsg(tea.Key{Code: tea.KeyEnter}))
after := time.Now()

assert.False(t, next.startedAt.IsZero(), "startedAt should be set after Enter on welcome")
assert.False(t, next.startedAt.Before(before), "startedAt should not be before test start")
assert.False(t, next.startedAt.After(after), "startedAt should not be after test end")
}
Loading