Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(funnels): memoize getPathUrl in FunnelStepMore #27053

Merged
merged 4 commits into from
Dec 20, 2024
Merged
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
52 changes: 27 additions & 25 deletions frontend/src/scenes/funnels/FunnelStepMore.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useValues } from 'kea'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { More } from 'lib/lemon-ui/LemonButton/More'
import { useCallback } from 'react'
import { insightLogic } from 'scenes/insights/insightLogic'
import { urls } from 'scenes/urls'

Expand All @@ -17,34 +18,35 @@ export function FunnelStepMore({ stepIndex }: FunnelStepMoreProps): JSX.Element
const { insightProps } = useValues(insightLogic)
const { querySource } = useValues(funnelDataLogic(insightProps))

const aggregationGroupTypeIndex = querySource?.aggregation_group_type_index

// Don't show paths modal if aggregating by groups - paths is user-based!
if (aggregationGroupTypeIndex != undefined) {
return null
}

const stepNumber = stepIndex + 1
const getPathUrl = (funnelPathType: FunnelPathType, dropOff = false): string => {
const query: InsightVizNode = {
kind: NodeKind.InsightVizNode,
source: {
kind: NodeKind.PathsQuery,
funnelPathsFilter: {
funnelStep: dropOff ? stepNumber * -1 : stepNumber,
funnelSource: querySource!,
funnelPathType,
},
pathsFilter: {
includeEventTypes: [PathType.PageView, PathType.CustomEvent],
const getPathUrl = useCallback(
(funnelPathType: FunnelPathType, dropOff = false): string => {
const query: InsightVizNode = {
kind: NodeKind.InsightVizNode,
source: {
kind: NodeKind.PathsQuery,
funnelPathsFilter: {
funnelStep: dropOff ? stepNumber * -1 : stepNumber,
funnelSource: querySource!,
funnelPathType,
},
pathsFilter: {
includeEventTypes: [PathType.PageView, PathType.CustomEvent],
},
dateRange: {
date_from: querySource?.dateRange?.date_from,
},
},
dateRange: {
date_from: querySource?.dateRange?.date_from,
},
},
}
}

return urls.insightNew(undefined, undefined, query)
},
[querySource, stepNumber]
)

return urls.insightNew(undefined, undefined, query)
// Don't show paths modal if aggregating by groups - paths is user-based!
if (querySource?.aggregation_group_type_index != undefined) {
return null
}

return (
Expand Down
Loading