Skip to content

Commit

Permalink
fix preflight analytics (#4309)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Feb 21, 2024
1 parent cae5a84 commit 505b9ec
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 17 deletions.
2 changes: 2 additions & 0 deletions api/server/handlers/project/update_onboarding_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ func (v *UpdateOnboardingStepHandler) ServeHTTP(w http.ResponseWriter, r *http.R
LastName: user.LastName,
CompanyName: user.CompanyName,
ErrorMessage: request.ErrorMessage,
ClusterName: request.ClusterName,
CloudProvider: request.Provider,
}))
if err != nil {
_ = telemetry.Error(ctx, span, err, "error tracking cluster preflight checks failed")
Expand Down
6 changes: 3 additions & 3 deletions dashboard/src/lib/clusters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ const eksConfigValidator = z.object({
clusterName: z
.string()
.min(1, { message: "Name must be at least 1 character" })
.max(31, { message: "Name must be 31 characters or less" })
.max(31, { message: "Name must be max 31 characters" })
.regex(/^[a-z0-9-]{1,61}$/, {
message: 'Lowercase letters, numbers, and "-" only.',
}),
Expand Down Expand Up @@ -456,7 +456,7 @@ const gkeConfigValidator = z.object({
clusterName: z
.string()
.min(1, { message: "Name must be at least 1 character" })
.max(31, { message: "Name must be 31 characters or less" })
.max(31, { message: "Name must be max 31 characters" })
.regex(/^[a-z0-9-]{1,61}$/, {
message: 'Lowercase letters, numbers, and "-" only.',
}),
Expand All @@ -470,7 +470,7 @@ const aksConfigValidator = z.object({
clusterName: z
.string()
.min(1, { message: "Name must be at least 1 character" })
.max(31, { message: "Name must be 31 characters or less" })
.max(31, { message: "Name must be max 31 characters" })
.regex(/^[a-z0-9-]{1,61}$/, {
message: 'Lowercase letters, numbers, and "-" only.',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@ const CreateEKSClusterForm: React.FC<Props> = ({
const { reportToAnalytics } = useClusterAnalytics();

useEffect(() => {
const projectNameLimit = 31 - "-cluster-".length - 6; // 6 characters for the random suffix
const truncatedProjectName = projectName.substring(0, projectNameLimit);
const clusterName = `${truncatedProjectName}-cluster-${Math.random()
.toString(36)
.substring(2, 8)}`;

reset({
cluster: {
projectId,
cloudProvider: "AWS" as const,
config: {
kind: "EKS" as const,
clusterName: `${projectName}-cluster-${Math.random()
.toString(36)
.substring(2, 8)}`,
clusterName,
region: "us-east-1",
nodeGroups: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ const CreateAKSClusterForm: React.FC<Props> = ({
const { reportToAnalytics } = useClusterAnalytics();

useEffect(() => {
const projectNameLimit = 31 - "-cluster-".length - 6; // 6 characters for the random suffix
const truncatedProjectName = projectName.substring(0, projectNameLimit);
const clusterName = `${truncatedProjectName}-cluster-${Math.random()
.toString(36)
.substring(2, 8)}`;

reset({
cluster: {
projectId,
cloudProvider: "Azure" as const,
config: {
kind: "AKS" as const,
clusterName: `${projectName}-cluster-${Math.random()
.toString(36)
.substring(2, 8)}`,
clusterName,
region: "eastus",
nodeGroups: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ const CreateGKEClusterForm: React.FC<Props> = ({
const { reportToAnalytics } = useClusterAnalytics();

useEffect(() => {
const projectNameLimit = 31 - "-cluster-".length - 6; // 6 characters for the random suffix
const truncatedProjectName = projectName.substring(0, projectNameLimit);
const clusterName = `${truncatedProjectName}-cluster-${Math.random()
.toString(36)
.substring(2, 8)}`;

reset({
cluster: {
projectId,
cloudProvider: "GCP" as const,
config: {
kind: "GKE" as const,
clusterName: `${projectName}-cluster-${Math.random()
.toString(36)
.substring(2, 8)}`,
clusterName,
region: "us-east1",
nodeGroups: [
{
Expand Down
14 changes: 9 additions & 5 deletions internal/analytics/tracks.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,13 @@ func CloudProviderPermissionsGrantedTrack(opts *CloudProviderPermissionsGrantedT
type ClusterPreflightChecksFailedTrackOpts struct {
*ProjectScopedTrackOpts

Email string
FirstName string
LastName string
CompanyName string
ErrorMessage string
Email string
FirstName string
LastName string
CompanyName string
ErrorMessage string
ClusterName string
CloudProvider string
}

// ClusterPreflightChecksFailedTrack returns a track for when a user fails preflight checks
Expand All @@ -1082,6 +1084,8 @@ func ClusterPreflightChecksFailedTrack(opts *ClusterPreflightChecksFailedTrackOp
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["error_message"] = opts.ErrorMessage
additionalProps["cluster_name"] = opts.ClusterName
additionalProps["cloud_provider"] = opts.CloudProvider

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand Down

0 comments on commit 505b9ec

Please sign in to comment.