Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Feroze Mohideen committed Sep 22, 2023
1 parent b507f36 commit 215864b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
6 changes: 4 additions & 2 deletions dashboard/src/lib/hooks/useAppAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ type AppStep =
| "stack-launch-failure"
| "stack-deletion";

export const useAppAnalytics = (appName?: string) => {
export const useAppAnalytics = () => {
const { currentCluster, currentProject } = useContext(Context);

const updateAppStep = async ({
appName,
step,
errorMessage = "",
deleteWorkflow = false,
}: {
appName?: string;
step: AppStep;
errorMessage?: string;
deleteWorkflow?: boolean;
Expand All @@ -38,7 +40,7 @@ export const useAppAnalytics = (appName?: string) => {
project_id: currentProject.id,
}
);
} catch (err) {}
} catch (err) { }
};

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Settings: React.FC = () => {
const history = useHistory();
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
const { porterApp, clusterId, projectId } = useLatestRevision();
const { updateAppStep } = useAppAnalytics(porterApp.name);
const { updateAppStep } = useAppAnalytics();
const [isDeleting, setIsDeleting] = useState(false);

const githubWorkflowFilename = `porter_stack_${porterApp.name}.yml`;
Expand Down Expand Up @@ -98,7 +98,7 @@ const Settings: React.FC = () => {
window.open(res.data.url, "_blank", "noreferrer");
}

updateAppStep({ step: "stack-deletion", deleteWorkflow: true });
updateAppStep({ step: "stack-deletion", deleteWorkflow: true, appName: porterApp.name });
history.push("/apps");
return;
}
Expand Down
14 changes: 7 additions & 7 deletions dashboard/src/main/home/app-dashboard/create-app/CreateApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
appName: "", // only want to know if porter.yaml has name set, otherwise use name from input
});
const deploymentTarget = useDefaultDeploymentTarget();
const { updateAppStep } = useAppAnalytics(name.value);
const { updateAppStep } = useAppAnalytics();
const { validateApp } = useAppValidation({
deploymentTargetID: deploymentTarget?.deployment_target_id,
creating: true,
Expand Down Expand Up @@ -238,7 +238,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
}) => {
setIsDeploying(true);
// log analytics event that we started form submission
updateAppStep({ step: "stack-launch-complete" });
updateAppStep({ step: "stack-launch-complete", appName: name.value });

try {
if (!currentProject?.id || !currentCluster?.id) {
Expand Down Expand Up @@ -308,7 +308,7 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
);

// log analytics event that we successfully deployed
updateAppStep({ step: "stack-launch-success" });
updateAppStep({ step: "stack-launch-success", appName: name.value });

if (source.type === "docker-registry") {
history.push(`/apps/${app.name}`);
Expand All @@ -320,14 +320,15 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
updateAppStep({
step: "stack-launch-failure",
errorMessage: err.response?.data?.error,
appName: name.value,
});
setDeployError(err.response?.data?.error);
return false;
}

const msg =
"An error occurred while deploying your application. Please try again.";
updateAppStep({ step: "stack-launch-failure", errorMessage: msg });
updateAppStep({ step: "stack-launch-failure", errorMessage: msg, appName: name.value });
setDeployError(msg);
return false;
} finally {
Expand Down Expand Up @@ -593,9 +594,8 @@ const CreateApp: React.FC<CreateAppProps> = ({ history }) => {
}
>
{detectedServices.count > 0
? `Detected ${detectedServices.count} service${
detectedServices.count > 1 ? "s" : ""
} from porter.yaml.`
? `Detected ${detectedServices.count} service${detectedServices.count > 1 ? "s" : ""
} from porter.yaml.`
: `Could not detect any services from porter.yaml. Make sure it exists in the root of your repo.`}
</Text>
</AppearingDiv>
Expand Down
8 changes: 8 additions & 0 deletions internal/analytics/tracks.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ func StackLaunchStartTrack(opts *StackLaunchStartOpts) segmentTrack {
additionalProps["email"] = opts.Email
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["validate_apply_v2"] = opts.ValidateApplyV2

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand All @@ -822,6 +823,7 @@ func StackLaunchCompleteTrack(opts *StackLaunchCompleteOpts) segmentTrack {
additionalProps["email"] = opts.Email
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["validate_apply_v2"] = opts.ValidateApplyV2

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand All @@ -848,6 +850,7 @@ func StackLaunchSuccessTrack(opts *StackLaunchSuccessOpts) segmentTrack {
additionalProps["email"] = opts.Email
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["validate_apply_v2"] = opts.ValidateApplyV2

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand Down Expand Up @@ -876,6 +879,7 @@ func StackLaunchFailureTrack(opts *StackLaunchFailureOpts) segmentTrack {
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["error_message"] = opts.ErrorMessage
additionalProps["validate_apply_v2"] = opts.ValidateApplyV2

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand Down Expand Up @@ -904,6 +908,7 @@ func StackDeletionTrack(opts *StackDeletionOpts) segmentTrack {
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["delete_workflow_file"] = opts.DeleteWorkflowFile
additionalProps["validate_apply_v2"] = opts.ValidateApplyV2

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand Down Expand Up @@ -932,6 +937,7 @@ func StackBuildFailureTrack(opts *StackBuildOpts) segmentTrack {
additionalProps["email"] = opts.Email
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["validate_apply_v2"] = opts.ValidateApplyV2

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand All @@ -946,6 +952,7 @@ func StackBuildSuccessTrack(opts *StackBuildOpts) segmentTrack {
additionalProps["email"] = opts.Email
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["validate_apply_v2"] = opts.ValidateApplyV2

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand All @@ -960,6 +967,7 @@ func StackBuildProgressingTrack(opts *StackBuildOpts) segmentTrack {
additionalProps["email"] = opts.Email
additionalProps["name"] = opts.FirstName + " " + opts.LastName
additionalProps["company"] = opts.CompanyName
additionalProps["validate_apply_v2"] = opts.ValidateApplyV2

return getSegmentProjectTrack(
opts.ProjectScopedTrackOpts,
Expand Down

0 comments on commit 215864b

Please sign in to comment.