Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion static/app/utils/analytics/logsAnalyticsEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export type LogsAnalyticsEventParameters = {
page_source: LogsAnalyticsPageSource;
};
'logs.auto_refresh.toggled': {
enabled: boolean;
fromPaused: boolean;
organization: Organization;
page_source: LogsAnalyticsPageSource;
toggleState: 'enabled' | 'disabled';
};
'logs.doc_link.clicked': {
organization: Organization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {useLogsQueryKeyWithInfinite} from 'sentry/views/explore/logs/useLogsQuer
export const LOGS_AUTO_REFRESH_KEY = 'live';
export const LOGS_REFRESH_INTERVAL_KEY = 'refreshEvery';
const LOGS_REFRESH_INTERVAL_DEFAULT = 5000;
const MAX_AUTO_REFRESH_PAUSED_TIME_MS = 60 * 1000; // 60 seconds
const MAX_AUTO_REFRESH_PAUSED_TIME_MS = 60 * 1000; // 10 seconds

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bug: Code Comment Mismatch: Auto-Refresh Timing

The MAX_AUTO_REFRESH_PAUSED_TIME_MS constant in static/app/views/explore/contexts/logs/logsAutoRefreshContext.tsx has a comment indicating '10 seconds', but its actual value remains 60 * 1000 (60 seconds). This discrepancy suggests the intended change to a 10-second duration was only applied to the comment, not the constant's value, leading to a mismatch between documented and actual behavior.

Locations (1)
Fix in Cursor Fix in Web


export const ABSOLUTE_MAX_AUTO_REFRESH_TIME_MS = 10 * 60 * 1000; // 10 minutes
export const CONSECUTIVE_PAGES_WITH_MORE_DATA = 5;
Expand Down Expand Up @@ -102,6 +102,11 @@ export function useLogsAutoRefreshEnabled() {
return isTableFrozen ? false : autoRefresh === 'enabled';
}

export function useLogsAutoRefreshContinued() {
const {autoRefresh, pausedAt} = useLogsAutoRefresh();
return autoRefresh === 'enabled' && pausedAtAllowedToContinue(pausedAt);
}

export function useAutorefreshEnabledOrWithinPauseWindow() {
const {autoRefresh, pausedAt} = useLogsAutoRefresh();
return (
Expand All @@ -113,11 +118,14 @@ export function useAutorefreshEnabledOrWithinPauseWindow() {
function withinPauseWindow(autoRefresh: AutoRefreshState, pausedAt: number | undefined) {
return (
(autoRefresh === 'paused' || autoRefresh === 'enabled') &&
pausedAt &&
Date.now() - pausedAt < MAX_AUTO_REFRESH_PAUSED_TIME_MS
pausedAtAllowedToContinue(pausedAt)
);
}

function pausedAtAllowedToContinue(pausedAt: number | undefined) {
return pausedAt && Date.now() - pausedAt < MAX_AUTO_REFRESH_PAUSED_TIME_MS;
}

export function useSetLogsAutoRefresh() {
const location = useLocation();
const navigate = useNavigate();
Expand All @@ -139,6 +147,7 @@ export function useSetLogsAutoRefresh() {
if (autoRefresh === 'paused') {
setPausedAt(newPausedAt);
} else if (autoRefresh !== 'enabled') {
// Any error state, or disabled state, should reset the pause state.
setPausedAt(undefined);
}

Expand Down
Loading
Loading