Skip to content

Commit

Permalink
fix(alerts): Fix open in explore date range (#82506)
Browse files Browse the repository at this point in the history
When rendering alert previews on a 7d time window, the alerts UI
actually renders using 9998m instead. Updates the `open in explore`
button for eap alerts to map 9998m back to 7d in explore instead.
  • Loading branch information
edwardgou-sentry authored Dec 23, 2024
1 parent e839f8d commit e583a3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions static/app/views/alerts/rules/utils.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,21 @@ describe('getExploreUrl', () => {
'/organizations/slug/traces/?dataset=spansRpc&environment=prod&interval=30m&project=1&query=span.op%3Ahttp.client&statsPeriod=7d&visualize=%7B%22chartType%22%3A1%2C%22yAxes%22%3A%5B%22p75%28span.duration%29%22%5D%7D'
);
});
it('should return the correct url for 9998m', () => {
const rule = MetricRuleFixture();
rule.dataset = Dataset.EVENTS_ANALYTICS_PLATFORM;
rule.timeWindow = TimeWindow.THIRTY_MINUTES;
rule.aggregate = 'p75(span.duration)';
rule.query = 'span.op:http.client';
rule.environment = 'prod';
const url = getAlertRuleExploreUrl({
rule,
orgSlug: 'slug',
period: '9998m',
projectId: '1',
});
expect(url).toEqual(
'/organizations/slug/traces/?dataset=spansRpc&environment=prod&interval=30m&project=1&query=span.op%3Ahttp.client&statsPeriod=7d&visualize=%7B%22chartType%22%3A1%2C%22yAxes%22%3A%5B%22p75%28span.duration%29%22%5D%7D'
);
});
});
2 changes: 1 addition & 1 deletion static/app/views/alerts/rules/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function getAlertRuleExploreUrl({
orgSlug,
selection: {
datetime: {
period,
period: period === '9998m' ? '7d' : period,
start: null,
end: null,
utc: null,
Expand Down

0 comments on commit e583a3d

Please sign in to comment.