Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit a727c6b

Browse files
committed
cli: Update UXState from config-ssh
Context: In optimizing the dashboard environment experiences, tracking whether a user has run config-ssh locally enables personalized education about the feature.
1 parent 0e6ae81 commit a727c6b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

coder-sdk/users.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ func (c Client) Me(ctx context.Context) (*User, error) {
4646
return c.UserByID(ctx, Me)
4747
}
4848

49+
// MyUXState updates the authenticated user's UX State.
50+
func (c Client) MyUXState(ctx context.Context, uxsPartial map[string]interface{}) error {
51+
if err := c.requestBody(ctx, http.MethodPut, "/api/private/users/me/ux-state", uxsPartial, nil); err != nil {
52+
return err
53+
}
54+
return nil
55+
}
56+
4957
// UserByID get the details of a user by their id.
5058
func (c Client) UserByID(ctx context.Context, id string) (*User, error) {
5159
var u User

internal/cmd/configssh.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ func configSSH(configpath *string, remove *bool) func(cmd *cobra.Command, _ []st
135135
fmt.Printf("Your private ssh key was written to \"%s\"\n", privateKeyFilepath)
136136
}
137137

138+
writeSSHUXState(ctx, client)
138139
fmt.Printf("An auto-generated ssh config was written to \"%s\"\n", *configpath)
139140
fmt.Println("You should now be able to ssh into your environment")
140141
fmt.Printf("For example, try running\n\n\t$ ssh coder.%s\n\n", envs[0].Name)
@@ -215,3 +216,12 @@ func readStr(filename string) (string, error) {
215216
}
216217
return string(contents), nil
217218
}
219+
220+
func writeSSHUXState(ctx context.Context, client *coder.Client) {
221+
// Update UXState that coder config-ssh has been run by the currently
222+
// authenticated user
223+
err := client.MyUXState(ctx, map[string]interface{}{"cliSSHConfigured": true})
224+
if err != nil {
225+
fmt.Println("⚠ The Coder web client may not recognize that you've configured SSH.")
226+
}
227+
}

0 commit comments

Comments
 (0)