From 7a4a5525d9cdb9861a85df2ebafa71737bc430cb Mon Sep 17 00:00:00 2001
From: Abdullah Khan <60121741+Abdkhan14@users.noreply.github.com>
Date: Fri, 29 Nov 2024 12:04:38 -0500
Subject: [PATCH] fix(new-trace): Making trace project slugs unique (#81435)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Co-authored-by: Abdullah Khan
---
.../views/performance/newTraceDetails/traceHeader/index.tsx | 4 ++--
.../performance/newTraceDetails/traceModels/traceTree.tsx | 6 ++----
.../traceTypeWarnings/errorsOnlyWarnings.tsx | 3 ++-
.../traceTypeWarnings/usePerformanceUsageStats.tsx | 2 +-
4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/static/app/views/performance/newTraceDetails/traceHeader/index.tsx b/static/app/views/performance/newTraceDetails/traceHeader/index.tsx
index c101ecc7bfb1d4..30658bdd496d6e 100644
--- a/static/app/views/performance/newTraceDetails/traceHeader/index.tsx
+++ b/static/app/views/performance/newTraceDetails/traceHeader/index.tsx
@@ -165,8 +165,8 @@ export function TraceMetaDataHeader(props: TraceMetadataHeaderProps) {
);
const projectSlugs = useMemo(() => {
- return Array.from(props.tree.projects).map(p => p.slug);
- }, [props.tree]);
+ return Array.from(props.tree.projects.values()).map(project => project.slug);
+ }, [props.tree.projects]);
if (!hasNewTraceViewUi) {
return ;
diff --git a/static/app/views/performance/newTraceDetails/traceModels/traceTree.tsx b/static/app/views/performance/newTraceDetails/traceModels/traceTree.tsx
index cda92934f8dd7a..bfa21a88b90541 100644
--- a/static/app/views/performance/newTraceDetails/traceModels/traceTree.tsx
+++ b/static/app/views/performance/newTraceDetails/traceModels/traceTree.tsx
@@ -133,7 +133,6 @@ export declare namespace TraceTree {
type TracePerformanceIssue = TracePerformanceIssueType;
type Profile = {profile_id: string} | {profiler_id: string};
type Project = {
- id: number;
slug: string;
};
type Root = null;
@@ -237,7 +236,7 @@ function fetchTrace(
export class TraceTree extends TraceTreeEventDispatcher {
eventsCount = 0;
- projects = new Set();
+ projects = new Map();
type: 'loading' | 'empty' | 'error' | 'trace' = 'trace';
root: TraceTreeNode = TraceTreeNode.Root();
@@ -295,8 +294,7 @@ export class TraceTree extends TraceTreeEventDispatcher {
value: TraceTree.Transaction | TraceTree.TraceError
) {
tree.eventsCount++;
- tree.projects.add({
- id: value.project_id,
+ tree.projects.set(value.project_id, {
slug: value.project_slug,
});
diff --git a/static/app/views/performance/newTraceDetails/traceTypeWarnings/errorsOnlyWarnings.tsx b/static/app/views/performance/newTraceDetails/traceTypeWarnings/errorsOnlyWarnings.tsx
index 5d4cbe9408bf94..74f47314fd6ab2 100644
--- a/static/app/views/performance/newTraceDetails/traceTypeWarnings/errorsOnlyWarnings.tsx
+++ b/static/app/views/performance/newTraceDetails/traceTypeWarnings/errorsOnlyWarnings.tsx
@@ -34,7 +34,8 @@ function filterProjects(projects: Project[], tree: TraceTree) {
const projectsWithOnboardingChecklist: Project[] = [];
for (const project of projects) {
- if (Array.from(tree.projects).some(p => Number(project.id) === p.id)) {
+ const hasProject = tree.projects.has(Number(project.id));
+ if (hasProject) {
if (!project.firstTransactionEvent) {
projectsWithNoPerformance.push(project);
if (project.platform && withPerformanceOnboarding.has(project.platform)) {
diff --git a/static/app/views/performance/newTraceDetails/traceTypeWarnings/usePerformanceUsageStats.tsx b/static/app/views/performance/newTraceDetails/traceTypeWarnings/usePerformanceUsageStats.tsx
index 0ea40b3d0054be..73432ddd5326c4 100644
--- a/static/app/views/performance/newTraceDetails/traceTypeWarnings/usePerformanceUsageStats.tsx
+++ b/static/app/views/performance/newTraceDetails/traceTypeWarnings/usePerformanceUsageStats.tsx
@@ -48,7 +48,7 @@ export function usePerformanceUsageStats({
field: 'sum(quantity)',
utc: true,
category: 'transaction_indexed',
- project: Array.from(tree.projects).map(project => project.id),
+ project: Array.from(tree.projects.keys()),
referrer: 'trace-view-warnings',
},
};