Skip to content

Commit

Permalink
fix(new-trace): Making trace project slugs unique (#81435)
Browse files Browse the repository at this point in the history
<img width="344" alt="Screenshot 2024-11-28 at 2 21 46 PM"
src="https://github.com/user-attachments/assets/c4941a45-cd25-430d-aaa5-aaa320241fb5">

Co-authored-by: Abdullah Khan <[email protected]>
  • Loading branch information
2 people authored and andrewshie-sentry committed Dec 2, 2024
1 parent 9a92071 commit 7a4a552
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <LegacyTraceMetadataHeader {...props} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -237,7 +236,7 @@ function fetchTrace(

export class TraceTree extends TraceTreeEventDispatcher {
eventsCount = 0;
projects = new Set<TraceTree.Project>();
projects = new Map<number, TraceTree.Project>();

type: 'loading' | 'empty' | 'error' | 'trace' = 'trace';
root: TraceTreeNode<null> = TraceTreeNode.Root();
Expand Down Expand Up @@ -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,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
};
Expand Down

0 comments on commit 7a4a552

Please sign in to comment.