From bdc1ab6c4bf917eedf95708ba27e5520c7498b85 Mon Sep 17 00:00:00 2001 From: Buddy Williams Date: Tue, 8 Jun 2021 13:40:05 -0400 Subject: [PATCH] Support funnel trends conversion window (#4618) * added conversion window in days to funnel trends * convert floats to ints so that the query doesn't break * use kea breakpoints instead of debouncing lib * put conversion input behind ee check --- frontend/src/scenes/funnels/FunnelViz.js | 22 +++++++++++++++++++--- frontend/src/scenes/funnels/funnelLogic.js | 16 ++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/frontend/src/scenes/funnels/FunnelViz.js b/frontend/src/scenes/funnels/FunnelViz.js index 57999f73aa0da..d83cc9ab65e76 100644 --- a/frontend/src/scenes/funnels/FunnelViz.js +++ b/frontend/src/scenes/funnels/FunnelViz.js @@ -8,6 +8,8 @@ import { ACTIONS_LINE_GRAPH_LINEAR } from 'lib/constants' import { LineGraph } from 'scenes/insights/LineGraph' import { router } from 'kea-router' import { IllustrationDanger } from 'lib/components/icons' +import { InputNumber } from 'antd' +import { preflightLogic } from 'scenes/PreflightCheck/logic' export function FunnelViz({ steps: stepsParam, @@ -20,9 +22,10 @@ export function FunnelViz({ const container = useRef(null) const [steps, setSteps] = useState(stepsParam) const logic = funnelLogic({ dashboardItemId, cachedResults, filters: defaultFilters }) - const { results: stepsResult, resultsLoading: funnelLoading, filters } = useValues(logic) - const { loadResults: loadFunnel } = useActions(logic) + const { results: stepsResult, resultsLoading: funnelLoading, filters, conversionWindowInDays } = useValues(logic) + const { loadResults: loadFunnel, loadConversionWindow } = useActions(logic) const [{ fromItem }] = useState(router.values.hashParams) + const { preflight } = useValues(preflightLogic) function buildChart() { if (!steps || steps.length === 0) { @@ -96,7 +99,20 @@ export function FunnelViz({ return steps && steps.length > 0 && steps[0].labels ? ( <>
- % of users converted between first and last step + {preflight?.is_clickhouse_enabled && ( + <> + converted within  + loadConversionWindow(days)} + /> +  days =  + + )} + % converted from first to last step
({ filters, refresh }), saveFunnelInsight: (name) => ({ name }), setStepsWithCountLoading: (stepsWithCountLoading) => ({ stepsWithCountLoading }), + loadConversionWindow: (days) => ({ days }), + setConversionWindowInDays: (days) => ({ days }), }), connect: { @@ -78,6 +80,7 @@ export const funnelLogic = kea({ ...(refresh ? { refresh: true } : {}), ...(from_dashboard ? { from_dashboard } : {}), ...cleanedParams, + funnel_window_days: values.conversionWindowInDays, } let result @@ -135,6 +138,14 @@ export const funnelLogic = kea({ people: { clearFunnel: () => null, }, + conversionWindowInDays: [ + 14, + { + setConversionWindowInDays: (state, { days }) => { + return days >= 1 && days <= 365 ? Math.round(days) : state.conversionWindowInDays + }, + }, + ], }), selectors: ({ selectors }) => ({ @@ -205,6 +216,11 @@ export const funnelLogic = kea({ actions.setFilters(filters, true) } }, + loadConversionWindow: async ({ days }, breakpoint) => { + await breakpoint(1000) + actions.setConversionWindowInDays(days) + actions.loadResults() + }, }), actionToUrl: ({ actions, values, props }) => ({ [actions.setSteps]: () => {