Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(cli): send telemetry on errors #829

Merged
merged 10 commits into from
Jul 23, 2021
Merged

Conversation

DanielMSchmidt
Copy link
Contributor

@DanielMSchmidt DanielMSchmidt commented Jul 12, 2021

This PR helps us track errors to understand the problems of our user-base better.
I added the Errors object in an adjecent effort of being deliberate about Error types

@@ -386,17 +393,17 @@ async function fetchRemoteTemplate(templateUrl: string): Promise<Template> {
console.error(
chalkColour`Please supply a valid url (including the protocol) or use one of the built-in templates.`
);
process.exit(1);
return await process.exit(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just read a bit on process.exit in the docs and it seems that we should refrain from using such calls. I have used them myself extensively in the past, but they'll make our error reporting unreliable as errors may not always have been sent completely by the time the process exits.
On another note: This is also why we don't need to await the exit and return is also not needed 😅

Copy link
Member

@ansgarm ansgarm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only two minor things, but good to go then 🚀

@@ -397,8 +398,10 @@ export const determineGoModuleName = async (dir: string): Promise<string> => {
const childdir = path.relative(currentDir, dir).replace(/\\/g, "/"); // replace '\' with '/' for windows paths
return childdir.length > 0 ? `${match[1]}/${childdir}` : match[1];
}
throw new Error(
`Could not determine the root Go module name. Found ${file} but failed to regex match the module name directive`
throw await Errors.Internal(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The await has no effect as report() is not awaited in reportPrefixedErrors

@@ -407,7 +410,9 @@ export const determineGoModuleName = async (dir: string): Promise<string> => {
currentDir = path.dirname(currentDir);
} while (currentDir !== previousDir);

throw new Error(
`Could not determine the root Go module name. No go.mod found in ${dir} and any parent directories`
throw await Errors.Usage(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above with await

}

function reportPrefixedError(type: string) {
return (command: string, message: string, context: Record<string, any>) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make the context optional? (Sometimes an empty object is passed)

@DanielMSchmidt DanielMSchmidt merged commit 2dcf9c9 into main Jul 23, 2021
@DanielMSchmidt DanielMSchmidt deleted the telemetry-improvements branch July 23, 2021 15:52
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants