Skip to content

Commit

Permalink
track segment reporting error (porter-dev#3846)
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen authored Oct 20, 2023
1 parent 293a62f commit 5333930
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions api/server/handlers/porter_app/analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func TrackStackBuildStatus(
)

if status == types.PorterAppEventStatus_Progressing {
return config.AnalyticsClient.Track(analytics.StackBuildProgressingTrack(&analytics.StackBuildOpts{
err := config.AnalyticsClient.Track(analytics.StackBuildProgressingTrack(&analytics.StackBuildOpts{
ProjectScopedTrackOpts: analytics.GetProjectScopedTrackOpts(user.ID, project.ID),
StackName: stackName,
Email: user.Email,
Expand All @@ -147,10 +147,13 @@ func TrackStackBuildStatus(
CompanyName: user.CompanyName,
ValidateApplyV2: validateApplyV2,
}))
if err != nil {
return telemetry.Error(ctx, span, err, "Failed to track stack build progressing")
}
}

if status == types.PorterAppEventStatus_Success {
return config.AnalyticsClient.Track(analytics.StackBuildSuccessTrack(&analytics.StackBuildOpts{
err := config.AnalyticsClient.Track(analytics.StackBuildSuccessTrack(&analytics.StackBuildOpts{
ProjectScopedTrackOpts: analytics.GetProjectScopedTrackOpts(user.ID, project.ID),
StackName: stackName,
Email: user.Email,
Expand All @@ -159,10 +162,13 @@ func TrackStackBuildStatus(
CompanyName: user.CompanyName,
ValidateApplyV2: validateApplyV2,
}))
if err != nil {
return telemetry.Error(ctx, span, err, "Failed to track stack build success")
}
}

if status == types.PorterAppEventStatus_Failed {
return config.AnalyticsClient.Track(analytics.StackBuildFailureTrack(&analytics.StackBuildOpts{
er := config.AnalyticsClient.Track(analytics.StackBuildFailureTrack(&analytics.StackBuildOpts{
ProjectScopedTrackOpts: analytics.GetProjectScopedTrackOpts(user.ID, project.ID),
StackName: stackName,
ErrorMessage: errorMessage,
Expand All @@ -173,6 +179,9 @@ func TrackStackBuildStatus(
CompanyName: user.CompanyName,
ValidateApplyV2: validateApplyV2,
}))
if er != nil {
return telemetry.Error(ctx, span, er, "Failed to track stack build failure")
}
}

return nil
Expand Down

0 comments on commit 5333930

Please sign in to comment.