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

Enable persons modal on funnel trends #5133

Merged
merged 19 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 6 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
24 changes: 21 additions & 3 deletions frontend/src/scenes/funnels/FunnelViz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import { ACTIONS_LINE_GRAPH_LINEAR, FEATURE_FLAGS } from 'lib/constants'
import { LineGraph } from 'scenes/insights/LineGraph'
import { FunnelBarGraph } from './FunnelBarGraph'
import { router } from 'kea-router'
import { InputNumber } from 'antd'
import { InputNumber, Row } from 'antd'
import { preflightLogic } from 'scenes/PreflightCheck/logic'
import { ChartDisplayType, ChartParams, FunnelStep } from '~/types'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { FunnelHistogram } from './FunnelHistogram'
import { personsModalLogic } from 'scenes/trends/personsModalLogic'
import { FunnelEmptyState } from 'scenes/insights/EmptyStates'

import './FunnelViz.scss'
Expand Down Expand Up @@ -42,6 +43,7 @@ export function FunnelViz({
areFiltersValid,
} = useValues(logic)
const { loadResults: loadFunnel, loadConversionWindow } = useActions(logic)
const { loadPeople } = useActions(personsModalLogic)
const [{ fromItem }] = useState(router.values.hashParams)
const { preflight } = useValues(preflightLogic)
const { featureFlags } = useValues(featureFlagLogic)
Expand Down Expand Up @@ -125,7 +127,7 @@ export function FunnelViz({
if (filters.display === ACTIONS_LINE_GRAPH_LINEAR) {
return steps && steps.length > 0 && steps[0].labels ? (
<>
<div style={{ position: 'absolute', marginTop: -20, textAlign: 'center', width: '90%' }}>
<Row style={{ marginTop: -16, justifyContent: 'center' }}>
{preflight?.is_clickhouse_enabled && (
<>
converted within&nbsp;
Expand All @@ -140,7 +142,7 @@ export function FunnelViz({
</>
)}
% converted from first to last step
</div>
</Row>
<LineGraph
data-attr="trend-line-graph-funnel"
type="line"
Expand All @@ -151,6 +153,22 @@ export function FunnelViz({
dashboardItemId={dashboardItemId || fromItem}
inSharedMode={inSharedMode}
percentage={true}
onClick={
dashboardItemId
? null
mariusandra marked this conversation as resolved.
Show resolved Hide resolved
: (point) => {
const { dataset, day } = point
loadPeople({
action: { id: point.index, name: point.label, properties: [], type: 'actions' },
label: point.label,
date_from: day,
date_to: day,
filters: filters,
breakdown_value: dataset.breakdown_value || dataset.status,
saveOriginal: true,
})
}
}
/>
</>
) : null
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/scenes/funnels/funnelLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export const cleanFunnelParams = (filters: FilterType): FilterType => {
...(filters.funnel_step ? { funnel_step: filters.funnel_step } : {}),
...(filters.funnel_viz_type ? { funnel_viz_type: filters.funnel_viz_type } : {}),
...(filters.funnel_step ? { funnel_to_step: filters.funnel_step } : {}),
...(filters.entrance_period_start ? { entrance_period_start: filters.entrance_period_start } : {}),
liyiy marked this conversation as resolved.
Show resolved Hide resolved
...(filters.drop_off ? { drop_off: filters.drop_off } : {}),
interval: autocorrectInterval(filters),
insight: ViewType.FUNNELS,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ACTIONS_PIE_CHART,
ACTIONS_TABLE,
FEATURE_FLAGS,
FUNNELS_TIME_TO_CONVERT,
FUNNEL_VIZ,
} from 'lib/constants'
import React from 'react'
import { ChartDisplayType, FilterType, ViewType } from '~/types'
Expand Down Expand Up @@ -116,7 +116,7 @@ export function InsightDisplayConfig({

{activeView === ViewType.RETENTION && <RetentionDatePicker />}

{showFunnelBarOptions && allFilters.display !== FUNNELS_TIME_TO_CONVERT && (
{showFunnelBarOptions && allFilters.display === FUNNEL_VIZ && (
alexkim205 marked this conversation as resolved.
Show resolved Hide resolved
<>
<FunnelDisplayLayoutPicker />
<FunnelStepReferencePicker />
Expand Down
1 change: 0 additions & 1 deletion frontend/src/scenes/insights/LineGraph/LineGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ export function LineGraph({

// This could either be a color or an array of colors (`horizontalBar`)
const colorSet = entityData.backgroundColor || entityData.borderColor

return (
<InsightLabel
action={action}
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/scenes/trends/personsModalLogic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import dayjs from 'dayjs'
import { kea } from 'kea'
import api from 'lib/api'
import { ACTIONS_LINE_GRAPH_LINEAR } from 'lib/constants'
import { errorToast, toParams } from 'lib/utils'
import { cleanFunnelParams, funnelLogic } from 'scenes/funnels/funnelLogic'
import { cohortLogic } from 'scenes/persons/cohortLogic'
Expand Down Expand Up @@ -145,8 +147,16 @@ export const personsModalLogic = kea<personsModalLogicType<PersonModalParams>>({
const filterParams = parsePeopleParams({ label, action, date_from, date_to, breakdown_value }, filters)
actions.setPeople(tempPeople)
people = await api.get(`api/person/stickiness/?${filterParams}${searchTermParam}`)
} else if (funnelStep) {
const params = { ...funnelLogic().values.filters, funnel_step: funnelStep }
} else if (funnelStep || filters.display === ACTIONS_LINE_GRAPH_LINEAR) {
liyiy marked this conversation as resolved.
Show resolved Hide resolved
let params
if (filters.display === ACTIONS_LINE_GRAPH_LINEAR) {
// funnel trends
const entrance_period_start = dayjs(date_from).format('YYYY-MM-DD HH:mm:ss')
params = { ...funnelLogic().values.filters, entrance_period_start, drop_off: false }
mariusandra marked this conversation as resolved.
Show resolved Hide resolved
} else {
// regular funnel steps
params = { ...funnelLogic().values.filters, funnel_step: funnelStep }
}
const cleanedParams = cleanFunnelParams(params)
const funnelParams = toParams(cleanedParams)
people = await api.create(`api/person/funnel/?${funnelParams}${searchTermParam}`)
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ export interface FilterType {
funnel_step?: number
funnel_viz_type?: string // this and the below param is used for funnels time to convert, it'll be updated soon
funnel_to_step?: number
entrance_period_start?: string
drop_off?: boolean
compare?: boolean
}

Expand Down