Skip to content

Commit

Permalink
track events with validate apply v2 ff
Browse files Browse the repository at this point in the history
  • Loading branch information
ianedwards committed Sep 22, 2023
1 parent 663fb3f commit b507f36
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
6 changes: 6 additions & 0 deletions api/server/handlers/porter_app/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ func (v *PorterAppAnalyticsHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
return
}

validateApplyV2 := project.GetFeatureFlag(models.ValidateApplyV2, v.Config().LaunchDarklyClient)
if request.Step == "stack-launch-start" {
v.Config().AnalyticsClient.Track(analytics.StackLaunchStartTrack(&analytics.StackLaunchStartOpts{
ProjectScopedTrackOpts: analytics.GetProjectScopedTrackOpts(user.ID, project.ID),
Email: user.Email,
FirstName: user.FirstName,
LastName: user.LastName,
CompanyName: user.CompanyName,
ValidateApplyV2: validateApplyV2,
}))
}

Expand All @@ -53,6 +55,7 @@ func (v *PorterAppAnalyticsHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
FirstName: user.FirstName,
LastName: user.LastName,
CompanyName: user.CompanyName,
ValidateApplyV2: validateApplyV2,
}))
}

Expand All @@ -64,6 +67,7 @@ func (v *PorterAppAnalyticsHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
FirstName: user.FirstName,
LastName: user.LastName,
CompanyName: user.CompanyName,
ValidateApplyV2: validateApplyV2,
}))
}

Expand All @@ -76,6 +80,7 @@ func (v *PorterAppAnalyticsHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
LastName: user.LastName,
CompanyName: user.CompanyName,
ErrorMessage: request.ErrorMessage,
ValidateApplyV2: validateApplyV2,
}))
}

Expand All @@ -88,6 +93,7 @@ func (v *PorterAppAnalyticsHandler) ServeHTTP(w http.ResponseWriter, r *http.Req
LastName: user.LastName,
CompanyName: user.CompanyName,
DeleteWorkflowFile: request.DeleteWorkflowFile,
ValidateApplyV2: validateApplyV2,
}))
}

Expand Down
58 changes: 32 additions & 26 deletions internal/analytics/tracks.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,10 +783,11 @@ func ClusterDestroyingSuccessTrack(opts *ClusterDestroyingSuccessTrackOpts) segm
type StackLaunchStartOpts struct {
*ProjectScopedTrackOpts

Email string
FirstName string
LastName string
CompanyName string
Email string
FirstName string
LastName string
CompanyName string
ValidateApplyV2 bool
}

// StackLaunchStartTrack returns a track for when a user starts creating a stack
Expand All @@ -806,11 +807,12 @@ func StackLaunchStartTrack(opts *StackLaunchStartOpts) segmentTrack {
type StackLaunchCompleteOpts struct {
*ProjectScopedTrackOpts

StackName string
Email string
FirstName string
LastName string
CompanyName string
StackName string
Email string
FirstName string
LastName string
CompanyName string
ValidateApplyV2 bool
}

// StackLaunchCompleteTrack returns a track for when a user completes creating a stack
Expand All @@ -831,11 +833,12 @@ func StackLaunchCompleteTrack(opts *StackLaunchCompleteOpts) segmentTrack {
type StackLaunchSuccessOpts struct {
*ProjectScopedTrackOpts

StackName string
Email string
FirstName string
LastName string
CompanyName string
StackName string
Email string
FirstName string
LastName string
CompanyName string
ValidateApplyV2 bool
}

// StackLaunchCompleteTrack returns a track for when a user completes creating a stack
Expand All @@ -856,12 +859,13 @@ func StackLaunchSuccessTrack(opts *StackLaunchSuccessOpts) segmentTrack {
type StackLaunchFailureOpts struct {
*ProjectScopedTrackOpts

StackName string
Email string
FirstName string
LastName string
CompanyName string
ErrorMessage string
StackName string
Email string
FirstName string
LastName string
CompanyName string
ErrorMessage string
ValidateApplyV2 bool
}

// StackLaunchFailureTrack returns a track for when a user fails creating a stack
Expand Down Expand Up @@ -889,6 +893,7 @@ type StackDeletionOpts struct {
LastName string
CompanyName string
DeleteWorkflowFile bool
ValidateApplyV2 bool
}

// StackDeletionTrack returns a track for when a user deletes a stack
Expand All @@ -910,12 +915,13 @@ func StackDeletionTrack(opts *StackDeletionOpts) segmentTrack {
type StackBuildOpts struct {
*ProjectScopedTrackOpts

StackName string
ErrorMessage string
Email string
FirstName string
LastName string
CompanyName string
StackName string
ErrorMessage string
Email string
FirstName string
LastName string
CompanyName string
ValidateApplyV2 bool
}

// StackBuildFailureTrack returns a track for when a stack fails to build
Expand Down

0 comments on commit b507f36

Please sign in to comment.