-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat: (Codecov) add updateRepository function to update local storage and url query params for repo selection #89818
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: (Codecov) add updateRepository function to update local storage and url query params for repo selection #89818
Conversation
…uery params for repo selection
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.
everything looks good to me
My initial thinking is that: it seems good to re-use the url and localstorage stuff that powers the global pageFilters stuff. However adding in optional params to the top-level code interface seems like it'll be annoying over time. You'll probably want a unique version of pageFilters that will capture and require org+repo+branch+time. So i'd really suggest taking a look at splitting things up and planning for something that has strong types, but can still share some methods under the hood. |
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #89818 +/- ##
==========================================
- Coverage 83.07% 83.07% -0.01%
==========================================
Files 10261 10261
Lines 579556 579549 -7
Branches 22622 22622
==========================================
- Hits 481491 481484 -7
Misses 97622 97622
Partials 443 443 |
Thanks for the pointers and advice @ryan953 and @malwilley! Proceeded to make separate but similar types for the Codecov filters, allowing to reuse most of the functionality and keep things separate. I did create some methods exclusive to Codecov where relevant, as well as rename some types like No sentry hook or file was affected, which is good w/ the type separation, just had to adjust a bunch of tests as the PageFilters' state will inevitably change with the addition of the Please let me know how it looks! |
@@ -72,20 +79,27 @@ interface PageFiltersStoreDefinition extends StrictStoreDefinition<PageFiltersSt | |||
pinned: Set<PinnedPageFilter>, | |||
persist?: boolean | |||
): void; | |||
onInitializeUrlStateWithCodecovData( |
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 feels wrong to me that we separate codecov and sentry selections in these functions, yet the underlying state is a combination of the two. But the only other option I can think of is creating a completely separate store to track the codecov selection which is probably prohibitively difficult.
Not requesting changes based on this, just noting my thoughts about it. Tagging the frontend github team to see if anyone else has good ideas.
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.
Yeah it's not the most elegant solution but it's the one that caused less friction.
I tried adding an extra param to the existing initialize function, but that affected a bunch of other tests - it's an option but I'm not the biggest fan. Luckily this function is only used once, so it'd only affect one code file there.
Alternatively, I had fused the newSelection param to expect type SentryFilters + CodecovFilters, and inside the initialize fn create a helper that split that object into 'sentrySelection' and 'codecovSelection', but I wasn't too convinced with this one either.
Open to ideas!
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 agree here with @malwilley, this feels wrong.
I tried adding an extra param to the existing initialize function, but that affected a bunch of other tests - it's an option but I'm not the biggest fan. Luckily this function is only used once, so it'd only affect one code file there.
Understood, but that is somewhat expected, as you are touching some code that is used very often at Sentry. Updating a ton of tests isn't great, and I get that it's tedious, but it's a lot easier than maintaining two different implementations under the hood.
…ate-repository-url-and-storage-fns
Thanks for the pointers @malwilley and @scttcper, ready for another pass! (I changed my GH account to my personal one so you'll see my recent commits are by a different user) |
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 feels like a bad move for the codebase for numerous reasons. I get that it's easy to add yet another flow, but this isn't the right solution. If Codecov is being merged into Sentry, we shouldn't need a separate code flow at the page filter level.
I would like to understand the issues of the considered alternatives (documenting them would go a long way here). You mentioned adding a query param breaks a lot of tests, which is somewhat expected, and while annoying, isn't particularly hard to fix. Miantaining an entirely separate flow and implementation for Codecov is something that is going to linger in the codebase forever, and I'd much rather we find a good implementation from the start and really integrate codecov into sentry as a first class product.
I am willing to help and dedicate some time to getting this properly integrated into our current pagefilters if that helps.
@@ -70,6 +83,10 @@ type PageFiltersUpdate = { | |||
utc?: boolean | null; | |||
}; | |||
|
|||
type CodecovPageFiltersUpdate = { |
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.
Why do we need a distinction of Codecov vs Sentry? If we are merging Codecov to Sentry, then this should not exist, and it should just be Sentry going forward.
I'm not a fan of this approach, as I'm fairly sure it will linger around until someone ultimately needs to address it (at which point, we'll have a lot of the code relying on this and it'll be a massive PITA to update)
@@ -72,20 +79,27 @@ interface PageFiltersStoreDefinition extends StrictStoreDefinition<PageFiltersSt | |||
pinned: Set<PinnedPageFilter>, | |||
persist?: boolean | |||
): void; | |||
onInitializeUrlStateWithCodecovData( |
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 agree here with @malwilley, this feels wrong.
I tried adding an extra param to the existing initialize function, but that affected a bunch of other tests - it's an option but I'm not the biggest fan. Luckily this function is only used once, so it'd only affect one code file there.
Understood, but that is somewhat expected, as you are touching some code that is used very often at Sentry. Updating a ton of tests isn't great, and I get that it's tedious, but it's a lot easier than maintaining two different implementations under the hood.
closing in favor of #90693 |
This PR adds the ability to store repository data to the URL query parameters as well as local storage and reflux.
For the Codecov to Sentry project, we're tasked with adding a series of components, some of which would benefit from saving fields into local storage and url params. Those selectors are seen in this image below, from left to right: Codecov organization (different from what Sentry calls an organization), a repository, a branch and a time range - this PR focuses on the adding repository functionality exclusively.

Main Features
updateRepository
function in actionCreators, which calls the updateRepository reflux store function and updates + persists the repository in local storage and the url.updateRepository
function in pageFiltersStore, which mainly updates the state w/ the repository selection (see notes on absence of desync).Update
Notes
Thanks!