Browse Source

feat(starfish): bias for events with profiles regardless of missing lcp or not (#58910)

Hack for demo purposes. bias for events with profiles regardless of
missing lcp or not
edwardgou-sentry 1 year ago
parent
commit
cb75703391

+ 18 - 0
static/app/views/performance/browser/webVitals/pageSamplePerformanceTable.tsx

@@ -102,6 +102,24 @@ export function PageSamplePerformanceTable({transaction}: Props) {
 
   const data = [...goodData, ...mehData, ...poorData];
 
+  // If we have enough data, but not enough with profiles, replace rows without profiles with no LCP data that have profiles
+  if (
+    data.length >= 9 &&
+    data.filter(row => row['profile.id']).length < 9 &&
+    noLcpData.filter(row => row['profile.id']).length > 0
+  ) {
+    const noLcpDataWithProfiles = noLcpData.filter(row => row['profile.id']);
+    let numRowsToReplace = Math.min(
+      data.filter(row => !row['profile.id']).length,
+      noLcpDataWithProfiles.length
+    );
+    while (numRowsToReplace > 0) {
+      const index = data.findIndex(row => !row['profile.id']);
+      data[index] = noLcpDataWithProfiles.pop()!;
+      numRowsToReplace--;
+    }
+  }
+
   // If we don't have enough data, fill in the rest with no LCP data
   if (data.length < 9) {
     data.push(...noLcpData.slice(0, 9 - data.length));