Skip to content

Commit 81dcc8c

Browse files
authored
feat(events-v2): Add filtering to heatmaps (#13650)
Filters heatmaps by project, environment, time and query
1 parent 4b14820 commit 81dcc8c

File tree

14 files changed

+31
-26
lines changed

14 files changed

+31
-26
lines changed

src/sentry/static/sentry/app/components/organizations/globalSelectionHeader/index.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import PropTypes from 'prop-types';
44
import React from 'react';
55
import styled from 'react-emotion';
66

7-
import {
8-
DATE_TIME_KEYS,
9-
URL_PARAM,
10-
} from 'app/components/organizations/globalSelectionHeader/constants';
7+
import {DATE_TIME_KEYS, URL_PARAM} from 'app/constants/globalSelectionHeader';
118
import {DEFAULT_STATS_PERIOD} from 'app/constants';
129
import {callIfFunction} from 'app/utils/callIfFunction';
1310
import {isEqualWithDates} from 'app/utils/isEqualWithDates';

src/sentry/static/sentry/app/components/organizations/globalSelectionHeader/utils.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {pick, pickBy, identity} from 'lodash';
33
import {defined} from 'app/utils';
44
import {getUtcToLocalDateObject} from 'app/utils/dates';
55

6-
import {URL_PARAM} from './constants';
6+
import {URL_PARAM} from 'app/constants/globalSelectionHeader';
77

88
// Parses URL query parameters for values relevant to global selection header
99
export function getStateFromQuery(query) {

src/sentry/static/sentry/app/stores/globalSelectionStore.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
DATE_TIME,
66
URL_PARAM,
77
LOCAL_STORAGE_KEY,
8-
} from 'app/components/organizations/globalSelectionHeader/constants';
8+
} from 'app/constants/globalSelectionHeader';
99
import {getStateFromQuery} from 'app/components/organizations/globalSelectionHeader/utils';
1010
import {isEqualWithDates} from 'app/utils/isEqualWithDates';
1111
import OrganizationsStore from 'app/stores/organizationsStore';

src/sentry/static/sentry/app/views/organizationEventsV2/data.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import DateTime from 'app/components/dateTime';
1212

1313
import {QueryLink} from './styles';
1414

15+
export const MODAL_QUERY_KEYS = ['eventSlug', 'groupSlug'];
16+
1517
export const ALL_VIEWS = deepFreeze([
1618
{
1719
id: 'all',

src/sentry/static/sentry/app/views/organizationEventsV2/events.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {getParams} from 'app/views/organizationEvents/utils/getParams';
1616
import Table from './table';
1717
import Tags from './tags';
1818
import {getQuery} from './utils';
19+
import {MODAL_QUERY_KEYS} from './data';
1920

2021
const CHART_AXIS_OPTIONS = [
2122
{label: 'Count', value: 'event_count'},
@@ -35,8 +36,8 @@ export default class Events extends AsyncComponent {
3536
componentDidUpdate(prevProps, prevContext) {
3637
// Do not update if we are just opening/closing the modal
3738
const locationHasChanged = !isEqual(
38-
omit(prevProps.location.query, 'eventSlug'),
39-
omit(this.props.location.query, 'eventSlug')
39+
omit(prevProps.location.query, MODAL_QUERY_KEYS),
40+
omit(this.props.location.query, MODAL_QUERY_KEYS)
4041
);
4142

4243
if (locationHasChanged) {

src/sentry/static/sentry/app/views/organizationEventsV2/tags.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
33
import styled from 'react-emotion';
4-
import {isEqual} from 'lodash';
4+
import {isEqual, omit} from 'lodash';
55

66
import SentryTypes from 'app/sentryTypes';
77
import TagDistributionMeter from 'app/components/tagDistributionMeter';
88
import withApi from 'app/utils/withApi';
9-
import withGlobalSelection from 'app/utils/withGlobalSelection';
109
import {fetchTags, getEventTagSearchUrl} from './utils';
10+
import {MODAL_QUERY_KEYS} from './data';
1111

1212
class Tags extends React.Component {
1313
static propTypes = {
1414
api: PropTypes.object.isRequired,
1515
organization: SentryTypes.Organization.isRequired,
1616
view: SentryTypes.EventView.isRequired,
17-
selection: SentryTypes.GlobalSelection.isRequired,
1817
location: PropTypes.object.isRequired,
1918
};
2019

@@ -28,19 +27,22 @@ class Tags extends React.Component {
2827
}
2928

3029
componentDidUpdate(prevProps) {
31-
if (
32-
this.props.view.id !== prevProps.view.id ||
33-
!isEqual(this.props.selection, prevProps.selection)
34-
) {
30+
// Do not update if we are just opening/closing the modal
31+
const locationHasChanged = !isEqual(
32+
omit(prevProps.location.query, MODAL_QUERY_KEYS),
33+
omit(this.props.location.query, MODAL_QUERY_KEYS)
34+
);
35+
36+
if (this.props.view.id !== prevProps.view.id || locationHasChanged) {
3537
this.fetchData();
3638
}
3739
}
3840

3941
fetchData = async () => {
40-
const {api, organization, view} = this.props;
42+
const {api, organization, view, location} = this.props;
4143

4244
try {
43-
const tags = await fetchTags(api, organization.slug, view.tags);
45+
const tags = await fetchTags(api, organization.slug, view.tags, location.query);
4446
this.setState({tags, isLoading: false});
4547
} catch (err) {
4648
this.setState({tags: {}, isLoading: false});
@@ -87,4 +89,4 @@ const Placeholder = styled('div')`
8789
`;
8890

8991
export {Tags};
90-
export default withApi(withGlobalSelection(Tags));
92+
export default withApi(Tags);

src/sentry/static/sentry/app/views/organizationEventsV2/utils.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {pick} from 'lodash';
22

33
import {DEFAULT_PER_PAGE} from 'app/constants';
4+
import {URL_PARAM} from 'app/constants/globalSelectionHeader';
45
import {ALL_VIEWS, SPECIAL_FIELDS} from './data';
56

67
/**
@@ -91,10 +92,12 @@ export function getEventTagSearchUrl(tagKey, tagValue, location) {
9192
* @param {Array} tagList
9293
* @returns {Promise<Object>}
9394
*/
94-
export function fetchTags(api, orgSlug, tagList) {
95+
export function fetchTags(api, orgSlug, tagList, query) {
96+
const urlParams = pick(query, Object.values(URL_PARAM));
97+
9598
return api
9699
.requestPromise(`/organizations/${orgSlug}/events-heatmap/`, {
97-
query: {keys: tagList},
100+
query: {...urlParams, keys: tagList, query: query.query},
98101
})
99102
.then(resp => {
100103
const tags = {};

src/sentry/static/sentry/app/views/organizationReleases/detail/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SentryTypes from 'app/sentryTypes';
66
import LoadingError from 'app/components/loadingError';
77
import LoadingIndicator from 'app/components/loadingIndicator';
88
import GlobalSelectionHeader from 'app/components/organizations/globalSelectionHeader';
9-
import {URL_PARAM} from 'app/components/organizations/globalSelectionHeader/constants';
9+
import {URL_PARAM} from 'app/constants/globalSelectionHeader';
1010
import withOrganization from 'app/utils/withOrganization';
1111
import AsyncView from 'app/views/asyncView';
1212
import {PageContent} from 'app/styles/organization';

src/sentry/static/sentry/app/views/organizationReleases/detail/releaseArtifacts.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
44
import React from 'react';
55

66
import {Panel, PanelHeader, PanelBody, PanelItem} from 'app/components/panels';
7-
import {URL_PARAM} from 'app/components/organizations/globalSelectionHeader/constants';
7+
import {URL_PARAM} from 'app/constants/globalSelectionHeader';
88
import {t} from 'app/locale';
99
import EmptyStateWarning from 'app/components/emptyStateWarning';
1010
import FileSize from 'app/components/fileSize';

src/sentry/static/sentry/app/views/organizationReleases/detail/releaseCommits.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React from 'react';
44
import createReactClass from 'create-react-class';
55

66
import {Panel, PanelHeader, PanelBody} from 'app/components/panels';
7-
import {URL_PARAM} from 'app/components/organizations/globalSelectionHeader/constants';
7+
import {URL_PARAM} from 'app/constants/globalSelectionHeader';
88
import {t} from 'app/locale';
99
import withApi from 'app/utils/withApi';
1010
import CommitRow from 'app/components/commitRow';

src/sentry/static/sentry/app/views/organizationReleases/list/utils.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {pick} from 'lodash';
2-
import {URL_PARAM} from 'app/components/organizations/globalSelectionHeader/constants';
2+
import {URL_PARAM} from 'app/constants/globalSelectionHeader';
33

44
/**
55
* Get query term for API given location.query

src/sentry/static/sentry/app/views/userFeedback/utils.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {pick} from 'lodash';
22
import qs from 'query-string';
33

4-
import {URL_PARAM} from 'app/components/organizations/globalSelectionHeader/constants';
4+
import {URL_PARAM} from 'app/constants/globalSelectionHeader';
55

66
const DEFAULT_STATUS = 'unresolved';
77

tests/js/spec/views/organizationEventsV2/tags.spec.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('Tags', function() {
4444
api={api}
4545
organization={org}
4646
selection={{projects: [], environments: [], datetime: {}}}
47-
location={{}}
47+
location={{query: {}}}
4848
/>
4949
);
5050

0 commit comments

Comments
 (0)