From 3338ea430034537cfd7eeabb739ae4d439722d13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20G=C3=B3is?= Date: Thu, 31 Jul 2025 11:22:40 +0100 Subject: [PATCH] chore: clear unknown flags every 24h instead of every 7d (#10446) https://linear.app/unleash/issue/2-3738/clear-unknown-flags-every-24h-instead-of-every-7d Clears unknown flags every 24h instead of every 7d. This ensures the list stays more relevant by removing stale entries sooner, allowing users to focus on actively reported unknown flags. Also includes small improvements, including a new paragraph on the unknown flags page that better explains the concept of unknown flag reports. --- .../unknownFlags/UnknownFlagsTable.tsx | 67 ++++++++++++------- .../unknown-flags/unknown-flags-controller.ts | 4 +- .../features/scheduler/schedule-services.ts | 4 +- src/lib/metrics.ts | 2 +- src/lib/openapi/spec/unknown-flag-schema.ts | 2 +- .../spec/unknown-flags-response-schema.ts | 3 +- 6 files changed, 49 insertions(+), 33 deletions(-) diff --git a/frontend/src/component/unknownFlags/UnknownFlagsTable.tsx b/frontend/src/component/unknownFlags/UnknownFlagsTable.tsx index b39e0a8f4d..3685a4e336 100644 --- a/frontend/src/component/unknownFlags/UnknownFlagsTable.tsx +++ b/frontend/src/component/unknownFlags/UnknownFlagsTable.tsx @@ -22,9 +22,15 @@ const StyledAlert = styled(Alert)(({ theme }) => ({ marginBottom: theme.spacing(3), })); +const StyledAlertContent = styled('div')(({ theme }) => ({ + display: 'flex', + flexDirection: 'column', + gap: theme.spacing(1), +})); + const StyledUl = styled('ul')(({ theme }) => ({ - paddingTop: theme.spacing(2), - paddingBottom: theme.spacing(2), + paddingTop: theme.spacing(1), + paddingBottom: theme.spacing(1), })); export const UnknownFlagsTable = () => { @@ -142,29 +148,40 @@ export const UnknownFlagsTable = () => { } > -

- Unknown flags are feature flags that your - SDKs tried to evaluate but which Unleash doesn't recognize. - Tracking them helps you catch typos, remove outdated flags, - and keep your code and configuration in sync. These can - include: -

+ +

+ Unknown flags are feature flags that + your SDKs tried to evaluate but which Unleash doesn't + recognize. Tracking them helps you catch typos, remove + outdated flags, and keep your code and configuration in + sync. These can include: +

- -
  • - Missing flags: typos or flags referenced in code - that don't exist in Unleash. -
  • -
  • - Invalid flags: flags with malformed or unexpected - names, unsupported by Unleash. -
  • -
    + +
  • + Missing flags: typos or flags referenced in + code that don't exist in Unleash. +
  • +
  • + Invalid flags: flags with malformed or + unexpected names, unsupported by Unleash. +
  • +
    -

    - We display up to 1,000 unknown flag reports from the last 7 - days. Older flags are automatically pruned. -

    +

    + Each row in the table represents an{' '} + unknown flag report, which is a unique + combination of flag name, application, + and environment. The same flag name may appear + multiple times if it's been seen in different + applications or environments. +

    + +

    + We display up to 1,000 unknown flag reports from the + last 24 hours. Older reports are automatically pruned. +

    +
    @@ -181,14 +198,14 @@ export const UnknownFlagsTable = () => { condition={searchValue?.length > 0} show={ - No unknown flags found matching “ + No unknown flag reports found matching “ {searchValue} ” } elseShow={ - No unknown flags reported in the last 7 days. + No unknown flags reported in the last 24 hours. } /> diff --git a/src/lib/features/metrics/unknown-flags/unknown-flags-controller.ts b/src/lib/features/metrics/unknown-flags/unknown-flags-controller.ts index 51cce606d6..2352c2a34d 100644 --- a/src/lib/features/metrics/unknown-flags/unknown-flags-controller.ts +++ b/src/lib/features/metrics/unknown-flags/unknown-flags-controller.ts @@ -43,9 +43,9 @@ export default class UnknownFlagsController extends Controller { openApiService.validPath({ operationId: 'getUnknownFlags', tags: ['Unstable'], - summary: 'Get latest reported unknown flag names', + summary: 'Get unknown flag reports', description: - 'Returns a list of unknown flag reports from the last 7 days, if any. Maximum of 1000.', + 'Returns a list of unknown flag reports from the last 24 hours, if any. Maximum of 1000.', responses: { 200: createResponseSchema('unknownFlagsResponseSchema'), }, diff --git a/src/lib/features/scheduler/schedule-services.ts b/src/lib/features/scheduler/schedule-services.ts index 6e2fef72b7..c4459f2588 100644 --- a/src/lib/features/scheduler/schedule-services.ts +++ b/src/lib/features/scheduler/schedule-services.ts @@ -203,8 +203,8 @@ export const scheduleServices = ( ); schedulerService.schedule( - unknownFlagsService.clear.bind(unknownFlagsService, 24 * 7), - hoursToMilliseconds(24), + unknownFlagsService.clear.bind(unknownFlagsService, 24), + hoursToMilliseconds(6), 'clearUnknownFlags', ); }; diff --git a/src/lib/metrics.ts b/src/lib/metrics.ts index c0027feccf..003c574207 100644 --- a/src/lib/metrics.ts +++ b/src/lib/metrics.ts @@ -761,7 +761,7 @@ export function registerPrometheusMetrics( const unknownFlagsGauge = createGauge({ name: 'unknown_flags', - help: 'Number of unknown flags reported in the last 24 hours, if any. Maximum of 10.', + help: 'Number of unknown flags reported in the last 24 hours, if any. Maximum of 1000.', }); // register event listeners diff --git a/src/lib/openapi/spec/unknown-flag-schema.ts b/src/lib/openapi/spec/unknown-flag-schema.ts index 553ddde708..c921c2c695 100644 --- a/src/lib/openapi/spec/unknown-flag-schema.ts +++ b/src/lib/openapi/spec/unknown-flag-schema.ts @@ -5,7 +5,7 @@ export const unknownFlagSchema = { type: 'object', additionalProperties: false, required: ['name', 'appName', 'seenAt', 'environment'], - description: 'An unknown flag that has been reported by the system', + description: 'An unknown flag report', properties: { name: { type: 'string', diff --git a/src/lib/openapi/spec/unknown-flags-response-schema.ts b/src/lib/openapi/spec/unknown-flags-response-schema.ts index f4efc82afa..549b54f0ec 100644 --- a/src/lib/openapi/spec/unknown-flags-response-schema.ts +++ b/src/lib/openapi/spec/unknown-flags-response-schema.ts @@ -6,8 +6,7 @@ export const unknownFlagsResponseSchema = { type: 'object', additionalProperties: false, required: ['unknownFlags'], - description: - 'A list of unknown flags that have been reported by the system', + description: 'A list of unknown flag reports', properties: { unknownFlags: { description: 'The list of recently reported unknown flags.',