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

feat(insights): keep configuration when navigating between insights #17156

Merged
merged 30 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0932d98
feat(insights): keep configuration when navigating between insights
thmsobrmlr Aug 23, 2023
eb146db
export query cache type
thmsobrmlr Aug 23, 2023
41ca440
fix tests
thmsobrmlr Aug 23, 2023
24a2688
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
f472ca1
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
6d81198
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
3777367
Merge branch 'master' into navigate-between-queries
thmsobrmlr Aug 23, 2023
d51842f
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
c3a9475
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
548fd2e
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
aab0e59
fix types
thmsobrmlr Aug 23, 2023
971e597
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
7f75dd9
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
b2b90b1
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 23, 2023
ad7a530
handle retention entities and common filters
thmsobrmlr Aug 24, 2023
3a43504
Merge branch 'master' into navigate-between-queries
thmsobrmlr Aug 24, 2023
719bf5b
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 24, 2023
a5dbd5e
Update UI snapshots for `chromium` (1)
github-actions[bot] Aug 24, 2023
aa1a909
Merge branch 'master' into navigate-between-queries
thmsobrmlr Sep 12, 2023
bd5396e
Update UI snapshots for `chromium` (2)
github-actions[bot] Sep 12, 2023
82af446
fixes
thmsobrmlr Sep 12, 2023
d152157
Merge branch 'master' into navigate-between-queries
thmsobrmlr Oct 26, 2023
f821cc9
Update UI snapshots for `chromium` (2)
github-actions[bot] Oct 26, 2023
60cdfb6
Update UI snapshots for `chromium` (1)
github-actions[bot] Oct 26, 2023
0c03c8b
remove shownAs
thmsobrmlr Oct 26, 2023
8e84384
add tests
thmsobrmlr Oct 26, 2023
d2e6416
set defaults for insight filter
thmsobrmlr Oct 26, 2023
b077b31
Merge branch 'master' into navigate-between-queries
thmsobrmlr Nov 2, 2023
14a558f
update the query cache on mount
thmsobrmlr Nov 2, 2023
6171a81
fix jest tests
thmsobrmlr Nov 2, 2023
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
thmsobrmlr marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion frontend/src/queries/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ const nodeKindToFilterProperty: Record<InsightNodeKind, InsightFilterProperty> =
[NodeKind.LifecycleQuery]: 'lifecycleFilter',
}

export function filterPropertyForQuery(node: InsightQueryNode): InsightFilterProperty {
export function filterKeyForQuery(node: InsightQueryNode): InsightFilterProperty {
return nodeKindToFilterProperty[node.kind]
}

Expand Down
184 changes: 181 additions & 3 deletions frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { insightLogic } from 'scenes/insights/insightLogic'
import { InsightLogicProps, InsightShortId, InsightType } from '~/types'
import { FunnelVizType, InsightLogicProps, InsightShortId, InsightType, StepOrderValue } from '~/types'
import { insightNavLogic } from 'scenes/insights/InsightNav/insightNavLogic'
import { expectLogic } from 'kea-test-utils'
import { initKeaTests } from '~/test/init'
import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
import { useMocks } from '~/mocks/jest'
import { NodeKind } from '~/queries/schema'
import { InsightVizNode, Node, NodeKind } from '~/queries/schema'
import { insightDataLogic } from '../insightDataLogic'
import { nodeKindToDefaultQuery } from '~/queries/nodes/InsightQuery/defaults'

Expand Down Expand Up @@ -62,7 +62,18 @@ describe('insightNavLogic', () => {
}).toMatchValues({
query: {
kind: NodeKind.InsightVizNode,
source: { ...nodeKindToDefaultQuery[NodeKind.FunnelsQuery], filterTestAccounts: true },
source: {
...nodeKindToDefaultQuery[NodeKind.FunnelsQuery],
filterTestAccounts: true,
series: [
{
event: '$pageview',
kind: 'EventsNode',
math: 'total',
name: '$pageview',
},
],
},
},
})
})
Expand Down Expand Up @@ -109,5 +120,172 @@ describe('insightNavLogic', () => {
})
})
})

describe('query cache', () => {
const trendsQuery: InsightVizNode = {
kind: NodeKind.InsightVizNode,
source: {
kind: NodeKind.TrendsQuery,
series: [
{
kind: NodeKind.EventsNode,
name: '$pageview',
event: '$pageview',
},
],
trendsFilter: { show_values_on_series: true },
},
}
const funnelsQuery: InsightVizNode = {
kind: NodeKind.InsightVizNode,
source: {
kind: NodeKind.FunnelsQuery,
series: [
{
kind: NodeKind.EventsNode,
name: '$pageview',
event: '$pageview',
},
{
kind: NodeKind.EventsNode,
name: '$pageleave',
event: '$pageleave',
},
],
funnelsFilter: {
funnel_order_type: StepOrderValue.STRICT,
funnel_viz_type: FunnelVizType.Steps,
},
},
}
const retentionQuery: InsightVizNode = {
kind: NodeKind.InsightVizNode,
source: {
kind: NodeKind.RetentionQuery,
retentionFilter: {
returning_entity: {
id: 'returning',
name: 'returning',
type: 'events',
},
target_entity: {
id: 'target',
name: 'target',
type: 'events',
},
},
},
}

it('is initialized on mount', async () => {
await expectLogic(logic).toMatchValues({
queryPropertyCache: {
...nodeKindToDefaultQuery[NodeKind.TrendsQuery],
commonFilter: {},
filterTestAccounts: true,
},
})
})

it('stores query updates', async () => {
await expectLogic(logic, () => {
builtInsightDataLogic.actions.setQuery(trendsQuery)
}).toMatchValues({
queryPropertyCache: expect.objectContaining({
series: [
{
event: '$pageview',
kind: 'EventsNode',
name: '$pageview',
},
],
}),
})

await expectLogic(logic, () => {
builtInsightDataLogic.actions.setQuery(funnelsQuery)
}).toMatchValues({
queryPropertyCache: expect.objectContaining({
series: [
{
event: '$pageview',
kind: 'EventsNode',
name: '$pageview',
},
{
event: '$pageleave',
kind: 'EventsNode',
name: '$pageleave',
},
],
}),
})
})

it('stores insight filter in commonFilter', async () => {
await expectLogic(logic, () => {
builtInsightDataLogic.actions.setQuery(trendsQuery)
}).toMatchValues({
queryPropertyCache: expect.objectContaining({
commonFilter: { show_values_on_series: true },
}),
})

await expectLogic(logic, () => {
builtInsightDataLogic.actions.setQuery(funnelsQuery)
}).toMatchValues({
queryPropertyCache: expect.objectContaining({
commonFilter: {
show_values_on_series: true,
funnel_order_type: 'strict',
funnel_viz_type: 'steps',
},
}),
})
})

it('stores series from retention entities', async () => {
await expectLogic(logic, () => {
builtInsightDataLogic.actions.setQuery(retentionQuery)
}).toMatchValues({
queryPropertyCache: expect.objectContaining({
series: [
{
event: 'target',
kind: 'EventsNode',
math: 'total',
name: 'target',
},
{
event: 'returning',
kind: 'EventsNode',
math: 'total',
name: 'returning',
},
],
}),
})
})

it('updates query when navigating', async () => {
await expectLogic(logic, () => {
builtInsightDataLogic.actions.setQuery(trendsQuery)
})

await expectLogic(logic, () => {
logic.actions.setActiveView(InsightType.LIFECYCLE)
}).toDispatchActions([
logic.actionCreators.setQuery({
kind: 'InsightVizNode',
source: {
kind: 'LifecycleQuery',
series: [{ kind: 'EventsNode', name: '$pageview', event: '$pageview' }],
filterTestAccounts: true,
lifecycleFilter: { show_values_on_series: true },
},
} as Node),
])
})
})
})
})
Loading
Loading