Skip to content

Conversation

@dcramer
Copy link
Member

@dcramer dcramer commented Dec 5, 2025

Add a development-time console warning when useProjects() is called without the slugs parameter. This prepares for removing the all_projects=1 bootstrap fetch by encouraging explicit project fetching.

Updates 18 components to pass specific slugs to useProjects(), ensuring they will continue working when projects are no longer pre-loaded.

Refs #104436

@dcramer dcramer requested review from a team as code owners December 5, 2025 18:27
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 5, 2025
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff            @@
##           master   #104462   +/-   ##
========================================
  Coverage   80.51%    80.51%           
========================================
  Files        9348      9348           
  Lines      399919    399892   -27     
  Branches    25651     25648    -3     
========================================
- Hits       322005    321990   -15     
+ Misses      77466     77454   -12     
  Partials      448       448           

const organization = useOrganization();

const project = useProjects().projects.find(p => {
const {projects} = useProjects({slugs: props.projectId ? [props.projectId] : []});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this one should just be empty if no projectId is set

trail.type === 'profile summary' || trail.type === 'flamechart'
)
.map(trail => trail.payload.projectSlug);
const {projects} = useProjects({slugs: projectSlugs});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theres gotta be a better way to do breadcrumbs than pulling in projects like this - might need to just look at the payload. if its got slug, it might have name?

...props
}: WrapperProps) {
const {projects} = useProjects();
const {projects} = useProjects({slugs: projectSlug ? [projectSlug] : []});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to the profiling one, project should be empty if no projectId? thus no projects defined?


export function TransactionCell({project, transaction, transactionMethod}: Props) {
const projects = useProjects();
const {projects} = useProjects({slugs: project ? [project] : []});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q: is project optional here becauase its not always present in the cells? does that mean we only need to look up project when its present similar to the other concerns with props above?

} = useGroup({groupId});

const groupProjectSlug = groupData?.project?.slug;
const {projects} = useProjects({slugs: groupProjectSlug ? [groupProjectSlug] : []});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if project slug isnt found we should hard error on the group - it means the project's missing/deleted/similar

const theme = useTheme();
const {projects} = useProjects();
const projectSlug = node.value.project_slug ?? node.event?.projectSlug;
const {projects} = useProjects({slugs: projectSlug ? [projectSlug] : []});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard error on missing slug i believe - someone correct me if im wrong

const location = useLocation();
const theme = useTheme();
const {projects} = useProjects();
const projectSlug = node.value.project_slug ?? node.event?.projectSlug;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard error on missing slug i believe - someone correct me if im wrong

@dcramer dcramer changed the title ref(ui): Add deprecation warning to useProjects() without slugs ref(ui): deprecate useProjects() without slugs Dec 5, 2025
@dcramer dcramer force-pushed the use-projects-warning branch from c3bbdac to 4ac7fcf Compare December 5, 2025 21:02
'This usage is deprecated and may break when all_projects=1 is removed. ' +
'Pass specific slugs to ensure projects are fetched on-demand.'
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Deprecation warning fires repeatedly on every render

The console.warn for deprecation is executed directly in the function body rather than inside a useEffect or with a ref guard. This means the warning will fire on every single re-render of any component calling useProjects() without slugs, spamming the console with repeated warnings. The warning needs to be deduplicated, typically by using a ref to track whether it has already warned, or by placing it in a useEffect with empty dependencies.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine

Add a development-time console warning when useProjects() is called
without the slugs parameter. This prepares for removing the all_projects=1
bootstrap fetch by encouraging explicit project fetching.

Updates 18 components to pass specific slugs to useProjects(), ensuring
they will continue working when projects are no longer pre-loaded.
@dcramer dcramer force-pushed the use-projects-warning branch from bf7c52d to 34f7904 Compare December 5, 2025 22:43
}: ContinuousProfileProviderProps) {
const api = useApi();
const {projects} = useProjects();
const {projects} = useProjects({slugs: projectSlug ? [projectSlug] : []});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing fetch state check causes false Sentry errors

The ContinuousProfileProvider now uses useProjects with specific slugs, but doesn't destructure the fetching state. When the project needs to be fetched from the API (not already in store), projects will be empty during the fetch. The useLayoutEffect runs immediately with the empty array, finds no project, and logs "Failed to fetch continuous profile - project not found" to Sentry - even though the project exists and is just being loaded. This causes false positive error reports. The component needs to check fetching before treating a missing project as an error.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants