-
Notifications
You must be signed in to change notification settings - Fork 2
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: crash reporter settings #393
Conversation
onCheckedChange={field.onChange} | ||
/>{' '} | ||
Send crash reports and error data to Grafana to help improve k6 | ||
Studio. <Link href="">Learn more.</Link> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll likely need a link here leading to a doc similar to the usage collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we remove the link until we have the doc? Currently, it reloads the app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was waiting for feedback and thinking that we could potentially have that link before releasing this feature. I just removed it and we can add it back later.
beforeSend: (event) => { | ||
if (appSettings.telemetry.errorReport) { | ||
return event | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sentry is always initialized in Prod mode, but the event is dynamically sent based on the errorReport
setting.
src/schemas/settings/v1/index.ts
Outdated
telemetry: { | ||
usageReport: settings.usageReport.enabled, | ||
errorReport: true, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A migration was needed since usageReport
was renamed to `telemetry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to bump schema version, copy schema to v3 and add the adjustments there?
Everything works now, but if we introduce another change that depends on useageReport
or telemetry
and the user has skipped one version between updates - the migration won't work anymore because we lose that middle step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right! I thought we hadn't released that change yet but it looks like v2 is the latest one in prod.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comments about migration and empty link
…studio into feat/crash-reporter-settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, the checkbox label/description should give the user a better understanding of where the data is sent, especially since we don't have the docs yet
} | ||
|
||
export const AppSettingsSchema = z.object({ | ||
version: z.literal('3.0'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably too late to ask this, but in which cases would we bump the "minor" version? Maybe it's unnecessary and could be omitted from this version on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since all migrations are required (and likely cause breaking changes) and automatically fast-forwarded, I don't think bumping the minor would ever be suitable 🤔. We could use timestamps instead, like other major frameworks do. This change could also be incorporated into #392 where the migration name and version are automatically generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use timestamps instead, like other major frameworks do. This change could also be incorporated into #392 where the migration name and version are automatically generated.
I like this idea!
|
||
// conditionally send the event based on the user's settings | ||
beforeSend: (event) => { | ||
if (appSettings.telemetry.errorReport) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember writing a comment about this, but can't find anymore, probably forgot to submit it, sorry about that 😅
appSettings
could be undefined, we need to update type to be AppSettings | undefined
where is declared and add checks here. I've added a throw to appReady callback before appSettings
variable is initialized and got this exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I chose to initialize the variable with the defaultSettings
object instead. If we leave it as undefined
, we'd need to perform additional type checks in multiple places, which could increase the overall maintenance effort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
@@ -79,7 +88,7 @@ const PROXY_RETRY_LIMIT = 5 | |||
let proxyRetryCount = 0 | |||
let currentClientRoute = '/' | |||
let wasAppClosedByClient = false | |||
export let appSettings: AppSettings | |||
export let appSettings = defaultSettings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how I feel about this, as it can lead to a situation when defaultSettings
would be used instead of the actual settings. I see that it's only imported in browser.ts
- can we add detectBrowserPath
as a parameter to launchBrowser
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how I feel about this, as it can lead to a situation when defaultSettings would be used instead of the actual settings
@going-confetti This already happens. The getSettings
method returns the default object if the settings file can't be parsed. It's a fault tolerance mechanism. appSettings
will be set at some point (either to the actual settings or failover to default)
Lines 68 to 72 in ff74970
} catch (error) { | |
log.error('Failed to parse settings file', error) | |
// if the file is invalid during runtime, | |
// return a valid settings object so the app can keep running | |
return defaultSettings |
I see that it's only imported in browser.ts - can we add detectBrowserPath as a parameter to launchBrowser instead?
This is a good idea! There will be probably additional places where we'll have to use appSettings
with the separation of modules that we plan to work on #378, so I'll defer this change to when we get there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This already happens. The getSettings method returns the default object if the settings file can't be parsed. It's a fault tolerance mechanism. appSettings will be set at some point (either to the actual settings or failover to default)
IMO it could be a big deal if the settings can't be parsed and we use default settings as a fallback without informing the user. For example, if they have custom proxy configuration and stuff suddenly stops working.
Seems out of scope of this PR though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed! We can work on something to let users know that the default config was loaded if the parsing fails.
Description
This PR depends on #365. It adds a new option to the Settings dialog that allows users to opt out of k6 Studio sending error/crash reports to Sentry.
How to Test
Checklist
npm run lint
) and all checks pass.npm test
) and all tests pass.Screenshots (if appropriate):
Related PR(s)/Issue(s)