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

fix: send analytics on successful commands #4227

Merged
merged 4 commits into from
Feb 9, 2022
Merged

fix: send analytics on successful commands #4227

merged 4 commits into from
Feb 9, 2022

Conversation

erezrokah
Copy link
Contributor

@erezrokah erezrokah commented Feb 8, 2022

🎉 Thanks for submitting a pull request! 🎉

Summary

Fixes #4196

Will think on how to test this and add a test Done


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@erezrokah erezrokah requested a review from lukasholzer February 8, 2022 17:24
@erezrokah erezrokah added the automerge Add to Kodiak auto merge queue label Feb 8, 2022
@github-actions github-actions bot added the type: bug code to address defects in shipped code label Feb 8, 2022
@github-actions
Copy link

github-actions bot commented Feb 8, 2022

📊 Benchmark results

Comparing with 71950d3

Package size: 508 MB

(no change)

^                                                                                                  508 MB 
│                                                                                                   ┌──┐  
│                                                                                                   |▒▒|  
│                                                                                                   |▒▒|  
│                                                                                                   |▒▒|  
│  377 MB  377 MB  377 MB  377 MB  377 MB  377 MB  377 MB  377 MB  377 MB  377 MB  368 MB  368 MB   |▒▒|  
│ ──┌──┐────┌──┐────┌──┐────┌──┐────┌──┐────┌──┐────┌──┐────┌──┐────┌──┐────┌──┐────┌──┐────┌──┐────|▒▒|──
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

@@ -300,13 +300,14 @@ class BaseCommand extends Command {
const duration = getDuration(startTime)
const status = error_ === undefined ? 'success' : 'error'

debug(`${this.name()}:onEnd`)(`Status: ${status}`)
debug(`${this.name()}:onEnd`)(`Duration: ${duration}ms`)
const command = Array.isArray(this.args) ? this.args[0] : this.name()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems rather defensive, but I rather not have the CLI error if something changes with commander

@@ -49,9 +49,40 @@ test.serial('should track --telemetry-enable', async (t) => {
test('should send netlify-cli/<version> user-agent', async (t) => {
await withMockApi(routes, async ({ apiUrl, requests }) => {
await callCli(['api', 'listSites'], getCLIOptions(apiUrl))
t.true(requests.length !== 0)
const request = requests.find(({ path }) => path === '/api/v1/track')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test was failing on my machine as the mock api can receive requests in a different order.
Updated the test to better search the analytics request

@erezrokah erezrokah requested a review from ehmicky February 9, 2022 12:56
program
.parseAsync(process.argv)
.then(() => {
program.onEnd()
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: if onEnd() throws, it will be called twice. Is that ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point! I don't see how it can throw

async onEnd(error_) {

We can put everything in onEnd to make it clear that it shouldn't throw, WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, it looks pretty safe.
I think it looks good as is 👍

@erezrokah erezrokah added automerge Add to Kodiak auto merge queue and removed automerge Add to Kodiak auto merge queue labels Feb 9, 2022
@kodiakhq kodiakhq bot merged commit 7251872 into main Feb 9, 2022
@kodiakhq kodiakhq bot deleted the fix/analytics branch February 9, 2022 14:52
@erezrokah
Copy link
Contributor Author

This PR shows a package size of 508MB for some reason. Going to open an issue to investigate

@erezrokah
Copy link
Contributor Author

erezrokah commented Feb 9, 2022

Size change unrelated to this PR. See PR to fix in #4247.

Looks like #4233 did it since netlify build had a pinned version of zisi (didn't dive into it too much)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Add to Kodiak auto merge queue type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI tracking of successful commands does not work currently
2 participants