:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(error-tracking): align rate limit copy and top issues window (#61180)
Aleksander Błaszkiewiczb7d2bc9965aa
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex efeb13980fc1..15f6ece17999 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5911,9 +5911,9 @@ snapshots:scenes-app-settings-environment--settings-environment-error-tracking--light:hash: v1.k794b7964.df02fcd95e1f9112616fe56e8541581568932b938d9450663a928cf01da1f12e.Ag0JlyyWvjEPr5Fn-2tw25Vmj5i3y5bnLNgOGMvEnVMscenes-app-settings-environment--settings-environment-error-tracking-configuration--dark:- hash: v1.k794b7964.300288a0ebffc24792ce30b3c4d406cf6094ebe17b302f20213395115e9541ff.l3W9IJOgmcF1ZamIqo4_uQQxaqDSKJ3fumH1-UInEwY+ hash: v1.k794b7964.80c679de8bf9284289f301eba371a17fdb989857adadc9ddd1accd62f6864a8d.KxdiTscByOSZT-ey3VVA2-8r79r4HILribwk9B9QAmsscenes-app-settings-environment--settings-environment-error-tracking-configuration--light:- hash: v1.k794b7964.bc36c7ac40d2aeb9af38f00b414aedb050bbed90814c93cb8fc8c59cff44862b.yJM5SxFw6K6OO9Uz73-yGl53mo8okt-2zie2ptlRKcU+ hash: v1.k794b7964.9d4e3cc3c75db7c236507539bd17fceb70d58e56ca2223c2022b20b301a9e9b3.eTnWulPHX9MremFBzJYUli8VaPHbUChZ287rEX9oIwwscenes-app-settings-environment--settings-environment-feature-flags--dark:hash: v1.k794b7964.ad14435de0672d1899cd23e51214c7ff70d1557ef6bc21de88946e1b02dc0ddd.rSQy7QhYRP-Zuzl8xAEtgcuc3f-KEtRX0rw257x5oTEscenes-app-settings-environment--settings-environment-feature-flags--light:diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/IssueRateLimitSettings.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/IssueRateLimitSettings.tsxindex 2b3c2bbf17df..19645a292e90 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/IssueRateLimitSettings.tsx+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/IssueRateLimitSettings.tsx@@ -31,7 +31,7 @@ export function IssueRateLimitSettings(): JSX.Element {<div><h3 className="font-semibold text-base mb-1">Per-issue rate limit</h3><p className="text-muted-foreground">- This limit applies to each issue individually. Once an issue exceeds the configured rate, further+ This limit applies to each issue per window. Once an issue exceeds the configured rate, furtherexceptions for it are dropped at ingestion.</p></div>@@ -84,9 +84,7 @@ function ConfigColumn(): JSX.Element {)}</LemonField>- <p className="text-muted-foreground text-xs">- Applies to every issue independently. Leave the value empty for no limit.- </p>+ <p className="text-muted-foreground text-xs">Leave the value empty for no limit.</p><div className="flex justify-start pt-2"><LemonButton@@ -103,10 +101,11 @@ function ConfigColumn(): JSX.Element {}function IssuesListColumn(): JSX.Element {- const { topIssues, topIssuesLoading, selectedIssueId } = useValues(issueRateLimitConfigLogic)+ const { topIssues, topIssuesLoading, selectedIssueId, configForm } = useValues(issueRateLimitConfigLogic)const { selectIssue } = useActions(issueRateLimitConfigLogic)- const heading = <div className="text-sm font-medium mb-1">Most active issues — past 7 days</div>+ const windowLabel = formatTotalDuration(configForm.per_issue_rate_limit_bucket_size_minutes)+ const heading = <div className="text-sm font-medium mb-1">Most active issues — past {windowLabel}</div>if (topIssuesLoading) {return (@@ -122,7 +121,7 @@ function IssuesListColumn(): JSX.Element {<div className="space-y-1">{heading}<div className="border rounded p-4 text-sm text-muted-foreground h-80 flex items-center justify-center text-center">- No exceptions captured in the past 7 days yet.+ No exceptions captured in the past {windowLabel} yet.</div></div>)diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings.tsx b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings.tsxindex f83280712997..f485fba972eb 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings.tsx+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/RateLimitSettings.tsx@@ -83,10 +83,7 @@ function ProjectRateLimitSection(): JSX.Element {)}</LemonField>- <p className="text-muted-foreground text-xs">- The maximum number of exceptions accepted per time window. Leave the value empty for no- limit.- </p>+ <p className="text-muted-foreground text-xs">Leave the value empty for no limit.</p><div className="flex justify-start pt-2"><LemonButtondiff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/issueRateLimitConfigLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/issueRateLimitConfigLogic.tsindex 4a1a1d35469e..2231feb1ca47 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/issueRateLimitConfigLogic.ts+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/issueRateLimitConfigLogic.ts@@ -24,8 +24,6 @@ export interface TopIssue {occurrences: number}-const TOP_ISSUES_WINDOW_DAYS = 7-const DEFAULT_CONFIG: IssueRateLimitConfigForm = {per_issue_rate_limit_value: null,per_issue_rate_limit_bucket_size_minutes: DEFAULT_BUCKET_MINUTES,@@ -72,7 +70,10 @@ export const issueRateLimitConfigLogic = kea<issueRateLimitConfigLogicType>([topIssues: [[] as TopIssue[],{- loadTopIssues: async () => {+ loadTopIssues: async ({ bucketMinutes }: { bucketMinutes: number }, breakpoint) => {+ const option = getBucketOption(bucketMinutes)+ const totalMinutes = option.minutes * option.bucketCount+ await breakpoint(300)const response = (await api.query({kind: NodeKind.HogQLQuery,query: `@@ -83,14 +84,15 @@ export const issueRateLimitConfigLogic = kea<issueRateLimitConfigLogicType>([count() AS occurrencesFROM eventsWHERE event = '$exception'- AND timestamp >= now() - INTERVAL ${TOP_ISSUES_WINDOW_DAYS} DAY+ AND timestamp >= now() - INTERVAL ${totalMinutes} MINUTEAND issue_id_v2 IS NOT NULLGROUP BY issue_id_v2ORDER BY occurrences DESC- LIMIT 100+ LIMIT 10`,tags: { productKey: ProductKey.ERROR_TRACKING },})) as HogQLQueryResponse+ breakpoint()return (response.results ?? []).map(([issue_id, name, description, occurrences]) => ({issue_id: String(issue_id),name: name == null ? null : String(name),@@ -103,15 +105,19 @@ export const issueRateLimitConfigLogic = kea<issueRateLimitConfigLogicType>([selectedIssueVolume: [[] as ExceptionVolumeBucket[],{- loadSelectedIssueVolume: async ({- issueId,- bucketMinutes,- }: {- issueId: string- bucketMinutes: number- }) => {+ loadSelectedIssueVolume: async (+ {+ issueId,+ bucketMinutes,+ }: {+ issueId: string+ bucketMinutes: number+ },+ breakpoint+ ) => {const option = getBucketOption(bucketMinutes)const totalMinutes = option.minutes * option.bucketCount+ await breakpoint(300)const response = (await api.query({kind: NodeKind.HogQLQuery,query: `@@ -127,6 +133,7 @@ export const issueRateLimitConfigLogic = kea<issueRateLimitConfigLogicType>([`,tags: { productKey: ProductKey.ERROR_TRACKING },})) as HogQLQueryResponse+ breakpoint()return (response.results ?? []).map(([bucket, count]) => ({bucket: String(bucket),count: Number(count),@@ -169,7 +176,9 @@ export const issueRateLimitConfigLogic = kea<issueRateLimitConfigLogicType>([listeners(({ actions, values }) => ({loadConfigSuccess: ({ config }) => {- const bucket = config?.per_issue_rate_limit_bucket_size_minutes ?? DEFAULT_BUCKET_MINUTES+ const bucket = getBucketOption(+ config?.per_issue_rate_limit_bucket_size_minutes ?? DEFAULT_BUCKET_MINUTES+ ).minutesconst limit = config?.per_issue_rate_limit_value ?? nullif (config) {actions.resetConfigForm({@@ -177,19 +186,12 @@ export const issueRateLimitConfigLogic = kea<issueRateLimitConfigLogicType>([per_issue_rate_limit_bucket_size_minutes: bucket,})}- actions.loadTopIssues()+ actions.loadTopIssues({ bucketMinutes: bucket })},setConfigFormValue: ({ name, value }) => {const fieldName = Array.isArray(name) ? name[name.length - 1] : name- if (- fieldName === 'per_issue_rate_limit_bucket_size_minutes' &&- typeof value === 'number' &&- values.selectedIssueId- ) {- actions.loadSelectedIssueVolume({- issueId: values.selectedIssueId,- bucketMinutes: value,- })+ if (fieldName === 'per_issue_rate_limit_bucket_size_minutes' && typeof value === 'number') {+ actions.loadTopIssues({ bucketMinutes: value })}},selectIssue: ({ issueId }) => {@@ -201,9 +203,11 @@ export const issueRateLimitConfigLogic = kea<issueRateLimitConfigLogicType>([}},loadTopIssuesSuccess: ({ topIssues }) => {- const first = topIssues[0]- if (first) {- actions.selectIssue(first.issue_id)+ const current = values.selectedIssueId+ const keep = current && topIssues.some((i) => i.issue_id === current)+ const nextId = keep ? current : (topIssues[0]?.issue_id ?? null)+ if (nextId) {+ actions.selectIssue(nextId)}},})),diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/rateLimitConfigLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/rateLimitConfigLogic.tsindex f992b8699167..e92ae7f67ce9 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/rateLimitConfigLogic.ts+++ b/products/error_tracking/frontend/scenes/ErrorTrackingConfigurationScene/rate_limit/rateLimitConfigLogic.ts@@ -26,8 +26,6 @@ export const BUCKET_OPTIONS: BucketOption[] = [{ label: '15 minutes', minutes: 15, bucketCount: 96 },{ label: '30 minutes', minutes: 30, bucketCount: 96 },{ label: '1 hour', minutes: 60, bucketCount: 168 },- { label: '1 day', minutes: 1440, bucketCount: 30 },- { label: '1 week', minutes: 10080, bucketCount: 12 },]export const DEFAULT_BUCKET_OPTION: BucketOption = BUCKET_OPTIONS.find((o) => o.minutes === 60) ?? BUCKET_OPTIONS[0]@@ -137,7 +135,9 @@ export const rateLimitConfigLogic = kea<rateLimitConfigLogicType>([listeners(({ actions }) => ({loadConfigSuccess: ({ config }) => {- const bucket = config?.project_rate_limit_bucket_size_minutes ?? DEFAULT_BUCKET_MINUTES+ const bucket = getBucketOption(+ config?.project_rate_limit_bucket_size_minutes ?? DEFAULT_BUCKET_MINUTES+ ).minutesif (config) {actions.resetConfigForm({project_rate_limit_value: config.project_rate_limit_value,