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

track(perf): Add >30d to unparam table analytics (#50549)

We had a case of 'none' which covered single projects, and we also want
to cover multi projects since they make up some of the new accounts as
well. Put a cap on # of iterated projects here so outliers don't have
bad performance.
Kev 1 год назад
Родитель
Сommit
457cafaebc

+ 2 - 1
static/app/utils/analytics/performanceAnalyticsEvents.tsx

@@ -40,7 +40,8 @@ export type PerformanceEventParameters = {
   };
   };
   'performance_views.landing.table.seen': {};
   'performance_views.landing.table.seen': {};
   'performance_views.landing.table.unparameterized': {
   'performance_views.landing.table.unparameterized': {
-    first_event: 'none' | '14d' | '30d';
+    first_event: 'none' | '14d' | '30d' | '>30d';
+    hit_multi_project_cap: boolean;
     sent_transaction: boolean;
     sent_transaction: boolean;
     single_project: boolean;
     single_project: boolean;
     stats_period: string;
     stats_period: string;

+ 23 - 6
static/app/views/performance/table.tsx

@@ -65,6 +65,19 @@ type State = {
   transactionThresholdMetric: TransactionThresholdMetric | undefined;
   transactionThresholdMetric: TransactionThresholdMetric | undefined;
   widths: number[];
   widths: number[];
 };
 };
+
+function getProjectFirstEventGroup(project: Project): '14d' | '30d' | '>30d' {
+  const fourteen_days_ago = new Date(+new Date() - 12096e5);
+  const thirty_days_ago = new Date(+new Date() - 25920e5);
+  const firstEventDate = new Date(project?.firstEvent ?? '');
+  if (firstEventDate > fourteen_days_ago) {
+    return '14d';
+  }
+  if (firstEventDate > thirty_days_ago) {
+    return '30d';
+  }
+  return '>30d';
+}
 class _Table extends Component<Props, State> {
 class _Table extends Component<Props, State> {
   state: State = {
   state: State = {
     widths: [],
     widths: [],
@@ -96,6 +109,7 @@ class _Table extends Component<Props, State> {
       sent_transaction: firstEventData.singleProject?.firstTransactionEvent ?? false,
       sent_transaction: firstEventData.singleProject?.firstTransactionEvent ?? false,
       single_project: firstEventData.isSingleProject,
       single_project: firstEventData.isSingleProject,
       stats_period: statsPeriod,
       stats_period: statsPeriod,
+      hit_multi_project_cap: firstEventData.isAtMultiCap,
     });
     });
   }
   }
 
 
@@ -105,17 +119,19 @@ class _Table extends Component<Props, State> {
   getFirstEventData() {
   getFirstEventData() {
     const {eventView, projects} = this.props;
     const {eventView, projects} = this.props;
     const isSingleProject = !areMultipleProjectsSelected(eventView);
     const isSingleProject = !areMultipleProjectsSelected(eventView);
-    const fourteen_days_ago = new Date(+new Date() - 12096e5);
-    const thirty_days_ago = new Date(+new Date() - 25920e5);
 
 
     const selectedProjects = eventView.getFullSelectedProjects(projects);
     const selectedProjects = eventView.getFullSelectedProjects(projects);
+    const isAtMultiCap = selectedProjects.length > 1000;
     const singleProject = selectedProjects[0];
     const singleProject = selectedProjects[0];
-    let firstEventWithin: 'none' | '14d' | '30d' = 'none';
+    let firstEventWithin: 'none' | '14d' | '30d' | '>30d' = '>30d';
     if (isSingleProject) {
     if (isSingleProject) {
-      const firstEventDate = new Date(singleProject?.firstEvent ?? '');
-      if (firstEventDate > fourteen_days_ago) {
+      firstEventWithin = getProjectFirstEventGroup(singleProject);
+    } else if (!isAtMultiCap) {
+      const dateGroups = selectedProjects.map(getProjectFirstEventGroup);
+      if (dateGroups.every(g => g === '14d')) {
         firstEventWithin = '14d';
         firstEventWithin = '14d';
-      } else if (firstEventDate > thirty_days_ago) {
+      }
+      if (dateGroups.every(g => g === '14d' || g === '30d')) {
         firstEventWithin = '30d';
         firstEventWithin = '30d';
       }
       }
     }
     }
@@ -123,6 +139,7 @@ class _Table extends Component<Props, State> {
       firstEventWithin,
       firstEventWithin,
       isSingleProject,
       isSingleProject,
       singleProject,
       singleProject,
+      isAtMultiCap,
     };
     };
   }
   }