Files
awesome-reviewers/_reviewers/posthog-minimize-expensive-operations.json
2025-08-19 12:19:58 +00:00

106 lines
23 KiB
JSON

[
{
"discussion_id": "2262597134",
"pr_number": 36360,
"pr_file": "frontend/src/scenes/insights/filters/BreakdownFilter/BreakdownTagMenu.tsx",
"created_at": "2025-08-08T10:40:23+00:00",
"commented_code": "onClick={() => {\n setHistogramBinsUsed(false)\n }}\n- active={!histogramBinsUsed}\n+ active={!histogramBinsUsed && !breakdownBins?.length}\n className=\"mt-2\"\n fullWidth\n >\n Do not bin numeric values\n </LemonButton>\n+ <LemonButton\n+ onClick={() => {\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ !breakdownBins?.length ? [{ low: null, high: null }] : []\n+ )\n+ }}\n+ active={!!breakdownBins?.length}\n+ className=\"mt-2\"\n+ fullWidth\n+ >\n+ Custom bins\n+ </LemonButton>\n+ {!!breakdownBins?.length && (\n+ <div className=\"p-2\">\n+ <div className=\"space-y-2\">\n+ {breakdownBins.map((bin: BreakdownBin, index: number) => (\n+ <div key={index} className=\"flex items-center gap-2\">\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.low ?? undefined}\n+ onChange={(lowNum) => {\n+ const low = lowNum !== undefined ? lowNum : null\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ breakdownBins.map((b: BreakdownBin, i: number) =>\n+ i === index ? { ...b, low } : b\n+ )\n+ )\n+ }}\n+ placeholder=\"Min\"\n+ />\n+ <span>-</span>\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.high ?? undefined}\n+ onChange={(highNum) => {",
"repo_full_name": "PostHog/posthog",
"discussion_comments": [
{
"comment_id": "2262597134",
"repo_full_name": "PostHog/posthog",
"pr_number": 36360,
"pr_file": "frontend/src/scenes/insights/filters/BreakdownFilter/BreakdownTagMenu.tsx",
"discussion_id": "2262597134",
"commented_code": "@@ -80,12 +89,93 @@ export const BreakdownTagMenu = (): JSX.Element => {\n onClick={() => {\n setHistogramBinsUsed(false)\n }}\n- active={!histogramBinsUsed}\n+ active={!histogramBinsUsed && !breakdownBins?.length}\n className=\"mt-2\"\n fullWidth\n >\n Do not bin numeric values\n </LemonButton>\n+ <LemonButton\n+ onClick={() => {\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ !breakdownBins?.length ? [{ low: null, high: null }] : []\n+ )\n+ }}\n+ active={!!breakdownBins?.length}\n+ className=\"mt-2\"\n+ fullWidth\n+ >\n+ Custom bins\n+ </LemonButton>\n+ {!!breakdownBins?.length && (\n+ <div className=\"p-2\">\n+ <div className=\"space-y-2\">\n+ {breakdownBins.map((bin: BreakdownBin, index: number) => (\n+ <div key={index} className=\"flex items-center gap-2\">\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.low ?? undefined}\n+ onChange={(lowNum) => {\n+ const low = lowNum !== undefined ? lowNum : null\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ breakdownBins.map((b: BreakdownBin, i: number) =>\n+ i === index ? { ...b, low } : b\n+ )\n+ )\n+ }}\n+ placeholder=\"Min\"\n+ />\n+ <span>-</span>\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.high ?? undefined}\n+ onChange={(highNum) => {",
"comment_created_at": "2025-08-08T10:40:23+00:00",
"comment_author": "zlwaterfield",
"comment_body": "I think we should only requery on blur not change because the UI becomes very jumpy",
"pr_file_module": null
},
{
"comment_id": "2262632310",
"repo_full_name": "PostHog/posthog",
"pr_number": 36360,
"pr_file": "frontend/src/scenes/insights/filters/BreakdownFilter/BreakdownTagMenu.tsx",
"discussion_id": "2262597134",
"commented_code": "@@ -80,12 +89,93 @@ export const BreakdownTagMenu = (): JSX.Element => {\n onClick={() => {\n setHistogramBinsUsed(false)\n }}\n- active={!histogramBinsUsed}\n+ active={!histogramBinsUsed && !breakdownBins?.length}\n className=\"mt-2\"\n fullWidth\n >\n Do not bin numeric values\n </LemonButton>\n+ <LemonButton\n+ onClick={() => {\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ !breakdownBins?.length ? [{ low: null, high: null }] : []\n+ )\n+ }}\n+ active={!!breakdownBins?.length}\n+ className=\"mt-2\"\n+ fullWidth\n+ >\n+ Custom bins\n+ </LemonButton>\n+ {!!breakdownBins?.length && (\n+ <div className=\"p-2\">\n+ <div className=\"space-y-2\">\n+ {breakdownBins.map((bin: BreakdownBin, index: number) => (\n+ <div key={index} className=\"flex items-center gap-2\">\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.low ?? undefined}\n+ onChange={(lowNum) => {\n+ const low = lowNum !== undefined ? lowNum : null\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ breakdownBins.map((b: BreakdownBin, i: number) =>\n+ i === index ? { ...b, low } : b\n+ )\n+ )\n+ }}\n+ placeholder=\"Min\"\n+ />\n+ <span>-</span>\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.high ?? undefined}\n+ onChange={(highNum) => {",
"comment_created_at": "2025-08-08T10:56:11+00:00",
"comment_author": "anirudhpillai",
"comment_body": "I'm iterating on this heavily as we speak, but seems to make sense to have a save button here to prevent all the re query (breakdown queries are expensive as is)\r\n\r\n<img width=\"323\" height=\"413\" alt=\"image\" src=\"https://github.com/user-attachments/assets/c2ef22f6-eba0-4de2-a307-2ca48046d9ea\" />\r\n",
"pr_file_module": null
},
{
"comment_id": "2262634301",
"repo_full_name": "PostHog/posthog",
"pr_number": 36360,
"pr_file": "frontend/src/scenes/insights/filters/BreakdownFilter/BreakdownTagMenu.tsx",
"discussion_id": "2262597134",
"commented_code": "@@ -80,12 +89,93 @@ export const BreakdownTagMenu = (): JSX.Element => {\n onClick={() => {\n setHistogramBinsUsed(false)\n }}\n- active={!histogramBinsUsed}\n+ active={!histogramBinsUsed && !breakdownBins?.length}\n className=\"mt-2\"\n fullWidth\n >\n Do not bin numeric values\n </LemonButton>\n+ <LemonButton\n+ onClick={() => {\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ !breakdownBins?.length ? [{ low: null, high: null }] : []\n+ )\n+ }}\n+ active={!!breakdownBins?.length}\n+ className=\"mt-2\"\n+ fullWidth\n+ >\n+ Custom bins\n+ </LemonButton>\n+ {!!breakdownBins?.length && (\n+ <div className=\"p-2\">\n+ <div className=\"space-y-2\">\n+ {breakdownBins.map((bin: BreakdownBin, index: number) => (\n+ <div key={index} className=\"flex items-center gap-2\">\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.low ?? undefined}\n+ onChange={(lowNum) => {\n+ const low = lowNum !== undefined ? lowNum : null\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ breakdownBins.map((b: BreakdownBin, i: number) =>\n+ i === index ? { ...b, low } : b\n+ )\n+ )\n+ }}\n+ placeholder=\"Min\"\n+ />\n+ <span>-</span>\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.high ?? undefined}\n+ onChange={(highNum) => {",
"comment_created_at": "2025-08-08T10:57:21+00:00",
"comment_author": "zlwaterfield",
"comment_body": "Cool, sorry saw the requested review so jumped in but I think it may have been an automated review request",
"pr_file_module": null
},
{
"comment_id": "2262932343",
"repo_full_name": "PostHog/posthog",
"pr_number": 36360,
"pr_file": "frontend/src/scenes/insights/filters/BreakdownFilter/BreakdownTagMenu.tsx",
"discussion_id": "2262597134",
"commented_code": "@@ -80,12 +89,93 @@ export const BreakdownTagMenu = (): JSX.Element => {\n onClick={() => {\n setHistogramBinsUsed(false)\n }}\n- active={!histogramBinsUsed}\n+ active={!histogramBinsUsed && !breakdownBins?.length}\n className=\"mt-2\"\n fullWidth\n >\n Do not bin numeric values\n </LemonButton>\n+ <LemonButton\n+ onClick={() => {\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ !breakdownBins?.length ? [{ low: null, high: null }] : []\n+ )\n+ }}\n+ active={!!breakdownBins?.length}\n+ className=\"mt-2\"\n+ fullWidth\n+ >\n+ Custom bins\n+ </LemonButton>\n+ {!!breakdownBins?.length && (\n+ <div className=\"p-2\">\n+ <div className=\"space-y-2\">\n+ {breakdownBins.map((bin: BreakdownBin, index: number) => (\n+ <div key={index} className=\"flex items-center gap-2\">\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.low ?? undefined}\n+ onChange={(lowNum) => {\n+ const low = lowNum !== undefined ? lowNum : null\n+ setBreakdownBins(\n+ breakdown,\n+ breakdownType,\n+ breakdownBins.map((b: BreakdownBin, i: number) =>\n+ i === index ? { ...b, low } : b\n+ )\n+ )\n+ }}\n+ placeholder=\"Min\"\n+ />\n+ <span>-</span>\n+ <LemonInput\n+ type=\"number\"\n+ className=\"w-24\"\n+ value={bin.high ?? undefined}\n+ onChange={(highNum) => {",
"comment_created_at": "2025-08-08T13:09:39+00:00",
"comment_author": "anirudhpillai",
"comment_body": "no worries at all, this is very helpful!\r\nthe reason I mention the save button is because of a discussion we were having at the hotel, will brief you. Mainly we have a long pending item 'insight edit mode' to add a run button to insight query so that it doesn't re query on every config change, but till then thought it makes sense to add a save button here",
"pr_file_module": null
}
]
},
{
"discussion_id": "2254270985",
"pr_number": 36200,
"pr_file": "frontend/src/scenes/surveys/SurveyEdit.tsx",
"created_at": "2025-08-05T12:58:57+00:00",
"commented_code": "const { thankYouMessageDescriptionContentType = null } = survey.appearance ?? {}\n useMountedLogic(actionsModel)\n \n+ // Load feature flag details if linked_flag_id exists but linked_flag doesn't\n+ useEffect(() => {\n+ if (survey.linked_flag_id && !survey.linked_flag) {\n+ api.featureFlags\n+ .get(survey.linked_flag_id)\n+ .then((flag) => {\n+ setSurveyValue('linked_flag', flag)\n+ })\n+ .catch(() => {\n+ // If flag doesn't exist anymore, clear the linked_flag_id\n+ setSurveyValue('linked_flag_id', null)\n+ })\n+ }\n+ }, [survey.linked_flag_id, survey.linked_flag, setSurveyValue])",
"repo_full_name": "PostHog/posthog",
"discussion_comments": [
{
"comment_id": "2254270985",
"repo_full_name": "PostHog/posthog",
"pr_number": 36200,
"pr_file": "frontend/src/scenes/surveys/SurveyEdit.tsx",
"discussion_id": "2254270985",
"commented_code": "@@ -249,6 +271,21 @@ export default function SurveyEdit(): JSX.Element {\n const { thankYouMessageDescriptionContentType = null } = survey.appearance ?? {}\n useMountedLogic(actionsModel)\n \n+ // Load feature flag details if linked_flag_id exists but linked_flag doesn't\n+ useEffect(() => {\n+ if (survey.linked_flag_id && !survey.linked_flag) {\n+ api.featureFlags\n+ .get(survey.linked_flag_id)\n+ .then((flag) => {\n+ setSurveyValue('linked_flag', flag)\n+ })\n+ .catch(() => {\n+ // If flag doesn't exist anymore, clear the linked_flag_id\n+ setSurveyValue('linked_flag_id', null)\n+ })\n+ }\n+ }, [survey.linked_flag_id, survey.linked_flag, setSurveyValue])",
"comment_created_at": "2025-08-05T12:58:57+00:00",
"comment_author": "marandaneto",
"comment_body": "is there a better way to do this?\r\nwhen flags are loaded and selected in the dropdown (only for new surveys), the `linked_flag` and its fields arent loaded yet.",
"pr_file_module": null
},
{
"comment_id": "2260403865",
"repo_full_name": "PostHog/posthog",
"pr_number": 36200,
"pr_file": "frontend/src/scenes/surveys/SurveyEdit.tsx",
"discussion_id": "2254270985",
"commented_code": "@@ -249,6 +271,21 @@ export default function SurveyEdit(): JSX.Element {\n const { thankYouMessageDescriptionContentType = null } = survey.appearance ?? {}\n useMountedLogic(actionsModel)\n \n+ // Load feature flag details if linked_flag_id exists but linked_flag doesn't\n+ useEffect(() => {\n+ if (survey.linked_flag_id && !survey.linked_flag) {\n+ api.featureFlags\n+ .get(survey.linked_flag_id)\n+ .then((flag) => {\n+ setSurveyValue('linked_flag', flag)\n+ })\n+ .catch(() => {\n+ // If flag doesn't exist anymore, clear the linked_flag_id\n+ setSurveyValue('linked_flag_id', null)\n+ })\n+ }\n+ }, [survey.linked_flag_id, survey.linked_flag, setSurveyValue])",
"comment_created_at": "2025-08-07T13:50:51+00:00",
"comment_author": "lucasheriques",
"comment_body": "instead of putting it on a `useEffect`, add it on the `onChange` handler for the flag id selector, as that's when it's needed\r\n\r\nor, you can use a [loader](https://keajs.org/docs/plugins/loaders) instead, and store all values in the kea logic\r\n\r\nso you'd do something like:\r\n\r\n```ts\r\nloaders(({ props, actions, values }) => ({\r\n ...otherLoaders,\r\n linkedFeatureFlag: {\r\n loadFeatureFlag: async () => {\r\n if (!values.survey?.linked_flag_id) {\r\n return undefined\r\n }\r\n\r\n return await api.featureFlags.get(values.survey.linked_flag_id)\r\n },\r\n },\r\n}))\r\n```",
"pr_file_module": null
},
{
"comment_id": "2260587259",
"repo_full_name": "PostHog/posthog",
"pr_number": 36200,
"pr_file": "frontend/src/scenes/surveys/SurveyEdit.tsx",
"discussion_id": "2254270985",
"commented_code": "@@ -249,6 +271,21 @@ export default function SurveyEdit(): JSX.Element {\n const { thankYouMessageDescriptionContentType = null } = survey.appearance ?? {}\n useMountedLogic(actionsModel)\n \n+ // Load feature flag details if linked_flag_id exists but linked_flag doesn't\n+ useEffect(() => {\n+ if (survey.linked_flag_id && !survey.linked_flag) {\n+ api.featureFlags\n+ .get(survey.linked_flag_id)\n+ .then((flag) => {\n+ setSurveyValue('linked_flag', flag)\n+ })\n+ .catch(() => {\n+ // If flag doesn't exist anymore, clear the linked_flag_id\n+ setSurveyValue('linked_flag_id', null)\n+ })\n+ }\n+ }, [survey.linked_flag_id, survey.linked_flag, setSurveyValue])",
"comment_created_at": "2025-08-07T14:55:49+00:00",
"comment_author": "marandaneto",
"comment_body": "done thanks",
"pr_file_module": null
}
]
}
]