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

feat: enable usage report #270

Merged
merged 9 commits into from
Oct 25, 2024
Merged

feat: enable usage report #270

merged 9 commits into from
Oct 25, 2024

Conversation

cristianoventura
Copy link
Collaborator

Description

This PR introduces changes to collect usage report data when running a k6 script as well as the following when running k6 Studio:

  • os
  • arch
  • version
  • timestamp

The user can opt-out of the usage report by disabling it in the Settings dialog.

How to Test

  • Check that usageReport.enabled property is properly saved
  • Run a script from k6 Studio and check that the option --no-usage-report is passed to the k6 binary (you can do that by logging the k6Args array in the script.ts file.

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (npm run lint) and all checks pass.
  • I have run tests locally (npm test) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Screenshots (if appropriate):

image

Related PR(s)/Issue(s)

@cristianoventura cristianoventura requested a review from a team as a code owner October 23, 2024 21:00
@cristianoventura cristianoventura requested review from going-confetti and Llandy3d and removed request for a team October 23, 2024 21:00
@@ -0,0 +1,55 @@
import { v4 as uuidv4 } from 'uuid'
Copy link
Collaborator

Choose a reason for hiding this comment

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

We use self.crypto.randomUUID in others places in k6 studio, I don't think a separate module is needed

Copy link
Member

Choose a reason for hiding this comment

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

That's on me!
I didn't notice :)

Comment on lines 29 to 30
Please send my anonymous usage data to Grafana to aid in
development of k6 Studio.{' '}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd avoid using "please" (as mentioned in Grafana's UX writing guide)

<Text size="2" as="label">
<Checkbox
{...register('usageReport.enabled')}
defaultChecked
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO this is redundant: the field should reflect the current settings: if they are saved in the file, the user will see the value from the file; if not, the user will see the default value

},
})
} catch (e) {
console.log('Error sending report', e)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we don't send the report when running the app in dev env, this line isn't really needed. I think we should either log it in the app logs, or fail silently instead

Copy link
Member

Choose a reason for hiding this comment

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

I think fail silently in this case is more appropriate, error from this would just be noise 🤔

Copy link
Collaborator

@going-confetti going-confetti left a comment

Choose a reason for hiding this comment

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

LGTM!

@cristianoventura cristianoventura merged commit 2907d3c into main Oct 25, 2024
2 checks passed
@cristianoventura cristianoventura deleted the feat/usage-report branch October 25, 2024 12:57
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.

3 participants