diff --git a/frontend/src/scenes/insights/views/Funnels/FunnelCorrelation.tsx b/frontend/src/scenes/insights/views/Funnels/FunnelCorrelation.tsx index 8c0dac9c41919..f74a93b3d7312 100644 --- a/frontend/src/scenes/insights/views/Funnels/FunnelCorrelation.tsx +++ b/frontend/src/scenes/insights/views/Funnels/FunnelCorrelation.tsx @@ -12,18 +12,21 @@ import { } from './FunnelCorrelationSkewWarning' import { FunnelCorrelationTable, FunnelCorrelationTableDataExploration } from './FunnelCorrelationTable' import { FunnelCorrelationFeedbackForm } from './FunnelCorrelationFeedbackForm' -import { FunnelPropertyCorrelationTable } from './FunnelPropertyCorrelationTable' +import { + FunnelPropertyCorrelationTable, + FunnelPropertyCorrelationTableDataExploration, +} from './FunnelPropertyCorrelationTable' import { AvailableFeature } from '~/types' import './FunnelCorrelation.scss' export const FunnelCorrelation = (): JSX.Element | null => { - const { insightProps, isUsingDataExploration } = useValues(insightLogic) + const { insightProps, isUsingDataExploration: dx } = useValues(insightLogic) const { steps: legacySteps } = useValues(funnelLogic(insightProps)) const { steps } = useValues(funnelDataLogic(insightProps)) useMountedLogic(funnelCorrelationUsageLogic(insightProps)) - if (isUsingDataExploration ? steps.length <= 1 : legacySteps.length <= 1) { + if (dx ? steps.length <= 1 : legacySteps.length <= 1) { return null } @@ -32,14 +35,10 @@ export const FunnelCorrelation = (): JSX.Element | null => {

Correlation analysis

- {isUsingDataExploration ? ( - - ) : ( - - )} - {isUsingDataExploration ? : } + {dx ? : } + {dx ? : } - {!isUsingDataExploration && } + {dx ? : }
diff --git a/frontend/src/scenes/insights/views/Funnels/FunnelCorrelationTable.tsx b/frontend/src/scenes/insights/views/Funnels/FunnelCorrelationTable.tsx index 318471f4b8061..4ae2f55d44c8d 100644 --- a/frontend/src/scenes/insights/views/Funnels/FunnelCorrelationTable.tsx +++ b/frontend/src/scenes/insights/views/Funnels/FunnelCorrelationTable.tsx @@ -37,7 +37,7 @@ export function FunnelCorrelationTableDataExploration(): JSX.Element | null { const { loadedEventCorrelationsTableOnce } = useValues(funnelCorrelationLogic(insightProps)) const { loadEventCorrelations } = useActions(funnelCorrelationLogic(insightProps)) - // Load correlations only if this component is mounted, and then reload if query changes + // Load correlations only if this component is mounted, and then reload if the query changes useEffect(() => { // We only automatically refresh results when the query changes after the user has manually asked for the first results to be loaded if (loadedEventCorrelationsTableOnce) { diff --git a/frontend/src/scenes/insights/views/Funnels/FunnelPropertyCorrelationTable.tsx b/frontend/src/scenes/insights/views/Funnels/FunnelPropertyCorrelationTable.tsx index 373fa3b0db0bd..4edb29c884b77 100644 --- a/frontend/src/scenes/insights/views/Funnels/FunnelPropertyCorrelationTable.tsx +++ b/frontend/src/scenes/insights/views/Funnels/FunnelPropertyCorrelationTable.tsx @@ -4,7 +4,12 @@ import Column from 'antd/lib/table/Column' import { useActions, useValues } from 'kea' import { RiseOutlined, FallOutlined, InfoCircleOutlined } from '@ant-design/icons' import { funnelLogic } from 'scenes/funnels/funnelLogic' -import { FunnelCorrelation, FunnelCorrelationResultsType, FunnelCorrelationType } from '~/types' +import { + FunnelCorrelation, + FunnelCorrelationResultsType, + FunnelCorrelationType, + FunnelStepWithNestedBreakdown, +} from '~/types' import Checkbox from 'antd/lib/checkbox/Checkbox' import { insightLogic } from 'scenes/insights/insightLogic' import { ValueInspectorButton } from 'scenes/funnels/ValueInspectorButton' @@ -20,10 +25,79 @@ import { PropertyCorrelationActionsCell } from './CorrelationActionsCell' import { funnelCorrelationUsageLogic } from 'scenes/funnels/funnelCorrelationUsageLogic' import { parseDisplayNameForCorrelation } from 'scenes/funnels/funnelUtils' import { funnelPropertyCorrelationLogic } from 'scenes/funnels/funnelPropertyCorrelationLogic' +import { Noun } from '~/models/groupsModel' +import { funnelDataLogic } from 'scenes/funnels/funnelDataLogic' + +export function FunnelPropertyCorrelationTableDataExploration(): JSX.Element | null { + const { insightProps } = useValues(insightLogic) + const { steps, querySource, aggregationTargetLabel } = useValues(funnelDataLogic(insightProps)) + const { loadedPropertyCorrelationsTableOnce, propertyNames, allProperties } = useValues( + funnelPropertyCorrelationLogic(insightProps) + ) + const { loadPropertyCorrelations, setPropertyNames } = useActions(funnelPropertyCorrelationLogic(insightProps)) + + // Load correlations only if this component is mounted, and then reload if the query change + useEffect(() => { + // We only automatically refresh results when the query changes after the user has manually asked for the first results to be loaded + if (loadedPropertyCorrelationsTableOnce) { + if (propertyNames.length === 0) { + setPropertyNames(allProperties) + } + + loadPropertyCorrelations({}) + } + }, [querySource]) + + return ( + + ) +} export function FunnelPropertyCorrelationTable(): JSX.Element | null { const { insightProps } = useValues(insightLogic) const { steps, filters, aggregationTargetLabel } = useValues(funnelLogic(insightProps)) + const { loadedPropertyCorrelationsTableOnce, propertyNames, allProperties } = useValues( + funnelPropertyCorrelationLogic(insightProps) + ) + const { loadPropertyCorrelations, setPropertyNames } = useActions(funnelPropertyCorrelationLogic(insightProps)) + + // Load correlations only if this component is mounted, and then reload if filters change + useEffect(() => { + // We only automatically refresh results when filters change after the user has manually asked for the first results to be loaded + if (loadedPropertyCorrelationsTableOnce) { + if (propertyNames.length === 0) { + setPropertyNames(allProperties) + } + + loadPropertyCorrelations({}) + } + }, [filters]) + + return ( + + ) +} + +type FunnelPropertyCorrelationTableComponentProps = { + steps: FunnelStepWithNestedBreakdown[] + aggregation_group_type_index?: number | undefined + aggregationTargetLabel: Noun +} + +export function FunnelPropertyCorrelationTableComponent({ + steps, + aggregation_group_type_index, + aggregationTargetLabel, +}: FunnelPropertyCorrelationTableComponentProps): JSX.Element | null { + const { insightProps } = useValues(insightLogic) const { openCorrelationPersonsModal } = useActions(funnelLogic(insightProps)) const { propertyCorrelationValues, @@ -41,18 +115,6 @@ export function FunnelPropertyCorrelationTable(): JSX.Element | null { const { correlationPropKey } = useValues(funnelCorrelationUsageLogic(insightProps)) const { reportCorrelationInteraction } = useActions(funnelCorrelationUsageLogic(insightProps)) - // Load correlations only if this component is mounted, and then reload if filters change - useEffect(() => { - // We only automatically refresh results when filters change after the user has manually asked for the first results to be loaded - if (loadedPropertyCorrelationsTableOnce) { - if (propertyNames.length === 0) { - setPropertyNames(allProperties) - } - - loadPropertyCorrelations({}) - } - }, [filters]) - const onClickCorrelationType = (correlationType: FunnelCorrelationType): void => { if (propertyCorrelationTypes) { if (propertyCorrelationTypes.includes(correlationType)) { @@ -120,7 +182,7 @@ export function FunnelPropertyCorrelationTable(): JSX.Element | null {
{capitalizeFirstLetter(aggregationTargetLabel.plural)}{' '} - {filters.aggregation_group_type_index != undefined ? 'that' : 'who'} converted were{' '} + {aggregation_group_type_index != undefined ? 'that' : 'who'} converted were{' '} {get_friendly_numeric_value(record.odds_ratio)}x {is_success ? 'more' : 'less'} likely @@ -243,7 +305,7 @@ export function FunnelPropertyCorrelationTable(): JSX.Element | null { Completed @@ -263,8 +325,8 @@ export function FunnelPropertyCorrelationTable(): JSX.Element | null { title={ <> {capitalizeFirstLetter(aggregationTargetLabel.plural)}{' '} - {filters.aggregation_group_type_index != undefined ? 'that' : 'who'}{' '} - have this property and did not complete the entire funnel. + {aggregation_group_type_index != undefined ? 'that' : 'who'} have this + property and did not complete the entire funnel. } >