Skip to content

: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.

perf(flags): fetch only the five related insights the flag page shows (#112838)

posthog[bot]cf48d031658f
diff --git a/frontend/src/scenes/feature-flags/featureFlagLogic.ts b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
index 26af1798f5ac..e67d9c62ad6b 100644
--- a/frontend/src/scenes/feature-flags/featureFlagLogic.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
@@ -3538,7 +3538,7 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
if (props.id && props.id !== 'new' && values.featureFlag.key) {
// nosemgrep: prefer-codegen-api -- Legacy raw API call with a hand-written URL and an unchecked response type. Use insightsList() from 'products/product_analytics/frontend/generated/api' instead.
const response = await api.get<PaginatedResponse<InsightModel>>(
- `api/projects/${values.currentProjectId}/insights/?feature_flag=${values.featureFlag.key}&order=-created_at`
+ `api/projects/${values.currentProjectId}/insights/?feature_flag=${values.featureFlag.key}&order=-last_modified_at&limit=5`
)
return response.results.map((legacyInsight) => getQueryBasedInsightModel(legacyInsight))
}