Просмотр исходного кода

feat(anr-rate): Update ANR rate defaults on project details (#43248)

Updating the defaults because "View Issues" button
takes the user to all ANR types in the issues stream.
There isn't a way to query just for foreground ANR issues
yet.

![Screen Shot 2023-01-13 at 12 22 09
PM](https://user-images.githubusercontent.com/63818634/212381170-722e0005-b7b4-426b-b296-455ed57827d9.png)
Shruthi 2 лет назад
Родитель
Сommit
1c84d9c653

+ 2 - 2
static/app/views/projectDetail/projectCharts.tsx

@@ -90,7 +90,7 @@ class ProjectCharts extends Component<Props, State> {
 
     if (hasSessions && !hasTransactions) {
       if (organization.features.includes('anr-rate') && project?.platform === 'android') {
-        return [DisplayModes.STABILITY, DisplayModes.FOREGROUND_ANR_RATE];
+        return [DisplayModes.STABILITY, DisplayModes.ANR_RATE];
       }
       return [DisplayModes.STABILITY, DisplayModes.ERRORS];
     }
@@ -100,7 +100,7 @@ class ProjectCharts extends Component<Props, State> {
     }
 
     if (organization.features.includes('anr-rate') && project?.platform === 'android') {
-      return [DisplayModes.STABILITY, DisplayModes.FOREGROUND_ANR_RATE];
+      return [DisplayModes.STABILITY, DisplayModes.ANR_RATE];
     }
 
     return [DisplayModes.STABILITY, DisplayModes.APDEX];

+ 5 - 5
static/app/views/projectDetail/projectScoreCards/projectAnrScoreCard.spec.tsx

@@ -38,7 +38,7 @@ describe('ProjectDetail > ProjectAnr', function () {
           {
             by: {},
             totals: {
-              'foreground_anr_rate()': 0.11561866125760649,
+              'anr_rate()': 0.11561866125760649,
             },
           },
         ],
@@ -54,7 +54,7 @@ describe('ProjectDetail > ProjectAnr', function () {
           {
             by: {},
             totals: {
-              'foreground_anr_rate()': 0.08558558558558559,
+              'anr_rate()': 0.08558558558558559,
             },
           },
         ],
@@ -83,7 +83,7 @@ describe('ProjectDetail > ProjectAnr', function () {
       expect.objectContaining({
         query: {
           environment: [],
-          field: ['foreground_anr_rate()'],
+          field: ['anr_rate()'],
           includeSeries: '0',
           includeTotals: '1',
           interval: '1h',
@@ -100,7 +100,7 @@ describe('ProjectDetail > ProjectAnr', function () {
         query: {
           end: '2017-10-10T02:41:20.000',
           environment: [],
-          field: ['foreground_anr_rate()'],
+          field: ['anr_rate()'],
           includeSeries: '0',
           includeTotals: '1',
           interval: '1h',
@@ -132,7 +132,7 @@ describe('ProjectDetail > ProjectAnr', function () {
 
     await waitFor(() => expect(screen.getByText('11.562%')).toBeInTheDocument());
 
-    expect(screen.getByRole('button', {name: 'Open in Issues'})).toHaveAttribute(
+    expect(screen.getByRole('button', {name: 'View Issues'})).toHaveAttribute(
       'href',
       '/organizations/org-slug/issues/?project=1&query=mechanism%3AANR%20release%3Aabc&sort=freq&statsPeriod=7d'
     );

+ 7 - 9
static/app/views/projectDetail/projectScoreCards/projectAnrScoreCard.tsx

@@ -51,7 +51,7 @@ export function ProjectAnrScoreCard({
 
     const requestData = {
       orgSlug: organization.slug,
-      field: ['foreground_anr_rate()'],
+      field: ['anr_rate()'],
       environment: environments,
       project: projects,
       query,
@@ -85,7 +85,7 @@ export function ProjectAnrScoreCard({
     } else {
       const requestData = {
         orgSlug: organization.slug,
-        field: ['foreground_anr_rate()'],
+        field: ['anr_rate()'],
         environment: environments,
         project: projects,
         query,
@@ -119,12 +119,10 @@ export function ProjectAnrScoreCard({
     };
   }, [start, end, period, api, organization.slug, environments, projects, query]);
 
-  const value = sessionsData
-    ? sessionsData.groups[0].totals['foreground_anr_rate()']
-    : null;
+  const value = sessionsData ? sessionsData.groups[0].totals['anr_rate()'] : null;
 
   const previousValue = previousSessionData
-    ? previousSessionData.groups[0].totals['foreground_anr_rate()']
+    ? previousSessionData.groups[0].totals['anr_rate()']
     : null;
 
   const hasCurrentAndPrevious = previousValue && value;
@@ -166,15 +164,15 @@ export function ProjectAnrScoreCard({
   function renderButton() {
     return (
       <Button data-test-id="issues-open" size="xs" to={issueSearch}>
-        {t('Open in Issues')}
+        {t('View Issues')}
       </Button>
     );
   }
 
   return (
     <ScoreCard
-      title={t('Foreground ANR Rate')}
-      help={getSessionTermDescription(SessionTerm.FOREGROUND_ANR_RATE, null)}
+      title={t('ANR Rate')}
+      help={getSessionTermDescription(SessionTerm.ANR_RATE, null)}
       score={value ? formatPercentage(value, 3) : '\u2014'}
       trend={renderTrend()}
       trendStatus={trendStatus}