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

✨ Async analytics #260

Merged
merged 6 commits into from
Jan 30, 2023
Merged

✨ Async analytics #260

merged 6 commits into from
Jan 30, 2023

Conversation

arnavkulk
Copy link
Contributor

@arnavkulk arnavkulk commented Jan 20, 2023

Summary:

Make analytics run concurrently alongside cli commands

  • Added package requests-futures (an extension of requests - what we use right now) for handling http requests asynchronously

New usage:

None, but the --use-analytics=True flag must be set for analytics to be recorded

Motivation:

CLI analytics are currently a blocking function on the actual command, and can take a long time to run for those with bad internet. This change sends analytics requests in the background, so that there is no blocking.

References (optional):

Closes #250

Test Plan:

For the following tests --use-analytics should be set to false

  • Run any command (Expected output: command runs successfully, no output because analytics aren't running)

For the following --use-analytics should be set to true

  • Run any command (Expected output: command runs successfully, analytics get sent. If there is an error with analytics, "Something went wrong while sending analytics!" is outputted)
  • Run a command without an Internet connection (Expected output: analytics fails, the above message is outputted)

Testing Screenshots:

No Analytics:
No Analytics

Successful Analytics:
Successful Analytics

Failed Analytics:
Failed analytics

Copy link
Member

@ayushuk ayushuk left a comment

Choose a reason for hiding this comment

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

Tested on my machine and lgtm just remove those old lines you commented out and we are good to merge

pros/ga/analytics.py Show resolved Hide resolved
response = future.result()

if not response.status_code==200:
print("Something went wrong while sending analytics!")
Copy link
Member

Choose a reason for hiding this comment

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

Out of scope for this pr but possibly might look into reading status codes for more specific error messages

@ayushuk ayushuk changed the title Feature/async analytics ✨ Async analytics Jan 30, 2023
Copy link
Member

@ayushuk ayushuk left a comment

Choose a reason for hiding this comment

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

lgtm

@arnavkulk arnavkulk merged commit 44adec3 into develop Jan 30, 2023
@ayushuk ayushuk deleted the feature/async-analytics branch January 30, 2023 02:50
@kunwarsahni01 kunwarsahni01 mentioned this pull request Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛Make analytics asynchronous
2 participants