Skip to content

Conversation

@Zylphrex
Copy link
Member

…egory

This replaces the custom functions we wrote for each data category with a hook that accepts a list of data categories so we can automatically determine what the expected date page filter props should be. This sets it up so that we can replace the hook with an alternate implementation in order to support the coming retention changes.

…egory

This replaces the custom functions we wrote for each data category with a hook
that accepts a list of data categories so we can automatically determine what
the expected date page filter props should be. This sets it up so that we can
replace the hook with an alternate implementation in order to support the coming
retention changes.
@Zylphrex Zylphrex requested review from a team as code owners November 21, 2025 16:59
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 21, 2025
Comment on lines +28 to +31
export function useMaxPickableDays({
dataCategories,
organization,
}: UseMaxPickableDaysProps): MaxPickableDaysOptions {
Copy link
Member Author

Choose a reason for hiding this comment

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

This hook will be replaced by an implementation that looks at the org's subscription.

Copy link
Member

@k-fish k-fish left a comment

Choose a reason for hiding this comment

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

The picking logic is a little convoluted but the test coverage looks good enough, so 👍. Couple minor nits

Comment on lines +90 to +97
case DataCategory.TRACE_METRICS:
case DataCategory.LOG_BYTE:
case DataCategory.LOG_ITEM:
return {
maxPickableDays: 30,
maxUpgradableDays: 30,
defaultPeriod: '24h',
};
Copy link

Choose a reason for hiding this comment

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

Bug: The max() function in useMaxPickableDays.tsx can incorrectly drop the defaultPeriod property when comparing MaxPickableDaysOptions objects.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The max() function in useMaxPickableDays.tsx (lines 55-68) incorrectly handles MaxPickableDaysOptions objects when one contains a defaultPeriod and another does not. If useMaxPickableDays is called with multiple data categories, and one category provides a defaultPeriod while another does not, the max() function may return an object missing the defaultPeriod. This can lead to datePageFilterProps.defaultPeriod being undefined in content.tsx, causing defaultSelection to be undefined when a default period should have been applied.

💡 Suggested Fix

Modify the max() function in useMaxPickableDays.tsx to ensure defaultPeriod is preserved if present in any of the compared MaxPickableDaysOptions objects, prioritizing the defaultPeriod from the object that "wins" the maxPickableDays and maxUpgradableDays comparison, or merging it if appropriate.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/utils/useMaxPickableDays.tsx#L90-L97

Potential issue: The `max()` function in `useMaxPickableDays.tsx` (lines 55-68)
incorrectly handles `MaxPickableDaysOptions` objects when one contains a `defaultPeriod`
and another does not. If `useMaxPickableDays` is called with multiple data categories,
and one category provides a `defaultPeriod` while another does not, the `max()` function
may return an object missing the `defaultPeriod`. This can lead to
`datePageFilterProps.defaultPeriod` being `undefined` in `content.tsx`, causing
`defaultSelection` to be `undefined` when a default period should have been applied.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 3289398

@Zylphrex Zylphrex merged commit b535ce8 into master Nov 24, 2025
49 checks passed
@Zylphrex Zylphrex deleted the txiao/feat/add-hooks-for-date-page-filter-props-based-on-data-category branch November 24, 2025 20:45
@Zylphrex Zylphrex added the Trigger: Revert Add to a merged PR to revert it (skips CI) label Nov 24, 2025
@getsentry-bot
Copy link
Contributor

PR reverted: 8a3d936

getsentry-bot added a commit that referenced this pull request Nov 24, 2025
…data cat… (#103822)"

This reverts commit b535ce8.

Co-authored-by: Zylphrex <10239353+Zylphrex@users.noreply.github.com>
Zylphrex added a commit that referenced this pull request Nov 25, 2025
#103931)

…egory

This replaces the custom functions we wrote for each data category with
a hook that accepts a list of data categories so we can automatically
determine what the expected date page filter props should be. This sets
it up so that we can replace the hook with an alternate implementation
in order to support the coming retention changes.

Same as #103822 but fixed typing issues in 17c69c7
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 Trigger: Revert Add to a merged PR to revert it (skips CI)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants