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(insights): Introduce sort by selector for releases #82302

Conversation

priscilawebdev
Copy link
Member

Before

Screen.Recording.2024-12-18.at.14.38.29.mov

After

Screen.Recording.2024-12-18.at.14.39.09.mov

closes #82004

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 18, 2024
@@ -0,0 +1,11 @@
export enum ReleasesSortOption {
Copy link
Member Author

Choose a reason for hiding this comment

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

this enum was just moved from

export enum ReleasesSortOption {
CRASH_FREE_USERS = 'crash_free_users',
CRASH_FREE_SESSIONS = 'crash_free_sessions',
USERS_24_HOURS = 'users_24h',
SESSIONS_24_HOURS = 'sessions_24h',
SESSIONS = 'sessions',
DATE = 'date',
BUILD = 'build',
SEMVER = 'semver',
ADOPTION = 'adoption',
}

Comment on lines +2 to +10
CRASH_FREE_USERS = 'crash_free_users',
CRASH_FREE_SESSIONS = 'crash_free_sessions',
USERS_24_HOURS = 'users_24h',
SESSIONS_24_HOURS = 'sessions_24h',
SESSIONS = 'sessions',
DATE = 'date',
BUILD = 'build',
SEMVER = 'semver',
ADOPTION = 'adoption',
Copy link
Member Author

Choose a reason for hiding this comment

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

@philipphofmann can you confirm that we would like to provide all these sort by options?

Copy link
Member

Choose a reason for hiding this comment

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

I would remove crash-free-users and crash-free-session, as we are filtering releases for performance data, and I don't think that is relevant. I would keep the rest.

Comment on lines 162 to 178
function getSortRealesesBy(
sort: ReleasesSortByOption,
environments: string[]
): ReleasesSortByOption {
// Require 1 environment for date adopted
if (sort === ReleasesSortOption.ADOPTION && environments.length !== 1) {
return ReleasesSortOption.DATE;
}

const sortExists = Object.keys(SORT_BY_OPTIONS).includes(sort ?? '');

if (sortExists) {
return sort;
}

return ReleasesSortOption.DATE;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

you can find the same logic here

static/app/views/insights/common/queries/useReleases.tsx Outdated Show resolved Hide resolved
@priscilawebdev priscilawebdev requested a review from a team December 18, 2024 13:49
@priscilawebdev priscilawebdev marked this pull request as ready for review December 18, 2024 13:49
@priscilawebdev priscilawebdev requested review from a team as code owners December 18, 2024 13:49
Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##           master   #82302       +/-   ##
===========================================
- Coverage   87.56%   80.41%    -7.15%     
===========================================
  Files        9410     7289     -2121     
  Lines      536906   319467   -217439     
  Branches    21118    20862      -256     
===========================================
- Hits       470131   256914   -213217     
+ Misses      66409    62148     -4261     
- Partials      366      405       +39     

Copy link
Member

@matejminar matejminar left a comment

Choose a reason for hiding this comment

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

@priscilawebdev @philipphofmann How about we save the sorting preference in the local storage so that it's remembered?

…-sort-by-selector' of github.com:getsentry/sentry into priscila/feat/screen-summary/releses-selector/introduce-sort-by-selector
@priscilawebdev
Copy link
Member Author

priscilawebdev commented Dec 18, 2024

@matejminar we can, but it won't be consistent with what we do on the releases page for example. We perform the queries based on the URLs parameters

@priscilawebdev
Copy link
Member Author

Thinking about it...since users should navigate these pages more, it seems like a good idea...will just wait for @philipphofmann thumbs up

@philipphofmann
Copy link
Member

@priscilawebdev @philipphofmann How about we save the sorting preference in the local storage so that it's remembered?

I think that would make sense unless it's a lot of work.

Copy link

codecov bot commented Dec 19, 2024

Bundle Report

Changes will increase total bundle size by 5.24kB (0.02%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
app-webpack-bundle-array-push 32.21MB 5.24kB (0.02%) ⬆️

@priscilawebdev
Copy link
Member Author

@matejminar we always get only 50 releases and the selected time range only affects the second request /events/ where we grab the event count.

@matejminar
Copy link
Member

Yeah, that's what I was afraid of. In that case I'd completely remove sort by Number of Events.
It is not a true sort and it might be confusing or straight up wrong for some customers.
The main motivation behind sorting by number of events anyway is to get to the releases that are used the most and for that we have already other sorting options (like sort by sessions, etc.)

@priscilawebdev
Copy link
Member Author

hey @matejminar yes it makes sense as it is not a true sorting. I have removed the option in the commit

@JonasBa
Copy link
Member

JonasBa commented Dec 20, 2024

@priscilawebdev I just did a quick drive-by review, none of my comments are blocking, so feel free to merge this once someone approves it :)

Copy link
Member

@gggritso gggritso left a comment

Choose a reason for hiding this comment

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

Makes sense! All I have is nits. Out of curiosity, where did the designs come from?

static/app/views/insights/common/queries/useReleases.tsx Outdated Show resolved Hide resolved
Comment on lines +199 to +221
useEffect(() => {
if (urlStoragedReleaseBy === localStoragedReleaseBy) {
return;
}

// this is useful in case the user shares the url with another user
// and the user has a different sort by in their local storage
if (!urlStoragedReleaseBy) {
navigate(
{
...location,
query: {
...location.query,
sortReleasesBy: localStoragedReleaseBy,
},
},
{replace: true}
);
return;
}

setLocalStoragedReleaseBy(urlStoragedReleaseBy);
}, [
Copy link
Member

Choose a reason for hiding this comment

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

I have a question about this! React documentation is very explicit that renders must be pure (though I guess in this case, it's not a huge deal). Maybe this is a good case for useLayoutEffect, since it block browser paint?

@priscilawebdev
Copy link
Member Author

priscilawebdev commented Jan 2, 2025

@gggritso Since there is a plan to refactor this page completely, the sort selector was a quick solution from @Jesse-Box

@priscilawebdev
Copy link
Member Author

priscilawebdev commented Jan 2, 2025

The only UX issue with this change is that, if no primary or secondary release is selected, useReleaseSelection will automatically choose the first and second releases from a list, which is ordered by date. The selected value is then moved to the top of the list, and depending on the sort by selection, this can make it unclear to users that only elements after the first one are actually sorted.

I had a solution in mind that addresses this issue (see below), but when no releases are returned based on the selected sortBy option, we would need to always display the label "Sorted By ...." anyways. To implement this, we would have to refactor the compact selector core component, which we prefer not to do since this is intended to be a temporary solution.

Screen.Recording.2025-01-02.at.15.05.49.mov

@gggritso do you have any thoughts on this?

@priscilawebdev priscilawebdev force-pushed the priscila/feat/screen-summary/releses-selector/introduce-sort-by-selector branch from e32c3aa to c2d43bf Compare January 2, 2025 14:16
@gggritso
Copy link
Member

gggritso commented Jan 2, 2025

@priscilawebdev 🤔 I have two questions!

useReleaseSelection will automatically choose the first and second releases from a list, which is ordered by date

Is it possible to update useReleaseSelection to pass the user-selected sort order to useReleases? If yes, does that eliminate the problem with the confusing sort order?

when no releases are returned based on the selected sortBy option

When does this happen? Is this caused by a server error, or is this a condition that might be caused by the user?

@priscilawebdev
Copy link
Member Author

@gggritso here the first answer:

Is it possible to update useReleaseSelection to pass the user-selected sort order to useReleases? If yes, does that eliminate the problem with the confusing sort order?

I initially considered this approach and implemented exactly what you suggested, which resolves the issue in the release selector. However, we don’t want the entire page to change based on the selected sortBy option. While we could address the problem just for the release selector, it would look odd to have a mismatch between the selected releases and the displayed data

@priscilawebdev
Copy link
Member Author

priscilawebdev commented Jan 3, 2025

@gggritso

When does this happen? Is this caused by a server error, or is this a condition that might be caused by the user?

For example, when selecting the "Build Number" sort option, I always get a response with 50 data items. However, when performing the /events/ query, the response is empty, and as a result, no options are displayed in the release list. I suspect there may be an issue with the query, possibly related to the Metrics Dataset. Also, why aren't we including the time range in the /releases/ query? maybe you or @shruthilayaj know something?

@gggritso
Copy link
Member

gggritso commented Jan 3, 2025

@priscilawebdev I took a quick look! A few things came up

  1. When sorting by "Build Number", the releases that come back from /releases/ are Android debug builds that don't have any events. I don't think there's any problem with the /events/ query
  2. The release dropdown omits any releases with 0 events, so the dropdown is empty
  3. I'm not sure why the /releases/ query doesn't include the date range, sorry!

As for your original question, sorry, I don't have a good suggestions for how to resolve the weird UI if you don't think using the sort works. This would be better answered by someone from Design or someone who worked/works on the module, as you said.

If it were me, I might just leave it alone. The behaviour is weird, yes, but it's the same behaviour as when you chose a date range far in the past, or a short date range with no events, etc.

Otherwise, maybe talk to Vu about supporting empty sections in CompactDropdown so the "Sorted by Date" section could say "No releases found" or something similar?

@priscilawebdev
Copy link
Member Author

@gggritso thanks so much for taking a look at this! 🙏 I always assumed that a release in Sentry always contained events, so this was really helpful to clarify.

As for the dropdown, I might just leave it as is for now, since these components are due for a refactor soon anyway. Hopefully, that’ll be happening sooner rather than later!

@priscilawebdev priscilawebdev enabled auto-merge (squash) January 7, 2025 07:23
@priscilawebdev priscilawebdev merged commit e7f0473 into master Jan 7, 2025
43 checks passed
@priscilawebdev priscilawebdev deleted the priscila/feat/screen-summary/releses-selector/introduce-sort-by-selector branch January 7, 2025 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insights - Mobile - Release Selector Sorting
5 participants