Skip to content

Commit be43d62

Browse files
authored
feat: add additional fields to first time setup trial flow (#11533)
* feat: add additional fields to first time setup trial flow * trial generator typo
1 parent 1196f83 commit be43d62

File tree

17 files changed

+1329
-28
lines changed

17 files changed

+1329
-28
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ provisionersdk/proto/*.go linguist-generated=true
1212
*.tfstate.dot linguist-generated=true
1313
*.tfplan.dot linguist-generated=true
1414
site/src/api/typesGenerated.ts linguist-generated=true
15+
site/src/pages/SetupPage/countries.tsx linguist-generated=true

.github/workflows/typos.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ darcula = "darcula"
1414
Hashi = "Hashi"
1515
trialer = "trialer"
1616
encrypter = "encrypter"
17-
hel = "hel" # as in helsinki
17+
hel = "hel" # as in helsinki
1818

1919
[files]
2020
extend-exclude = [
@@ -31,4 +31,5 @@ extend-exclude = [
3131
"**/*.test.tsx",
3232
"**/pnpm-lock.yaml",
3333
"tailnet/testdata/**",
34+
"site/src/pages/SetupPage/countries.tsx",
3435
]

coderd/apidoc/docs.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ type Options struct {
123123
TracerProvider trace.TracerProvider
124124
ExternalAuthConfigs []*externalauth.Config
125125
RealIPConfig *httpmw.RealIPConfig
126-
TrialGenerator func(ctx context.Context, email string) error
126+
TrialGenerator func(ctx context.Context, body codersdk.LicensorTrialRequest) error
127127
// TLSCertificates is used to mesh DERP servers securely.
128128
TLSCertificates []tls.Certificate
129129
TailnetCoordinator tailnet.Coordinator

coderd/coderdtest/coderdtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ type Options struct {
107107
Auditor audit.Auditor
108108
TLSCertificates []tls.Certificate
109109
ExternalAuthConfigs []*externalauth.Config
110-
TrialGenerator func(context.Context, string) error
110+
TrialGenerator func(ctx context.Context, body codersdk.LicensorTrialRequest) error
111111
TemplateScheduleStore schedule.TemplateScheduleStore
112112
Coordinator tailnet.Coordinator
113113

coderd/users.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,16 @@ func (api *API) postFirstUser(rw http.ResponseWriter, r *http.Request) {
152152
}
153153

154154
if createUser.Trial && api.TrialGenerator != nil {
155-
err = api.TrialGenerator(ctx, createUser.Email)
155+
err = api.TrialGenerator(ctx, codersdk.LicensorTrialRequest{
156+
Email: createUser.Email,
157+
FirstName: createUser.TrialInfo.FirstName,
158+
LastName: createUser.TrialInfo.LastName,
159+
PhoneNumber: createUser.TrialInfo.PhoneNumber,
160+
JobTitle: createUser.TrialInfo.JobTitle,
161+
CompanyName: createUser.TrialInfo.CompanyName,
162+
Country: createUser.TrialInfo.Country,
163+
Developers: createUser.TrialInfo.Developers,
164+
})
156165
if err != nil {
157166
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
158167
Message: "Failed to generate trial",

coderd/users_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestFirstUser(t *testing.T) {
7676
t.Parallel()
7777
called := make(chan struct{})
7878
client := coderdtest.New(t, &coderdtest.Options{
79-
TrialGenerator: func(ctx context.Context, s string) error {
79+
TrialGenerator: func(context.Context, codersdk.LicensorTrialRequest) error {
8080
close(called)
8181
return nil
8282
},

codersdk/users.go

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,38 @@ type GetUsersResponse struct {
6363
Count int `json:"count"`
6464
}
6565

66+
// @typescript-ignore LicensorTrialRequest
67+
type LicensorTrialRequest struct {
68+
DeploymentID string `json:"deployment_id"`
69+
Email string `json:"email"`
70+
Source string `json:"source"`
71+
72+
// Personal details.
73+
FirstName string `json:"first_name"`
74+
LastName string `json:"last_name"`
75+
PhoneNumber string `json:"phone_number"`
76+
JobTitle string `json:"job_title"`
77+
CompanyName string `json:"company_name"`
78+
Country string `json:"country"`
79+
Developers string `json:"developers"`
80+
}
81+
6682
type CreateFirstUserRequest struct {
67-
Email string `json:"email" validate:"required,email"`
68-
Username string `json:"username" validate:"required,username"`
69-
Password string `json:"password" validate:"required"`
70-
Trial bool `json:"trial"`
83+
Email string `json:"email" validate:"required,email"`
84+
Username string `json:"username" validate:"required,username"`
85+
Password string `json:"password" validate:"required"`
86+
Trial bool `json:"trial"`
87+
TrialInfo CreateFirstUserTrialInfo `json:"trial_info"`
88+
}
89+
90+
type CreateFirstUserTrialInfo struct {
91+
FirstName string `json:"first_name"`
92+
LastName string `json:"last_name"`
93+
PhoneNumber string `json:"phone_number"`
94+
JobTitle string `json:"job_title"`
95+
CompanyName string `json:"company_name"`
96+
Country string `json:"country"`
97+
Developers string `json:"developers"`
7198
}
7299

73100
// CreateFirstUserResponse contains IDs for newly created user info.

docs/api/schemas.md

Lines changed: 42 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)