Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(insights): one insight model, no dashboard generic (#104233)

Thomas Obermüller9f9b434608c6
diff --git a/frontend/src/exporter/__mocks__/Exporter.mocks.tsx b/frontend/src/exporter/__mocks__/Exporter.mocks.tsx
deleted file mode 100644
index dd25d3b648c7..000000000000
--- a/frontend/src/exporter/__mocks__/Exporter.mocks.tsx
+++ /dev/null
@@ -1,1255 +0,0 @@
-import { FunnelLayout, ShownAsValue } from 'lib/constants'
-
-import {
- AccessControlLevel,
- ChartDisplayType,
- DashboardTile,
- DashboardType,
- FunnelVizType,
- InsightColor,
- InsightShortId,
- InsightType,
-} from '~/types'
-
-export const dashboard: DashboardType = {
- id: 1,
- name: 'My App Dashboard',
- description: '',
- pinned: true,
- tiles: [
- {
- id: 0,
- layouts: {
- sm: {
- h: 5,
- w: 6,
- x: 0,
- y: 0,
- minH: 5,
- minW: 3,
- },
- xs: {
- h: 5,
- w: 1,
- x: 0,
- y: 0,
- minH: 5,
- minW: 3,
- moved: false,
- static: false,
- },
- },
- color: InsightColor.Blue,
- last_refresh: '2022-07-01T13:33:12.871519Z',
- insight: {
- id: 1,
- short_id: 'Bhtk8tjh' as InsightShortId,
- last_refresh: '2022-07-01T13:33:12.871519Z',
- name: 'Daily active users (DAUs)',
- derived_name: null,
- filters: {
- events: [
- {
- id: '$pageview',
- math: 'dau',
- type: 'events',
- },
- ],
- insight: InsightType.TRENDS,
- interval: 'day',
- },
- order: null,
- deleted: false,
- dashboards: [1],
- dashboard_tiles: [{ id: 1, dashboard_id: 1 }],
- result: [
- {
- action: {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: 'dau',
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- label: '$pageview',
- count: 235.0,
- data: [0.0, 0.0, 0.0, 0.0, 0.0, 93.0, 0.0, 142.0],
- labels: [
- '24-Jun-2022',
- '25-Jun-2022',
- '26-Jun-2022',
- '27-Jun-2022',
- '28-Jun-2022',
- '29-Jun-2022',
- '30-Jun-2022',
- '1-Jul-2022',
- ],
- days: [
- '2022-06-24',
- '2022-06-25',
- '2022-06-26',
- '2022-06-27',
- '2022-06-28',
- '2022-06-29',
- '2022-06-30',
- '2022-07-01',
- ],
- persons_urls: [
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'dau',
- date_from: '2022-06-24T00:00:00Z',
- date_to: '2022-06-24T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=dau&date_from=2022-06-24T00%3A00%3A00%2B00%3A00&date_to=2022-06-24T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'dau',
- date_from: '2022-06-25T00:00:00Z',
- date_to: '2022-06-25T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=dau&date_from=2022-06-25T00%3A00%3A00%2B00%3A00&date_to=2022-06-25T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'dau',
- date_from: '2022-06-26T00:00:00Z',
- date_to: '2022-06-26T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=dau&date_from=2022-06-26T00%3A00%3A00%2B00%3A00&date_to=2022-06-26T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'dau',
- date_from: '2022-06-27T00:00:00Z',
- date_to: '2022-06-27T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=dau&date_from=2022-06-27T00%3A00%3A00%2B00%3A00&date_to=2022-06-27T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'dau',
- date_from: '2022-06-28T00:00:00Z',
- date_to: '2022-06-28T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=dau&date_from=2022-06-28T00%3A00%3A00%2B00%3A00&date_to=2022-06-28T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'dau',
- date_from: '2022-06-29T00:00:00Z',
- date_to: '2022-06-29T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=dau&date_from=2022-06-29T00%3A00%3A00%2B00%3A00&date_to=2022-06-29T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'dau',
- date_from: '2022-06-30T00:00:00Z',
- date_to: '2022-06-30T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=dau&date_from=2022-06-30T00%3A00%3A00%2B00%3A00&date_to=2022-06-30T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'dau',
- date_from: '2022-07-01T00:00:00Z',
- date_to: '2022-07-01T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=dau&date_from=2022-07-01T00%3A00%3A00%2B00%3A00&date_to=2022-07-01T00%3A00%3A00%2B00%3A00',
- },
- ],
- filter: {
- breakdown_attribution_type: 'first_touch',
- display: 'ActionsLineGraph',
- events: [
- {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: 'dau',
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- ],
- insight: InsightType.TRENDS,
- interval: 'day',
- smoothing_intervals: 1,
- },
- },
- ],
- created_at: '2022-06-29T10:18:57.715671Z',
- created_by: null,
- description: 'Shows the number of unique users that use your app every day.',
- updated_at: '2022-06-29T10:18:57.715760Z',
- favorited: false,
- saved: false,
- last_modified_at: '2022-06-29T10:18:57.714051Z',
- last_modified_by: null,
- is_sample: false,
- timezone: null,
- tags: [],
- user_access_level: AccessControlLevel.Editor,
- },
- } as DashboardTile,
- {
- id: 1,
- layouts: {
- sm: {
- h: 5,
- w: 6,
- x: 6,
- y: 0,
- minH: 5,
- minW: 3,
- },
- xs: {
- h: 5,
- w: 1,
- x: 0,
- y: 5,
- minH: 5,
- minW: 3,
- moved: false,
- static: false,
- },
- },
- color: InsightColor.Green,
- last_refresh: '2022-07-01T13:33:13.630227Z',
- insight: {
- last_refresh: '2022-07-01T13:33:13.630227Z',
-
- id: 2,
- short_id: 'e8FxXHZ6' as InsightShortId,
- name: 'Weekly active users (WAUs)',
- derived_name: null,
- filters: {
- events: [
- {
- id: '$pageview',
- math: 'weekly_active',
- type: 'events',
- },
- ],
- insight: InsightType.TRENDS,
- interval: 'week',
- },
- order: null,
- deleted: false,
- dashboards: [1],
- dashboard_tiles: [{ id: 1, dashboard_id: 1 }],
- result: [
- {
- action: {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: 'weekly_active',
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- label: '$pageview',
- count: 327.0,
- data: [0.0, 0.0, 93.0, 234.0],
- labels: ['19-Jun-2022', '26-Jun-2022', '29-Jun-2022', '1-Jul-2022'],
- days: ['2022-06-19', '2022-06-26', '2022-06-29', '2022-07-01'],
- persons_urls: [
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'weekly_active',
- date_from: '2022-06-19T00:00:00Z',
- date_to: '2022-06-19T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22weekly_active%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=week&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=weekly_active&date_from=2022-06-19T00%3A00%3A00%2B00%3A00&date_to=2022-06-19T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'weekly_active',
- date_from: '2022-06-26T00:00:00Z',
- date_to: '2022-06-26T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22weekly_active%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=week&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=weekly_active&date_from=2022-06-26T00%3A00%3A00%2B00%3A00&date_to=2022-06-26T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'weekly_active',
- date_from: '2022-06-29T00:00:00Z',
- date_to: '2022-06-29T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22weekly_active%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=week&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=weekly_active&date_from=2022-06-29T00%3A00%3A00%2B00%3A00&date_to=2022-06-29T00%3A00%3A00%2B00%3A00',
- },
- {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- entity_math: 'weekly_active',
- date_from: '2022-07-01T00:00:00Z',
- date_to: '2022-07-01T00:00:00Z',
- entity_order: null,
- },
- url: 'api/projects/1/persons/trends/?breakdown_attribution_type=first_touch&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22weekly_active%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=week&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_math=weekly_active&date_from=2022-07-01T00%3A00%3A00%2B00%3A00&date_to=2022-07-01T00%3A00%3A00%2B00%3A00',
- },
- ],
- filter: {
- breakdown_attribution_type: 'first_touch',
- display: 'ActionsLineGraph',
- events: [
- {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: 'weekly_active',
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- ],
- insight: InsightType.TRENDS,
- interval: 'week',
- smoothing_intervals: 1,
- },
- },
- ],
- created_at: '2022-06-29T10:18:57.724595Z',
- created_by: null,
- description: 'Shows the number of unique users that use your app every week.',
- updated_at: '2022-06-29T10:18:57.724674Z',
- favorited: false,
- saved: false,
- last_modified_at: '2022-06-29T10:18:57.723355Z',
- last_modified_by: null,
- is_sample: false,
- timezone: null,
- tags: [],
- user_access_level: AccessControlLevel.Editor,
- },
- } as DashboardTile,
- {
- id: 2,
- layouts: {
- sm: {
- h: 5,
- w: 6,
- x: 0,
- y: 10,
- minH: 5,
- minW: 3,
- },
- xs: {
- h: 5,
- w: 1,
- x: 0,
- y: 20,
- minH: 5,
- minW: 3,
- moved: false,
- static: false,
- },
- },
- color: InsightColor.Black,
- last_refresh: '2022-07-01T13:33:13.694015Z',
- insight: {
- id: 5,
- short_id: 'sMPkWHir' as InsightShortId,
- name: 'Referring domain (last 14 days)',
- derived_name: null,
- filters: {
- events: [
- {
- id: '$pageview',
- math: 'dau',
- type: 'events',
- },
- ],
- display: ChartDisplayType.ActionsBarValue,
- insight: InsightType.TRENDS,
- interval: 'day',
- breakdown: '$referring_domain',
- date_from: '-14d',
- breakdown_type: 'event',
- },
- last_refresh: '2022-07-01T13:33:13.694015Z',
- order: null,
- deleted: false,
- dashboards: [1],
- dashboard_tiles: [{ id: 1, dashboard_id: 1 }],
- result: [
- {
- action: {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: 'dau',
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- label: '$pageview - none',
- count: 0,
- data: [],
- labels: [],
- days: [
- '2022-06-17',
- '2022-06-18',
- '2022-06-19',
- '2022-06-20',
- '2022-06-21',
- '2022-06-22',
- '2022-06-23',
- '2022-06-24',
- '2022-06-25',
- '2022-06-26',
- '2022-06-27',
- '2022-06-28',
- '2022-06-29',
- '2022-06-30',
- '2022-07-01',
- ],
- aggregated_value: 233,
- filter: {
- breakdown: '$referring_domain',
- breakdown_attribution_type: 'first_touch',
- breakdown_type: 'event',
- date_from: '-14d',
- display: 'ActionsBarValue',
- events: '[{"id": "$pageview", "type": "events", "order": null, "name": "$pageview", "custom_name": null, "math": "dau", "math_property": null, "math_group_type_index": null, "properties": {}}]',
- insight: InsightType.TRENDS,
- interval: 'day',
- smoothing_intervals: 1,
- },
- persons: {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- breakdown_value: '',
- breakdown_type: 'event',
- },
- url: 'api/projects/1/persons/trends/?breakdown=%24referring_domain&breakdown_attribution_type=first_touch&breakdown_type=event&date_from=-14d&display=ActionsBarValue&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&breakdown_value=',
- },
- breakdown_value: '',
- },
- {
- action: {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: 'dau',
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- label: '$pageview - localhost:8000',
- count: 0,
- data: [],
- labels: [],
- days: [
- '2022-06-17',
- '2022-06-18',
- '2022-06-19',
- '2022-06-20',
- '2022-06-21',
- '2022-06-22',
- '2022-06-23',
- '2022-06-24',
- '2022-06-25',
- '2022-06-26',
- '2022-06-27',
- '2022-06-28',
- '2022-06-29',
- '2022-06-30',
- '2022-07-01',
- ],
- aggregated_value: 1,
- filter: {
- breakdown: '$referring_domain',
- breakdown_attribution_type: 'first_touch',
- breakdown_type: 'event',
- date_from: '-14d',
- display: 'ActionsBarValue',
- events: '[{"id": "$pageview", "type": "events", "order": null, "name": "$pageview", "custom_name": null, "math": "dau", "math_property": null, "math_group_type_index": null, "properties": {}}]',
- insight: InsightType.TRENDS,
- interval: 'day',
- smoothing_intervals: 1,
- },
- persons: {
- filter: {
- entity_id: '$pageview',
- entity_type: 'events',
- breakdown_value: 'localhost:8000',
- breakdown_type: 'event',
- },
- url: 'api/projects/1/persons/trends/?breakdown=%24referring_domain&breakdown_attribution_type=first_touch&breakdown_type=event&date_from=-14d&display=ActionsBarValue&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+%22dau%22%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&breakdown_value=localhost%3A8000',
- },
- breakdown_value: 'localhost:8000',
- },
- ],
- created_at: '2022-06-29T10:18:57.750861Z',
- created_by: null,
- description: 'Shows the most common referring domains for your users over the past 14 days.',
- updated_at: '2022-06-29T10:18:57.750934Z',
- favorited: false,
- saved: false,
- last_modified_at: '2022-06-29T10:18:57.749799Z',
- last_modified_by: null,
- is_sample: false,
- timezone: null,
- tags: [],
- user_access_level: AccessControlLevel.Editor,
- },
- } as DashboardTile,
- {
- id: 3,
- layouts: {
- sm: {
- h: 5,
- w: 6,
- x: 0,
- y: 5,
- minH: 5,
- minW: 3,
- },
- xs: {
- h: 5,
- w: 1,
- x: 0,
- y: 15,
- minH: 5,
- minW: 3,
- moved: false,
- static: false,
- },
- },
- color: InsightColor.Purple,
- last_refresh: '2022-07-01T13:33:14.001864Z',
- insight: {
- id: 4,
- short_id: 'KcoMGkag' as InsightShortId,
- name: 'Growth accounting',
- derived_name: null,
- filters: {
- events: [
- {
- id: '$pageview',
- type: 'events',
- },
- ],
- insight: InsightType.LIFECYCLE,
- interval: 'week',
- shown_as: ShownAsValue.LIFECYCLE,
- date_from: '-30d',
- entity_type: 'events',
- },
-
- order: null,
- deleted: false,
- dashboards: [1],
- dashboard_tiles: [{ id: 1, dashboard_id: 1 }],
- last_refresh: '2022-07-01T13:33:14.001864Z',
- result: [
- {
- action: {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: null,
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- label: '$pageview - new',
- count: 234.0,
- data: [0.0, 0.0, 0.0, 0.0, 234.0],
- labels: ['30-May-2022', '6-Jun-2022', '13-Jun-2022', '20-Jun-2022', '27-Jun-2022'],
- days: ['2022-05-30', '2022-06-06', '2022-06-13', '2022-06-20', '2022-06-27'],
- status: 'new',
- },
- {
- action: {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: null,
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- label: '$pageview - dormant',
- count: 0.0,
- data: [0.0, 0.0, 0.0, 0.0, 0.0],
- labels: ['30-May-2022', '6-Jun-2022', '13-Jun-2022', '20-Jun-2022', '27-Jun-2022'],
- days: ['2022-05-30', '2022-06-06', '2022-06-13', '2022-06-20', '2022-06-27'],
- status: 'dormant',
- },
- {
- action: {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: null,
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- label: '$pageview - resurrecting',
- count: 0.0,
- data: [0.0, 0.0, 0.0, 0.0, 0.0],
- labels: ['30-May-2022', '6-Jun-2022', '13-Jun-2022', '20-Jun-2022', '27-Jun-2022'],
- days: ['2022-05-30', '2022-06-06', '2022-06-13', '2022-06-20', '2022-06-27'],
- status: 'resurrecting',
- },
- {
- action: {
- id: '$pageview',
- type: 'events',
- order: null,
- name: '$pageview',
- custom_name: null,
- math: null,
- math_property: null,
- math_group_type_index: null,
- properties: {},
- },
- label: '$pageview - returning',
- count: 0.0,
- data: [0.0, 0.0, 0.0, 0.0, 0.0],
- labels: ['30-May-2022', '6-Jun-2022', '13-Jun-2022', '20-Jun-2022', '27-Jun-2022'],
- days: ['2022-05-30', '2022-06-06', '2022-06-13', '2022-06-20', '2022-06-27'],
- status: 'returning',
- },
- ],
- created_at: '2022-06-29T10:18:57.743718Z',
- created_by: null,
- description: 'How many of your users are new, returning, resurrecting, or dormant each week.',
- updated_at: '2022-06-29T10:18:57.743797Z',
- favorited: false,
- saved: false,
- last_modified_at: '2022-06-29T10:18:57.738355Z',
- last_modified_by: null,
- is_sample: false,
- timezone: null,
- tags: [],
- user_access_level: AccessControlLevel.Editor,
- },
- } as DashboardTile,
- {
- id: 4,
- layouts: {
- sm: {
- h: 5,
- w: 6,
- x: 6,
- y: 5,
- minH: 5,
- minW: 3,
- },
- xs: {
- h: 5,
- w: 1,
- x: 0,
- y: 10,
- minH: 5,
- minW: 3,
- moved: false,
- static: false,
- },
- },
- color: InsightColor.Blue,
- last_refresh: '2022-07-01T13:33:14.399653Z',
- insight: {
- id: 3,
- short_id: '4nk6BVnw' as InsightShortId,
- name: 'Retention',
- derived_name: null,
- filters: {
- period: 'Week',
- insight: InsightType.RETENTION,
- target_entity: {
- id: '$pageview',
- type: 'events',
- },
- retention_type: 'retention_first_time',
- returning_entity: {
- id: '$pageview',
- type: 'events',
- },
- },
-
- order: null,
- deleted: false,
- dashboards: [1],
- dashboard_tiles: [{ id: 1, dashboard_id: 1 }],
- last_refresh: '2022-07-01T13:33:14.399653Z',
- result: [
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 0',
- date: '2022-04-17T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B0%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 1',
- date: '2022-04-24T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B1%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 2',
- date: '2022-05-01T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B2%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 3',
- date: '2022-05-08T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B3%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 4',
- date: '2022-05-15T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B4%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 5',
- date: '2022-05-22T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B5%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 6',
- date: '2022-05-29T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B6%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 7',
- date: '2022-06-05T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B7%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 8',
- date: '2022-06-12T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B8%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 0,
- people: [],
- },
- {
- count: 0,
- people: [],
- },
- ],
- label: 'Week 9',
- date: '2022-06-19T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B9%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- {
- values: [
- {
- count: 234,
- people: [],
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B10%5D&display=RetentionTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- ],
- label: 'Week 10',
- date: '2022-06-26T00:00:00Z',
- people_url:
- '/api/person/retention/?breakdown_attribution_type=first_touch&breakdown_values=%5B10%5D&display=ActionsTable&insight=RETENTION&period=Week&retention_type=retention_first_time&returning_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&target_entity=%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+null%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D&total_intervals=11',
- },
- ],
- created_at: '2022-06-29T10:18:57.732328Z',
- created_by: null,
- description: 'Weekly retention of your users.',
- updated_at: '2022-06-29T10:18:57.732405Z',
- favorited: false,
- saved: false,
- last_modified_at: '2022-06-29T10:18:57.731207Z',
- last_modified_by: null,
- is_sample: false,
- timezone: null,
- tags: [],
- user_access_level: AccessControlLevel.Editor,
- },
- } as DashboardTile,
- {
- id: 5,
- layouts: {
- sm: {
- h: 5,
- w: 6,
- x: 6,
- y: 10,
- minH: 5,
- minW: 3,
- },
- xs: {
- h: 5,
- w: 1,
- x: 0,
- y: 25,
- minH: 5,
- minW: 3,
- moved: false,
- static: false,
- },
- },
- color: InsightColor.Green,
- last_refresh: '2022-07-01T13:33:15.069874Z',
- insight: {
- id: 6,
- short_id: 'Ht75IvAs' as InsightShortId,
- name: 'Pageview funnel, by browser',
- derived_name: null,
- filters: {
- events: [
- {
- id: '$pageview',
- type: 'events',
- order: 0,
- custom_name: 'First page view',
- },
- {
- id: '$pageview',
- type: 'events',
- order: 1,
- custom_name: 'Second page view',
- },
- {
- id: '$pageview',
- type: 'events',
- order: 2,
- custom_name: 'Third page view',
- },
- ],
- layout: FunnelLayout.horizontal,
- insight: InsightType.FUNNELS,
- interval: 'day',
- breakdowns: [
- {
- type: 'event',
- property: '$browser',
- },
- ],
- exclusions: [],
- breakdown_type: 'event',
- funnel_viz_type: FunnelVizType.Steps,
- },
- last_refresh: '2022-07-01T13:33:15.069874Z',
- order: null,
- deleted: false,
- dashboards: [1],
- dashboard_tiles: [{ id: 1, dashboard_id: 1 }],
- result: [
- [
- {
- action_id: '$pageview',
- name: '$pageview',
- custom_name: 'First page view',
- order: 0,
- people: [],
- count: 234,
- type: 'events',
- average_conversion_time: null,
- median_conversion_time: null,
- breakdown: ['Chrome'],
- breakdown_value: ['Chrome'],
- converted_people_url:
- '/api/person/funnel/?breakdown=%5B%22%24browser%22%5D&breakdowns=%5B%7B%22property%22%3A+%22%24browser%22%2C+%22type%22%3A+%22event%22%7D%5D&breakdown_attribution_type=first_touch&breakdown_type=event&date_from=2022-06-24T00%3A00%3A00%2B00%3A00&display=FunnelViz&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+0%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22First+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+1%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Second+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+2%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Third+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&funnel_step_breakdown=%5B%22Chrome%22%5D&funnel_step=1&funnel_viz_type=steps&funnel_window_interval=14&funnel_window_interval_unit=day&insight=FUNNELS&interval=day&layout=horizontal&limit=100&smoothing_intervals=1',
- dropped_people_url: null,
- },
- {
- action_id: '$pageview',
- name: '$pageview',
- custom_name: 'Second page view',
- order: 1,
- people: [],
- count: 180,
- type: 'events',
- average_conversion_time: 4.977061699111973,
- median_conversion_time: 0.0,
- breakdown: ['Chrome'],
- breakdown_value: ['Chrome'],
- converted_people_url:
- '/api/person/funnel/?breakdown=%5B%22%24browser%22%5D&breakdowns=%5B%7B%22property%22%3A+%22%24browser%22%2C+%22type%22%3A+%22event%22%7D%5D&breakdown_attribution_type=first_touch&breakdown_type=event&date_from=2022-06-24T00%3A00%3A00%2B00%3A00&display=FunnelViz&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+0%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22First+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+1%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Second+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+2%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Third+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&funnel_step_breakdown=%5B%22Chrome%22%5D&funnel_step=2&funnel_viz_type=steps&funnel_window_interval=14&funnel_window_interval_unit=day&insight=FUNNELS&interval=day&layout=horizontal&limit=100&smoothing_intervals=1',
- dropped_people_url:
- '/api/person/funnel/?breakdown=%5B%22%24browser%22%5D&breakdowns=%5B%7B%22property%22%3A+%22%24browser%22%2C+%22type%22%3A+%22event%22%7D%5D&breakdown_attribution_type=first_touch&breakdown_type=event&date_from=2022-06-24T00%3A00%3A00%2B00%3A00&display=FunnelViz&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+0%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22First+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+1%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Second+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+2%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Third+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&funnel_step_breakdown=%5B%22Chrome%22%5D&funnel_step=-2&funnel_viz_type=steps&funnel_window_interval=14&funnel_window_interval_unit=day&insight=FUNNELS&interval=day&layout=horizontal&limit=100&smoothing_intervals=1',
- },
- {
- action_id: '$pageview',
- name: '$pageview',
- custom_name: 'Third page view',
- order: 2,
- people: [],
- count: 65,
- type: 'events',
- average_conversion_time: 6.742016378668548,
- median_conversion_time: 0.0,
- breakdown: ['Chrome'],
- breakdown_value: ['Chrome'],
- converted_people_url:
- '/api/person/funnel/?breakdown=%5B%22%24browser%22%5D&breakdowns=%5B%7B%22property%22%3A+%22%24browser%22%2C+%22type%22%3A+%22event%22%7D%5D&breakdown_attribution_type=first_touch&breakdown_type=event&date_from=2022-06-24T00%3A00%3A00%2B00%3A00&display=FunnelViz&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+0%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22First+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+1%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Second+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+2%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Third+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&funnel_step_breakdown=%5B%22Chrome%22%5D&funnel_step=3&funnel_viz_type=steps&funnel_window_interval=14&funnel_window_interval_unit=day&insight=FUNNELS&interval=day&layout=horizontal&limit=100&smoothing_intervals=1',
- dropped_people_url:
- '/api/person/funnel/?breakdown=%5B%22%24browser%22%5D&breakdowns=%5B%7B%22property%22%3A+%22%24browser%22%2C+%22type%22%3A+%22event%22%7D%5D&breakdown_attribution_type=first_touch&breakdown_type=event&date_from=2022-06-24T00%3A00%3A00%2B00%3A00&display=FunnelViz&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+0%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22First+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+1%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Second+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+2%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+%22Third+page+view%22%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&funnel_step_breakdown=%5B%22Chrome%22%5D&funnel_step=-3&funnel_viz_type=steps&funnel_window_interval=14&funnel_window_interval_unit=day&insight=FUNNELS&interval=day&layout=horizontal&limit=100&smoothing_intervals=1',
- },
- ],
- ],
- created_at: '2022-06-29T10:18:57.757573Z',
- created_by: null,
- description:
- 'This example funnel shows how many of your users have completed 3 page views, broken down by browser.',
- updated_at: '2022-06-29T10:18:57.757644Z',
- favorited: false,
- saved: false,
- last_modified_at: '2022-06-29T10:18:57.756123Z',
- last_modified_by: null,
- is_sample: true,
- timezone: null,
- tags: [],
- user_access_level: AccessControlLevel.Editor,
- },
- } as DashboardTile,
- ],
- created_at: '2022-06-29T10:18:57.707542Z',
- created_by: null,
- last_accessed_at: null,
- is_shared: true,
- deleted: false,
- creation_mode: 'default',
- filters: {},
- user_access_level: AccessControlLevel.Editor,
- tags: [],
-}
diff --git a/frontend/src/exporter/scenes/ExporterDashboardScene.tsx b/frontend/src/exporter/scenes/ExporterDashboardScene.tsx
index ae7a20ae6aa8..64b5a5af8f4f 100644
--- a/frontend/src/exporter/scenes/ExporterDashboardScene.tsx
+++ b/frontend/src/exporter/scenes/ExporterDashboardScene.tsx
@@ -7,7 +7,7 @@ import { AUTO_REFRESH_INITIAL_INTERVAL_SECONDS } from 'scenes/dashboard/dashboar
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
import { getQueryBasedDashboard } from '~/queries/nodes/InsightViz/utils'
-import { DashboardPlacement, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardType } from '~/types'
import { ExportType, ExportedData } from '../types'
@@ -16,7 +16,7 @@ function SharedDashboardAutoRefresh({
dashboard,
}: {
dashboardId: number
- dashboard: DashboardType<QueryBasedInsightModel>
+ dashboard: DashboardType
}): JSX.Element | null {
// Pass `dashboard` so dashboardLogic.afterMount uses the cached branch
// (loadDashboardSuccess) instead of firing an unauthenticated loadDashboard.
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 0b572dd7b3a9..46e58a369fb9 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -177,7 +177,6 @@ import {
PropertyDefinition,
PropertyDefinitionType,
PropertyGroupFilter,
- QueryBasedInsightModel,
QueryTabState,
QuickFilter,
RawAnnotationType,
@@ -605,7 +604,7 @@ export class ApiRequest {
return this.teamProjectDetail(teamId).addPathComponent('insights')
}
- public insight(id: QueryBasedInsightModel['id'], teamId?: TeamType['id']): ApiRequest {
+ public insight(id: InsightModel['id'], teamId?: TeamType['id']): ApiRequest {
return this.insights(teamId).addPathComponent(id)
}
@@ -613,19 +612,15 @@ export class ApiRequest {
return this.insights(teamId).addPathComponent('activity')
}
- public insightSharing(id: QueryBasedInsightModel['id'], teamId?: TeamType['id']): ApiRequest {
+ public insightSharing(id: InsightModel['id'], teamId?: TeamType['id']): ApiRequest {
return this.insight(id, teamId).addPathComponent('sharing')
}
- public insightSharingPasswords(id: QueryBasedInsightModel['id'], teamId?: TeamType['id']): ApiRequest {
+ public insightSharingPasswords(id: InsightModel['id'], teamId?: TeamType['id']): ApiRequest {
return this.insightSharing(id, teamId).addPathComponent('passwords')
}
- public insightSharingPassword(
- id: QueryBasedInsightModel['id'],
- passwordId: string,
- teamId?: TeamType['id']
- ): ApiRequest {
+ public insightSharingPassword(id: InsightModel['id'], passwordId: string, teamId?: TeamType['id']): ApiRequest {
return this.insightSharingPasswords(id, teamId).addPathComponent(passwordId)
}
@@ -3834,7 +3829,7 @@ const api = {
notebookShortId,
}: {
dashboardId?: DashboardType['id']
- insightId?: QueryBasedInsightModel['id']
+ insightId?: InsightModel['id']
recordingId?: SessionRecordingType['id']
notebookShortId?: NotebookType['short_id']
}): Promise<SharingConfigurationType | null> {
@@ -3857,7 +3852,7 @@ const api = {
notebookShortId,
}: {
dashboardId?: DashboardType['id']
- insightId?: QueryBasedInsightModel['id']
+ insightId?: InsightModel['id']
recordingId?: SessionRecordingType['id']
notebookShortId?: NotebookType['short_id']
},
@@ -3882,7 +3877,7 @@ const api = {
notebookShortId,
}: {
dashboardId?: DashboardType['id']
- insightId?: QueryBasedInsightModel['id']
+ insightId?: InsightModel['id']
recordingId?: SessionRecordingType['id']
notebookShortId?: NotebookType['short_id']
},
@@ -3907,7 +3902,7 @@ const api = {
notebookShortId,
}: {
dashboardId?: DashboardType['id']
- insightId?: QueryBasedInsightModel['id']
+ insightId?: InsightModel['id']
recordingId?: SessionRecordingType['id']
notebookShortId?: NotebookType['short_id']
},
diff --git a/frontend/src/lib/components/AddToDashboard/AddToDashboard.tsx b/frontend/src/lib/components/AddToDashboard/AddToDashboard.tsx
index 65c017e0c6ab..abe1bf45950f 100644
--- a/frontend/src/lib/components/AddToDashboard/AddToDashboard.tsx
+++ b/frontend/src/lib/components/AddToDashboard/AddToDashboard.tsx
@@ -6,10 +6,10 @@ import { IconWithCount } from 'lib/lemon-ui/icons'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { dashboardsModel } from '~/models/dashboardsModel'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
interface SaveToDashboardProps {
- insight: Partial<QueryBasedInsightModel>
+ insight: Partial<InsightModel>
setOpenModal: (open: boolean) => void
}
diff --git a/frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.test.ts b/frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.test.ts
index 9c7ce61dec85..d973d8aad620 100644
--- a/frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.test.ts
+++ b/frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.test.ts
@@ -15,7 +15,7 @@ import {
DashboardBasicType,
DashboardType,
InsightShortId,
- QueryBasedInsightModel,
+ InsightModel,
UserBasicType,
} from '~/types'
@@ -23,7 +23,7 @@ import { addToDashboardModalLogic } from './addToDashboardModalLogic'
const Insight1 = '1' as InsightShortId
-const MOCK_INSIGHT: QueryBasedInsightModel = {
+const MOCK_INSIGHT: InsightModel = {
id: 1,
short_id: Insight1,
name: 'Test Insight',
@@ -56,7 +56,7 @@ const MOCK_INSIGHT: QueryBasedInsightModel = {
layouts: {},
color: null,
user_access_level: AccessControlLevel.Editor,
-} as QueryBasedInsightModel
+} as InsightModel
const OTHER_USER_UUID = 'other-user-uuid'
@@ -130,7 +130,7 @@ describe('addToDashboardModalLogic', () => {
id: 99,
name: 'New Dashboard',
tiles: [],
- } as unknown as DashboardType<QueryBasedInsightModel>
+ } as unknown as DashboardType
await expectLogic(logic, () => {
dashboardsModel.actions.addDashboardSuccess(newDashboard)
@@ -144,7 +144,7 @@ describe('addToDashboardModalLogic', () => {
})
it('orders dashboards: on insight first, then mine, then others pinned, then the rest', async () => {
- const insightOnlyOnDash2: QueryBasedInsightModel = {
+ const insightOnlyOnDash2: InsightModel = {
...MOCK_INSIGHT,
dashboards: [2],
dashboard_tiles: [{ dashboard_id: 2 }] as any,
@@ -198,7 +198,7 @@ describe('addToDashboardModalLogic', () => {
it('when user is not loaded, dashboards with no creator are not grouped as mine', async () => {
window.POSTHOG_APP_CONTEXT = { current_user: null } as unknown as AppContext
- const insightOnlyOnDash2: QueryBasedInsightModel = {
+ const insightOnlyOnDash2: InsightModel = {
...MOCK_INSIGHT,
dashboards: [2],
dashboard_tiles: [{ dashboard_id: 2 }] as any,
@@ -249,7 +249,7 @@ describe('addToDashboardModalLogic', () => {
})
it('places mine pinned in the mine bucket before others pinned', async () => {
- const insightOnlyOnDash2: QueryBasedInsightModel = {
+ const insightOnlyOnDash2: InsightModel = {
...MOCK_INSIGHT,
dashboards: [2],
dashboard_tiles: [{ dashboard_id: 2 }] as any,
diff --git a/frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.ts b/frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.ts
index 53a50a802720..a329b19ade8f 100644
--- a/frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.ts
+++ b/frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.ts
@@ -15,14 +15,14 @@ import { dashboardsModel, nameCompareFunction } from '~/models/dashboardsModel'
import { DashboardBasicType, DashboardType, InsightLogicProps } from '~/types'
import type { Node } from '../../../queries/schema/schema-general'
-import type { QueryBasedInsightModel, UserType } from '../../../types'
+import type { InsightModel, UserType } from '../../../types'
// Helping kea-typegen navigate the exported default class for Fuse
export interface Fuse extends FuseClass<any> {}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface addToDashboardModalLogicValues {
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> // insightLogic
+ insight: Partial<InsightModel<Node<Record<string, any>>>> // insightLogic
user: UserType | null // userLogic
_dashboardToNavigateTo: number | null
availableDashboards: DashboardBasicType[]
@@ -41,25 +41,25 @@ export interface addToDashboardModalLogicActions {
value: true
} // eventUsageLogic
reportRemovedInsightFromDashboard: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null,
dashboardId: number | null
) => {
dashboardId: number | null
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null
} // eventUsageLogic
reportSavedInsightToDashboard: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null,
dashboardId: number | null
) => {
dashboardId: number | null
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null
} // eventUsageLogic
updateInsight: (
- insightUpdate: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ insightUpdate: Partial<InsightModel<Node<Record<string, any>>>>,
callback?: (() => void) | undefined
) => {
callback: (() => void) | undefined
- insightUpdate: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insightUpdate: Partial<InsightModel<Node<Record<string, any>>>>
} // insightLogic
updateInsightFailure: (
error: string,
@@ -69,18 +69,18 @@ export interface addToDashboardModalLogicActions {
errorObject?: any
} // insightLogic
updateInsightSuccess: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ insight: Partial<InsightModel<Node<Record<string, any>>>>,
payload?:
| {
callback: (() => void) | undefined
- insightUpdate: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insightUpdate: Partial<InsightModel<Node<Record<string, any>>>>
}
| undefined
) => {
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>
payload?: {
callback: (() => void) | undefined
- insightUpdate: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insightUpdate: Partial<InsightModel<Node<Record<string, any>>>>
}
} // insightLogic
showNewDashboardModal: () => {
@@ -110,23 +110,15 @@ export interface addToDashboardModalLogicActions {
export interface addToDashboardModalLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- dashboardsFuse: (
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
- )[]
- ) => Fuse
+ dashboardsFuse: (nameSortedDashboards: (DashboardBasicType | DashboardType)[]) => Fuse
filteredDashboards: (
searchQuery: string,
dashboardsFuse: Fuse,
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
- )[]
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[]
) => DashboardBasicType[]
currentDashboards: (
filteredDashboards: DashboardBasicType[],
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>
) => DashboardBasicType[]
availableDashboards: (
filteredDashboards: DashboardBasicType[],
@@ -192,16 +184,7 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
selectors({
dashboardsFuse: [
() => [dashboardsModel.selectors.nameSortedDashboards],
- (
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<
- import('~/types').QueryBasedInsightModel<
- import('../../../queries/schema').Node<Record<string, any>>
- >
- >
- )[]
- ): Fuse => {
+ (nameSortedDashboards: (DashboardBasicType | DashboardType)[]): Fuse => {
return createFuse(nameSortedDashboards || [], {
keys: ['name', 'description', 'tags'],
})
@@ -212,14 +195,7 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
(
searchQuery: string,
dashboardsFuse: Fuse,
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<
- import('~/types').QueryBasedInsightModel<
- import('../../../queries/schema').Node<Record<string, any>>
- >
- >
- )[]
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[]
): DashboardBasicType[] =>
searchQuery.length
? dashboardsFuse.search(searchQuery).map((r: FuseResult<DashboardType>) => r.item)
@@ -230,9 +206,7 @@ export const addToDashboardModalLogic = kea<addToDashboardModalLogicType>([
(
filteredDashboards: DashboardBasicType[],
insight: Partial<
- import('~/types').QueryBasedInsightModel<
- import('../../../queries/schema').Node<Record<string, any>>
- >
+ import('~/types').InsightModel<import('../../../queries/schema').Node<Record<string, any>>>
>
): DashboardBasicType[] =>
filteredDashboards.filter((d) => insight.dashboard_tiles?.map((dt) => dt.dashboard_id)?.includes(d.id)),
diff --git a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts
index 5ae80057de78..24831f7073c8 100644
--- a/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts
+++ b/frontend/src/lib/components/AnnotationsOverlay/annotationsOverlayLogic.ts
@@ -21,7 +21,7 @@ import {
InsightLogicProps,
IntervalType,
PropertyGroupFilter,
- QueryBasedInsightModel,
+ InsightModel,
} from '~/types'
import type { AnnotationData } from '../../../models/annotationsModel'
@@ -31,7 +31,7 @@ import type { FeatureFlagsSet } from '../../logic/featureFlagLogic'
export interface AnnotationsOverlayLogicProps extends Omit<InsightLogicProps, 'dashboardId'> {
dashboardId: DashboardType['id'] | undefined
- insightNumericId: QueryBasedInsightModel['id'] | 'new'
+ insightNumericId: InsightModel['id'] | 'new'
dates: string[]
ticks: { value: number }[]
/** Disambiguator for charts that mount more than one overlay against the same insight
@@ -81,7 +81,7 @@ export interface annotationsOverlayLogicValues {
annotationsLoading: boolean // annotationsModel
featureFlags: FeatureFlagsSet // featureFlagLogic
insightId: number | null // insightLogic
- savedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> // insightLogic
+ savedInsight: Partial<InsightModel<Node<Record<string, any>>>> // insightLogic
annotationsScope: AnnotationScope | null | undefined // insightVizDataLogic
breakdownFilter: BreakdownFilter | null | undefined // insightVizDataLogic
interval: IntervalType | null | undefined // insightVizDataLogic
@@ -159,7 +159,7 @@ export interface annotationsOverlayLogicMeta {
featureFlags: FeatureFlagsSet,
insightNumericId: number | 'new',
dashboardId: number | undefined,
- savedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ savedInsight: Partial<InsightModel<Node<Record<string, any>>>>,
properties: PropertyGroupFilter | AnyPropertyFilter[] | null | undefined,
breakdownFilter: BreakdownFilter | null | undefined,
annotationsScope: AnnotationScope | null | undefined
@@ -302,7 +302,7 @@ export const annotationsOverlayLogic = kea<annotationsOverlayLogicType>([
insightNumericId: number | 'new',
dashboardId: number | undefined,
savedInsight: Partial<
- QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
+ InsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
>,
properties: PropertyGroupFilter | AnyPropertyFilter[] | null | undefined,
breakdownFilter: BreakdownFilter | null | undefined,
diff --git a/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCard.stories.tsx b/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCard.stories.tsx
index ad9972428967..d4fe04892b0e 100644
--- a/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCard.stories.tsx
+++ b/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCard.stories.tsx
@@ -2,7 +2,7 @@ import '~/scenes/dashboard/DashboardItems.scss'
import type { Meta, StoryObj } from '@storybook/react'
-import { DashboardPlacement, DashboardTile, InsightColor, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile, InsightColor } from '~/types'
import { ButtonTileCard } from './ButtonTileCard'
@@ -26,7 +26,7 @@ const makeButtonTile = (
transparentBackground?: boolean
color?: InsightColor | null
} = {}
-): DashboardTile<QueryBasedInsightModel> => {
+): DashboardTile => {
return {
id: 1,
button_tile: {
diff --git a/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCard.tsx b/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCard.tsx
index 2a4849b3df2b..1e9098afee4f 100644
--- a/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCard.tsx
+++ b/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCard.tsx
@@ -11,10 +11,10 @@ import { EditModeEdge, EditModeEdgeOverlay } from 'lib/components/Cards/InsightC
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { More, MoreProps } from 'lib/lemon-ui/LemonButton/More'
-import { DashboardPlacement, DashboardTile, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile } from '~/types'
interface ButtonTileCardProps extends React.HTMLAttributes<HTMLDivElement>, Resizeable {
- buttonTile: DashboardTile<QueryBasedInsightModel>
+ buttonTile: DashboardTile
placement: DashboardPlacement
children?: JSX.Element
canEnterEditModeFromEdge?: boolean
diff --git a/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCardModal.tsx b/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCardModal.tsx
index 0d930c81b156..7f2a7f9c232e 100644
--- a/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCardModal.tsx
+++ b/frontend/src/lib/components/Cards/ButtonTileCard/ButtonTileCardModal.tsx
@@ -9,7 +9,7 @@ import { LemonModal } from 'lib/lemon-ui/LemonModal'
import { LemonSegmentedButton } from 'lib/lemon-ui/LemonSegmentedButton'
import { LemonSwitch } from 'lib/lemon-ui/LemonSwitch'
-import { DashboardPlacement, DashboardTile, DashboardTileIdOrNew, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile, DashboardTileIdOrNew, DashboardType } from '~/types'
export function ButtonTileCardModal({
isOpen,
@@ -19,7 +19,7 @@ export function ButtonTileCardModal({
}: {
isOpen: boolean
onClose: () => void
- dashboard: DashboardType<QueryBasedInsightModel>
+ dashboard: DashboardType
buttonTileId: DashboardTileIdOrNew
}): JSX.Element {
const isNewTile = buttonTileId === null
@@ -33,7 +33,7 @@ export function ButtonTileCardModal({
}
const firstError = buttonTileValidationErrors.url || buttonTileValidationErrors.text
- const previewTile: DashboardTile<QueryBasedInsightModel> = {
+ const previewTile: DashboardTile = {
id: buttonTileId ?? 0,
color: null,
button_tile: { ...buttonTile, text: buttonTile.text || 'Click me' },
diff --git a/frontend/src/lib/components/Cards/ButtonTileCard/buttonTileCardModalLogic.ts b/frontend/src/lib/components/Cards/ButtonTileCard/buttonTileCardModalLogic.ts
index 47d00e9b1edd..d75c5698653d 100644
--- a/frontend/src/lib/components/Cards/ButtonTileCard/buttonTileCardModalLogic.ts
+++ b/frontend/src/lib/components/Cards/ButtonTileCard/buttonTileCardModalLogic.ts
@@ -6,7 +6,7 @@ import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
import { dashboardsModel } from '~/models/dashboardsModel'
-import { DashboardTileIdOrNew, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardTileIdOrNew, DashboardType } from '~/types'
export interface ButtonTileForm {
url: string
@@ -17,15 +17,12 @@ export interface ButtonTileForm {
}
export interface ButtonTileCardModalProps {
- dashboard: DashboardType<QueryBasedInsightModel>
+ dashboard: DashboardType
buttonTileId: DashboardTileIdOrNew
onClose: () => void
}
-const getExistingButtonTile = (
- dashboard: DashboardType<QueryBasedInsightModel>,
- buttonTileId: number
-): ButtonTileForm => {
+const getExistingButtonTile = (dashboard: DashboardType, buttonTileId: number): ButtonTileForm => {
const tile = dashboard.tiles?.find((t) => t.id === buttonTileId)
if (tile?.button_tile) {
return {
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightCard.stories.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightCard.stories.tsx
index 21dd8773d764..a37d5a4edea8 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightCard.stories.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightCard.stories.tsx
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react'
import { useState } from 'react'
import { TileFilters } from '~/queries/schema/schema-general'
-import { AccessControlLevel, DashboardTile, InsightColor, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardTile, InsightColor, InsightShortId, InsightModel } from '~/types'
import EXAMPLE_DATA_TABLE_NODE_EVENTS_QUERY from '../../../../mocks/fixtures/api/projects/team_id/insights/dataTableEvents.json'
import EXAMPLE_DATA_TABLE_NODE_HOGQL_QUERY from '../../../../mocks/fixtures/api/projects/team_id/insights/dataTableHogQL.json'
@@ -33,7 +33,7 @@ const defaultTile = {
},
],
} as TileFilters,
-} as DashboardTile<QueryBasedInsightModel>
+} as DashboardTile
const examples = [
EXAMPLE_TRENDS,
@@ -49,7 +49,7 @@ const examples = [
EXAMPLE_LIFECYCLE,
EXAMPLE_DATA_TABLE_NODE_HOGQL_QUERY,
EXAMPLE_DATA_TABLE_NODE_EVENTS_QUERY,
-] as unknown as QueryBasedInsightModel[]
+] as unknown as InsightModel[]
const meta: Meta<InsightCardProps> = {
title: 'Components/Cards/Insight Card',
@@ -80,7 +80,7 @@ const meta: Meta<InsightCardProps> = {
insight: {
name: '',
description: '',
- } as unknown as QueryBasedInsightModel,
+ } as unknown as InsightModel,
},
}
export default meta
@@ -101,7 +101,7 @@ export const InsightCard: Story = {
...EXAMPLE_TRENDS,
name: args.insight.name,
description: args.insight.description,
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
ribbonColor={insightColor}
loading={args.loading}
@@ -125,7 +125,7 @@ export const InsightCard: Story = {
description:
'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.',
tags: ['every', 'green', 'bus', 'drives', 'fast', 'face'],
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
rename={() => {}}
duplicate={() => {}}
@@ -144,7 +144,7 @@ export const InsightCard: Story = {
name: '',
description: '',
last_modified_by: null,
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
rename={() => {}}
duplicate={() => {}}
@@ -169,7 +169,7 @@ export const InsightCard: Story = {
},
},
name: 'What a pitiful funnel',
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
rename={() => {}}
duplicate={() => {}}
@@ -186,7 +186,7 @@ export const InsightCard: Story = {
{
...EXAMPLE_FUNNEL,
name: 'What a plentiful funnel',
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
rename={() => {}}
duplicate={() => {}}
@@ -201,7 +201,7 @@ export const InsightCard: Story = {
<InsightCardComponent
tile={args.tile}
key={e.id}
- insight={e as unknown as QueryBasedInsightModel}
+ insight={e as unknown as InsightModel}
rename={() => {}}
duplicate={() => {}}
placement="SavedInsightGrid"
@@ -268,7 +268,7 @@ export const ErrorStates: Story = {
<InsightCardComponent
key={name}
tile={defaultTile}
- insight={{ ...EXAMPLE_TRENDS, name } as unknown as QueryBasedInsightModel}
+ insight={{ ...EXAMPLE_TRENDS, name } as unknown as InsightModel}
apiErrored
apiError={error}
refresh={() => {}}
@@ -296,7 +296,7 @@ export const AccessControlNoAccess: Story = {
name: 'Sales Analysis - Restricted',
description: 'This insight contains sensitive sales data.',
user_access_level: 'none',
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
rename={() => {}}
duplicate={() => {}}
@@ -321,7 +321,7 @@ export const AccessControlViewerAccess: Story = {
name: 'User Engagement Metrics - View Only',
description: 'You can view this insight but cannot edit it.',
user_access_level: AccessControlLevel.Viewer,
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
ribbonColor={insightColor}
updateColor={setInsightColor}
@@ -350,7 +350,7 @@ export const AccessControlEditorAccess: Story = {
name: 'Product Analytics - Full Access',
description: 'You can view, edit, and manage this insight.',
user_access_level: AccessControlLevel.Editor,
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
ribbonColor={insightColor}
updateColor={setInsightColor}
@@ -381,7 +381,7 @@ export const AccessControlManagerAccess: Story = {
name: 'Executive Dashboard - Manager Access',
description: 'You have full management permissions for this insight.',
user_access_level: AccessControlLevel.Manager,
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
ribbonColor={insightColor}
updateColor={setInsightColor}
@@ -413,7 +413,7 @@ export const AccessControlLegacyInsight: Story = {
name: 'Legacy Insight - No Access Control',
description: 'This insight was created before access control was implemented.',
// user_access_level is intentionally undefined to test fallback behavior
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
ribbonColor={insightColor}
updateColor={setInsightColor}
@@ -443,7 +443,7 @@ export const AccessControlMixedPermissions: Story = {
...EXAMPLE_TRENDS,
name: 'Restricted Data',
user_access_level: 'none',
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
rename={() => {}}
duplicate={() => {}}
@@ -458,7 +458,7 @@ export const AccessControlMixedPermissions: Story = {
...EXAMPLE_FUNNEL,
name: 'View Only Funnel',
user_access_level: AccessControlLevel.Viewer,
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
ribbonColor={insightColor}
updateColor={setInsightColor}
@@ -475,7 +475,7 @@ export const AccessControlMixedPermissions: Story = {
...EXAMPLE_RETENTION,
name: 'Editable Retention',
user_access_level: AccessControlLevel.Editor,
- } as unknown as QueryBasedInsightModel
+ } as unknown as InsightModel
}
ribbonColor={insightColor}
updateColor={setInsightColor}
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightCard.test.ts b/frontend/src/lib/components/Cards/InsightCard/InsightCard.test.ts
index 9b9297dfa928..8c91c52bafaf 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightCard.test.ts
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightCard.test.ts
@@ -1,17 +1,17 @@
import { NodeKind } from '~/queries/schema/schema-general'
-import { ChartDisplayType, DashboardPlacement, QueryBasedInsightModel } from '~/types'
+import { ChartDisplayType, DashboardPlacement, InsightModel } from '~/types'
import { shouldRenderInsightCardViz } from './InsightCard'
-const tableQuery = { kind: NodeKind.DataTableNode } as QueryBasedInsightModel['query']
+const tableQuery = { kind: NodeKind.DataTableNode } as InsightModel['query']
const autoSqlQuery = {
kind: NodeKind.DataVisualizationNode,
display: ChartDisplayType.Auto,
-} as QueryBasedInsightModel['query']
+} as InsightModel['query']
const canvasQuery = {
kind: NodeKind.DataVisualizationNode,
display: ChartDisplayType.ActionsLineGraph,
-} as QueryBasedInsightModel['query']
+} as InsightModel['query']
describe('InsightCard', () => {
it.each([
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx
index d30b976f3fec..c61ab40041d1 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightCard.tsx
@@ -41,7 +41,7 @@ import {
InsightColor,
InsightLogicProps,
InsightShortId,
- QueryBasedInsightModel,
+ InsightModel,
} from '~/types'
import type { AlertType } from 'products/alerts/frontend/types'
@@ -64,7 +64,7 @@ export function shouldRenderInsightCardViz({
placement: DashboardPlacement | 'SavedInsightGrid'
inView: boolean
isPageVisible: boolean
- query: QueryBasedInsightModel['query']
+ query: InsightModel['query']
}): boolean {
if (isStorybook || placement === DashboardPlacement.Export) {
return true
@@ -155,7 +155,7 @@ type AlertModalState = {
export interface InsightCardProps extends Resizeable {
/** Insight to display. */
- insight: QueryBasedInsightModel
+ insight: InsightModel
/** id of the dashboard the card is on (when the card is being displayed on a dashboard) **/
dashboardId?: DashboardType['id']
canEditDashboard?: boolean
@@ -175,7 +175,7 @@ export interface InsightCardProps extends Resizeable {
timedOut?: boolean
/** Whether the editing controls should be enabled or not. */
showEditingControls?: boolean
- refreshAfterDisplayOptionsChange?: (insight: QueryBasedInsightModel) => void
+ refreshAfterDisplayOptionsChange?: (insight: InsightModel) => void
/** While this tile is being resized: throttle canvas chart redraws instead of repainting on every frame. */
isResizing?: boolean
/** Whether the controls for showing details should be enabled or not. */
@@ -211,7 +211,7 @@ export interface InsightCardProps extends Resizeable {
className?: string
style?: React.CSSProperties
children?: React.ReactNode
- tile?: DashboardTile<QueryBasedInsightModel>
+ tile?: DashboardTile
/** survey opportunity for this insight */
surveyOpportunity?: boolean
/** Show a direct action for creating an anomaly detection alert for this saved insight. */
@@ -300,7 +300,7 @@ function InsightCardInternal(
const canPersistDisplayOptions = !!dashboardId && canEditInsight
const refreshAfterDisplayOptionsChangeRef = useRef(refreshAfterDisplayOptionsChange)
refreshAfterDisplayOptionsChangeRef.current = refreshAfterDisplayOptionsChange
- const handleRefreshAfterDisplayOptionsChange = useCallback((updatedInsight: QueryBasedInsightModel): void => {
+ const handleRefreshAfterDisplayOptionsChange = useCallback((updatedInsight: InsightModel): void => {
refreshAfterDisplayOptionsChangeRef.current?.(updatedInsight)
}, [])
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.stories.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.stories.tsx
index 8ee4e22c6076..b57d150b636f 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightDetails.stories.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightDetails.stories.tsx
@@ -1,7 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react'
import { DashboardFilter, TileFilters } from '~/queries/schema/schema-general'
-import { AnyPropertyFilter, PropertyFilterType, PropertyOperator, QueryBasedInsightModel } from '~/types'
+import { AnyPropertyFilter, PropertyFilterType, PropertyOperator, InsightModel } from '~/types'
import __dataTableEvents from '../../../../mocks/fixtures/api/projects/team_id/insights/dataTableEvents.json'
import __dataTableHogQL from '../../../../mocks/fixtures/api/projects/team_id/insights/dataTableHogQL.json'
@@ -21,12 +21,12 @@ import __userPaths from '../../../../mocks/fixtures/api/projects/team_id/insight
import { InsightDetails as InsightDetailsComponent } from './InsightDetails'
interface StoryArgs {
- insight: QueryBasedInsightModel
+ insight: InsightModel
filtersOverride?: DashboardFilter
tileFiltersOverride?: TileFilters | null
}
-function withOwnProperties(properties: AnyPropertyFilter[]): QueryBasedInsightModel {
+function withOwnProperties(properties: AnyPropertyFilter[]): InsightModel {
const insight = structuredClone(__trendsLine) as any
insight.query.source.properties = properties
return insight
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
index 7a5c572e722e..74437ec3c49a 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
@@ -66,7 +66,7 @@ import {
InsightColor,
InsightLogicProps,
InsightShortId,
- QueryBasedInsightModel,
+ InsightModel,
} from '~/types'
import {
@@ -115,8 +115,8 @@ interface InsightMetaProps extends Pick<
> {
/** Called when the user mousedowns on the card meta (drag handle) in view mode to enter edit mode. */
onDragHandleMouseDown?: React.MouseEventHandler<HTMLDivElement>
- tile?: DashboardTile<QueryBasedInsightModel>
- insight: QueryBasedInsightModel
+ tile?: DashboardTile
+ insight: InsightModel
areDetailsShown?: boolean
setAreDetailsShown?: React.Dispatch<React.SetStateAction<boolean>>
persistDisplayOptions?: (node: Node) => void
@@ -260,7 +260,7 @@ export function InsightMeta({
: true
// A killed run has no result to carry the scan, so it arrives on the query status instead.
- const queryScan: QueryBasedInsightModel['query_scan'] = insight.query_scan ?? insight.query_status?.query_scan
+ const queryScan: InsightModel['query_scan'] = insight.query_scan ?? insight.query_status?.query_scan
const scanFindings = queryScan?.analysis?.findings ?? []
const queryScanTooltip =
canEditInsight && queryScan && scanFindings.length > 0 ? (
diff --git a/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.ts b/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.ts
index 8443d0cba807..81b33ff606ab 100644
--- a/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.ts
+++ b/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.ts
@@ -5,8 +5,7 @@ import { accessLevelSatisfied } from 'lib/utils/accessControlUtils'
import { dashboardsModel } from '~/models/dashboardsModel'
import { AccessControlLevel, AccessControlResourceType, DashboardBasicType, DashboardTileBasicType } from '~/types'
-import type { Node } from '../../../../queries/schema/schema-general'
-import type { DashboardType, QueryBasedInsightModel } from '../../../../types'
+import type { DashboardType } from '../../../../types'
import type { DashboardWidgetPlacementDestination } from './DashboardWidgetPlacementMenu'
/** Stable key for kea; e.g. insight short_id, `text-${id}`, `button-${id}`, or `text-tile-${tileId}`. */
@@ -25,7 +24,7 @@ function canEditDestinationDashboard(d: DashboardBasicType): boolean {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface dashboardWidgetMenusLogicValues {
- nameSortedDashboards: (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[] // dashboardsModel
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[] // dashboardsModel
copyToDestinations: DashboardWidgetPlacementDestination[]
dashboardIdsWithThisWidget: Set<number>
}
@@ -40,10 +39,7 @@ export interface dashboardWidgetMenusLogicMeta {
dashboardId: number | null | undefined
) => Set<number>
copyToDestinations: (
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
- )[],
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[],
dashboardIdsWithThisWidget: Set<number>,
dashboardId: number | null | undefined
) => DashboardWidgetPlacementDestination[]
@@ -95,14 +91,7 @@ export const dashboardWidgetMenusLogic = kea<dashboardWidgetMenusLogicType>([
copyToDestinations: [
(s, p) => [s.nameSortedDashboards, s.dashboardIdsWithThisWidget, p.dashboardId],
(
- nameSortedDashboards: (
- | DashboardBasicType
- | import('~/types').DashboardType<
- import('~/types').QueryBasedInsightModel<
- import('../../../../queries/schema').Node<Record<string, any>>
- >
- >
- )[],
+ nameSortedDashboards: (DashboardBasicType | import('~/types').DashboardType)[],
dashboardIdsWithThisWidget: Set<number>,
dashboardId: number | null | undefined
): DashboardWidgetPlacementDestination[] => {
diff --git a/frontend/src/lib/components/Cards/InsightCard/insightCardImageCapture.ts b/frontend/src/lib/components/Cards/InsightCard/insightCardImageCapture.ts
index 8dddbd1b0764..90811976cb7f 100644
--- a/frontend/src/lib/components/Cards/InsightCard/insightCardImageCapture.ts
+++ b/frontend/src/lib/components/Cards/InsightCard/insightCardImageCapture.ts
@@ -1,6 +1,6 @@
import { CaptureImageTarget } from 'lib/components/Scenes/InsightOrDashboard/captureImageLogic'
-import { DashboardTile, QueryBasedInsightModel } from '~/types'
+import { DashboardTile, InsightModel } from '~/types'
/**
* Marks each card with a key of its own. A dashboard renders many cards, so a capture that looked for a
@@ -20,10 +20,7 @@ export function dashboardTileScreenshotKey(dashboardId?: number | null): string
/** The card's own chrome: the controls in the corner, the resize handles, and the grid's own handles. */
const CARD_CHROME_SELECTOR = '.CardMeta__controls, .handle, .react-resizable-handle'
-export function insightCardKey(
- insight: Pick<QueryBasedInsightModel, 'short_id'>,
- tile?: Pick<DashboardTile<QueryBasedInsightModel>, 'id'>
-): string {
+export function insightCardKey(insight: Pick<InsightModel, 'short_id'>, tile?: Pick<DashboardTile, 'id'>): string {
// The same insight can sit on a dashboard more than once, so the tile identifies the card when there is one.
return tile?.id != null ? `tile-${tile.id}` : `insight-${insight.short_id}`
}
@@ -35,8 +32,8 @@ export function insightCardKey(
* "⋯" menu sits in the corner at all times, and a picture of a menu helps nobody.
*/
export function insightCardCaptureTarget(
- insight: Pick<QueryBasedInsightModel, 'short_id' | 'name' | 'derived_name'>,
- tile?: Pick<DashboardTile<QueryBasedInsightModel>, 'id'>,
+ insight: Pick<InsightModel, 'short_id' | 'name' | 'derived_name'>,
+ tile?: Pick<DashboardTile, 'id'>,
dashboardId?: number | null
): CaptureImageTarget {
return {
diff --git a/frontend/src/lib/components/Cards/TextCard/TextCard.stories.tsx b/frontend/src/lib/components/Cards/TextCard/TextCard.stories.tsx
index ffed3125c85f..d20f12942cf9 100644
--- a/frontend/src/lib/components/Cards/TextCard/TextCard.stories.tsx
+++ b/frontend/src/lib/components/Cards/TextCard/TextCard.stories.tsx
@@ -1,6 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react'
-import { DashboardPlacement, DashboardTile, InsightColor, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile, InsightColor } from '~/types'
import { TextCard } from './TextCard'
import { WORD_ART_PRESETS } from './WordArt/wordArtPresets'
@@ -13,7 +13,7 @@ const meta: Meta = {
export default meta
type Story = StoryObj<{}>
-const makeTextTile = (body: string, color: InsightColor | null = null): DashboardTile<QueryBasedInsightModel> => {
+const makeTextTile = (body: string, color: InsightColor | null = null): DashboardTile => {
return {
id: 1,
text: {
diff --git a/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx b/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx
index 1a322952f1b5..cdb9cd4a989a 100644
--- a/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx
+++ b/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx
@@ -2,13 +2,11 @@ import '@testing-library/jest-dom'
import { fireEvent, render } from '@testing-library/react'
-import { DashboardPlacement, DashboardTile, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile } from '~/types'
import { TextCard, TextContent } from './TextCard'
-const makeTextTile = (
- overrides: Partial<DashboardTile<QueryBasedInsightModel>> = {}
-): DashboardTile<QueryBasedInsightModel> =>
+const makeTextTile = (overrides: Partial<DashboardTile> = {}): DashboardTile =>
({
id: 1,
text: {
@@ -18,7 +16,7 @@ const makeTextTile = (
layouts: {},
color: null,
...overrides,
- }) as DashboardTile<QueryBasedInsightModel>
+ }) as DashboardTile
describe('TextCard', () => {
it('shows the more button when placement is not Public', () => {
diff --git a/frontend/src/lib/components/Cards/TextCard/TextCard.tsx b/frontend/src/lib/components/Cards/TextCard/TextCard.tsx
index 678018bd63dc..be39462ebd91 100644
--- a/frontend/src/lib/components/Cards/TextCard/TextCard.tsx
+++ b/frontend/src/lib/components/Cards/TextCard/TextCard.tsx
@@ -13,12 +13,12 @@ import { useRichContentEditor } from 'lib/components/RichContentEditor'
import { More, MoreProps } from 'lib/lemon-ui/LemonButton/More'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
-import { DashboardPlacement, DashboardTile, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile } from '~/types'
import { TEXT_CARD_MARKDOWN_READONLY_EXTENSIONS, textCardConverter } from './textCardMarkdown'
interface TextCardProps extends React.HTMLAttributes<HTMLDivElement>, Resizeable {
- textTile: DashboardTile<QueryBasedInsightModel>
+ textTile: DashboardTile
placement: DashboardPlacement
children?: JSX.Element
/** Whether hovering near the card edge should hint that edit mode is available. */
diff --git a/frontend/src/lib/components/Cards/TextCard/TextCardModal.tsx b/frontend/src/lib/components/Cards/TextCard/TextCardModal.tsx
index f0021a06dd6e..592e40c2ade9 100644
--- a/frontend/src/lib/components/Cards/TextCard/TextCardModal.tsx
+++ b/frontend/src/lib/components/Cards/TextCard/TextCardModal.tsx
@@ -11,7 +11,7 @@ import { LemonSwitch } from 'lib/lemon-ui/LemonSwitch'
import { DialogClose, DialogPrimitive, DialogPrimitiveTitle } from 'lib/ui/DialogPrimitive/DialogPrimitive'
import { cn } from 'lib/utils/css-classes'
-import { DashboardTileIdOrNew, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardTileIdOrNew, DashboardType } from '~/types'
export function TextCardModal({
isOpen,
@@ -21,7 +21,7 @@ export function TextCardModal({
}: {
isOpen: boolean
onClose: () => void
- dashboard: DashboardType<QueryBasedInsightModel>
+ dashboard: DashboardType
textTileId: DashboardTileIdOrNew
}): JSX.Element {
const isNewTile = textTileId === null
diff --git a/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.test.ts b/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.test.ts
index 28535f9c9f0e..5d770b7231fc 100644
--- a/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.test.ts
+++ b/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.test.ts
@@ -4,11 +4,11 @@ import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
import { initKeaTests } from '~/test/init'
-import { AccessControlLevel, DashboardType, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardType } from '~/types'
import { textCardModalLogic } from './textCardModalLogic'
-const makeDashboard = (body: string = 'existing text'): DashboardType<QueryBasedInsightModel> =>
+const makeDashboard = (body: string = 'existing text'): DashboardType =>
({
id: 123,
name: 'Test dashboard',
@@ -34,7 +34,7 @@ const makeDashboard = (body: string = 'existing text'): DashboardType<QueryBased
filters: {},
tags: [],
user_access_level: AccessControlLevel.Editor,
- }) as DashboardType<QueryBasedInsightModel>
+ }) as DashboardType
describe('textCardModalLogic', () => {
beforeEach(() => {
diff --git a/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.ts b/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.ts
index ead23c5f25e5..82ce688ab962 100644
--- a/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.ts
+++ b/frontend/src/lib/components/Cards/TextCard/textCardModalLogic.ts
@@ -6,7 +6,7 @@ import posthog from 'posthog-js'
import { lemonToast } from '@posthog/lemon-ui'
import { dashboardsModel } from '~/models/dashboardsModel'
-import { DashboardTile, DashboardTileIdOrNew, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardTile, DashboardTileIdOrNew, DashboardType } from '~/types'
import { getImageOnlyTextCardImage } from 'products/dashboards/frontend/components/ImageTile/imageTileUtils'
@@ -20,7 +20,7 @@ export interface TextTileForm {
export type TextCardTileType = 'text' | 'image'
export interface TextCardModalProps {
- dashboard: DashboardType<QueryBasedInsightModel>
+ dashboard: DashboardType
textTileId: DashboardTileIdOrNew
onClose: () => void
tileType: TextCardTileType
@@ -28,7 +28,7 @@ export interface TextCardModalProps {
const MAX_TEXT_CARD_BODY_LENGTH = 4000
-const getExistingTextTile = (dashboard: DashboardType<QueryBasedInsightModel>, textTileId: number): TextTileForm => {
+const getExistingTextTile = (dashboard: DashboardType, textTileId: number): TextTileForm => {
const tile = dashboard.tiles?.find((tt) => tt.id === textTileId)
return {
body: tile?.text?.body || '',
diff --git a/frontend/src/lib/components/SceneDashboardChoice/sceneDashboardChoiceModalLogic.ts b/frontend/src/lib/components/SceneDashboardChoice/sceneDashboardChoiceModalLogic.ts
index 31cd0d811f36..53c75f5a2546 100644
--- a/frontend/src/lib/components/SceneDashboardChoice/sceneDashboardChoiceModalLogic.ts
+++ b/frontend/src/lib/components/SceneDashboardChoice/sceneDashboardChoiceModalLogic.ts
@@ -10,8 +10,7 @@ import { userLogic } from 'scenes/userLogic'
import { dashboardsModel } from '~/models/dashboardsModel'
import { DashboardBasicType } from '~/types'
-import type { Node } from '../../../queries/schema/schema-general'
-import type { DashboardType, QueryBasedInsightModel, TeamPublicType, TeamType, UserType } from '../../../types'
+import type { DashboardType, TeamPublicType, TeamType, UserType } from '../../../types'
export type DashboardCompatibleScenes = Scene.ProjectHomepage | Scene.Person | Scene.Group
@@ -27,11 +26,11 @@ export const sceneDescription: Record<DashboardCompatibleScenes, string> = {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface sceneDashboardChoiceModalLogicValues {
- nameSortedDashboards: (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[] // dashboardsModel
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[] // dashboardsModel
currentTeam: TeamPublicType | TeamType | null // teamLogic
user: UserType | null // userLogic
currentDashboardId: number | null
- dashboards: (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[]
+ dashboards: (DashboardBasicType | DashboardType)[]
isOpen: boolean
searchTerm: string | null
}
@@ -66,11 +65,8 @@ export interface sceneDashboardChoiceModalLogicMeta {
currentDashboardId: (currentTeam: TeamPublicType | TeamType | null, user: UserType | null) => number | null
dashboards: (
searchTerm: string | null,
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
- )[]
- ) => (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[]
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[]
+ ) => (DashboardBasicType | DashboardType)[]
}
}
@@ -126,17 +122,7 @@ export const sceneDashboardChoiceModalLogic = kea<sceneDashboardChoiceModalLogic
],
dashboards: [
(s) => [s.searchTerm, s.nameSortedDashboards],
- (
- searchTerm: string | null,
- dashboards: (
- | DashboardBasicType
- | import('~/types').DashboardType<
- import('~/types').QueryBasedInsightModel<
- import('../../../queries/schema').Node<Record<string, any>>
- >
- >
- )[]
- ) => {
+ (searchTerm: string | null, dashboards: (DashboardBasicType | import('~/types').DashboardType)[]) => {
dashboards = dashboards
.filter((d) => !d.deleted)
.sort((a, b) => (a.name ?? 'Untitled').localeCompare(b.name ?? 'Untitled'))
diff --git a/frontend/src/lib/components/Scenes/SceneSubscribeButton.tsx b/frontend/src/lib/components/Scenes/SceneSubscribeButton.tsx
index 09f5ab0cf393..13e679d420a5 100644
--- a/frontend/src/lib/components/Scenes/SceneSubscribeButton.tsx
+++ b/frontend/src/lib/components/Scenes/SceneSubscribeButton.tsx
@@ -7,7 +7,7 @@ import { IconWithCount } from 'lib/lemon-ui/icons/icons'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { userLogic } from 'scenes/userLogic'
-import { AvailableFeature, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { AvailableFeature, InsightShortId, InsightModel } from '~/types'
import { subscriptionsLogic } from 'products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic'
import {
@@ -18,7 +18,7 @@ import {
import { SceneDataAttrKeyProps } from './utils'
interface SceneSubscribeButtonProps extends SubscriptionBaseProps, SceneDataAttrKeyProps {
- insight?: Partial<QueryBasedInsightModel>
+ insight?: Partial<InsightModel>
dashboardId?: number
}
diff --git a/frontend/src/lib/components/Sharing/SharingModal.stories.tsx b/frontend/src/lib/components/Sharing/SharingModal.stories.tsx
index 7e839bed04e6..700710cd892f 100644
--- a/frontend/src/lib/components/Sharing/SharingModal.stories.tsx
+++ b/frontend/src/lib/components/Sharing/SharingModal.stories.tsx
@@ -9,11 +9,11 @@ import { useStorybookMocks } from '~/mocks/browser'
import { useAvailableFeatures } from '~/mocks/features'
import type { MockResolverInfo } from '~/mocks/utils'
import { examples } from '~/queries/examples'
-import { AvailableFeature, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { AvailableFeature, InsightShortId, InsightModel } from '~/types'
import { SharingModal, SharingModalProps } from './SharingModal'
-const fakeInsight: Partial<QueryBasedInsightModel> = {
+const fakeInsight: Partial<InsightModel> = {
id: 123,
short_id: 'insight123' as InsightShortId,
query: examples.InsightTrendsQuery,
diff --git a/frontend/src/lib/components/Sharing/SharingModal.test.tsx b/frontend/src/lib/components/Sharing/SharingModal.test.tsx
index 7e663e6fc750..2dac66bf4c53 100644
--- a/frontend/src/lib/components/Sharing/SharingModal.test.tsx
+++ b/frontend/src/lib/components/Sharing/SharingModal.test.tsx
@@ -11,7 +11,7 @@ import { useAvailableFeatures } from '~/mocks/features'
import { useMocks } from '~/mocks/jest'
import { NodeKind } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
-import { InsightShortId, QueryBasedInsightModel } from '~/types'
+import { InsightShortId, InsightModel } from '~/types'
import { AvailableFeature } from '~/types'
import { sharingLogic } from './sharingLogic'
@@ -173,7 +173,7 @@ describe('SharingModal (dashboard)', () => {
})
describe('SharingModal (insight)', () => {
- const fakeInsight: Partial<QueryBasedInsightModel> = {
+ const fakeInsight: Partial<InsightModel> = {
id: defaultInsightId,
short_id: insightShortId,
name: 'My insight',
diff --git a/frontend/src/lib/components/Sharing/SharingModal.tsx b/frontend/src/lib/components/Sharing/SharingModal.tsx
index 44bae06f3d8a..15fa267325de 100644
--- a/frontend/src/lib/components/Sharing/SharingModal.tsx
+++ b/frontend/src/lib/components/Sharing/SharingModal.tsx
@@ -38,13 +38,7 @@ import { nodeKindToInsightType } from '~/queries/nodes/InsightQuery/utils/queryN
import { AnyResponseType, Node } from '~/queries/schema/schema-general'
import { NodeKind } from '~/queries/schema/schema-general'
import { isDataTableNode, isDataVisualizationNode, isInsightVizNode } from '~/queries/utils'
-import {
- AccessControlLevel,
- AccessControlResourceType,
- AvailableFeature,
- InsightShortId,
- QueryBasedInsightModel,
-} from '~/types'
+import { AccessControlLevel, AccessControlResourceType, AvailableFeature, InsightShortId, InsightModel } from '~/types'
import { InsightType } from '~/types'
import { upgradeModalLogic } from '../UpgradeModal/upgradeModalLogic'
@@ -77,7 +71,7 @@ export const SHARING_MODAL_WIDTH = 640
export interface SharingModalBaseProps {
dashboardId?: number
insightShortId?: InsightShortId
- insight?: Partial<QueryBasedInsightModel>
+ insight?: Partial<InsightModel>
cachedResults?: AnyResponseType
recordingId?: string
notebookShortId?: string
@@ -548,7 +542,7 @@ function createRenderQuerySnippet({
}: {
renderQueryUrl: string
iframeId: string
- cachedResults: AnyResponseType | Partial<QueryBasedInsightModel> | null | undefined
+ cachedResults: AnyResponseType | Partial<InsightModel> | null | undefined
query: Node | null | undefined
}): string {
const preparedResults = prepareCachedResultsForSnippet(cachedResults)
@@ -620,8 +614,8 @@ function indentMultiline(value: string, indent: number): string {
}
function prepareCachedResultsForSnippet(
- cachedResults: AnyResponseType | Partial<QueryBasedInsightModel> | null | undefined
-): AnyResponseType | Partial<QueryBasedInsightModel> | null {
+ cachedResults: AnyResponseType | Partial<InsightModel> | null | undefined
+): AnyResponseType | Partial<InsightModel> | null {
if (!cachedResults) {
return null
}
@@ -755,7 +749,7 @@ SharingModal.open = (props: SharingModalBaseProps) => {
* and unsaved/draft insights (pass the raw query object).
*/
export function getInsightDefinitionUrl(
- insight: Pick<QueryBasedInsightModel, 'query'> | { query: Node<Record<string, any>> },
+ insight: Pick<InsightModel, 'query'> | { query: Node<Record<string, any>> },
baseUrl: string
): string {
if (!insight?.query) {
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 5f285539bb78..bea003439f41 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -113,7 +113,7 @@ import {
PropertyDefinition,
PropertyDefinitionType,
PropertyFilterType,
- QueryBasedInsightModel,
+ InsightModel,
SessionRecordingPlaylistType,
TeamType,
} from '~/types'
@@ -1966,8 +1966,8 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
endpoint: combineUrl(`api/environments/${teamId}/insights/`, {
saved: true,
}).url,
- getName: (insight: QueryBasedInsightModel) => insight.name,
- getValue: (insight: QueryBasedInsightModel) => insight.short_id,
+ getName: (insight: InsightModel) => insight.name,
+ getValue: (insight: InsightModel) => insight.short_id,
getPopoverHeader: () => `Insights`,
},
{
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
index 6b62c1309b2b..bde334a6d14b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
@@ -68,7 +68,7 @@ import {
PropertyDefinition,
PropertyDefinitionType,
PropertyFilterType,
- QueryBasedInsightModel,
+ InsightModel,
SessionRecordingPlaylistType,
TeamType,
} from '~/types'
@@ -935,8 +935,8 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
endpoint: combineUrl(`api/environments/${teamId}/insights/`, {
saved: true,
}).url,
- getName: (insight: QueryBasedInsightModel) => insight.name,
- getValue: (insight: QueryBasedInsightModel) => insight.short_id,
+ getName: (insight: InsightModel) => insight.name,
+ getValue: (insight: InsightModel) => insight.short_id,
getPopoverHeader: () => `Insights`,
},
{
diff --git a/frontend/src/lib/components/TerraformExporter/dashboardHclExporter.ts b/frontend/src/lib/components/TerraformExporter/dashboardHclExporter.ts
index 49a6d19e7b4c..3c9b58d5dc4f 100644
--- a/frontend/src/lib/components/TerraformExporter/dashboardHclExporter.ts
+++ b/frontend/src/lib/components/TerraformExporter/dashboardHclExporter.ts
@@ -81,7 +81,7 @@ const DASHBOARD_EXPORTER: ResourceExporter<Partial<DashboardBasicType>, Dashboar
}
export function generateDashboardHCL(
- dashboard: Partial<DashboardType<any>>,
+ dashboard: Partial<DashboardType>,
options: DashboardHclExportOptions = {}
): DashboardExportResult {
const allWarnings: string[] = []
diff --git a/frontend/src/lib/components/TerraformExporter/dashboardLayoutHclExporter.ts b/frontend/src/lib/components/TerraformExporter/dashboardLayoutHclExporter.ts
index a3448af61790..c43294b84197 100644
--- a/frontend/src/lib/components/TerraformExporter/dashboardLayoutHclExporter.ts
+++ b/frontend/src/lib/components/TerraformExporter/dashboardLayoutHclExporter.ts
@@ -11,7 +11,7 @@ export interface DashboardLayoutHclExportOptions extends HclExportOptions {
insightIdReplacements: Map<number, string>
}
-function formatTileObject(tile: DashboardTile<any>, insightIdReplacements: Map<number, string>): string[] {
+function formatTileObject(tile: DashboardTile, insightIdReplacements: Map<number, string>): string[] {
const lines: string[] = []
lines.push(' {')
@@ -43,7 +43,7 @@ function formatTileObject(tile: DashboardTile<any>, insightIdReplacements: Map<n
/**
* @see https://registry.terraform.io/providers/PostHog/posthog/latest/docs/resources/dashboard_layout
*/
-const DASHBOARD_LAYOUT_FIELD_MAPPINGS: FieldMapping<Partial<DashboardType<any>>, DashboardLayoutHclExportOptions>[] = [
+const DASHBOARD_LAYOUT_FIELD_MAPPINGS: FieldMapping<Partial<DashboardType>, DashboardLayoutHclExportOptions>[] = [
{
source: 'id',
target: 'dashboard_id',
@@ -75,7 +75,7 @@ function validateDashboardLayout(): string[] {
return []
}
-const DASHBOARD_LAYOUT_EXPORTER: ResourceExporter<Partial<DashboardType<any>>, DashboardLayoutHclExportOptions> = {
+const DASHBOARD_LAYOUT_EXPORTER: ResourceExporter<Partial<DashboardType>, DashboardLayoutHclExportOptions> = {
resourceType: 'posthog_dashboard_layout',
resourceLabel: 'dashboard_layout',
fieldMappings: DASHBOARD_LAYOUT_FIELD_MAPPINGS,
@@ -85,7 +85,7 @@ const DASHBOARD_LAYOUT_EXPORTER: ResourceExporter<Partial<DashboardType<any>>, D
}
export function generateDashboardLayoutHCL(
- dashboard: Partial<DashboardType<any>>,
+ dashboard: Partial<DashboardType>,
options: DashboardLayoutHclExportOptions
): HclExportResult {
return generateHCL(dashboard, DASHBOARD_LAYOUT_EXPORTER, options)
diff --git a/frontend/src/lib/components/TerraformExporter/useTerraformExport.ts b/frontend/src/lib/components/TerraformExporter/useTerraformExport.ts
index 2ff8c80322bd..5803bfaac6b0 100644
--- a/frontend/src/lib/components/TerraformExporter/useTerraformExport.ts
+++ b/frontend/src/lib/components/TerraformExporter/useTerraformExport.ts
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
import { teamLogic } from 'scenes/teamLogic'
-import { DashboardType, HogFunctionType, InsightModel, QueryBasedInsightModel } from '~/types'
+import { DashboardType, HogFunctionType, InsightModel } from '~/types'
import { buildAlertFilterConfig } from 'products/alerts/frontend/logic/alertNotifications'
import { AlertType } from 'products/alerts/frontend/types'
@@ -17,7 +17,7 @@ export type TerraformExportResult = DashboardExportResult | InsightExportResult
export type TerraformExportResource =
| { type: 'insight'; data: Partial<InsightModel> }
- | { type: 'dashboard'; data: DashboardType<QueryBasedInsightModel> }
+ | { type: 'dashboard'; data: DashboardType }
export interface TerraformExportState {
loading: boolean
@@ -123,7 +123,7 @@ async function exportInsight(
}
async function exportDashboard(
- dashboard: DashboardType<QueryBasedInsightModel>,
+ dashboard: DashboardType,
checkStale: () => boolean,
projectId: number
): Promise<DashboardExportResult> {
diff --git a/frontend/src/lib/utils/deleteWithUndo.tsx b/frontend/src/lib/utils/deleteWithUndo.tsx
index 0709f8b6aeb5..966842e52b21 100644
--- a/frontend/src/lib/utils/deleteWithUndo.tsx
+++ b/frontend/src/lib/utils/deleteWithUndo.tsx
@@ -3,7 +3,7 @@ import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
import { deleteFromTree, refreshTreeItem } from '~/layout/panel-layout/ProjectTree/projectTreeLogic'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
export async function deleteWithUndo<T extends Record<string, any>>({
undo = false,
@@ -51,9 +51,9 @@ export async function deleteInsightWithUndo({
}: {
undo?: boolean
endpoint: string
- object: QueryBasedInsightModel
- idField?: keyof QueryBasedInsightModel
- callback?: (undo: boolean, object: QueryBasedInsightModel) => void
+ object: InsightModel
+ idField?: keyof InsightModel
+ callback?: (undo: boolean, object: InsightModel) => void
}): Promise<void> {
try {
await api.update(`api/${props.endpoint}/${props.object[props.idField || 'id']}`, {
diff --git a/frontend/src/lib/utils/eventUsageLogic.test.ts b/frontend/src/lib/utils/eventUsageLogic.test.ts
index 8ad294019f54..6e0ce3390372 100644
--- a/frontend/src/lib/utils/eventUsageLogic.test.ts
+++ b/frontend/src/lib/utils/eventUsageLogic.test.ts
@@ -22,7 +22,6 @@ import {
FilterLogicalOperator,
FunnelVizType,
PropertyFilterType,
- type QueryBasedInsightModel,
StepOrderValue,
} from '~/types'
@@ -394,9 +393,7 @@ describe('eventUsageLogic', () => {
})
describe('dashboardViewedProperties', () => {
- const dashboard = (
- tiles: Partial<DashboardTile<QueryBasedInsightModel>>[]
- ): DashboardType<QueryBasedInsightModel> =>
+ const dashboard = (tiles: Partial<DashboardTile>[]): DashboardType =>
({
id: 7,
created_at: '2026-01-01T00:00:00Z',
@@ -405,12 +402,12 @@ describe('eventUsageLogic', () => {
creation_mode: 'default',
created_by: { uuid: 'creator' },
tiles,
- }) as unknown as DashboardType<QueryBasedInsightModel>
+ }) as unknown as DashboardType
- const insightTile = (query: unknown, is_sample = false): Partial<DashboardTile<QueryBasedInsightModel>> =>
- ({ insight: { query, is_sample } }) as unknown as Partial<DashboardTile<QueryBasedInsightModel>>
+ const insightTile = (query: unknown, is_sample = false): Partial<DashboardTile> =>
+ ({ insight: { query, is_sample } }) as unknown as Partial<DashboardTile>
- const cases: [string, Partial<DashboardTile<QueryBasedInsightModel>>[], Record<string, unknown>][] = [
+ const cases: [string, Partial<DashboardTile>[], Record<string, unknown>][] = [
['no tiles', [], { item_count: 0, sample_items_count: 0 }],
[
'an insight tile with a query',
@@ -431,9 +428,7 @@ describe('eventUsageLogic', () => {
],
[
'text and widget tiles',
- [{ text: { body: 'hi' } }, { text: { body: 'there' } }, { widget: {} }] as Partial<
- DashboardTile<QueryBasedInsightModel>
- >[],
+ [{ text: { body: 'hi' } }, { text: { body: 'there' } }, { widget: {} }] as Partial<DashboardTile>[],
{ item_count: 3, text_tiles_count: 2, widget_tiles_count: 1 },
],
]
@@ -464,7 +459,7 @@ describe('eventUsageLogic', () => {
]
it.each(viewerCases)('reports viewer_is_creator when %s', (_, created_by, viewerUuid, expected) => {
- const withCreator = { ...dashboard([]), created_by } as unknown as DashboardType<QueryBasedInsightModel>
+ const withCreator = { ...dashboard([]), created_by } as unknown as DashboardType
expect(dashboardViewedProperties(withCreator, null, viewerUuid)).toMatchObject({
viewer_is_creator: expected,
created_by_system: created_by === null,
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.ts
index 064150bce1ec..d38308883c00 100644
--- a/frontend/src/lib/utils/eventUsageLogic.ts
+++ b/frontend/src/lib/utils/eventUsageLogic.ts
@@ -73,7 +73,7 @@ import {
OnboardingStepKey,
ProductTour,
PropertyFilterType,
- QueryBasedInsightModel,
+ InsightModel,
type SDK,
Survey,
SurveyQuestionType,
@@ -600,7 +600,7 @@ export function getEventPropertiesForExperiment(experiment: Experiment): object
}
}
-function sanitizeInsight(insight: Partial<QueryBasedInsightModel> | null): object | undefined {
+function sanitizeInsight(insight: Partial<InsightModel> | null): object | undefined {
if (!insight) {
return undefined
}
@@ -618,7 +618,7 @@ function sanitizeInsight(insight: Partial<QueryBasedInsightModel> | null): objec
return sanitizedInsight
}
-function sanitizeTile(tile: DashboardTile<QueryBasedInsightModel> | null): object | undefined {
+function sanitizeTile(tile: DashboardTile | null): object | undefined {
if (!tile) {
return undefined
}
@@ -629,7 +629,7 @@ function sanitizeTile(tile: DashboardTile<QueryBasedInsightModel> | null): objec
}
}
-function sanitizeDashboard(dashboard: DashboardType<QueryBasedInsightModel> | null): object | null {
+function sanitizeDashboard(dashboard: DashboardType | null): object | null {
if (!dashboard) {
return null
}
@@ -724,12 +724,12 @@ function increment(counts: Record<string, any>, key: string): void {
counts[key] = (counts[key] || 0) + 1
}
-function insightTileCountKey(tile: DashboardTile<QueryBasedInsightModel>): string {
+function insightTileCountKey(tile: DashboardTile): string {
const query = isNodeWithSource(tile.insight?.query) ? tile.insight.query.source : tile.insight?.query
return `${query?.kind || !!tile.text ? 'text' : 'empty'}_count`
}
-function countDashboardTiles(tiles: DashboardTile<QueryBasedInsightModel>[], properties: Record<string, any>): void {
+function countDashboardTiles(tiles: DashboardTile[], properties: Record<string, any>): void {
for (const tile of tiles) {
if (tile.insight) {
increment(properties, insightTileCountKey(tile))
@@ -747,7 +747,7 @@ function countDashboardTiles(tiles: DashboardTile<QueryBasedInsightModel>[], pro
}
export function dashboardViewedProperties(
- dashboard: DashboardType<QueryBasedInsightModel>,
+ dashboard: DashboardType,
lastRefreshed: Dayjs | null,
viewerUuid: string | undefined
): Record<string, any> {
@@ -1021,38 +1021,38 @@ export interface eventUsageLogicActions {
source: 'header'
}
reportDashboardBreakdownColorsSaved: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
manualCount: number,
autoCount: number,
breakdownTypes: string[]
) => {
autoCount: number
breakdownTypes: string[]
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
manualCount: number
}
reportDashboardColorThemeSet: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
themeId: number | null
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
themeId: number | null
}
reportDashboardDateRangeChanged: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
dateFrom?: string | Dayjs | null,
dateTo?: string | Dayjs | null
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
dateFrom: string | Dayjs | null | undefined
dateTo: string | Dayjs | null | undefined
}
reportDashboardEditModeDiscardPrompt: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
action: 'discarded' | 'kept_editing' | 'shown'
) => {
action: 'discarded' | 'kept_editing' | 'shown'
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
}
reportDashboardEmptyAddChartClicked: (dashboardId: number | undefined) => {
dashboardId: number | undefined
@@ -1084,12 +1084,12 @@ export interface eventUsageLogicActions {
exportFormat: ExporterFormat
}
reportDashboardFiltersChanged: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
changeType: DashboardFilterChangeType,
properties: Record<string, boolean | number | string | null | undefined>
) => {
changeType: DashboardFilterChangeType
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
properties: Record<string, boolean | number | string | null | undefined>
}
reportDashboardFrontEndUpdate: (
@@ -1146,20 +1146,20 @@ export interface eventUsageLogicActions {
source: DashboardEventSource
}
reportDashboardLayoutEditModeEntered: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
source: DashboardEventSource,
layoutZoom: number | null
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
layoutZoom: number | null
source: DashboardEventSource
}
reportDashboardLayoutZoomChanged: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
layoutZoom: number,
source: 'button' | 'shortcut'
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
layoutZoom: number
source: 'button' | 'shortcut'
}
@@ -1171,13 +1171,13 @@ export interface eventUsageLogicActions {
loadingMilliseconds: number
}
reportDashboardModeToggled: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
mode: DashboardMode | null,
source: DashboardEventSource | null,
layoutZoom: number | null,
layoutEditMode?: boolean
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
layoutEditMode: boolean | undefined
layoutZoom: number | null
mode: DashboardMode | null
@@ -1199,8 +1199,8 @@ export interface eventUsageLogicActions {
pinned: boolean
source: DashboardEventSource
}
- reportDashboardPropertiesChanged: (dashboard: DashboardType<QueryBasedInsightModel> | null) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ reportDashboardPropertiesChanged: (dashboard: DashboardType | null) => {
+ dashboard: DashboardType | null
}
reportDashboardRefreshed: (
dashboardId: number,
@@ -1254,7 +1254,7 @@ export interface eventUsageLogicActions {
}
reportDashboardTileRefreshed: (
dashboardId: number,
- tile: DashboardTile<QueryBasedInsightModel>,
+ tile: DashboardTile,
filters: Record<string, any>,
variables: Record<string, any>,
refreshDurationMs: number,
@@ -1264,7 +1264,7 @@ export interface eventUsageLogicActions {
filters: Record<string, any>
individualRefresh: boolean
refreshDurationMs: number
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
variables: Record<string, any>
}
reportDashboardTileRepositioned: (
@@ -1277,11 +1277,11 @@ export interface eventUsageLogicActions {
layoutZoom: number
}
reportDashboardViewed: (
- dashboard: DashboardType<QueryBasedInsightModel>,
+ dashboard: DashboardType,
lastRefreshed: Dayjs | null,
delay?: number
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ dashboard: DashboardType
delay: number | undefined
lastRefreshed: Dayjs | null
}
@@ -1964,12 +1964,12 @@ export interface eventUsageLogicActions {
insightId: number | null
}
reportInsightSaved: (
- insight: Partial<QueryBasedInsightModel> | null,
+ insight: Partial<InsightModel> | null,
query: Node | null,
isNewInsight: boolean,
saveType: 'save' | 'save_as'
) => {
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null
isNewInsight: boolean
query: Node<Record<string, any>> | null
saveType: 'save' | 'save_as'
@@ -1978,13 +1978,13 @@ export interface eventUsageLogicActions {
query: Node<Record<string, any>> | null
}
reportInsightViewed: (
- insightModel: Partial<QueryBasedInsightModel>,
+ insightModel: Partial<InsightModel>,
query: Node | null,
isFirstLoad: boolean,
delay?: number
) => {
delay: number | undefined
- insightModel: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insightModel: Partial<InsightModel<Node<Record<string, any>>>>
isFirstLoad: boolean
query: Node<Record<string, any>> | null
}
@@ -2248,11 +2248,11 @@ export interface eventUsageLogicActions {
value: true
}
reportRemovedInsightFromDashboard: (
- insight: Partial<QueryBasedInsightModel> | null,
+ insight: Partial<InsightModel> | null,
dashboardId: number | null
) => {
dashboardId: number | null
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null
}
reportRevenueAnalyticsDataSourceDisabled: (sourceType: string) => {
sourceType: string
@@ -2300,11 +2300,11 @@ export interface eventUsageLogicActions {
tab: string
}
reportSavedInsightToDashboard: (
- insight: Partial<QueryBasedInsightModel> | null,
+ insight: Partial<InsightModel> | null,
dashboardId: number | null
) => {
dashboardId: number | null
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null
}
reportSessionTableVersionUpdated: (version: string) => {
version: string
@@ -2616,13 +2616,13 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
reportInsightMetadataAiGenerationFailed: (queryKind: NodeKind) => ({ queryKind }),
reportInsightStarted: (query: Node | null) => ({ query }),
reportInsightSaved: (
- insight: Partial<QueryBasedInsightModel> | null,
+ insight: Partial<InsightModel> | null,
query: Node | null,
isNewInsight: boolean,
saveType: 'save' | 'save_as'
) => ({ insight, query, isNewInsight, saveType }),
reportInsightViewed: (
- insightModel: Partial<QueryBasedInsightModel>,
+ insightModel: Partial<InsightModel>,
query: Node | null,
isFirstLoad: boolean,
delay?: number
@@ -2706,29 +2706,25 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
oldPropertyType?: string,
newPropertyType?: string
) => ({ action, totalProperties, oldPropertyType, newPropertyType }),
- reportDashboardViewed: (
- dashboard: DashboardType<QueryBasedInsightModel>,
- lastRefreshed: Dayjs | null,
- delay?: number
- ) => ({
+ reportDashboardViewed: (dashboard: DashboardType, lastRefreshed: Dayjs | null, delay?: number) => ({
dashboard,
delay,
lastRefreshed,
}),
reportDashboardModeToggled: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
mode: DashboardMode | null,
source: DashboardEventSource | null,
layoutZoom: number | null,
layoutEditMode?: boolean
) => ({ dashboard, mode, source, layoutZoom, layoutEditMode }),
reportDashboardLayoutEditModeEntered: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
source: DashboardEventSource,
layoutZoom: number | null
) => ({ dashboard, source, layoutZoom }),
reportDashboardFiltersChanged: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
changeType: DashboardFilterChangeType,
properties: Record<string, string | number | boolean | null | undefined>
) => ({ dashboard, changeType, properties }),
@@ -2738,25 +2734,25 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
ignored: boolean
) => ({ dashboardId, insightId, ignored }),
reportDashboardLayoutZoomChanged: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
layoutZoom: number,
source: 'button' | 'shortcut'
) => ({ dashboard, layoutZoom, source }),
reportDashboardTileDensityConfigured: (tileDensity: DashboardTileSpacing) => ({ tileDensity }),
reportDashboardEditModeDiscardPrompt: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
action: 'shown' | 'discarded' | 'kept_editing'
) => ({ dashboard, action }),
reportDashboardBreakdownColorsSaved: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
manualCount: number,
autoCount: number,
breakdownTypes: string[]
) => ({ dashboard, manualCount, autoCount, breakdownTypes }),
- reportDashboardColorThemeSet: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
- themeId: number | null
- ) => ({ dashboard, themeId }),
+ reportDashboardColorThemeSet: (dashboard: DashboardType | null, themeId: number | null) => ({
+ dashboard,
+ themeId,
+ }),
reportDashboardRefreshed: (
dashboardId: number,
filters: Record<string, any>,
@@ -2783,7 +2779,7 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
}),
reportDashboardTileRefreshed: (
dashboardId: number,
- tile: DashboardTile<QueryBasedInsightModel>,
+ tile: DashboardTile,
filters: Record<string, any>,
variables: Record<string, any>,
refreshDurationMs: number,
@@ -2797,7 +2793,7 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
individualRefresh,
}),
reportDashboardDateRangeChanged: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
dateFrom?: string | Dayjs | null,
dateTo?: string | Dayjs | null
) => ({
@@ -2805,7 +2801,7 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
dateFrom,
dateTo,
}),
- reportDashboardPropertiesChanged: (dashboard: DashboardType<QueryBasedInsightModel> | null) => ({ dashboard }),
+ reportDashboardPropertiesChanged: (dashboard: DashboardType | null) => ({ dashboard }),
reportDashboardPinToggled: (dashboardId: number, pinned: boolean, source: DashboardEventSource) => ({
dashboardId,
pinned,
@@ -2896,14 +2892,14 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
template_variable_count: number
template_scope: DashboardTemplateScope | null
}) => payload,
- reportSavedInsightToDashboard: (
- insight: Partial<QueryBasedInsightModel> | null,
- dashboardId: number | null
- ) => ({ insight, dashboardId }),
- reportRemovedInsightFromDashboard: (
- insight: Partial<QueryBasedInsightModel> | null,
- dashboardId: number | null
- ) => ({ insight, dashboardId }),
+ reportSavedInsightToDashboard: (insight: Partial<InsightModel> | null, dashboardId: number | null) => ({
+ insight,
+ dashboardId,
+ }),
+ reportRemovedInsightFromDashboard: (insight: Partial<InsightModel> | null, dashboardId: number | null) => ({
+ insight,
+ dashboardId,
+ }),
reportCopiedDashboardTileToDashboard: (
fromDashboardId: number,
toDashboardId: number,
diff --git a/frontend/src/models/dashboardsModel.tsx b/frontend/src/models/dashboardsModel.tsx
index ef10b19d9290..50167e5515f9 100644
--- a/frontend/src/models/dashboardsModel.tsx
+++ b/frontend/src/models/dashboardsModel.tsx
@@ -17,19 +17,19 @@ import { deleteFromTree, refreshTreeItem } from '~/layout/panel-layout/ProjectTr
import { parentPath, reparentPath } from '~/layout/panel-layout/ProjectTree/utils'
import { tagsModel } from '~/models/tagsModel'
import { getQueryBasedDashboard } from '~/queries/nodes/InsightViz/utils'
-import { DashboardBasicType, DashboardTile, DashboardType, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { DashboardBasicType, DashboardTile, DashboardType, InsightShortId, InsightModel } from '~/types'
import type { Node } from '../queries/schema/schema-general'
/** A dashboard's folder is its file system path without the dashboard's own name, so the two move together. */
-function filedAt<T extends DashboardBasicType | DashboardType<QueryBasedInsightModel>>(dashboard: T, path: string): T {
+function filedAt<T extends DashboardBasicType | DashboardType>(dashboard: T, path: string): T {
return { ...dashboard, file_system_path: path, folder: parentPath(path) }
}
export function mergeTileTextUpdatesIntoDashboard(
- dashboard: DashboardType<QueryBasedInsightModel>,
+ dashboard: DashboardType,
tilesPayload: Partial<DashboardTile>[] | undefined
-): DashboardType<QueryBasedInsightModel> {
+): DashboardType {
// Optimistically reconcile text tile updates in-place after save.
// Some dashboard PATCH responses can momentarily return stale tile.text values, so we patch the
// returned dashboard with the just-submitted text body for matching tiles to avoid UI flicker/regression.
@@ -72,17 +72,17 @@ export function mergeTileTextUpdatesIntoDashboard(
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface dashboardsModelValues {
- dashboard: DashboardType<QueryBasedInsightModel> | null
+ dashboard: DashboardType | null
dashboardLoading: boolean
dashboardsLoading: boolean
loadDashboardsFailed: boolean
- nameSortedDashboards: (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[]
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[]
pagedDashboards: PaginatedResponse<DashboardBasicType> | null
pagedDashboardsLoading: boolean
pagingDashboardsCompleted: boolean
- pinSortedDashboards: (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[]
- pinnedDashboards: (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[]
- rawDashboards: Record<string, DashboardBasicType | DashboardType<QueryBasedInsightModel>>
+ pinSortedDashboards: (DashboardBasicType | DashboardType)[]
+ pinnedDashboards: (DashboardBasicType | DashboardType)[]
+ rawDashboards: Record<string, DashboardBasicType | DashboardType>
redirect: boolean
}
@@ -91,8 +91,8 @@ export interface dashboardsModelActions {
loadTags: () => {
value: true
} // tagsModel
- addDashboardSuccess: (dashboard: DashboardType<QueryBasedInsightModel>) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ addDashboardSuccess: (dashboard: DashboardType) => {
+ dashboard: DashboardType
}
dashboardsFullyLoaded: () => {
value: true
@@ -109,10 +109,10 @@ export interface dashboardsModelActions {
errorObject?: any
}
deleteDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ dashboard: DashboardType,
payload?: any
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ dashboard: DashboardType
payload?: any
}
duplicateDashboard: ({
@@ -139,7 +139,7 @@ export interface dashboardsModelActions {
errorObject?: any
}
duplicateDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ dashboard: DashboardType,
payload?: {
duplicateTiles: boolean
id: number
@@ -147,7 +147,7 @@ export interface dashboardsModelActions {
show: boolean
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ dashboard: DashboardType
payload?: {
duplicateTiles: boolean
id: number
@@ -178,7 +178,7 @@ export interface dashboardsModelActions {
count?: undefined
next?: string | null | undefined
previous?: string | null | undefined
- results: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>[]
+ results: DashboardType[]
},
payload?: string
) => {
@@ -193,7 +193,7 @@ export interface dashboardsModelActions {
count?: undefined
next?: string | null | undefined
previous?: string | null | undefined
- results: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>[]
+ results: DashboardType[]
}
payload?: string
}
@@ -215,13 +215,13 @@ export interface dashboardsModelActions {
errorObject?: any
}
pinDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ dashboard: DashboardType,
payload?: {
id: number
source: DashboardEventSource
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ dashboard: DashboardType
payload?: {
id: number
source: DashboardEventSource
@@ -243,10 +243,10 @@ export interface dashboardsModelActions {
errorObject?: any
}
restoreDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ dashboard: DashboardType,
payload?: any
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ dashboard: DashboardType
payload?: any
}
setDiveSourceId: (id: InsightShortId | null) => {
@@ -256,21 +256,15 @@ export interface dashboardsModelActions {
dashboardId: number
}
tileMovedToDashboard: (
- tile: DashboardTile<QueryBasedInsightModel>,
+ tile: DashboardTile,
dashboardId: number
) => {
dashboardId: number
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
}
- tileRemovedFromDashboard: ({
- tile,
- dashboardId,
- }: {
- dashboardId?: number
- tile?: DashboardTile<QueryBasedInsightModel>
- }) => {
+ tileRemovedFromDashboard: ({ tile, dashboardId }: { dashboardId?: number; tile?: DashboardTile }) => {
dashboardId: number | undefined
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>> | undefined
+ tile: DashboardTile | undefined
}
unpinDashboard: (
id: number,
@@ -287,13 +281,13 @@ export interface dashboardsModelActions {
errorObject?: any
}
unpinDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ dashboard: DashboardType,
payload?: {
id: number
source: DashboardEventSource
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ dashboard: DashboardType
payload?: {
id: number
source: DashboardEventSource
@@ -308,19 +302,19 @@ export interface dashboardsModelActions {
errorObject?: any
}
updateDashboardInsight: (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
extraDashboardIds?: number[],
sourceDashboardId?: number
) => {
extraDashboardIds: number[] | undefined
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
sourceDashboardId: number | undefined
}
updateDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined,
+ dashboard: DashboardType | null | undefined,
payload?: any
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined
+ dashboard: DashboardType | null | undefined
payload?: any
}
}
@@ -329,24 +323,15 @@ export interface dashboardsModelActions {
export interface dashboardsModelMeta {
__keaTypeGenInternalSelectorTypes: {
nameSortedDashboards: (
- rawDashboards: Record<
- string,
- DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
- >
- ) => (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[]
+ rawDashboards: Record<string, DashboardBasicType | DashboardType>
+ ) => (DashboardBasicType | DashboardType)[]
pinSortedDashboards: (
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
- )[]
- ) => (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[]
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[]
+ ) => (DashboardBasicType | DashboardType)[]
dashboardsLoading: (pagedDashboardsLoading: boolean, pagingDashboardsCompleted: boolean) => boolean
pinnedDashboards: (
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
- )[]
- ) => (DashboardBasicType | DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>)[]
+ nameSortedDashboards: (DashboardBasicType | DashboardType)[]
+ ) => (DashboardBasicType | DashboardType)[]
}
}
@@ -370,7 +355,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
patchDashboardFolders: (paths: Record<string, string>) => ({ paths }),
reparentDashboardFolders: (oldPath: string, newPath: string) => ({ oldPath, newPath }),
setDiveSourceId: (id: InsightShortId | null) => ({ id }),
- addDashboardSuccess: (dashboard: DashboardType<QueryBasedInsightModel>) => ({ dashboard }),
+ addDashboardSuccess: (dashboard: DashboardType) => ({ dashboard }),
/**
* this is moved out of dashboardLogic, so that you can click "undo" on an item move when already
* on another dashboard - both dashboards can listen to and share this event, even if one is not yet mounted
@@ -382,11 +367,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
* when placement info is incomplete (copy/move/remove).
* @param sourceDashboardId - Set for a dashboard-scoped GET/refresh; merged `query` is only valid for that dashboard.
*/
- updateDashboardInsight: (
- insight: QueryBasedInsightModel,
- extraDashboardIds?: number[],
- sourceDashboardId?: number
- ) => ({
+ updateDashboardInsight: (insight: InsightModel, extraDashboardIds?: number[], sourceDashboardId?: number) => ({
insight,
extraDashboardIds,
sourceDashboardId,
@@ -409,17 +390,11 @@ export const dashboardsModel = kea<dashboardsModelType>([
show: show || false,
duplicateTiles: duplicateTiles || false,
}),
- tileMovedToDashboard: (tile: DashboardTile<QueryBasedInsightModel>, dashboardId: number) => ({
+ tileMovedToDashboard: (tile: DashboardTile, dashboardId: number) => ({
tile,
dashboardId,
}),
- tileRemovedFromDashboard: ({
- tile,
- dashboardId,
- }: {
- tile?: DashboardTile<QueryBasedInsightModel>
- dashboardId?: number
- }) => ({
+ tileRemovedFromDashboard: ({ tile, dashboardId }: { tile?: DashboardTile; dashboardId?: number }) => ({
tile,
dashboardId,
}),
@@ -466,7 +441,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
// We're not using this loader as a reducer per se, but just calling it `dashboard`
// to have the right payload ({ dashboard }) in the Success actions
dashboard: {
- __default: null as null | DashboardType<QueryBasedInsightModel>,
+ __default: null as null | DashboardType,
updateDashboard: async ({ id, allowUndo, discardResult, ...payload }, breakpoint) => {
if (!Object.entries(payload).length) {
return
@@ -525,7 +500,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
deleted: true,
delete_insights: deleteInsights,
})
- ) as DashboardType<QueryBasedInsightModel>
+ ) as DashboardType
deleteFromTree('dashboard', String(id))
return deleted
},
@@ -534,7 +509,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
await api.update(`api/environments/${teamLogic.values.currentTeamId}/dashboards/${id}`, {
deleted: false,
})
- ) as DashboardType<QueryBasedInsightModel>
+ ) as DashboardType
refreshTreeItem('dashboard', String(id))
return restored
},
@@ -599,7 +574,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
},
],
rawDashboards: [
- {} as Record<string, DashboardBasicType | DashboardType<QueryBasedInsightModel>>,
+ {} as Record<string, DashboardBasicType | DashboardType>,
{
loadDashboardsSuccess: (state, { pagedDashboards }) => {
if (!pagedDashboards) {
@@ -655,7 +630,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
selectors(({ selectors }) => ({
nameSortedDashboards: [
() => [selectors.rawDashboards],
- (rawDashboards: Record<string, DashboardBasicType | DashboardType<QueryBasedInsightModel>>) => {
+ (rawDashboards: Record<string, DashboardBasicType | DashboardType>) => {
return Object.values(rawDashboards)
.filter((dashboard) => !(dashboard.name ?? 'Untitled').startsWith(GENERATED_DASHBOARD_PREFIX))
.sort(nameCompareFunction)
@@ -664,12 +639,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
/** Display dashboards are additionally sorted by pin status: pinned first. */
pinSortedDashboards: [
() => [selectors.nameSortedDashboards],
- (
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<QueryBasedInsightModel<import('../queries/schema').Node<Record<string, any>>>>
- )[]
- ) => {
+ (nameSortedDashboards: (DashboardBasicType | DashboardType)[]) => {
return [...nameSortedDashboards].sort(
(a, b) => (Number(b.pinned) - Number(a.pinned)) * 10 + nameCompareFunction(a, b)
)
@@ -682,12 +652,7 @@ export const dashboardsModel = kea<dashboardsModelType>([
],
pinnedDashboards: [
() => [selectors.nameSortedDashboards],
- (
- nameSortedDashboards: (
- | DashboardBasicType
- | DashboardType<QueryBasedInsightModel<import('../queries/schema').Node<Record<string, any>>>>
- )[]
- ) => {
+ (nameSortedDashboards: (DashboardBasicType | DashboardType)[]) => {
const pinnedDashboards = nameSortedDashboards.filter((dashboard) => dashboard.pinned)
return [...pinnedDashboards].sort((a, b) => {
diff --git a/frontend/src/models/insightsModel.tsx b/frontend/src/models/insightsModel.tsx
index e3b0647edf47..744d8bda9be8 100644
--- a/frontend/src/models/insightsModel.tsx
+++ b/frontend/src/models/insightsModel.tsx
@@ -7,34 +7,34 @@ import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { insightsApi } from 'scenes/insights/utils/api'
import { teamLogic } from 'scenes/teamLogic'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import type { Node } from '../queries/schema/schema-general'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface insightsModelActions {
- duplicateInsight: (item: QueryBasedInsightModel) => {
- item: QueryBasedInsightModel<Node<Record<string, any>>>
+ duplicateInsight: (item: InsightModel) => {
+ item: InsightModel<Node<Record<string, any>>>
}
- duplicateInsightSuccess: (item: QueryBasedInsightModel) => {
- item: QueryBasedInsightModel<Node<Record<string, any>>>
+ duplicateInsightSuccess: (item: InsightModel) => {
+ item: InsightModel<Node<Record<string, any>>>
}
insightsAddedToDashboard: ({ dashboardId, insightIds }: { dashboardId: number; insightIds: number[] }) => {
dashboardId: number
insightIds: number[]
}
- renameInsight: (item: QueryBasedInsightModel) => {
- item: QueryBasedInsightModel<Node<Record<string, any>>>
+ renameInsight: (item: InsightModel) => {
+ item: InsightModel<Node<Record<string, any>>>
}
- renameInsightSuccess: (item: QueryBasedInsightModel) => {
- item: QueryBasedInsightModel<Node<Record<string, any>>>
+ renameInsightSuccess: (item: InsightModel) => {
+ item: InsightModel<Node<Record<string, any>>>
}
updateInsightDirect: (
- item: QueryBasedInsightModel,
- updates: Partial<QueryBasedInsightModel>
+ item: InsightModel,
+ updates: Partial<InsightModel>
) => {
- item: QueryBasedInsightModel<Node<Record<string, any>>>
- updates: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ item: InsightModel<Node<Record<string, any>>>
+ updates: Partial<InsightModel<Node<Record<string, any>>>>
}
}
@@ -44,15 +44,15 @@ export const insightsModel = kea<insightsModelType>([
path(['models', 'insightsModel']),
connect(() => ({ logic: [teamLogic] })),
actions(() => ({
- renameInsight: (item: QueryBasedInsightModel) => ({ item }),
- updateInsightDirect: (item: QueryBasedInsightModel, updates: Partial<QueryBasedInsightModel>) => ({
+ renameInsight: (item: InsightModel) => ({ item }),
+ updateInsightDirect: (item: InsightModel, updates: Partial<InsightModel>) => ({
item,
updates,
}),
- renameInsightSuccess: (item: QueryBasedInsightModel) => ({ item }),
+ renameInsightSuccess: (item: InsightModel) => ({ item }),
// TODO: this duplicates the insight but not the dashboard tile (e.g. if duplicated from dashboard you lose tile color
- duplicateInsight: (item: QueryBasedInsightModel) => ({ item }),
- duplicateInsightSuccess: (item: QueryBasedInsightModel) => ({ item }),
+ duplicateInsight: (item: InsightModel) => ({ item }),
+ duplicateInsightSuccess: (item: InsightModel) => ({ item }),
insightsAddedToDashboard: ({ dashboardId, insightIds }: { dashboardId: number; insightIds: number[] }) => ({
dashboardId,
insightIds,
diff --git a/frontend/src/models/notebooksModel.ts b/frontend/src/models/notebooksModel.ts
index 750e82a14ce0..c614561602b2 100644
--- a/frontend/src/models/notebooksModel.ts
+++ b/frontend/src/models/notebooksModel.ts
@@ -18,7 +18,7 @@ import { urls } from 'scenes/urls'
import { deleteFromTree, getLastNewFolder, refreshTreeItem } from '~/layout/panel-layout/ProjectTree/projectTreeLogic'
import { InsightVizNode, Node, ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
-import { DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardType } from '~/types'
import type { NotebookType } from '../scenes/notebooks/types'
@@ -109,8 +109,8 @@ export interface notebooksModelActions {
error: string
errorObject?: any
}
- createNotebookFromDashboard: (dashboard: DashboardType<QueryBasedInsightModel>) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ createNotebookFromDashboard: (dashboard: DashboardType) => {
+ dashboard: DashboardType
}
createNotebookSuccess: (
notebooks: NotebookListItemType[],
@@ -205,7 +205,7 @@ export const notebooksModel = kea<notebooksModelType>([
receiveNotebookUpdate: (notebook: NotebookListItemType) => ({ notebook }),
loadNotebooks: true,
deleteNotebook: (shortId: NotebookListItemType['short_id'], title?: string) => ({ shortId, title }),
- createNotebookFromDashboard: (dashboard: DashboardType<QueryBasedInsightModel>) => ({ dashboard }),
+ createNotebookFromDashboard: (dashboard: DashboardType) => ({ dashboard }),
}),
connect(() => ({
values: [projectLogic, ['currentProjectId']],
diff --git a/frontend/src/queries/nodes/DataNode/queryScan.test.ts b/frontend/src/queries/nodes/DataNode/queryScan.test.ts
index 961bc8efa2fe..92c8f1a2ae52 100644
--- a/frontend/src/queries/nodes/DataNode/queryScan.test.ts
+++ b/frontend/src/queries/nodes/DataNode/queryScan.test.ts
@@ -1,5 +1,5 @@
import { QueryScanSummary, QueryScanWarning } from '~/queries/schema/schema-general'
-import { DashboardTile, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { DashboardTile, InsightShortId, InsightModel } from '~/types'
import {
QueryScanPollResult,
@@ -31,8 +31,8 @@ const BY_DESIGN_FINDING: QueryScanWarning = {
actionable: false,
}
-function tile(id: number, insight: Partial<QueryBasedInsightModel> | null): DashboardTile<QueryBasedInsightModel> {
- return { id, color: null, insight: insight ? (insight as QueryBasedInsightModel) : undefined }
+function tile(id: number, insight: Partial<InsightModel> | null): DashboardTile {
+ return { id, color: null, insight: insight ? (insight as InsightModel) : undefined }
}
function slowInsight(
@@ -40,7 +40,7 @@ function slowInsight(
name: string,
findings: QueryScanWarning[],
summary: Partial<QueryScanSummary> = {}
-): Partial<QueryBasedInsightModel> {
+): Partial<InsightModel> {
return {
short_id: shortId as InsightShortId,
name,
diff --git a/frontend/src/queries/nodes/DataNode/queryScan.ts b/frontend/src/queries/nodes/DataNode/queryScan.ts
index 9795de2c08cc..b081a77689af 100644
--- a/frontend/src/queries/nodes/DataNode/queryScan.ts
+++ b/frontend/src/queries/nodes/DataNode/queryScan.ts
@@ -2,7 +2,7 @@ import { humanFriendlyNumber } from 'lib/utils/numbers'
import { QueryScanAnalysis, QueryScanSummary, QueryScanWarning } from '~/queries/schema/schema-general'
import { integer } from '~/queries/schema/type-utils'
-import { DashboardTile, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { DashboardTile, InsightShortId } from '~/types'
export interface QueryScanState {
summary: QueryScanSummary
@@ -106,7 +106,7 @@ export interface QueryScanDashboardEntry {
}
/** The insights on a dashboard whose last fresh run has advice the viewer can act on. */
-export function queryScanDashboardEntries(tiles: DashboardTile<QueryBasedInsightModel>[]): QueryScanDashboardEntry[] {
+export function queryScanDashboardEntries(tiles: DashboardTile[]): QueryScanDashboardEntry[] {
const entries: QueryScanDashboardEntry[] = []
for (const tile of tiles) {
const insight = tile.insight
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Variables/variableModalLogic.ts b/frontend/src/queries/nodes/DataVisualization/Components/Variables/variableModalLogic.ts
index f86cb2753f94..8dd5f40168ce 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Variables/variableModalLogic.ts
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Variables/variableModalLogic.ts
@@ -7,7 +7,7 @@ import { dayjs } from 'lib/dayjs'
import { fetchInsightsUsingVariable } from 'scenes/data-management/variables/insightsLoader'
import { teamLogic } from 'scenes/teamLogic'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import type { HogQLVariable, Node } from '../../../../schema/schema-general'
import {
@@ -96,7 +96,7 @@ const getDefaultVariableForType = (variableType: VariableType): Variable => {
export interface variableModalLogicValues {
currentTeamId: number | null // teamLogic
insightsLoading: boolean
- insightsUsingVariable: QueryBasedInsightModel[]
+ insightsUsingVariable: InsightModel[]
isModalOpen: boolean
isSaving: boolean
modalType: 'existing' | 'new'
@@ -137,8 +137,8 @@ export interface variableModalLogicActions {
setInsightsLoading: (loading: boolean) => {
loading: boolean
}
- setInsightsUsingVariable: (insights: QueryBasedInsightModel[]) => {
- insights: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ setInsightsUsingVariable: (insights: InsightModel[]) => {
+ insights: InsightModel<Node<Record<string, any>>>[]
}
updateVariable: (variable: Variable) => {
variable: Variable
@@ -179,7 +179,7 @@ export const variableModalLogic = kea<variableModalLogicType>([
saveSuccess: true,
saveFailure: true,
changeTypeExistingVariable: (variableType: VariableType) => ({ variableType }),
- setInsightsUsingVariable: (insights: QueryBasedInsightModel[]) => ({ insights }),
+ setInsightsUsingVariable: (insights: InsightModel[]) => ({ insights }),
setInsightsLoading: (loading: boolean) => ({ loading }),
}),
reducers({
@@ -230,7 +230,7 @@ export const variableModalLogic = kea<variableModalLogicType>([
},
],
insightsUsingVariable: [
- [] as QueryBasedInsightModel[],
+ [] as InsightModel[],
{
setInsightsUsingVariable: (_, { insights }) => insights,
closeModal: () => [],
diff --git a/frontend/src/queries/nodes/InsightViz/utils.test.ts b/frontend/src/queries/nodes/InsightViz/utils.test.ts
index 5512431a20c5..f2ebb3536c19 100644
--- a/frontend/src/queries/nodes/InsightViz/utils.test.ts
+++ b/frontend/src/queries/nodes/InsightViz/utils.test.ts
@@ -1,4 +1,5 @@
-import { InsightModel, InsightType } from '~/types'
+import { Node, NodeKind } from '~/queries/schema/schema-general'
+import { InsightModel } from '~/types'
import { extractValidationErrorCode, getQueryBasedInsightModel } from './utils'
@@ -56,14 +57,10 @@ describe('getQueryBasedInsightModel', () => {
expect(result.dashboards).toEqual(expected)
})
- it('drops stored filters rather than converting them', () => {
- // A blank insight is the accepted outcome here, not a fault: saving one writes a query.
- const result = getQueryBasedInsightModel({
- query: null,
- filters: { insight: InsightType.TRENDS, events: [{ id: '$pageview' }] },
- } as Partial<InsightModel>)
+ it('leaves the rest of the insight untouched', () => {
+ const query = { kind: NodeKind.TrendsQuery } as Node
+ const result = getQueryBasedInsightModel({ id: 7, name: 'Pageviews', query })
- expect(result.query).toBeNull()
- expect(result).not.toHaveProperty('filters')
+ expect(result).toEqual({ id: 7, name: 'Pageviews', query })
})
})
diff --git a/frontend/src/queries/nodes/InsightViz/utils.ts b/frontend/src/queries/nodes/InsightViz/utils.ts
index b16c40d22462..12254b9c2a4b 100644
--- a/frontend/src/queries/nodes/InsightViz/utils.ts
+++ b/frontend/src/queries/nodes/InsightViz/utils.ts
@@ -14,7 +14,7 @@ import {
NodeKind,
} from '~/queries/schema/schema-general'
import { isInsightQueryWithSeries, setLatestVersionsOnQuery } from '~/queries/utils'
-import { ActionType, DashboardTile, DashboardType, InsightModel, InsightType, QueryBasedInsightModel } from '~/types'
+import { ActionType, DashboardTile, DashboardType, InsightModel, InsightType } from '~/types'
import { ProductAnalyticsInsightNodeKind, getNodeKindToDefaultQuery } from '../InsightQuery/defaults'
@@ -41,9 +41,9 @@ export const getAllEventNames = (query: InsightQueryNode, allActions: ActionType
}
export const getCachedResults = (
- cachedInsight: Partial<QueryBasedInsightModel> | undefined | null,
+ cachedInsight: Partial<InsightModel> | undefined | null,
query: InsightQueryNode
-): Partial<QueryBasedInsightModel> | undefined => {
+): Partial<InsightModel> | undefined => {
if (!cachedInsight) {
return undefined
}
@@ -67,30 +67,17 @@ export const getCachedResults = (
return cachedInsight
}
-// these types exist so that the return type reflects the input model
-// i.e. when given a partial model the return model is types as
-// partial as well
-type InputInsightModel = InsightModel | Partial<InsightModel>
-
-type ReturnInsightModel<T> = T extends InsightModel
- ? QueryBasedInsightModel
- : T extends Partial<InsightModel>
- ? Partial<QueryBasedInsightModel>
- : never
-
-/** Get an insight with `query` only. */
-export function getQueryBasedInsightModel<T extends InputInsightModel>(insight: T): ReturnInsightModel<T> {
- const { filters, ...baseInsight } = insight
- // The API is phasing out the deprecated `dashboards` field (already omitted for token
- // callers, eventually for all); derive it from `dashboard_tiles` so remaining readers
- // keep working regardless of whether the response still carries it.
+/**
+ * Backfill the deprecated `dashboards` field from `dashboard_tiles`.
+ *
+ * Session-authenticated callers already never receive `dashboards`, and token callers will stop
+ * receiving it too, so derive it here to keep the remaining readers working whether or not the
+ * response still carries the field.
+ */
+export function getQueryBasedInsightModel<T extends InsightModel | Partial<InsightModel>>(insight: T): T {
const dashboards =
insight.dashboards ?? insight.dashboard_tiles?.filter((tile) => !tile.deleted).map((tile) => tile.dashboard_id)
- return {
- ...baseInsight,
- ...(dashboards ? { dashboards } : {}),
- query: insight.query ?? null,
- } as unknown as ReturnInsightModel<T>
+ return { ...insight, ...(dashboards ? { dashboards } : {}) }
}
export const queryFromKind = (
@@ -144,10 +131,8 @@ export const getDefaultQuery = (
throw new Error('encountered unexpected type for view')
}
-/** Get a dashboard whose tiles carry `query` only. */
-export const getQueryBasedDashboard = (
- dashboard: DashboardType<InsightModel> | DashboardType<QueryBasedInsightModel> | null
-): DashboardType<QueryBasedInsightModel> | null => {
+/** Backfill the deprecated `dashboards` field on each tile's insight. */
+export const getQueryBasedDashboard = (dashboard: DashboardType | null): DashboardType | null => {
if (dashboard == null) {
return null
}
@@ -159,7 +144,7 @@ export const getQueryBasedDashboard = (
({
...tile,
...(tile.insight != null ? { insight: getQueryBasedInsightModel(tile.insight) } : {}),
- }) as DashboardTile<QueryBasedInsightModel>
+ }) as DashboardTile
),
}
}
diff --git a/frontend/src/render-query/RenderQueryApp.tsx b/frontend/src/render-query/RenderQueryApp.tsx
index 30eef7e5b546..24adcd6a1d44 100644
--- a/frontend/src/render-query/RenderQueryApp.tsx
+++ b/frontend/src/render-query/RenderQueryApp.tsx
@@ -7,13 +7,13 @@ import { useThemedHtml } from 'lib/hooks/useThemedHtml'
import { Query } from '~/queries/Query/Query'
import { AnyResponseType, Node } from '~/queries/schema/schema-general'
import { QueryContext } from '~/queries/types'
-import { DataColorThemeModel, QueryBasedInsightModel } from '~/types'
+import { DataColorThemeModel, InsightModel } from '~/types'
interface RenderQueryExternalPayload {
query?: Node | string | null
- cachedResults?: AnyResponseType | Partial<QueryBasedInsightModel> | null
+ cachedResults?: AnyResponseType | Partial<InsightModel> | null
context?: QueryContext<any> | null
- insight?: Partial<QueryBasedInsightModel> | null
+ insight?: Partial<InsightModel> | null
themes?: DataColorThemeModel[]
}
diff --git a/frontend/src/scenes/dashboard/Dashboard.tsx b/frontend/src/scenes/dashboard/Dashboard.tsx
index 4cfa1963c62d..260c52224f16 100644
--- a/frontend/src/scenes/dashboard/Dashboard.tsx
+++ b/frontend/src/scenes/dashboard/Dashboard.tsx
@@ -21,7 +21,7 @@ import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneStickyBar } from '~/layout/scenes/components/SceneStickyBar'
import { ProductKey } from '~/queries/schema/schema-general'
-import { DashboardPlacement, DashboardType, DataColorThemeModel, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardType, DataColorThemeModel } from '~/types'
import { useAttachedContext } from 'products/posthog_ai/frontend/api/logics'
@@ -44,7 +44,7 @@ function DashboardSubscribeNudgeTrigger({ dashboardId }: { dashboardId: number }
interface DashboardProps {
id?: string
- dashboard?: DashboardType<QueryBasedInsightModel>
+ dashboard?: DashboardType
placement?: DashboardPlacement
themes?: DataColorThemeModel[]
/** When set, the "Edit dashboard" menu item links to the dashboard editor with a back button pointing here. */
diff --git a/frontend/src/scenes/dashboard/DashboardHeader.test.tsx b/frontend/src/scenes/dashboard/DashboardHeader.test.tsx
index 4abb996f5983..2473340b3b19 100644
--- a/frontend/src/scenes/dashboard/DashboardHeader.test.tsx
+++ b/frontend/src/scenes/dashboard/DashboardHeader.test.tsx
@@ -7,7 +7,7 @@ import { DashboardEventSource } from 'lib/utils/eventUsageLogic'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { AccessControlLevel, DashboardMode, DashboardType, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardMode, DashboardType, InsightModel } from '~/types'
import { useMcpToolApplyBack } from 'products/posthog_ai/frontend/api/logics'
import type { ToolStreamEvent } from 'products/posthog_ai/frontend/types/streamTypes'
@@ -26,7 +26,7 @@ jest.mock('products/posthog_ai/frontend/api/logics', () => ({
useMcpToolApplyBack: jest.fn(),
}))
-const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {
+const MOCK_DASHBOARD: DashboardType = {
id: 5,
name: 'Test Dashboard',
description: 'A test dashboard',
@@ -51,7 +51,7 @@ const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {
variables: {},
}
-function makeDashboard(overrides: Record<string, any> = {}): DashboardType<QueryBasedInsightModel> {
+function makeDashboard(overrides: Record<string, any> = {}): DashboardType {
return { ...MOCK_DASHBOARD, ...overrides }
}
@@ -78,7 +78,7 @@ describe('DashboardHeader', () => {
})
function renderHeader(opts: {
- dashboard?: DashboardType<QueryBasedInsightModel> | null
+ dashboard?: DashboardType | null
dashboardMode?: DashboardMode | null
dashboardEditing?: { filters: boolean; layout: boolean } | null
dashboardModeSource?: DashboardEventSource
@@ -276,7 +276,7 @@ describe('DashboardHeader', () => {
id: 1,
color: null,
layouts: {},
- insight: { id: 1, short_id: 'test', name: 'Test' } as QueryBasedInsightModel,
+ insight: { id: 1, short_id: 'test', name: 'Test' } as InsightModel,
},
]
: [],
diff --git a/frontend/src/scenes/dashboard/DashboardInsightColorsModal.stories.tsx b/frontend/src/scenes/dashboard/DashboardInsightColorsModal.stories.tsx
index cd44622dadfd..6f00fce5e223 100644
--- a/frontend/src/scenes/dashboard/DashboardInsightColorsModal.stories.tsx
+++ b/frontend/src/scenes/dashboard/DashboardInsightColorsModal.stories.tsx
@@ -8,7 +8,7 @@ import { dashboardInsightColorsModalLogic } from 'scenes/dashboard/dashboardInsi
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
import { useStorybookMocks } from '~/mocks/browser'
-import { DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardType } from '~/types'
const DASHBOARD_ID = 5
@@ -16,7 +16,7 @@ const dashboard = {
...dashboardFixture,
id: DASHBOARD_ID,
tiles: dashboardFixture.tiles.map((tile, index) => ({ ...tile, id: index + 1 })),
-} as unknown as DashboardType<QueryBasedInsightModel>
+} as unknown as DashboardType
const meta: Meta = {
title: 'Scenes/Dashboards/Customize breakdown colors',
diff --git a/frontend/src/scenes/dashboard/DashboardModals.test.tsx b/frontend/src/scenes/dashboard/DashboardModals.test.tsx
index 3567c0687dfd..164144d7dffc 100644
--- a/frontend/src/scenes/dashboard/DashboardModals.test.tsx
+++ b/frontend/src/scenes/dashboard/DashboardModals.test.tsx
@@ -1,7 +1,7 @@
import { render } from '@testing-library/react'
import { useActions, useValues } from 'kea'
-import type { DashboardType, QueryBasedInsightModel } from '~/types'
+import type { DashboardType } from '~/types'
import { dashboardLogic } from './dashboardLogic'
import { DashboardModals } from './DashboardModals'
@@ -108,7 +108,7 @@ describe('DashboardModals', () => {
})
it('returns to the dashboard when a tile route references a missing tile', () => {
- const dashboard = { id: 5, tiles: [] } as unknown as DashboardType<QueryBasedInsightModel>
+ const dashboard = { id: 5, tiles: [] } as unknown as DashboardType
render(<DashboardModals dashboard={dashboard} />)
diff --git a/frontend/src/scenes/dashboard/DashboardModals.tsx b/frontend/src/scenes/dashboard/DashboardModals.tsx
index 786752629e72..21b7f63751fc 100644
--- a/frontend/src/scenes/dashboard/DashboardModals.tsx
+++ b/frontend/src/scenes/dashboard/DashboardModals.tsx
@@ -13,7 +13,7 @@ import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
import { dashboardsModel } from '~/models/dashboardsModel'
-import { DashboardMode, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardMode, DashboardType } from '~/types'
import { ImageTileModal } from 'products/dashboards/frontend/components/ImageTile/ImageTileModal'
import { getImageOnlyTextCardImage } from 'products/dashboards/frontend/components/ImageTile/imageTileUtils'
@@ -25,7 +25,7 @@ import { DashboardTemplateEditor } from './DashboardTemplateEditor'
import { DeleteDashboardModal } from './DeleteDashboardModal'
import { DuplicateDashboardModal } from './DuplicateDashboardModal'
-export function DashboardModals({ dashboard }: { dashboard: DashboardType<QueryBasedInsightModel> }): JSX.Element {
+export function DashboardModals({ dashboard }: { dashboard: DashboardType }): JSX.Element {
const {
dashboardMode,
canEditDashboard,
diff --git a/frontend/src/scenes/dashboard/DashboardPublicAccessBanner.test.tsx b/frontend/src/scenes/dashboard/DashboardPublicAccessBanner.test.tsx
index d0a00632c593..d0d728273470 100644
--- a/frontend/src/scenes/dashboard/DashboardPublicAccessBanner.test.tsx
+++ b/frontend/src/scenes/dashboard/DashboardPublicAccessBanner.test.tsx
@@ -2,11 +2,11 @@ import '@testing-library/jest-dom'
import { cleanup, render, screen } from '@testing-library/react'
-import { AccessControlLevel, DashboardPlacement, DashboardType, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardPlacement, DashboardType } from '~/types'
import { DashboardPublicAccessBanner } from './DashboardPublicAccessBanner'
-const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {
+const MOCK_DASHBOARD: DashboardType = {
id: 5,
name: 'Test dashboard',
description: 'A test dashboard',
@@ -31,9 +31,7 @@ const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {
variables: {},
}
-function makeDashboard(
- overrides: Partial<DashboardType<QueryBasedInsightModel>> = {}
-): DashboardType<QueryBasedInsightModel> {
+function makeDashboard(overrides: Partial<DashboardType> = {}): DashboardType {
return { ...MOCK_DASHBOARD, ...overrides }
}
@@ -41,7 +39,7 @@ function renderBanner({
dashboard = makeDashboard({ is_shared: true }),
placement = DashboardPlacement.Dashboard,
}: {
- dashboard?: DashboardType<QueryBasedInsightModel>
+ dashboard?: DashboardType
placement?: DashboardPlacement
} = {}): void {
render(<DashboardPublicAccessBanner dashboard={dashboard} placement={placement} />)
diff --git a/frontend/src/scenes/dashboard/DashboardPublicAccessBanner.tsx b/frontend/src/scenes/dashboard/DashboardPublicAccessBanner.tsx
index d51f39f62b6b..f51fc88294ad 100644
--- a/frontend/src/scenes/dashboard/DashboardPublicAccessBanner.tsx
+++ b/frontend/src/scenes/dashboard/DashboardPublicAccessBanner.tsx
@@ -5,7 +5,7 @@ import { LemonBanner } from '@posthog/lemon-ui'
import { urls } from 'scenes/urls'
-import { DashboardPlacement, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardType } from '~/types'
const DASHBOARD_PUBLIC_ACCESS_BANNER_PLACEMENTS = [
DashboardPlacement.Dashboard,
@@ -17,7 +17,7 @@ export function DashboardPublicAccessBanner({
dashboard,
placement,
}: {
- dashboard: DashboardType<QueryBasedInsightModel> | null
+ dashboard: DashboardType | null
placement: DashboardPlacement
}): JSX.Element | null {
const { push } = useActions(router)
diff --git a/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx b/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
index 82ca319e3472..e7453b9e0f42 100644
--- a/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
+++ b/frontend/src/scenes/dashboard/EmptyDashboardComponent.test.tsx
@@ -12,13 +12,13 @@ import { urls } from 'scenes/urls'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { AccessControlLevel, DashboardType, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardType } from '~/types'
import { addInsightToDashboardLogic } from './addInsightToDashboardModalLogic'
import { dashboardLogic } from './dashboardLogic'
import { EmptyDashboardComponent } from './EmptyDashboardComponent'
-const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {
+const MOCK_DASHBOARD: DashboardType = {
id: 5,
name: 'Test Dashboard',
description: 'A test dashboard',
diff --git a/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx b/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
index 3173d94d3158..ec3b839f04bd 100644
--- a/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
+++ b/frontend/src/scenes/dashboard/EmptyDashboardComponent.tsx
@@ -15,13 +15,7 @@ import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
import { urls } from 'scenes/urls'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
-import {
- AccessControlLevel,
- AccessControlResourceType,
- DashboardType,
- QueryBasedInsightModel,
- SidePanelTab,
-} from '~/types'
+import { AccessControlLevel, AccessControlResourceType, DashboardType, SidePanelTab } from '~/types'
import { addInsightToDashboardLogic } from './addInsightToDashboardModalLogic'
import { DashboardAiPromptComposer } from './DashboardAiPromptComposer'
@@ -47,7 +41,7 @@ function DashboardEmptyActions({
onOpenAiWithPrompt,
}: {
canEdit: boolean
- dashboard: DashboardType<QueryBasedInsightModel> | null | undefined
+ dashboard: DashboardType | null | undefined
aiDisabledReason: string | false
dashboardWidgetsEnabled: boolean
onAddInsight: () => void
diff --git a/frontend/src/scenes/dashboard/TileFiltersOverride.tsx b/frontend/src/scenes/dashboard/TileFiltersOverride.tsx
index 3b2114fbbde3..6ba7a692c244 100644
--- a/frontend/src/scenes/dashboard/TileFiltersOverride.tsx
+++ b/frontend/src/scenes/dashboard/TileFiltersOverride.tsx
@@ -18,7 +18,7 @@ import { urls } from 'scenes/urls'
import { groupsModel } from '~/models/groupsModel'
import { BreakdownFilter, NodeKind } from '~/queries/schema/schema-general'
import { isInsightQueryWithBreakdown, isInsightQueryWithSeries, isInsightVizNode } from '~/queries/utils'
-import type { DashboardTile, InsightLogicProps, IntervalType, QueryBasedInsightModel } from '~/types'
+import type { DashboardTile, InsightLogicProps, IntervalType } from '~/types'
import { tileLogic } from './tileLogic'
@@ -36,7 +36,7 @@ const CHOICE_HINTS: Record<TestAccountFilterChoice, string> = {
include: 'Internal and test users are included in this insight.',
}
-export function TileFiltersOverride({ tile }: { tile: DashboardTile<QueryBasedInsightModel> }): JSX.Element {
+export function TileFiltersOverride({ tile }: { tile: DashboardTile }): JSX.Element {
const { overrides } = useValues(tileLogic)
const { setDates, setProperties, setBreakdown, setInterval, setFilterTestAccounts, setIgnoreDashboardFilters } =
useActions(tileLogic)
diff --git a/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts b/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts
index 69489b00cd0c..5d1339648877 100644
--- a/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts
@@ -1,5 +1,5 @@
import { InsightQueryNode, InsightVizNode, NodeKind } from '~/queries/schema/schema-general'
-import { AccessControlLevel, DashboardTile, FunnelVizType, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardTile, FunnelVizType, InsightShortId, InsightModel } from '~/types'
import {
BreakdownColorConfig,
@@ -18,9 +18,7 @@ import {
} from './dashboardBreakdownColors'
describe('dashboardBreakdownColors', () => {
- const createTestTile = (
- overrides: Partial<QueryBasedInsightModel> = {}
- ): DashboardTile<QueryBasedInsightModel> => ({
+ const createTestTile = (overrides: Partial<InsightModel> = {}): DashboardTile => ({
id: 1,
layouts: {},
color: null,
@@ -47,7 +45,7 @@ describe('dashboardBreakdownColors', () => {
},
})
- const trendsTile = (result: any[], breakdownFilter?: Record<string, any>): DashboardTile<QueryBasedInsightModel> =>
+ const trendsTile = (result: any[], breakdownFilter?: Record<string, any>): DashboardTile =>
createTestTile({
result,
query: {
@@ -246,7 +244,7 @@ describe('dashboardBreakdownColors', () => {
})
it('handles retention insights with a breakdown', () => {
- const retentionTile = (result: any[]): DashboardTile<QueryBasedInsightModel> =>
+ const retentionTile = (result: any[]): DashboardTile =>
createTestTile({
result,
query: {
@@ -318,7 +316,7 @@ describe('dashboardBreakdownColors', () => {
})
it('handles cohort breakdowns, keying them all to the shared cohort property', () => {
- const cohortTile = (values: number[][]): DashboardTile<QueryBasedInsightModel> =>
+ const cohortTile = (values: number[][]): DashboardTile =>
createTestTile({
result: values.map((breakdown_value) => ({ action: { order: 0 }, breakdown_value })),
query: {
diff --git a/frontend/src/scenes/dashboard/dashboardBreakdownColors.ts b/frontend/src/scenes/dashboard/dashboardBreakdownColors.ts
index bc604dbc2556..8a47703a42f2 100644
--- a/frontend/src/scenes/dashboard/dashboardBreakdownColors.ts
+++ b/frontend/src/scenes/dashboard/dashboardBreakdownColors.ts
@@ -3,7 +3,7 @@ import { getFunnelDatasetKey, getTrendDatasetKey, isNullBreakdown, isOtherBreakd
import { BreakdownFilter } from '~/queries/schema/schema-general'
import { hasBreakdownFilter, isFunnelsQuery, isInsightVizNode, isRetentionQuery, isTrendsQuery } from '~/queries/utils'
-import { DashboardTile, FunnelVizType, QueryBasedInsightModel } from '~/types'
+import { DashboardTile, FunnelVizType } from '~/types'
export type BreakdownColorSource = 'auto' | 'manual'
@@ -201,7 +201,7 @@ function makeBreakdownValue(
: { breakdownValue, breakdownType, breakdownProperty: breakdownPropertyKey }
}
-function extractTileBreakdownValues(tile: DashboardTile<QueryBasedInsightModel>): BreakdownValueAndType[] {
+function extractTileBreakdownValues(tile: DashboardTile): BreakdownValueAndType[] {
if (!isInsightVizNode(tile.insight?.query)) {
return []
}
@@ -269,9 +269,7 @@ function extractTileBreakdownValues(tile: DashboardTile<QueryBasedInsightModel>)
/** Breakdown values per tile, deduplicated within each tile; tiles without values are dropped.
* Tile identity matters for assignment: which values co-occur on one chart decides which
* colors may collide, and how many tiles share a value decides whether it gets one at all. */
-export function extractBreakdownValuesByTile(
- insightTiles: DashboardTile<QueryBasedInsightModel>[] | null
-): BreakdownValueAndType[][] {
+export function extractBreakdownValuesByTile(insightTiles: DashboardTile[] | null): BreakdownValueAndType[][] {
if (insightTiles == null) {
return []
}
@@ -282,7 +280,7 @@ export function extractBreakdownValuesByTile(
* unavailable (a refresh errored or was aborted before the insight ever got results). Such a
* tile's breakdown values are unknown rather than absent, so tile counts under-report sharing:
* pruning or persisting auto colors in this state would drop entries that are still valid. */
-export function hasUnresolvedBreakdownTiles(insightTiles: DashboardTile<QueryBasedInsightModel>[] | null): boolean {
+export function hasUnresolvedBreakdownTiles(insightTiles: DashboardTile[] | null): boolean {
return (insightTiles ?? []).some((tile) => {
if (tile.insight?.result != null || !isInsightVizNode(tile.insight?.query)) {
return false
@@ -304,9 +302,7 @@ export function hasUnresolvedBreakdownTiles(insightTiles: DashboardTile<QueryBas
/** Deduplicated breakdown values across all tiles, clustered by breakdown property in the
* order properties first appear on the dashboard, then ordered within each property the way
* auto-assignment ranks them, so the colors modal lists values the way colors are handed out. */
-export function extractBreakdownValues(
- insightTiles: DashboardTile<QueryBasedInsightModel>[] | null
-): BreakdownValueAndType[] {
+export function extractBreakdownValues(insightTiles: DashboardTile[] | null): BreakdownValueAndType[] {
const tileBreakdownValues = extractBreakdownValuesByTile(insightTiles)
const stats = collectValueTileStats(tileBreakdownValues)
const compareAssignmentRank = buildAssignmentRankComparator(stats)
diff --git a/frontend/src/scenes/dashboard/dashboardInsightColorsModalLogic.ts b/frontend/src/scenes/dashboard/dashboardInsightColorsModalLogic.ts
index 50329a742509..9a38d5efd39c 100644
--- a/frontend/src/scenes/dashboard/dashboardInsightColorsModalLogic.ts
+++ b/frontend/src/scenes/dashboard/dashboardInsightColorsModalLogic.ts
@@ -2,7 +2,7 @@ import { MakeLogicType, actions, kea, listeners, path, reducers, selectors } fro
import { DashboardEventSource } from 'lib/utils/eventUsageLogic'
-import { DashboardTile, QueryBasedInsightModel } from '~/types'
+import { DashboardTile } from '~/types'
import {
BreakdownColorConfig,
@@ -26,7 +26,7 @@ export interface dashboardInsightColorsModalLogicValues {
breakdownValues: BreakdownValueAndType[]
colorStateAtOpen: ColorStateAtOpen | null
dashboardId: number | null
- insightTiles: DashboardTile<QueryBasedInsightModel>[] | null
+ insightTiles: DashboardTile[] | null
insightTilesLoading: boolean | null
isOpen: boolean
}
@@ -51,17 +51,9 @@ export interface dashboardInsightColorsModalLogicActions {
export interface dashboardInsightColorsModalLogicMeta {
__keaTypeGenInternalSelectorTypes: {
isOpen: (dashboardId: number | null) => boolean
- insightTiles: (
- arg:
- | DashboardTile<QueryBasedInsightModel<import('../../queries/schema').Node<Record<string, any>>>>[]
- | null
- ) => DashboardTile<QueryBasedInsightModel>[] | null
+ insightTiles: (arg: DashboardTile[] | null) => DashboardTile[] | null
insightTilesLoading: (arg: null | true) => boolean | null
- breakdownValues: (
- insightTiles:
- | DashboardTile<QueryBasedInsightModel<import('../../queries/schema').Node<Record<string, any>>>>[]
- | null
- ) => BreakdownValueAndType[]
+ breakdownValues: (insightTiles: DashboardTile[] | null) => BreakdownValueAndType[]
breakdownValueGroups: (breakdownValues: BreakdownValueAndType[]) => BreakdownValueGroup[]
}
}
@@ -135,11 +127,7 @@ export const dashboardInsightColorsModalLogic = kea<dashboardInsightColorsModalL
isOpen: [(s) => [s.dashboardId], (dashboardId: number | null) => dashboardId != null],
insightTiles: [
(s) => [(state) => dashboardLogic.findMounted({ id: s.dashboardId(state) })?.values.insightTiles || null],
- (
- insightTiles:
- | DashboardTile<QueryBasedInsightModel<import('../../queries/schema').Node<Record<string, any>>>>[]
- | null
- ): DashboardTile<QueryBasedInsightModel>[] | null => insightTiles,
+ (insightTiles: DashboardTile[] | null): DashboardTile[] | null => insightTiles,
],
insightTilesLoading: [
(s) => [(state) => dashboardLogic.findMounted({ id: s.dashboardId(state) })?.values.itemsLoading || null],
@@ -148,7 +136,7 @@ export const dashboardInsightColorsModalLogic = kea<dashboardInsightColorsModalL
],
breakdownValues: [
(s) => [s.insightTiles],
- (insightTiles: DashboardTile<QueryBasedInsightModel>[] | null) => extractBreakdownValues(insightTiles),
+ (insightTiles: DashboardTile[] | null) => extractBreakdownValues(insightTiles),
],
breakdownValueGroups: [
(s) => [s.breakdownValues],
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.test.ts b/frontend/src/scenes/dashboard/dashboardLogic.test.ts
index 0e0581a615df..3c609bf5ed68 100644
--- a/frontend/src/scenes/dashboard/dashboardLogic.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardLogic.test.ts
@@ -41,35 +41,35 @@ import {
InsightShortId,
PropertyFilterType,
PropertyOperator,
- QueryBasedInsightModel,
+ InsightModel,
} from '~/types'
import { DashboardGridCompaction } from 'products/dashboards/frontend/dashboardCustomization'
import { dashboardResult, insightOnDashboard, tileFromInsight } from './dashboardLogic.testHelpers'
-const TEXT_TILE: DashboardTile<QueryBasedInsightModel> = {
+const TEXT_TILE: DashboardTile = {
id: 4,
text: { body: 'I AM A TEXT', last_modified_at: '2021-01-01T00:00:00Z' },
layouts: {},
color: InsightColor.Blue,
}
-const WIDGET_TILE: DashboardTile<QueryBasedInsightModel> = {
+const WIDGET_TILE: DashboardTile = {
id: 7,
widget: { id: '1', widget_type: 'error_tracking_list', config: {} },
layouts: {},
color: null,
}
-const WIDGET_TILE_WITH_CUSTOM_NAME: DashboardTile<QueryBasedInsightModel> = {
+const WIDGET_TILE_WITH_CUSTOM_NAME: DashboardTile = {
id: 8,
widget: { id: '2', widget_type: 'error_tracking_list', config: {}, name: 'Critical errors' },
layouts: {},
color: null,
}
-const uncached = (insight: QueryBasedInsightModel): QueryBasedInsightModel => ({
+const uncached = (insight: InsightModel): InsightModel => ({
...insight,
result: null,
last_refresh: null,
@@ -83,7 +83,7 @@ export const boxToId = (param: string | readonly string[]): number => {
throw new Error("this shouldn't be an array")
}
-const insight800 = (): QueryBasedInsightModel => ({
+const insight800 = (): InsightModel => ({
...insightOnDashboard(800, [9, 10]),
id: 800,
short_id: '800' as InsightShortId,
@@ -111,12 +111,12 @@ describe('dashboardLogic', () => {
* / \
* i666 i999
*/
- let dashboards: Record<number, DashboardType<QueryBasedInsightModel>> = {}
+ let dashboards: Record<number, DashboardType> = {}
beforeEach(() => {
jest.spyOn(api, 'update')
- const insights: Record<number, QueryBasedInsightModel> = {
+ const insights: Record<number, InsightModel> = {
172: {
...insightOnDashboard(172, [5, 6], {
query: examples.InsightRetention,
@@ -296,7 +296,7 @@ describe('dashboardLogic', () => {
}
const insightId = boxToId(params.id as string | readonly string[])
- const starting: QueryBasedInsightModel = insights[insightId]
+ const starting: InsightModel = insights[insightId]
insights[insightId] = {
...starting,
...updates,
@@ -473,10 +473,10 @@ describe('dashboardLogic', () => {
it('persists the latest movement mode after a save is already in flight', async () => {
await expectLogic(logic).toFinishAllListeners()
- let resolveFirstSave: (dashboard: DashboardType<QueryBasedInsightModel>) => void = () => {
+ let resolveFirstSave: (dashboard: DashboardType) => void = () => {
throw new Error('First save resolver is unavailable')
}
- const firstSave = new Promise<DashboardType<QueryBasedInsightModel>>((resolve) => {
+ const firstSave = new Promise<DashboardType>((resolve) => {
resolveFirstSave = resolve
})
;(api.update as jest.Mock).mockImplementationOnce(() => firstSave)
@@ -563,10 +563,10 @@ describe('dashboardLogic', () => {
await expectLogic(logic).toFinishAllListeners()
const staleLayoutResponse = logic.values.dashboard!
- let finishLayoutSave: (dashboard: DashboardType<QueryBasedInsightModel>) => void = () => {
+ let finishLayoutSave: (dashboard: DashboardType) => void = () => {
throw new Error('Layout save resolver is unavailable')
}
- const layoutSave = new Promise<DashboardType<QueryBasedInsightModel>>((resolve) => {
+ const layoutSave = new Promise<DashboardType>((resolve) => {
finishLayoutSave = resolve
})
jest.spyOn(api, 'update')
@@ -1030,7 +1030,7 @@ describe('dashboardLogic', () => {
it('keeps unapplied filters separate from layout cancellation and layout saving', async () => {
const autoPreviewLimit = jest.replaceProperty(dashboardUtils, 'AUTO_PREVIEW_TILE_LIMIT', 8)
- const nineTileDashboard: DashboardType<QueryBasedInsightModel> = {
+ const nineTileDashboard: DashboardType = {
...dashboards[5],
tiles: Array.from({ length: 9 }, (_, index) => ({
...dashboards[5].tiles[0],
@@ -2231,7 +2231,7 @@ describe('dashboardLogic', () => {
})
await expectLogic(dashboardEightlogic, () => {
- dashboardsModel.actions.tileMovedToDashboard({} as DashboardTile<QueryBasedInsightModel>, 8)
+ dashboardsModel.actions.tileMovedToDashboard({} as DashboardTile, 8)
}).toMatchValues({
dashboard: truth(({ tiles }) => {
return tiles.length === 2
@@ -2252,7 +2252,7 @@ describe('dashboardLogic', () => {
})
await expectLogic(dashboardEightlogic, () => {
- dashboardsModel.actions.tileMovedToDashboard({} as DashboardTile<QueryBasedInsightModel>, 10)
+ dashboardsModel.actions.tileMovedToDashboard({} as DashboardTile, 10)
}).toMatchValues({
dashboard: truth(({ tiles }) => {
return tiles.length === 1
@@ -3376,10 +3376,10 @@ describe('dashboardLogic', () => {
it('keeps edits made while dashboard changes save', async () => {
await mountDashboardWithVariable({})
- let finishSave: (dashboard: DashboardType<QueryBasedInsightModel>) => void = () => {
+ let finishSave: (dashboard: DashboardType) => void = () => {
throw new Error('Save resolver is unavailable')
}
- const save = new Promise<DashboardType<QueryBasedInsightModel>>((resolve) => {
+ const save = new Promise<DashboardType>((resolve) => {
finishSave = resolve
})
jest.spyOn(api, 'update').mockReturnValueOnce(save)
@@ -3454,10 +3454,10 @@ describe('dashboardLogic', () => {
it('makes Preview available when a SQL variable changes during an older preview', async () => {
const autoPreviewLimit = jest.replaceProperty(dashboardUtils, 'AUTO_PREVIEW_TILE_LIMIT', 0)
await mountDashboardWithVariable({})
- let finishPreview: (insight: QueryBasedInsightModel) => void = () => {
+ let finishPreview: (insight: InsightModel) => void = () => {
throw new Error('Preview resolver is unavailable')
}
- const preview = new Promise<QueryBasedInsightModel>((resolve) => {
+ const preview = new Promise<InsightModel>((resolve) => {
finishPreview = resolve
})
const getInsightWithRetrySpy = jest.spyOn(dashboardUtils, 'getInsightWithRetry').mockReturnValue(preview)
@@ -3671,7 +3671,7 @@ describe('dashboardLogic', () => {
await expectLogic(logic, () => {
dashboardsModel.actions.updateDashboardInsight({
short_id: 'not_already_on_the_dashboard' as InsightShortId,
- } as QueryBasedInsightModel)
+ } as InsightModel)
})
.toFinishAllListeners()
.toDispatchActions(['loadDashboard'])
@@ -3974,7 +3974,7 @@ describe('dashboardLogic', () => {
}))
).toEqual([{ dashboards: [9, 10], short_id: '800' }])
- const changedInsight: QueryBasedInsightModel = { ...insight800(), dashboards: [10, 5] } // Moved from to 9 to 5
+ const changedInsight: InsightModel = { ...insight800(), dashboards: [10, 5] } // Moved from to 9 to 5
dashboardsModel.actions.updateDashboardInsight(changedInsight, [9])
expect(
@@ -4055,7 +4055,7 @@ describe('dashboardLogic', () => {
dashboard: {
...dashboards[5],
tiles: [...dashboards[5].tiles, WIDGET_TILE],
- } as DashboardType<QueryBasedInsightModel>,
+ } as DashboardType,
})
logic.mount()
await expectLogic(logic).toFinishAllListeners()
@@ -4076,7 +4076,7 @@ describe('dashboardLogic', () => {
dashboard: {
...dashboards[5],
tiles: [...dashboards[5].tiles, WIDGET_TILE],
- } as DashboardType<QueryBasedInsightModel>,
+ } as DashboardType,
})
logic.mount()
await expectLogic(logic).toFinishAllListeners()
@@ -4154,7 +4154,7 @@ describe('dashboardLogic', () => {
widget: { id: '3', widget_type: 'error_tracking_list', config: { limit: 5 } },
layouts: { sm: { i: '99', x: 0, y: 10, w: 6, h: 5 } },
color: null,
- } as unknown as DashboardTile<QueryBasedInsightModel>
+ } as unknown as DashboardTile
jest.spyOn(api, 'update').mockResolvedValueOnce(
dashboardResult(5, [...dashboards[5].tiles, WIDGET_TILE, duplicatedTile])
@@ -4218,7 +4218,7 @@ describe('dashboardLogic', () => {
widget: { id: '3', widget_type: 'error_tracking_list', config: { limit: 5 } },
layouts: { sm: { i: '99', x: 0, y: 10, w: 6, h: 5 } },
color: null,
- } as unknown as DashboardTile<QueryBasedInsightModel>
+ } as unknown as DashboardTile
jest.spyOn(api, 'create').mockResolvedValueOnce({
tiles: [addedTile],
@@ -4260,7 +4260,7 @@ describe('dashboardLogic', () => {
description: 'Top issues this week',
config: { limit: 5 },
},
- } as DashboardTile<QueryBasedInsightModel>)
+ } as DashboardTile)
logic = dashboardLogic({ id: 5 })
logic.mount()
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.testHelpers.ts b/frontend/src/scenes/dashboard/dashboardLogic.testHelpers.ts
index 7658906ea97a..7eadfebc45b0 100644
--- a/frontend/src/scenes/dashboard/dashboardLogic.testHelpers.ts
+++ b/frontend/src/scenes/dashboard/dashboardLogic.testHelpers.ts
@@ -1,6 +1,6 @@
import { getQueryBasedDashboard } from '~/queries/nodes/InsightViz/utils'
import { DashboardFilter } from '~/queries/schema/schema-general'
-import { DashboardTile, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardTile, DashboardType, InsightModel } from '~/types'
import _dashboardJson from './__mocks__/dashboard.json'
@@ -9,8 +9,8 @@ const dashboardJson = getQueryBasedDashboard(_dashboardJson as any as DashboardT
export function insightOnDashboard(
insightId: number,
dashboardsRelation: number[],
- insight: Partial<QueryBasedInsightModel> = {}
-): QueryBasedInsightModel {
+ insight: Partial<InsightModel> = {}
+): InsightModel {
const tiles = dashboardJson.tiles.filter((tile) => !!tile.insight && tile.insight?.id === insightId)
let tile = dashboardJson.tiles[0]
if (tiles.length) {
@@ -28,10 +28,7 @@ export function insightOnDashboard(
}
let tileId = 0
-export const tileFromInsight = (
- insight: QueryBasedInsightModel,
- id: number = tileId++
-): DashboardTile<QueryBasedInsightModel> => ({
+export const tileFromInsight = (insight: InsightModel, id: number = tileId++): DashboardTile => ({
id: id,
layouts: {},
color: null,
@@ -40,9 +37,9 @@ export const tileFromInsight = (
export const dashboardResult = (
dashboardId: number,
- tiles: DashboardTile<QueryBasedInsightModel>[],
+ tiles: DashboardTile[],
filters: Partial<DashboardFilter> = {}
-): DashboardType<QueryBasedInsightModel> => {
+): DashboardType => {
return {
...dashboardJson,
filters: { ...dashboardJson.filters, ...filters },
diff --git a/frontend/src/scenes/dashboard/dashboardLogic.tsx b/frontend/src/scenes/dashboard/dashboardLogic.tsx
index 6e2a84f6487b..9ecbadbc24fb 100644
--- a/frontend/src/scenes/dashboard/dashboardLogic.tsx
+++ b/frontend/src/scenes/dashboard/dashboardLogic.tsx
@@ -103,7 +103,6 @@ import {
InsightShortId,
IntervalType,
ProjectTreeRef,
- QueryBasedInsightModel,
TextModel,
TileLayout,
} from '~/types'
@@ -160,7 +159,7 @@ import { tileLogic } from './tileLogic'
export interface DashboardLogicProps {
id: number
- dashboard?: DashboardType<QueryBasedInsightModel>
+ dashboard?: DashboardType
placement?: DashboardPlacement
}
@@ -225,19 +224,19 @@ function parseDashboardTileId(tileId: string | undefined): DashboardTileIdOrNew
}
const tileLayoutsFromDashboard = (
- dashboard: DashboardType<QueryBasedInsightModel> | null | undefined
+ dashboard: DashboardType | null | undefined
): Record<number, DashboardTile['layouts']> => {
const tileIdToLayouts: Record<number, DashboardTile['layouts']> = {}
- dashboard?.tiles.forEach((tile: DashboardTile<QueryBasedInsightModel>) => {
+ dashboard?.tiles.forEach((tile: DashboardTile) => {
tileIdToLayouts[tile.id] = tile.layouts
})
return tileIdToLayouts
}
function mergeUpdatedWidgetTileIntoDashboard(
- dashboard: DashboardType<QueryBasedInsightModel>,
- updatedTile: DashboardTile<QueryBasedInsightModel>
-): DashboardType<QueryBasedInsightModel> | null {
+ dashboard: DashboardType,
+ updatedTile: DashboardTile
+): DashboardType | null {
return getQueryBasedDashboard({
...dashboard,
tiles: dashboard.tiles.map((existingTile) => {
@@ -254,7 +253,7 @@ function mergeUpdatedWidgetTileIntoDashboard(
: (updatedTile.widget ?? existingTile.widget),
}
}),
- } as DashboardType<InsightModel>)
+ } as DashboardType)
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -299,7 +298,7 @@ export interface dashboardLogicValues {
currentDashboardSettings: DashboardSettings
currentDashboardVariables: Record<string, HogQLVariable>
currentLayoutSize: 'sm' | 'xs'
- dashboard: DashboardType<QueryBasedInsightModel> | null
+ dashboard: DashboardType | null
dashboardCustomizeMenuOpen: boolean
dashboardEditing: DashboardEditing | null
dashboardFailedToLoad: boolean
@@ -342,7 +341,7 @@ export interface dashboardLogicValues {
highlightedInsightId: any
initialDashboardSettingsOverride: DashboardSettings
initialVariablesLoaded: boolean
- insightTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
+ insightTiles: DashboardTile[]
isPinned: boolean
isRefreshing: (id: string) => boolean
isRefreshingQueued: (id: string) => boolean
@@ -393,8 +392,8 @@ export interface dashboardLogicValues {
} | null
terraformModalOpen: boolean
textTileId: DashboardTileIdOrNew
- textTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
- tiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
+ textTiles: DashboardTile[]
+ tiles: DashboardTile[]
urlFilters: DashboardFilter
urlSearchParamsAtEditModeEntry: {
filters?: unknown
@@ -413,7 +412,7 @@ export interface dashboardLogicValues {
widgetResultsByTileId: Record<number, DashboardWidgetRunResultApi>
widgetTileUpdate: null
widgetTileUpdateLoading: boolean
- widgetTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
+ widgetTiles: DashboardTile[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -472,13 +471,13 @@ export interface dashboardLogicActions {
value: true
}
copyToDashboard: (
- tile: DashboardTile<QueryBasedInsightModel>,
+ tile: DashboardTile,
fromDashboard: number,
toDashboard: number,
toDashboardName: string
) => {
fromDashboard: number
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
toDashboard: number
toDashboardName: string
}
@@ -490,18 +489,18 @@ export interface dashboardLogicActions {
errorObject?: any
}
copyToDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
payload?: {
fromDashboard: number
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
toDashboard: number
toDashboardName: string
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
payload?: {
fromDashboard: number
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
toDashboard: number
toDashboardName: string
}
@@ -515,8 +514,8 @@ export interface dashboardLogicActions {
discardLayoutChanges: () => {
value: true
}
- duplicateTile: (tile: DashboardTile<QueryBasedInsightModel>) => {
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ duplicateTile: (tile: DashboardTile) => {
+ tile: DashboardTile
}
duplicateTileFailure: (
error: string,
@@ -526,14 +525,14 @@ export interface dashboardLogicActions {
errorObject?: any
}
duplicateTileSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
payload?: {
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
payload?: {
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
}
}
forceRefreshIfStale: () => {
@@ -549,8 +548,8 @@ export interface dashboardLogicActions {
error: string
errorObject?: any
}
- loadDashboardMetadataSuccess: (dashboard: DashboardType<QueryBasedInsightModel> | null) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ loadDashboardMetadataSuccess: (dashboard: DashboardType | null) => {
+ dashboard: DashboardType | null
}
loadDashboardStreaming: (payload: { action: DashboardLoadAction; manualDashboardRefresh?: boolean }) => {
action: DashboardLoadAction
@@ -577,12 +576,12 @@ export interface dashboardLogicActions {
}
}
loadDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
payload?: {
action: DashboardLoadAction
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
payload?: {
action: DashboardLoadAction
}
@@ -591,7 +590,7 @@ export interface dashboardLogicActions {
action: DashboardLoadAction
}
moveToDashboard: (
- tile: DashboardTile<QueryBasedInsightModel>,
+ tile: DashboardTile,
fromDashboard: number,
toDashboard: number,
toDashboardName: string,
@@ -599,7 +598,7 @@ export interface dashboardLogicActions {
) => {
allowUndo: boolean
fromDashboard: number
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
toDashboard: number
toDashboardName: string
}
@@ -611,20 +610,20 @@ export interface dashboardLogicActions {
errorObject?: any
}
moveToDashboardSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
payload?: {
allowUndo: boolean
fromDashboard: number
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
toDashboard: number
toDashboardName: string
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
payload?: {
allowUndo: boolean
fromDashboard: number
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
toDashboard: number
toDashboardName: string
}
@@ -660,8 +659,8 @@ export interface dashboardLogicActions {
order: number
tile: any
}
- refreshDashboardItem: (payload: { tile: DashboardTile<QueryBasedInsightModel> }) => {
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ refreshDashboardItem: (payload: { tile: DashboardTile }) => {
+ tile: DashboardTile
}
refreshDashboardItems: (payload: {
action: DashboardLoadAction | RefreshDashboardItemsAction
@@ -676,8 +675,8 @@ export interface dashboardLogicActions {
forceRefresh?: boolean | undefined
tileIds: number[]
}
- removeTile: (tile: DashboardTile<QueryBasedInsightModel>) => {
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ removeTile: (tile: DashboardTile) => {
+ tile: DashboardTile
}
removeTileFailure: (
error: string,
@@ -687,21 +686,21 @@ export interface dashboardLogicActions {
errorObject?: any
}
removeTileSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
payload?: {
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
payload?: {
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ tile: DashboardTile
}
}
reportDashboardViewed: () => {
value: true
}
- reportInsightsViewed: (insights: QueryBasedInsightModel[]) => {
- insights: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ reportInsightsViewed: (insights: InsightModel[]) => {
+ insights: InsightModel<Node<Record<string, any>>>[]
}
requestScrollToBottom: () => {
value: true
@@ -731,10 +730,10 @@ export interface dashboardLogicActions {
error: string
}
saveDashboardChangesSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
settings: DashboardSettings | null
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
settings: DashboardSettings | null
}
saveDashboardColorChanges: () => {
@@ -757,12 +756,12 @@ export interface dashboardLogicActions {
errorObject?: any
}
saveEditModeChangesSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
payload?: {
scope: DashboardEditSaveScope
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
payload?: {
scope: DashboardEditSaveScope
}
@@ -816,13 +815,13 @@ export interface dashboardLogicActions {
errorObject?: any
}
setDashboardEditingSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
payload?: {
editing: DashboardEditing | null
source: DashboardEventSource
}
) => {
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
payload?: {
editing: DashboardEditing | null
source: DashboardEventSource
@@ -939,14 +938,14 @@ export interface dashboardLogicActions {
setTextTileId: (textTileId: DashboardTileIdOrNew) => {
textTileId: DashboardTileIdOrNew
}
- setTileOverride: (tile: DashboardTile<QueryBasedInsightModel>) => {
- tile: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>
+ setTileOverride: (tile: DashboardTile) => {
+ tile: DashboardTile
}
setTileProperty: (
tileId: number,
properties: Partial<Pick<DashboardTile, 'color' | 'show_description'>>
) => {
- properties: Partial<Pick<DashboardTile<InsightModel>, 'color' | 'show_description'>>
+ properties: Partial<Pick<DashboardTile, 'color' | 'show_description'>>
tileId: number
}
setWidgetRefreshStatuses: (
@@ -1017,9 +1016,9 @@ export interface dashboardLogicActions {
config?: Record<string, unknown>
description?: string
name?: string | null
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
}) => {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
config?: Record<string, unknown>
name?: string | null
description?: string
@@ -1034,7 +1033,7 @@ export interface dashboardLogicActions {
updateWidgetTileSuccess: (
widgetTileUpdate: null,
payload?: {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
config?: Record<string, unknown>
name?: string | null
description?: string
@@ -1042,7 +1041,7 @@ export interface dashboardLogicActions {
) => {
widgetTileUpdate: null
payload?: {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
config?: Record<string, unknown>
name?: string | null
description?: string
@@ -1086,10 +1085,8 @@ export interface dashboardLogicMeta {
filterEditModeActive: (dashboardEditing: DashboardEditing | null) => boolean
layoutEditMode: (dashboardEditing: DashboardEditing | null) => boolean
shouldUseStreaming: (featureFlags: FeatureFlagsSet) => boolean
- canAutoPreview: (insightTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]) => boolean
- savedDashboardSettings: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
- ) => DashboardSettings
+ canAutoPreview: (insightTiles: DashboardTile[]) => boolean
+ savedDashboardSettings: (dashboard: DashboardType | null) => DashboardSettings
currentDashboardSettings: (
savedDashboardSettings: DashboardSettings,
initialDashboardSettingsOverride: DashboardSettings,
@@ -1118,16 +1115,16 @@ export interface dashboardLogicMeta {
persistableDashboardFilters: (currentDashboardSettings: DashboardSettings) => DashboardFilter
filtersDirty: (
dashboardSettingsState: DashboardSettingsState,
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
persistableDashboardFilters: DashboardFilter
) => boolean
variablesDirty: (
dashboardSettingsState: DashboardSettingsState,
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
currentDashboardVariables: Record<string, HogQLVariable>
) => boolean
filterChanges: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
persistableDashboardFilters: DashboardFilter
) => DashboardFilterChange[]
changedFilterCount: (filterChanges: DashboardSettingsChange[]) => number
@@ -1137,7 +1134,7 @@ export interface dashboardLogicMeta {
variables: Variable[]
) => DashboardSettingsChange[]
anyInsightExceedsRetention: (
- insightTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[],
+ insightTiles: DashboardTile[],
effectiveEditBarFilters: DashboardFilter,
retentionMonths: number | null
) => boolean
@@ -1152,14 +1149,14 @@ export interface dashboardLogicMeta {
) => DashboardFilter
currentDashboardVariables: (currentDashboardSettings: DashboardSettings) => Record<string, HogQLVariable>
hasUnsavedLayoutChanges: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
dashboardLayouts: Record<
number,
Record<string, never> | Record<DashboardLayoutSize, TileLayout> | undefined
>
) => boolean
effectiveVariablesAndAssociatedInsights: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
variables: Variable[],
currentDashboardVariables: Record<string, HogQLVariable>
) => {
@@ -1177,9 +1174,7 @@ export interface dashboardLogicMeta {
variable: Variable
}[]
) => boolean
- asDashboardTemplate: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
- ) => DashboardTemplateEditorType | undefined
+ asDashboardTemplate: (dashboard: DashboardType | null) => DashboardTemplateEditorType | undefined
placement: (arg: any) => DashboardPlacement
apiUrl: (
id: number
@@ -1190,23 +1185,15 @@ export interface dashboardLogicMeta {
layoutSize?: 'sm' | 'xs' | undefined
) => string
currentLayoutSize: (containerWidth: number | null) => 'sm' | 'xs'
- tiles: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
- ) => DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
- widgetTiles: (
- tiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
- ) => DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
+ tiles: (dashboard: DashboardType | null) => DashboardTile[]
+ widgetTiles: (tiles: DashboardTile[]) => DashboardTile[]
dashboardWidgetsEnabled: (
featureFlags: FeatureFlagsSet,
- tiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[],
+ tiles: DashboardTile[],
placement: DashboardPlacement
) => boolean
- insightTiles: (
- tiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
- ) => DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
- textTiles: (
- tiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
- ) => DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
+ insightTiles: (tiles: DashboardTile[]) => DashboardTile[]
+ textTiles: (tiles: DashboardTile[]) => DashboardTile[]
itemsLoading: (
dashboardLoading: boolean,
dashboardStreaming: boolean,
@@ -1216,7 +1203,7 @@ export interface dashboardLogicMeta {
isRefreshingQueued: (refreshStatus: Record<string, RefreshStatus>) => (id: string) => boolean
isRefreshing: (refreshStatus: Record<string, RefreshStatus>) => (id: string) => boolean
highlightedInsightId: (searchParams: Record<string, any>) => any
- sortedDates: (insightTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]) => Dayjs[]
+ sortedDates: (insightTiles: DashboardTile[]) => Dayjs[]
oldestRefreshed: (sortedDates: Dayjs[], pageVisibility: boolean) => Dayjs | null
effectiveLastRefresh: (lastDashboardRefresh: Dayjs | null, oldestRefreshed: Dayjs | null) => Dayjs | null
nextAllowedDashboardRefresh: (lastDashboardRefresh: Dayjs | null) => Dayjs | null
@@ -1225,22 +1212,18 @@ export interface dashboardLogicMeta {
placement: DashboardPlacement,
pageVisibility: boolean
) => boolean
- canEditDashboard: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
- ) => boolean
+ canEditDashboard: (dashboard: DashboardType | null) => boolean
canSaveProjectDashboardTemplate: (
canEditDashboard: boolean,
asDashboardTemplate: DashboardTemplateEditorType | undefined
) => boolean
canRestrictDashboard: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
user: null | import('~/types').UserType,
currentTeam: null | import('~/types').TeamPublicType | import('~/types').TeamType
) => boolean
sizeKey: (columns: number | null) => DashboardLayoutSize | undefined
- layouts: (
- tiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
- ) => Partial<Record<DashboardLayoutSize, Layout>>
+ layouts: (tiles: DashboardTile[]) => Partial<Record<DashboardLayoutSize, Layout>>
layout: (
layouts: Partial<Record<DashboardLayoutSize, Layout>>,
sizeKey: DashboardLayoutSize | undefined
@@ -1254,35 +1237,30 @@ export interface dashboardLogicMeta {
total: number
}
breadcrumbs: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
error404: boolean,
dashboardFailedToLoad: boolean,
searchParams: Record<string, any>
) => Breadcrumb[]
projectTreeRef: (arg: number) => ProjectTreeRef
hasInvalidDashboardId: (arg: number) => boolean
- sidePanelContext: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
- ) => SidePanelSceneContext | null
+ sidePanelContext: (dashboard: DashboardType | null) => SidePanelSceneContext | null
dataColorThemeId: (
temporaryDataColorThemeId: {
themeId: number | null
} | null,
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
) => number | null
dataColorTheme: (
dataColorThemeId: number | null,
getTheme: (themeId: number | string | null | undefined) => DataColorTheme | null // dataThemeLogic
) => DataColorTheme | null
autoBreakdownColorsEnabled: (featureFlags: FeatureFlagsSet) => boolean
- breakdownValuesIncomplete: (
- itemsLoading: boolean,
- insightTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[]
- ) => boolean
+ breakdownValuesIncomplete: (itemsLoading: boolean, insightTiles: DashboardTile[]) => boolean
effectiveBreakdownColors: (
temporaryBreakdownColors: BreakdownColorConfig[],
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
- insightTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[],
+ dashboard: DashboardType | null,
+ insightTiles: DashboardTile[],
breakdownValuesIncomplete: boolean,
autoBreakdownColorsEnabled: boolean,
dataColorTheme: DataColorTheme | null
@@ -1292,11 +1270,9 @@ export interface dashboardLogicMeta {
temporaryDataColorThemeId: {
themeId: number | null
} | null,
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
+ dashboard: DashboardType | null
) => boolean
- maxContext: (
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null
- ) => MaxContextInput[]
+ maxContext: (dashboard: DashboardType | null) => MaxContextInput[]
}
}
@@ -1353,7 +1329,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
/** Load dashboard with streaming tiles approach. */
loadDashboardStreaming: (payload: { action: DashboardLoadAction; manualDashboardRefresh?: boolean }) => payload,
/** Dashboard metadata loaded successfully. */
- loadDashboardMetadataSuccess: (dashboard: DashboardType<QueryBasedInsightModel> | null) => ({ dashboard }),
+ loadDashboardMetadataSuccess: (dashboard: DashboardType | null) => ({ dashboard }),
/** Single tile received from stream. */
receiveTileFromStream: (data: { tile: any; order: number }) => data,
/** Tile streaming completed. */
@@ -1375,7 +1351,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
*/
forceRefreshIfStale: true,
/** Manually refresh a single insight from the insight card on the dashboard. */
- refreshDashboardItem: (payload: { tile: DashboardTile<QueryBasedInsightModel> }) => payload,
+ refreshDashboardItem: (payload: { tile: DashboardTile }) => payload,
/** Refresh tiles of a loaded dashboard e.g. stale tiles after initial load, previewed tiles after applying filters, etc. */
refreshDashboardItems: (payload: {
action: RefreshDashboardItemsAction | DashboardLoadAction
@@ -1450,10 +1426,10 @@ export const dashboardLogic = kea<dashboardLogicType>([
previewDashboardChanges: true,
previewDashboardChangesFailure: true,
saveDashboardChanges: true,
- saveDashboardChangesSuccess: (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
- settings: DashboardSettings | null
- ) => ({ dashboard, settings }),
+ saveDashboardChangesSuccess: (dashboard: DashboardType | null, settings: DashboardSettings | null) => ({
+ dashboard,
+ settings,
+ }),
saveDashboardChangesFailure: (error: string) => ({ error }),
discardDashboardChanges: true,
saveDashboardColorChanges: true,
@@ -1508,10 +1484,10 @@ export const dashboardLogic = kea<dashboardLogicType>([
tileId,
properties,
}),
- duplicateTile: (tile: DashboardTile<QueryBasedInsightModel>) => ({ tile }),
- removeTile: (tile: DashboardTile<QueryBasedInsightModel>) => ({ tile }),
+ duplicateTile: (tile: DashboardTile) => ({ tile }),
+ removeTile: (tile: DashboardTile) => ({ tile }),
moveToDashboard: (
- tile: DashboardTile<QueryBasedInsightModel>,
+ tile: DashboardTile,
fromDashboard: number,
toDashboard: number,
toDashboardName: string,
@@ -1524,7 +1500,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
allowUndo: allowUndo === undefined ? true : allowUndo,
}),
copyToDashboard: (
- tile: DashboardTile<QueryBasedInsightModel>,
+ tile: DashboardTile,
fromDashboard: number,
toDashboard: number,
toDashboardName: string
@@ -1540,14 +1516,14 @@ export const dashboardLogic = kea<dashboardLogicType>([
openTextTileModal: true,
openImageTileModal: true,
openButtonTileModal: true,
- setTileOverride: (tile: DashboardTile<QueryBasedInsightModel>) => ({ tile }),
+ setTileOverride: (tile: DashboardTile) => ({ tile }),
/**
* Usage tracking.
*/
setShouldReportOnAPILoad: (shouldReport: boolean) => ({ shouldReport }), // See reducer for details
reportDashboardViewed: true, // Reports `viewed dashboard` and `dashboard analyzed` events
- reportInsightsViewed: (insights: QueryBasedInsightModel[]) => ({ insights }),
+ reportInsightsViewed: (insights: InsightModel[]) => ({ insights }),
/**
* Dashboard result colors.
@@ -1570,7 +1546,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
loaders(({ actions, props, values, cache }) => ({
dashboard: [
- null as DashboardType<QueryBasedInsightModel> | null,
+ null as DashboardType | null,
{
loadDashboard: async ({ action }, breakpoint) => {
actions.loadingDashboardItemsStarted(action)
@@ -1584,7 +1560,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
values.currentDashboardVariables
)
const dashboardResponse: Response = await api.getResponse(apiUrl)
- const dashboard: DashboardType<InsightModel> | null = await getJSONOrNull(dashboardResponse)
+ const dashboard: DashboardType | null = await getJSONOrNull(dashboardResponse)
actions.setInitialLoadResponseBytes(getResponseBytes(dashboardResponse))
@@ -1620,7 +1596,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
if (data.type === 'metadata') {
metadataReceived = true
actions.loadDashboardMetadataSuccess(
- getQueryBasedDashboard(data.dashboard as DashboardType<InsightModel>)
+ getQueryBasedDashboard(data.dashboard as DashboardType)
)
} else if (data.type === 'tile') {
actions.receiveTileFromStream(data)
@@ -1701,7 +1677,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
: {
tiles: layoutsToUpdate,
}
- const persistedDashboard: DashboardType<InsightModel> = await api.update(
+ const persistedDashboard: DashboardType = await api.update(
`api/environments/${values.currentTeamId}/dashboards/${props.id}`,
payload
)
@@ -1756,7 +1732,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
return {
...values.dashboard,
tiles: [...(values.tiles || []), tile],
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
}
},
setDashboardEditing: async ({ editing, source }) => {
@@ -1780,14 +1756,14 @@ export const dashboardLogic = kea<dashboardLogicType>([
},
duplicateTile: async ({ tile }) => {
try {
- const newTile = { ...tile } as Partial<DashboardTile<QueryBasedInsightModel>>
+ const newTile = { ...tile } as Partial<DashboardTile>
if (newTile.text) {
newTile.text = { body: newTile.text.body } as TextModel
}
const { duplicateLayouts, tilesToUpdate } = calculateDuplicateLayout(values.layouts, tile.id)
- const dashboard: DashboardType<InsightModel> = await api.update(
+ const dashboard: DashboardType = await api.update(
`api/environments/${values.currentTeamId}/dashboards/${props.id}`,
{
duplicate_tiles: [{ ...newTile, layouts: duplicateLayouts }],
@@ -1810,7 +1786,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
if (fromDashboard !== props.id) {
return values.dashboard
}
- const dashboard: DashboardType<InsightModel> = await api.update(
+ const dashboard: DashboardType = await api.update(
`api/environments/${teamLogic.values.currentTeamId}/dashboards/${props.id}/move_tile`,
{
tile,
@@ -1897,7 +1873,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
name,
description,
}: {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
config?: Record<string, unknown>
name?: string | null
description?: string
@@ -2082,7 +2058,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
},
],
dashboard: [
- null as DashboardType<QueryBasedInsightModel> | null,
+ null as DashboardType | null,
{
dashboardNotFound: () => null,
setAccessDeniedToDashboard: () => null,
@@ -2096,13 +2072,13 @@ export const dashboardLogic = kea<dashboardLogicType>([
...tile,
layouts: itemLayouts[tile.id]?.sm ? { sm: itemLayouts[tile.id].sm } : {},
})),
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
},
setTileProperty: (state, { tileId, properties }) => {
return {
...state,
tiles: state?.tiles?.map((tile) => (tile.id === tileId ? { ...tile, ...properties } : tile)),
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
},
setDashboardTileSpacing: (state, { tileSpacing }) =>
state
@@ -2123,7 +2099,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
return {
...state,
tiles: state?.tiles?.filter((t) => t.id !== tile.id),
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
},
[dashboardsModel.actionTypes.tileMovedToDashboard]: (state, { tile, dashboardId }) => {
if (state && state.id === dashboardId) {
@@ -2141,7 +2117,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
extraDashboardIds,
sourceDashboardId,
}: {
- insight: QueryBasedInsightModel
+ insight: InsightModel
extraDashboardIds?: number[]
sourceDashboardId?: number
}
@@ -2182,7 +2158,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
return {
...state,
tiles: newTiles.filter((t) => !t.deleted || !t.insight?.deleted),
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
}
return null
@@ -2198,10 +2174,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
persisted_variables: dashboard.persisted_variables,
}
: state,
- [insightsModel.actionTypes.renameInsightSuccess]: (
- state,
- { item }
- ): DashboardType<QueryBasedInsightModel> | null => {
+ [insightsModel.actionTypes.renameInsightSuccess]: (state, { item }): DashboardType | null => {
const tileIndex = state?.tiles.findIndex((t) => !!t.insight && t.insight.short_id === item.short_id)
const tiles = state?.tiles.slice(0)
@@ -2214,7 +2187,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
// tile's already-computed chart data instead of blanking it into "Chart data didn't load".
// SQL insights draw from `columns` and `types` rather than `result`, so those have to
// survive the merge too or the tile loses the columns it picks its axes from.
- const existing = tiles[tileIndex].insight as QueryBasedInsightModel
+ const existing = tiles[tileIndex].insight as InsightModel
tiles[tileIndex] = {
...tiles[tileIndex],
insight: {
@@ -2231,7 +2204,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
return {
...state,
tiles,
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
},
loadDashboardMetadataSuccess: (state, { dashboard }) => {
if (!dashboard) {
@@ -2254,7 +2227,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
return {
...state,
tiles: newTiles,
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
},
},
],
@@ -2676,15 +2649,11 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
canAutoPreview: [
(s) => [s.insightTiles],
- (
- insightTiles: DashboardTile<
- QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
- >[]
- ): boolean => insightTiles.length < AUTO_PREVIEW_TILE_LIMIT,
+ (insightTiles: DashboardTile[]): boolean => insightTiles.length < AUTO_PREVIEW_TILE_LIMIT,
],
savedDashboardSettings: [
(s) => [s.dashboard],
- (dashboard: DashboardType<QueryBasedInsightModel> | null): DashboardSettings => ({
+ (dashboard: DashboardType | null): DashboardSettings => ({
filters: dashboard?.persisted_filters || {},
variables: dashboard?.persisted_variables || {},
}),
@@ -2765,7 +2734,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
(s) => [s.dashboardSettingsState, s.dashboard, s.persistableDashboardFilters],
(
state: DashboardSettingsState,
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
persistableDashboardFilters: DashboardFilter
): boolean =>
state === 'unsavedChanges' && !equal(dashboard?.persisted_filters || {}, persistableDashboardFilters),
@@ -2774,7 +2743,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
(s) => [s.dashboardSettingsState, s.dashboard, s.currentDashboardVariables],
(
state: DashboardSettingsState,
- dashboard: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>> | null,
+ dashboard: DashboardType | null,
variables: {
[x: string]: HogQLVariable
}
@@ -2782,10 +2751,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
filterChanges: [
(s) => [s.dashboard, s.persistableDashboardFilters],
- (
- dashboard: DashboardType<QueryBasedInsightModel> | null,
- persistableDashboardFilters: DashboardFilter
- ): DashboardFilterChange[] =>
+ (dashboard: DashboardType | null, persistableDashboardFilters: DashboardFilter): DashboardFilterChange[] =>
getDashboardFilterChanges(dashboard?.persisted_filters || {}, persistableDashboardFilters),
],
changedFilterCount: [
@@ -2821,7 +2787,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
anyInsightExceedsRetention: [
(s) => [s.insightTiles, s.effectiveEditBarFilters, s.retentionMonths],
(
- insightTiles: DashboardTile<QueryBasedInsightModel<Node<Record<string, any>>>>[],
+ insightTiles: DashboardTile[],
dashboardFilters: DashboardFilter,
retentionMonths: number | null
): boolean =>
@@ -2860,13 +2826,13 @@ export const dashboardLogic = kea<dashboardLogicType>([
hasUnsavedLayoutChanges: [
(s) => [s.dashboard, s.dashboardLayouts],
(
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
dashboardLayouts: Record<DashboardTile['id'], DashboardTile['layouts']>
): boolean => {
if (!dashboard) {
return false
}
- return (dashboard.tiles || []).some((tile: DashboardTile<QueryBasedInsightModel>) => {
+ return (dashboard.tiles || []).some((tile: DashboardTile) => {
const originalSm = dashboardLayouts?.[tile.id]?.sm
const currentSm = tile.layouts?.sm
return !equal(originalSm || {}, currentSm || {})
@@ -3017,24 +2983,14 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
tiles: [
(s) => [s.dashboard],
- (dashboard: DashboardType<QueryBasedInsightModel> | null) =>
- dashboard?.tiles?.filter((t) => !t.deleted) || [],
- ],
- widgetTiles: [
- (s) => [s.tiles],
- (
- tiles: DashboardTile<
- QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
- >[]
- ) => tiles.filter((t) => !!t.widget),
+ (dashboard: DashboardType | null) => dashboard?.tiles?.filter((t) => !t.deleted) || [],
],
+ widgetTiles: [(s) => [s.tiles], (tiles: DashboardTile[]) => tiles.filter((t) => !!t.widget)],
dashboardWidgetsEnabled: [
(s) => [s.featureFlags, s.tiles, s.placement],
(
featureFlags: import('lib/logic/featureFlagLogic').FeatureFlagsSet,
- tiles: DashboardTile<
- QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
- >[],
+ tiles: DashboardTile[],
placement: DashboardPlacement
): boolean => {
// Shared dashboards don't receive team feature flags; render widget tiles when
@@ -3047,20 +3003,9 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
insightTiles: [
(s) => [s.tiles],
- (
- tiles: DashboardTile<
- QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
- >[]
- ) => tiles.filter((t) => !!t.insight).filter((i) => !i.insight?.deleted),
- ],
- textTiles: [
- (s) => [s.tiles],
- (
- tiles: DashboardTile<
- QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
- >[]
- ) => tiles.filter((t) => !!t.text),
+ (tiles: DashboardTile[]) => tiles.filter((t) => !!t.insight).filter((i) => !i.insight?.deleted),
],
+ textTiles: [(s) => [s.tiles], (tiles: DashboardTile[]) => tiles.filter((t) => !!t.text)],
itemsLoading: [
(s) => [s.dashboardLoading, s.dashboardStreaming, s.refreshStatus, s.initialVariablesLoaded],
(
@@ -3091,11 +3036,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
sortedDates: [
(s) => [s.insightTiles],
- (
- insightTiles: DashboardTile<
- QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
- >[]
- ): Dayjs[] => {
+ (insightTiles: DashboardTile[]): Dayjs[] => {
if (!insightTiles || !insightTiles.length) {
return []
}
@@ -3151,7 +3092,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
canEditDashboard: [
(s) => [s.dashboard],
- (dashboard: DashboardType<QueryBasedInsightModel> | null) => {
+ (dashboard: DashboardType | null) => {
return dashboard?.user_access_level
? accessLevelSatisfied(
AccessControlResourceType.Dashboard,
@@ -3171,7 +3112,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
// Sync conditions with backend can_user_restrict
(s) => [s.dashboard, userLogic.selectors.user, teamLogic.selectors.currentTeam],
(
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
user: null | import('~/types').UserType,
currentTeam: null | import('~/types').TeamPublicType | import('~/types').TeamType
): boolean =>
@@ -3191,11 +3132,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
layouts: [
(s) => [s.tiles],
- (
- tiles: DashboardTile<
- QueryBasedInsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>>
- >[]
- ) => calculateLayouts(tiles),
+ (tiles: DashboardTile[]) => calculateLayouts(tiles),
// Tile refreshes replace `tiles` once per insight response without touching geometry;
// keeping the result reference stable stops react-grid-layout re-laying-out every tile
// N times per dashboard refresh cycle.
@@ -3235,7 +3172,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
breadcrumbs: [
(s) => [s.dashboard, s.error404, s.dashboardFailedToLoad, router.selectors.searchParams],
(
- dashboard: DashboardType<QueryBasedInsightModel> | null,
+ dashboard: DashboardType | null,
error404: boolean,
dashboardFailedToLoad: boolean,
searchParams: Record<string, any>
@@ -3282,7 +3219,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
[SIDE_PANEL_CONTEXT_KEY]: [
(s) => [s.dashboard],
- (dashboard: DashboardType<QueryBasedInsightModel> | null): SidePanelSceneContext | null => {
+ (dashboard: DashboardType | null): SidePanelSceneContext | null => {
return dashboard
? {
activity_scope: ActivityScope.DASHBOARD,
@@ -3297,7 +3234,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
(s) => [s.temporaryDataColorThemeId, s.dashboard],
(
temporaryDataColorThemeId: { themeId: number | null } | null,
- dashboard: DashboardType<QueryBasedInsightModel> | null
+ dashboard: DashboardType | null
): number | null =>
temporaryDataColorThemeId
? temporaryDataColorThemeId.themeId
@@ -3320,7 +3257,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
// loading settles, hiding its breakdown values from the sharing check.
breakdownValuesIncomplete: [
(s) => [s.itemsLoading, s.insightTiles],
- (itemsLoading: boolean, insightTiles: DashboardTile<QueryBasedInsightModel>[] | null): boolean =>
+ (itemsLoading: boolean, insightTiles: DashboardTile[] | null): boolean =>
itemsLoading || hasUnresolvedBreakdownTiles(insightTiles),
],
// Persisted colors with unsaved edits merged over them, plus auto-assigned colors for
@@ -3338,8 +3275,8 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
(
temporaryBreakdownColors: BreakdownColorConfig[],
- dashboard: DashboardType<QueryBasedInsightModel> | null,
- insightTiles: DashboardTile<QueryBasedInsightModel>[] | null,
+ dashboard: DashboardType | null,
+ insightTiles: DashboardTile[] | null,
breakdownValuesIncomplete: boolean,
autoBreakdownColorsEnabled: boolean,
dataColorTheme: DataColorTheme | null
@@ -3374,7 +3311,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
(
temporaryBreakdownColors: BreakdownColorConfig[],
temporaryDataColorThemeId: { themeId: number | null } | null,
- dashboard: DashboardType<QueryBasedInsightModel> | null
+ dashboard: DashboardType | null
): boolean => {
const persisted = dashboard?.breakdown_colors ?? []
const colorsChanged = temporaryBreakdownColors.some((config) => {
@@ -3396,7 +3333,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
],
maxContext: [
(s) => [s.dashboard],
- (dashboard: DashboardType<QueryBasedInsightModel> | null): MaxContextInput[] => {
+ (dashboard: DashboardType | null): MaxContextInput[] => {
if (!dashboard) {
return []
}
@@ -3603,7 +3540,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
extraDashboardIds,
sourceDashboardId,
}: {
- insight: QueryBasedInsightModel
+ insight: InsightModel
extraDashboardIds?: number[]
sourceDashboardId?: number
}) => {
@@ -3626,7 +3563,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
actions.loadDashboard({ action: DashboardLoadAction.Update })
}
},
- [insightsModel.actionTypes.renameInsightSuccess]: ({ item }: { item: QueryBasedInsightModel }) => {
+ [insightsModel.actionTypes.renameInsightSuccess]: ({ item }: { item: InsightModel }) => {
const targetDashboards = (item.dashboard_tiles || []).map((tile) => tile.dashboard_id)
if (!targetDashboards.includes(props.id)) {
// this update is not for this dashboard
@@ -3667,7 +3604,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
cache.removedTileForUndo = tile
},
removeTileSuccess: () => {
- const tile = cache.removedTileForUndo as DashboardTile<QueryBasedInsightModel> | undefined
+ const tile = cache.removedTileForUndo as DashboardTile | undefined
cache.removedTileForUndo = undefined
if (!tile) {
return
@@ -3845,7 +3782,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
}
const { tile, fromDashboard, toDashboard, toDashboardName } = payload
- const updatedTile: DashboardTile<QueryBasedInsightModel> = { ...tile }
+ const updatedTile: DashboardTile = { ...tile }
const nextTilePlacement = (
existing: DashboardTileBasicType[] | null | undefined
@@ -3931,7 +3868,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
cache.dashboardTileSpacingSaveInFlight = true
actions.setDashboardTileSpacingSaving(true)
try {
- const dashboard = await api.update<DashboardType<QueryBasedInsightModel>>(
+ const dashboard = await api.update<DashboardType>(
`api/environments/${values.currentTeamId}/dashboards/${props.id}`,
{
grid_spacing: tileSpacing,
@@ -3974,7 +3911,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
: DashboardGridCompaction.Vertical
cache.dashboardGridCompactionSaveInFlight = true
try {
- const dashboard = await api.update<DashboardType<QueryBasedInsightModel>>(
+ const dashboard = await api.update<DashboardType>(
`api/environments/${values.currentTeamId}/dashboards/${props.id}`,
{
layout_compaction: layoutCompaction,
@@ -4117,9 +4054,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
const sortedTilesToRefresh = allInsightTiles
// sort tiles so we poll them in the exact order they are computed on the backend
.sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
- .filter(
- (t): t is DashboardTile<QueryBasedInsightModel> & { insight: QueryBasedInsightModel } => !!t.insight
- )
+ .filter((t): t is DashboardTile & { insight: InsightModel } => !!t.insight)
// only refresh stale insights
.filter(
(t) =>
@@ -4364,7 +4299,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
const dashboard = getQueryBasedDashboard({
...values.dashboard,
tiles: [...values.dashboard.tiles, ...createdTiles],
- } as DashboardType<InsightModel>)
+ } as DashboardType)
if (dashboard) {
dashboardsModel.actions.updateDashboardSuccess(dashboard)
@@ -4636,10 +4571,8 @@ export const dashboardLogic = kea<dashboardLogicType>([
dashboardNotFound: () => {
sceneLogic.findMounted()?.actions.resetUnavailableHomepage(urls.dashboard(props.id))
},
- reportInsightsViewed: ({ insights }: { insights: QueryBasedInsightModel[] }) => {
- const insightIds = insights
- .map((insight: QueryBasedInsightModel) => insight?.id)
- .filter((id): id is number => !!id)
+ reportInsightsViewed: ({ insights }: { insights: InsightModel[] }) => {
+ const insightIds = insights.map((insight: InsightModel) => insight?.id).filter((id): id is number => !!id)
if (insightIds.length > 0 && values.currentTeamId && !isSharedView()) {
void api.create(`api/environments/${values.currentTeamId}/insights/viewed`, {
@@ -4654,7 +4587,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
if (dashboard) {
eventUsageLogic.actions.reportDashboardViewed(dashboard, lastDashboardRefresh)
- const insights = tiles.map((t) => t.insight).filter((i): i is QueryBasedInsightModel => !!i)
+ const insights = tiles.map((t) => t.insight).filter((i): i is InsightModel => !!i)
actions.reportInsightsViewed(insights)
await breakpoint(IS_TEST_MODE ? 1 : 10000) // Tests will wait for all breakpoints to finish
diff --git a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.test.ts b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.test.ts
index 77575ad0ec6f..497f868cf08a 100644
--- a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.test.ts
@@ -18,14 +18,7 @@ import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'
import { useMocks } from '~/mocks/jest'
import { SubscriptionFreeTierLimit } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
-import {
- AccessControlLevel,
- AvailableFeature,
- DashboardPlacement,
- DashboardType,
- QueryBasedInsightModel,
- UserType,
-} from '~/types'
+import { AccessControlLevel, AvailableFeature, DashboardPlacement, DashboardType, UserType } from '~/types'
import { subscriptionsLogic } from 'products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic'
import { subscriptionsList } from 'products/subscriptions/frontend/generated/api'
@@ -66,13 +59,13 @@ const USER_WITH_SUBSCRIPTIONS_FEATURE: UserType = {
},
}
-function mockDashboard(): DashboardType<QueryBasedInsightModel> {
+function mockDashboard(): DashboardType {
return {
id: DASHBOARD_ID,
name: 'Test dashboard',
user_access_level: AccessControlLevel.Editor,
tiles: [],
- } as unknown as DashboardType<QueryBasedInsightModel>
+ } as unknown as DashboardType
}
function capturesOf(event: string): any[][] {
diff --git a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
index 4ee94aab56ec..bbffdcfd276f 100644
--- a/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
+++ b/frontend/src/scenes/dashboard/dashboardSubscribeNudgeLogic.ts
@@ -36,7 +36,7 @@ import {
import { subscriptionsLogic } from 'products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic'
import { canNudgeToSubscribe } from 'products/subscriptions/frontend/components/Subscriptions/utils'
-import type { DashboardType, QueryBasedInsightModel } from '../../types'
+import type { DashboardType } from '../../types'
import type { DashboardViewLog } from './dashboardSubscribeNudgeStoreLogic'
export const DASHBOARD_SUBSCRIBE_NUDGE_VIEW_THRESHOLD = 3
@@ -48,7 +48,7 @@ export interface DashboardSubscribeNudgeLogicProps {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface dashboardSubscribeNudgeLogicValues {
canEditDashboard: boolean // dashboardLogic
- dashboard: DashboardType<QueryBasedInsightModel> | null // dashboardLogic
+ dashboard: DashboardType | null // dashboardLogic
placement: DashboardPlacement // dashboardLogic
notifiedDashboardIds: number[] // dashboardSubscribeNudgeStoreLogic
suppressedDashboardIds: number[] // dashboardSubscribeNudgeStoreLogic
@@ -142,9 +142,7 @@ export interface dashboardSubscribeNudgeLogicMeta {
isSuppressed: (suppressedDashboardIds: number[], arg: any) => boolean
isNotified: (notifiedDashboardIds: number[], arg: any) => boolean
isDashboardEligible: (
- dashboard: DashboardType<
- QueryBasedInsightModel<import('../../queries/schema').Node<Record<string, any>>>
- > | null,
+ dashboard: DashboardType | null,
canEditDashboard: boolean,
placement: DashboardPlacement
) => boolean
@@ -258,13 +256,8 @@ export const dashboardSubscribeNudgeLogic = kea<dashboardSubscribeNudgeLogicType
// is the count check in `isWithinSubscriptionLimit` instead.
isDashboardEligible: [
(s) => [s.dashboard, s.canEditDashboard, s.placement],
- (
- dashboard: DashboardType<
- QueryBasedInsightModel<import('../../queries/schema').Node<Record<string, any>>>
- > | null,
- canEditDashboard: boolean,
- placement: DashboardPlacement
- ): boolean => !!dashboard && canEditDashboard && placement === DashboardPlacement.Dashboard,
+ (dashboard: DashboardType | null, canEditDashboard: boolean, placement: DashboardPlacement): boolean =>
+ !!dashboard && canEditDashboard && placement === DashboardPlacement.Dashboard,
],
hasSubscriptionsFeature: [
(s) => [s.hasAvailableFeature],
diff --git a/frontend/src/scenes/dashboard/dashboardUtils.test.ts b/frontend/src/scenes/dashboard/dashboardUtils.test.ts
index 313a10b7ca60..8d075f766530 100644
--- a/frontend/src/scenes/dashboard/dashboardUtils.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardUtils.test.ts
@@ -11,7 +11,6 @@ import {
InsightModel,
PropertyFilterType,
PropertyOperator,
- QueryBasedInsightModel,
} from '~/types'
import {
@@ -72,7 +71,7 @@ describe('searchParamsWithUrlFilters', () => {
describe('getDashboardTileDisplayName', () => {
it('uses widget header title when no custom name is set', () => {
- const tile: DashboardTile<QueryBasedInsightModel> = {
+ const tile: DashboardTile = {
id: 1,
widget: { id: '1', widget_type: 'error_tracking_list', config: {} },
layouts: {},
@@ -83,7 +82,7 @@ describe('getDashboardTileDisplayName', () => {
})
it('uses custom widget name when set', () => {
- const tile: DashboardTile<QueryBasedInsightModel> = {
+ const tile: DashboardTile = {
id: 1,
widget: { id: '1', widget_type: 'error_tracking_list', config: {}, name: 'Critical errors' },
layouts: {},
@@ -115,7 +114,7 @@ describe('dashboardToSaveableTemplate', () => {
color: null,
},
],
- } as unknown as DashboardType<InsightModel>
+ } as unknown as DashboardType
const tile = dashboardToSaveableTemplate(dashboard)?.tiles[0]
expect(tile).toMatchObject({
@@ -160,7 +159,7 @@ describe('dashboardToSaveableTemplate', () => {
transparent_background: false,
},
],
- } as unknown as DashboardType<InsightModel>
+ } as unknown as DashboardType
expect(dashboardToSaveableTemplate(dashboard)?.tiles).toMatchObject([
{ type: 'TEXT', transparent_background: true },
@@ -266,7 +265,7 @@ describe('dashboardSearchParamsFromOverrides', () => {
})
describe('getInsightWithRetry', () => {
- const insight = { id: 300, short_id: 'abc123', name: 'Test insight' } as QueryBasedInsightModel
+ const insight = { id: 300, short_id: 'abc123', name: 'Test insight' } as InsightModel
const MAX_ATTEMPTS = 3
afterEach(() => {
diff --git a/frontend/src/scenes/dashboard/dashboardUtils.ts b/frontend/src/scenes/dashboard/dashboardUtils.ts
index c27e830cf33d..89f038d1e127 100644
--- a/frontend/src/scenes/dashboard/dashboardUtils.ts
+++ b/frontend/src/scenes/dashboard/dashboardUtils.ts
@@ -28,13 +28,12 @@ import {
DashboardWidgetType,
InsightFilterOverrideContext,
InsightModel,
- QueryBasedInsightModel,
TileLayout,
} from '~/types'
import { SHARED_DASHBOARD_AUTO_FORCE_IF_STALE_MINUTES } from './dashboardConstants'
-export function getInsightQueryError(insight: QueryBasedInsightModel): ApiError | null {
+export function getInsightQueryError(insight: InsightModel): ApiError | null {
const queryStatus = insight.query_status
if (!queryStatus?.error) {
return null
@@ -50,7 +49,7 @@ export function getInsightQueryError(insight: QueryBasedInsightModel): ApiError
/** Shape used for staff JSON export, customer save-as-template, and API `create_from_template_json`. */
export function dashboardToSaveableTemplate(
- dashboard: DashboardType<InsightModel> | null | undefined
+ dashboard: DashboardType | null | undefined
): DashboardTemplateEditorType | undefined {
if (!dashboard) {
return undefined
@@ -113,7 +112,7 @@ export function dashboardToSaveableTemplate(
}
}
-export function getDashboardTileDisplayName(tile: DashboardTile<QueryBasedInsightModel>): string {
+export function getDashboardTileDisplayName(tile: DashboardTile): string {
if (tile.insight) {
return tile.insight.name || tile.insight.derived_name || 'Unnamed insight'
}
@@ -137,7 +136,7 @@ export function getDashboardTileDisplayName(tile: DashboardTile<QueryBasedInsigh
/** Which widget payload is set on a dashboard tile row. Add a branch per `DashboardWidgetType` when new tile kinds ship. */
export function getDashboardWidgetType(
- tile: Pick<DashboardTile<InsightModel | QueryBasedInsightModel>, 'insight' | 'text' | 'button_tile' | 'widget'>
+ tile: Pick<DashboardTile, 'insight' | 'text' | 'button_tile' | 'widget'>
): DashboardWidgetType {
if (tile.insight) {
return 'insight'
@@ -186,7 +185,7 @@ const RATE_LIMIT_ERROR_MESSAGE = 'concurrency_limit_exceeded'
// A refresh that was rejected (concurrency limit, server-side calculation error) still resolves with an
// insight-shaped payload: no result, an errored query_status. Committing it to the dashboard would wipe
// the tile's existing data and render as an empty insight instead of an error.
-export function isRefreshRejectionStub(insight: QueryBasedInsightModel): boolean {
+export function isRefreshRejectionStub(insight: InsightModel): boolean {
return !!insight.query_status?.error && insight.result == null
}
@@ -274,7 +273,7 @@ export const layoutsByTile = (layouts: ResponsiveLayouts): Record<string, Record
*/
export async function getInsightWithRetry(
currentTeamId: number | null,
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
dashboardId: number,
queryId: string,
refresh: 'force_blocking' | 'blocking',
@@ -284,7 +283,7 @@ export async function getInsightWithRetry(
tileFiltersOverride?: TileFilters,
maxAttempts: number = 5,
initialDelay: number = 1200
-): Promise<QueryBasedInsightModel | null> {
+): Promise<InsightModel | null> {
// Check if user has access to this insight before making API calls
const canViewInsight = insight.user_access_level
? accessLevelSatisfied(AccessControlResourceType.Insight, insight.user_access_level, AccessControlLevel.Viewer)
diff --git a/frontend/src/scenes/dashboard/dashboards/dashboardsLogic.ts b/frontend/src/scenes/dashboard/dashboards/dashboardsLogic.ts
index 68d8c36eab17..8340f5ee5889 100644
--- a/frontend/src/scenes/dashboard/dashboards/dashboardsLogic.ts
+++ b/frontend/src/scenes/dashboard/dashboards/dashboardsLogic.ts
@@ -226,23 +226,8 @@ export interface dashboardsLogicMeta {
__keaTypeGenInternalSelectorTypes: {
isFiltering: (filters: DashboardsFilters) => boolean
dashboards: (
- nameSortedDashboards: (
- | DashboardBasicType
- | import('~/types').DashboardType<
- import('~/types').QueryBasedInsightModel<
- import('~/queries/schema/schema-general').Node<Record<string, any>>
- >
- >
- )[],
- rawDashboards: Record<
- string,
- | DashboardBasicType
- | import('~/types').DashboardType<
- import('~/types').QueryBasedInsightModel<
- import('~/queries/schema/schema-general').Node<Record<string, any>>
- >
- >
- >,
+ nameSortedDashboards: (DashboardBasicType | import('~/types').DashboardType)[],
+ rawDashboards: Record<string, DashboardBasicType | import('~/types').DashboardType>,
searchedDashboards: DashboardBasicType[] | null,
filters: DashboardsFilters,
currentTab: DashboardsTab,
@@ -441,10 +426,7 @@ export const dashboardsLogic = kea<dashboardsLogicType>([
],
(
allDashboards: DashboardBasicType[],
- rawDashboards: Record<
- string,
- DashboardBasicType | import('~/types').DashboardType<import('~/types').QueryBasedInsightModel>
- >,
+ rawDashboards: Record<string, DashboardBasicType | import('~/types').DashboardType>,
searchedDashboards: DashboardBasicType[] | null,
filters: DashboardsFilters,
currentTab: DashboardsTab,
diff --git a/frontend/src/scenes/dashboard/duplicateDashboardLogic.ts b/frontend/src/scenes/dashboard/duplicateDashboardLogic.ts
index 1ac26a61e9ce..b08b523207fe 100644
--- a/frontend/src/scenes/dashboard/duplicateDashboardLogic.ts
+++ b/frontend/src/scenes/dashboard/duplicateDashboardLogic.ts
@@ -8,7 +8,7 @@ import { urls } from 'scenes/urls'
import { dashboardsModel } from '~/models/dashboardsModel'
import { insightsModel } from '~/models/insightsModel'
-import type { DashboardType, QueryBasedInsightModel } from '../../types'
+import type { DashboardType } from '../../types'
export interface DuplicateDashboardForm {
dashboardId: number | null
@@ -143,7 +143,7 @@ export const duplicateDashboardLogic = kea<duplicateDashboardLogicType>([
dashboard,
payload,
}: {
- dashboard: DashboardType<QueryBasedInsightModel>
+ dashboard: DashboardType
payload?: Pick<DuplicateDashboardForm, 'duplicateTiles' | 'show'>
}) => {
actions.hideDuplicateDashboardModal()
diff --git a/frontend/src/scenes/dashboard/items/DashboardButtonTileItem.tsx b/frontend/src/scenes/dashboard/items/DashboardButtonTileItem.tsx
index f33a0edcdafb..86532d3302f2 100644
--- a/frontend/src/scenes/dashboard/items/DashboardButtonTileItem.tsx
+++ b/frontend/src/scenes/dashboard/items/DashboardButtonTileItem.tsx
@@ -7,7 +7,7 @@ import { DashboardWidgetPlacementMenus } from 'lib/components/Cards/InsightCard/
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
-import type { DashboardPlacement, DashboardTile, DashboardType, QueryBasedInsightModel } from '~/types'
+import type { DashboardPlacement, DashboardTile, DashboardType } from '~/types'
type BaseButtonTileCardProps = React.ComponentProps<typeof ButtonTileCard>
@@ -15,7 +15,7 @@ interface DashboardButtonTileItemProps extends Omit<
BaseButtonTileCardProps,
'buttonTile' | 'placement' | 'moreButtonOverlay'
> {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
placement: DashboardPlacement
dashboardId?: number | null
onEdit: () => void
diff --git a/frontend/src/scenes/dashboard/items/DashboardErrorTileItem.tsx b/frontend/src/scenes/dashboard/items/DashboardErrorTileItem.tsx
index 38777456c5d1..a63742dd3127 100644
--- a/frontend/src/scenes/dashboard/items/DashboardErrorTileItem.tsx
+++ b/frontend/src/scenes/dashboard/items/DashboardErrorTileItem.tsx
@@ -7,12 +7,12 @@ import { EditModeEdge, EditModeEdgeOverlay } from 'lib/components/Cards/InsightC
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { InsightErrorState } from 'scenes/insights/EmptyStates'
-import { DashboardPlacement, DashboardTile, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile } from '~/types'
import { getDashboardTileDisplayName } from '../dashboardUtils'
interface DashboardErrorTileItemProps extends React.HTMLAttributes<HTMLDivElement>, Resizeable {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
canEnterEditModeFromEdge?: boolean
onEnterEditModeFromEdge?: (event: React.MouseEvent<HTMLDivElement>, edge: EditModeEdge) => void
onDragHandleMouseDown?: React.MouseEventHandler<HTMLDivElement>
diff --git a/frontend/src/scenes/dashboard/newDashboardLogic.ts b/frontend/src/scenes/dashboard/newDashboardLogic.ts
index 5dc124bb18af..d0961288c0f3 100644
--- a/frontend/src/scenes/dashboard/newDashboardLogic.ts
+++ b/frontend/src/scenes/dashboard/newDashboardLogic.ts
@@ -45,7 +45,6 @@ import {
import { WEBSITE_METRICS_METRIC_CARD_TILES } from 'products/dashboards/frontend/websiteMetricsMetricCardTemplate'
import type { FeatureFlagsSet } from '../../lib/logic/featureFlagLogic'
-import type { InsightModel } from '../../types'
import { UNFILED_DASHBOARDS_FOLDER } from './dashboardConstants'
export interface NewDashboardForm {
@@ -245,7 +244,7 @@ export interface newDashboardLogicActions {
result: DashboardType,
variables?: DashboardTemplateVariableType[]
) => {
- result: DashboardType<InsightModel>
+ result: DashboardType
variables: DashboardTemplateVariableType[] | undefined
}
touchNewDashboardField: (key: string) => {
diff --git a/frontend/src/scenes/dashboard/tileLayouts.test.ts b/frontend/src/scenes/dashboard/tileLayouts.test.ts
index 75af1ebad369..9776d9b83737 100644
--- a/frontend/src/scenes/dashboard/tileLayouts.test.ts
+++ b/frontend/src/scenes/dashboard/tileLayouts.test.ts
@@ -3,22 +3,19 @@ import { Layout, LayoutItem } from 'react-grid-layout'
import { calculateDuplicateLayout, calculateInsertionLayout, calculateLayouts } from 'scenes/dashboard/tileLayouts'
import { NodeKind } from '~/queries/schema/schema-general'
-import { ChartDisplayType, DashboardLayoutSize, DashboardTile, QueryBasedInsightModel, TileLayout } from '~/types'
+import { ChartDisplayType, DashboardLayoutSize, DashboardTile, TileLayout } from '~/types'
-function textTileWithLayout(
- layouts: Record<DashboardLayoutSize, TileLayout>,
- tileId: number = 1
-): DashboardTile<QueryBasedInsightModel> {
+function textTileWithLayout(layouts: Record<DashboardLayoutSize, TileLayout>, tileId: number = 1): DashboardTile {
return {
id: tileId,
text: 'test',
layouts: layouts,
- } as unknown as DashboardTile<QueryBasedInsightModel>
+ } as unknown as DashboardTile
}
describe('calculating tile layouts', () => {
it('minimum width and height are added if missing', () => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
+ const tiles: DashboardTile[] = [
textTileWithLayout({
sm: { i: '1', x: 0, y: 0, w: 1, h: 1 },
} as Record<DashboardLayoutSize, TileLayout>),
@@ -31,12 +28,12 @@ describe('calculating tile layouts', () => {
})
it('sets a 1 by 2 minimum for image tiles', () => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
+ const tiles: DashboardTile[] = [
{
id: 1,
text: { body: '![image](https://example.com/image.png)' },
layouts: {},
- } as unknown as DashboardTile<QueryBasedInsightModel>,
+ } as unknown as DashboardTile,
]
const layouts = calculateLayouts(tiles)
@@ -46,27 +43,25 @@ describe('calculating tile layouts', () => {
})
it('raises a stored image tile height to its minimum', () => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
+ const tiles: DashboardTile[] = [
{
id: 1,
text: { body: '![image](https://example.com/image.png)' },
layouts: { sm: { i: '1', x: 0, y: 0, w: 1, h: 1 } },
- } as unknown as DashboardTile<QueryBasedInsightModel>,
+ } as unknown as DashboardTile,
]
expect(calculateLayouts(tiles).sm?.[0]).toMatchObject({ w: 1, h: 2, minW: 1, minH: 2 })
})
it('defaults button tiles to two columns', () => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
- { id: 1, button_tile: { id: '1' }, layouts: {} } as unknown as DashboardTile<QueryBasedInsightModel>,
- ]
+ const tiles: DashboardTile[] = [{ id: 1, button_tile: { id: '1' }, layouts: {} } as unknown as DashboardTile]
expect(calculateLayouts(tiles).sm?.[0]).toMatchObject({ w: 2, h: 1 })
})
it('defaults SQL metric tiles without a stored layout to 3 by 3', () => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
+ const tiles: DashboardTile[] = [
{
id: 1,
insight: {
@@ -77,7 +72,7 @@ describe('calculating tile layouts', () => {
},
},
layouts: {},
- } as unknown as DashboardTile<QueryBasedInsightModel>,
+ } as unknown as DashboardTile,
]
expect(calculateLayouts(tiles).sm?.[0]).toMatchObject({ w: 3, h: 3 })
@@ -95,7 +90,7 @@ describe('calculating tile layouts', () => {
{ i: '3', x: 6, y: 6, w: 6, h: 6, minW: 3, minH: 2 },
{ i: '4', x: 6, y: 0, w: 6, h: 6, minW: 3, minH: 2 },
]
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
+ const tiles: DashboardTile[] = [
textTileWithLayout({ sm: smLayouts[0] } as Record<DashboardLayoutSize, TileLayout>, 1),
textTileWithLayout({ sm: smLayouts[2] } as Record<DashboardLayoutSize, TileLayout>, 2),
textTileWithLayout({ sm: smLayouts[3] } as Record<DashboardLayoutSize, TileLayout>, 3),
@@ -135,13 +130,13 @@ describe('calculating tile layouts', () => {
expectedXsH: 2,
},
])('xs uses text default row height when $name', ({ layouts, expectedXsH }) => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [textTileWithLayout(layouts, 1)]
+ const tiles: DashboardTile[] = [textTileWithLayout(layouts, 1)]
const result = calculateLayouts(tiles)
expect(result.xs?.[0]?.h).toBe(expectedXsH)
})
it('xs follows final sm row-major order when some tiles have no stored sm layout', () => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
+ const tiles: DashboardTile[] = [
textTileWithLayout(
{ sm: { i: '1', x: 0, y: 0, w: 6, h: 5 } } as Record<DashboardLayoutSize, TileLayout>,
1
@@ -189,12 +184,12 @@ describe('calculating tile layouts', () => {
expectedMinW: 3,
},
])('$name', ({ widgetType, expectedMinH, expectedMinW }) => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
+ const tiles: DashboardTile[] = [
{
id: 1,
widget: { widget_type: widgetType, config: {} },
layouts: { sm: { i: '1', x: 0, y: 0, w: 6, h: 5 } },
- } as unknown as DashboardTile<QueryBasedInsightModel>,
+ } as unknown as DashboardTile,
]
const result = calculateLayouts(tiles)
@@ -206,7 +201,7 @@ describe('calculating tile layouts', () => {
})
it('xs follows sm dirty-placement order when no tiles have stored sm layouts', () => {
- const tiles: DashboardTile<QueryBasedInsightModel>[] = [
+ const tiles: DashboardTile[] = [
textTileWithLayout({} as Record<DashboardLayoutSize, TileLayout>, 1),
textTileWithLayout({} as Record<DashboardLayoutSize, TileLayout>, 2),
textTileWithLayout({} as Record<DashboardLayoutSize, TileLayout>, 3),
diff --git a/frontend/src/scenes/dashboard/tileLayouts.ts b/frontend/src/scenes/dashboard/tileLayouts.ts
index ac934afc33c3..1791f280952e 100644
--- a/frontend/src/scenes/dashboard/tileLayouts.ts
+++ b/frontend/src/scenes/dashboard/tileLayouts.ts
@@ -11,7 +11,7 @@ import { BREAKPOINT_COLUMN_COUNTS } from 'scenes/dashboard/dashboardUtils'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
import { isFunnelsQuery, isMetricInsightQuery, isPathsQuery, isRetentionQuery, isTrendsQuery } from '~/queries/utils'
-import { ChartDisplayType, DashboardLayoutSize, DashboardTile, QueryBasedInsightModel } from '~/types'
+import { ChartDisplayType, DashboardLayoutSize, DashboardTile } from '~/types'
import { getImageOnlyTextCardImage } from 'products/dashboards/frontend/components/ImageTile/imageTileUtils'
@@ -203,11 +203,8 @@ export function defaultSmLayoutAtBottom(smLayout: Layout | undefined, w: number,
return { x: 0, y: maxBottom, w, h }
}
-export const sortTilesByLayout = (
- tiles: Array<DashboardTile<QueryBasedInsightModel>>,
- col: DashboardLayoutSize
-): Array<DashboardTile<QueryBasedInsightModel>> => {
- return [...tiles].sort((a: DashboardTile<QueryBasedInsightModel>, b: DashboardTile<QueryBasedInsightModel>) => {
+export const sortTilesByLayout = (tiles: Array<DashboardTile>, col: DashboardLayoutSize): Array<DashboardTile> => {
+ return [...tiles].sort((a: DashboardTile, b: DashboardTile) => {
const ax = a.layouts?.[col]?.x ?? 0
const ay = a.layouts?.[col]?.y ?? 0
const bx = b.layouts?.[col]?.x ?? 0
@@ -221,9 +218,7 @@ export const sortTilesByLayout = (
return 0
})
}
-export const calculateLayouts = (
- tiles: DashboardTile<QueryBasedInsightModel>[]
-): Partial<Record<DashboardLayoutSize, Layout>> => {
+export const calculateLayouts = (tiles: DashboardTile[]): Partial<Record<DashboardLayoutSize, Layout>> => {
const allLayouts: Partial<Record<keyof typeof BREAKPOINT_COLUMN_COUNTS, Layout>> = {}
const imageTileIds = new Set(
tiles
@@ -237,7 +232,7 @@ export const calculateLayouts = (
for (const breakpoint of Object.keys(BREAKPOINT_COLUMN_COUNTS) as (keyof typeof BREAKPOINT_COLUMN_COUNTS)[]) {
const columnCount = BREAKPOINT_COLUMN_COUNTS[breakpoint]
- let sortedDashboardTiles: DashboardTile<QueryBasedInsightModel>[] | undefined
+ let sortedDashboardTiles: DashboardTile[] | undefined
if (referenceOrder === undefined) {
sortedDashboardTiles = sortTilesByLayout(tiles, 'sm')
} else {
diff --git a/frontend/src/scenes/dashboard/widgetFetchUtils.test.ts b/frontend/src/scenes/dashboard/widgetFetchUtils.test.ts
index 440d4eb251d3..0c0519d96b1d 100644
--- a/frontend/src/scenes/dashboard/widgetFetchUtils.test.ts
+++ b/frontend/src/scenes/dashboard/widgetFetchUtils.test.ts
@@ -1,9 +1,9 @@
-import type { DashboardTile, QueryBasedInsightModel } from '~/types'
+import type { DashboardTile } from '~/types'
import { chunkTileIds, findNewlyAddedWidgetTiles } from './widgetFetchUtils'
describe('widgetFetchUtils', () => {
- const widgetTile = (id: number): DashboardTile<QueryBasedInsightModel> => ({
+ const widgetTile = (id: number): DashboardTile => ({
id,
widget: { id: String(id), widget_type: 'error_tracking_list', config: {} },
layouts: {},
diff --git a/frontend/src/scenes/dashboard/widgetFetchUtils.ts b/frontend/src/scenes/dashboard/widgetFetchUtils.ts
index aa620cbb0b6c..f571e3f5ea5d 100644
--- a/frontend/src/scenes/dashboard/widgetFetchUtils.ts
+++ b/frontend/src/scenes/dashboard/widgetFetchUtils.ts
@@ -1,14 +1,14 @@
import { dashboardsRunWidgetsRetrieve } from '@posthog/products-dashboards/frontend/generated/api'
import type { DashboardWidgetRunResultApi } from '@posthog/products-dashboards/frontend/generated/api.schemas'
-import type { DashboardTile, QueryBasedInsightModel } from '~/types'
+import type { DashboardTile } from '~/types'
export const WIDGET_CLIENT_TTL_MS = 15 * 60 * 1000
export function findNewlyAddedWidgetTiles(
previousTileIds: ReadonlySet<number>,
- tiles: DashboardTile<QueryBasedInsightModel>[] | undefined | null
-): DashboardTile<QueryBasedInsightModel>[] {
+ tiles: DashboardTile[] | undefined | null
+): DashboardTile[] {
if (!tiles?.length) {
return []
}
diff --git a/frontend/src/scenes/data-management/events/EventDefinitionInsights.tsx b/frontend/src/scenes/data-management/events/EventDefinitionInsights.tsx
index 9c525d540ef0..caddf1388d53 100644
--- a/frontend/src/scenes/data-management/events/EventDefinitionInsights.tsx
+++ b/frontend/src/scenes/data-management/events/EventDefinitionInsights.tsx
@@ -12,7 +12,7 @@ import { InsightIcon } from 'scenes/saved-insights/SavedInsights'
import { urls } from 'scenes/urls'
import { SceneSection } from '~/layout/scenes/components/SceneSection'
-import { EventDefinition, QueryBasedInsightModel } from '~/types'
+import { EventDefinition, InsightModel } from '~/types'
export function EventDefinitionInsights({ definition }: { definition: EventDefinition }): JSX.Element {
const event = definition.name
@@ -20,7 +20,7 @@ export function EventDefinitionInsights({ definition }: { definition: EventDefin
const { setPage, setFilters } = useActions(eventInsightsLogic({ event }))
const summarizeInsight = useSummarizeInsight()
- const columns: LemonTableColumns<QueryBasedInsightModel> = [
+ const columns: LemonTableColumns<InsightModel> = [
{
key: 'id',
width: 32,
@@ -45,8 +45,8 @@ export function EventDefinitionInsights({ definition }: { definition: EventDefin
},
sorter: (a, b) => (a.name || summarizeInsight(a.query)).localeCompare(b.name || summarizeInsight(b.query)),
},
- createdByColumn() as LemonTableColumn<QueryBasedInsightModel, keyof QueryBasedInsightModel | undefined>,
- createdAtColumn() as LemonTableColumn<QueryBasedInsightModel, keyof QueryBasedInsightModel | undefined>,
+ createdByColumn() as LemonTableColumn<InsightModel, keyof InsightModel | undefined>,
+ createdAtColumn() as LemonTableColumn<InsightModel, keyof InsightModel | undefined>,
{
title: 'Last modified',
sorter: true,
diff --git a/frontend/src/scenes/data-management/variables/insightColumns.tsx b/frontend/src/scenes/data-management/variables/insightColumns.tsx
index 5ca2b3a0f623..621c8966c176 100644
--- a/frontend/src/scenes/data-management/variables/insightColumns.tsx
+++ b/frontend/src/scenes/data-management/variables/insightColumns.tsx
@@ -4,9 +4,9 @@ import { TZLabel } from 'lib/components/TZLabel'
import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'
import { urls } from 'scenes/urls'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
-export const VARIABLE_INSIGHT_COLUMNS: LemonTableColumns<QueryBasedInsightModel> = [
+export const VARIABLE_INSIGHT_COLUMNS: LemonTableColumns<InsightModel> = [
{
title: 'Name',
dataIndex: 'name',
diff --git a/frontend/src/scenes/data-management/variables/insightsLoader.ts b/frontend/src/scenes/data-management/variables/insightsLoader.ts
index 820997aca1af..3e20b9382557 100644
--- a/frontend/src/scenes/data-management/variables/insightsLoader.ts
+++ b/frontend/src/scenes/data-management/variables/insightsLoader.ts
@@ -3,7 +3,7 @@ import { lemonToast } from '@posthog/lemon-ui'
import api, { CountedPaginatedResponse } from 'lib/api'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
-import { InsightModel, QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { insightUsesVariable } from './utils'
@@ -19,12 +19,9 @@ import { insightUsesVariable } from './utils'
* @returns Array of insights that use the variable
* @throws Error if the fetch fails
*/
-export async function fetchInsightsUsingVariable(
- teamId: number,
- variableId: string
-): Promise<QueryBasedInsightModel[]> {
+export async function fetchInsightsUsingVariable(teamId: number, variableId: string): Promise<InsightModel[]> {
try {
- const matchingInsights: QueryBasedInsightModel[] = []
+ const matchingInsights: InsightModel[] = []
let offset = 0
const limit = 100
diff --git a/frontend/src/scenes/data-management/variables/sqlVariableEditSceneLogic.ts b/frontend/src/scenes/data-management/variables/sqlVariableEditSceneLogic.ts
index 5e936722bd3a..4b19b3eba7e8 100644
--- a/frontend/src/scenes/data-management/variables/sqlVariableEditSceneLogic.ts
+++ b/frontend/src/scenes/data-management/variables/sqlVariableEditSceneLogic.ts
@@ -16,7 +16,7 @@ import {
} from '~/queries/nodes/DataVisualization/Components/Variables/VariableFields'
import { getListVariableSelectedValues } from '~/queries/nodes/DataVisualization/Components/Variables/variableUtils'
import { ListVariable, Variable, VariableType } from '~/queries/nodes/DataVisualization/types'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import type { Node } from '../../../queries/schema/schema-general'
import { fetchInsightsUsingVariable } from './insightsLoader'
@@ -70,7 +70,7 @@ export interface sqlVariableEditSceneLogicValues {
}
)[]
hasChanges: boolean
- insightsUsingVariable: QueryBasedInsightModel[]
+ insightsUsingVariable: InsightModel[]
insightsUsingVariableLoading: boolean
isNew: boolean
isVariableFormSubmitting: boolean
@@ -101,10 +101,10 @@ export interface sqlVariableEditSceneLogicActions {
errorObject?: any
}
loadInsightsUsingVariableSuccess: (
- insightsUsingVariable: QueryBasedInsightModel<Node<Record<string, any>>>[],
+ insightsUsingVariable: InsightModel<Node<Record<string, any>>>[],
payload?: any
) => {
- insightsUsingVariable: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ insightsUsingVariable: InsightModel<Node<Record<string, any>>>[]
payload?: any
}
loadVariable: () => any
@@ -226,7 +226,7 @@ export const sqlVariableEditSceneLogic = kea<sqlVariableEditSceneLogicType>([
},
],
insightsUsingVariable: [
- [] as QueryBasedInsightModel[],
+ [] as InsightModel[],
{
loadInsightsUsingVariable: async () => {
if (props.id === 'new') {
diff --git a/frontend/src/scenes/data-management/variables/utils.ts b/frontend/src/scenes/data-management/variables/utils.ts
index 7189bc760528..9bd6b47289a2 100644
--- a/frontend/src/scenes/data-management/variables/utils.ts
+++ b/frontend/src/scenes/data-management/variables/utils.ts
@@ -1,5 +1,5 @@
import { DataVisualizationNode, HogQLVariable } from '~/queries/schema/schema-general'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
/**
* Type guard to check if a query is a DataVisualizationNode
@@ -11,7 +11,7 @@ export function isDataVisualizationNode(query: any): query is DataVisualizationN
/**
* Check if an insight uses a specific variable
*/
-export function insightUsesVariable(insight: QueryBasedInsightModel, variableId: string): boolean {
+export function insightUsesVariable(insight: InsightModel, variableId: string): boolean {
if (!isDataVisualizationNode(insight.query)) {
return false
}
diff --git a/frontend/src/scenes/data-warehouse/editor/InsightHistory.tsx b/frontend/src/scenes/data-warehouse/editor/InsightHistory.tsx
index 59ae92cfa788..1a333c3e6e54 100644
--- a/frontend/src/scenes/data-warehouse/editor/InsightHistory.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/InsightHistory.tsx
@@ -13,7 +13,7 @@ import { TZLabel } from 'lib/components/TZLabel'
import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture'
import { fullName } from 'lib/utils/strings'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { editorSceneLogic } from './editorSceneLogic'
import { InsightQueryVersion, insightHistoryLogic } from './insightHistoryLogic'
@@ -125,7 +125,7 @@ function OriginalVersionRow({
sql,
isCurrent,
}: {
- insight: QueryBasedInsightModel
+ insight: InsightModel
sql: string
isCurrent: boolean
}): JSX.Element {
@@ -186,7 +186,7 @@ function SqlDiffViewer({ before, after }: { before: string; after: string }): JS
)
}
-export function InsightHistory({ insight }: { insight: QueryBasedInsightModel | null }): JSX.Element {
+export function InsightHistory({ insight }: { insight: InsightModel | null }): JSX.Element {
return insight ? (
<InsightHistoryContent insight={insight} />
) : (
@@ -205,7 +205,7 @@ function InsightHistorySkeleton(): JSX.Element {
)
}
-function InsightHistoryContent({ insight }: { insight: QueryBasedInsightModel }): JSX.Element {
+function InsightHistoryContent({ insight }: { insight: InsightModel }): JSX.Element {
const logic = insightHistoryLogic({ insightId: insight.id })
const { versions, activityPageLoading, historyComplete } = useValues(logic)
diff --git a/frontend/src/scenes/data-warehouse/editor/editorSceneLogic.tsx b/frontend/src/scenes/data-warehouse/editor/editorSceneLogic.tsx
index 4d2cf86144c6..31e75e6ac25c 100644
--- a/frontend/src/scenes/data-warehouse/editor/editorSceneLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/editorSceneLogic.tsx
@@ -17,7 +17,7 @@ import { DataVisualizationNode, FileSystemIconType, HogQLFilters, NodeKind } fro
import { Breadcrumb } from '~/types'
import type { FeatureFlagsSet } from '../../../lib/logic/featureFlagLogic'
-import type { DataWarehouseSavedQuery, LinkBreadcrumb, QueryBasedInsightModel } from '../../../types'
+import type { DataWarehouseSavedQuery, LinkBreadcrumb, InsightModel } from '../../../types'
import { NEW_QUERY, normalizeFiltersForUrl, sqlEditorLogic, toDataVisualizationNode } from './sqlEditorLogic'
import type { QueryTab, SqlEditorSource } from './sqlEditorLogic'
@@ -62,7 +62,7 @@ export interface EditorSceneLogicProps {
export function buildSqlNotebook(
queryInput: string,
activeTab: QueryTab | null,
- editingInsight: QueryBasedInsightModel | null,
+ editingInsight: InsightModel | null,
featureFlags: FeatureFlagsSet
): { title: string; content: JSONContent[] } {
const activeTabName = activeTab?.name === NEW_QUERY ? undefined : activeTab?.name
@@ -102,7 +102,7 @@ export interface editorSceneLogicValues {
activeTab: QueryTab | null // sqlEditorLogic
dashboardId: number | null // sqlEditorLogic
dataLogicKey: string // sqlEditorLogic
- editingInsight: QueryBasedInsightModel | null // sqlEditorLogic
+ editingInsight: InsightModel | null // sqlEditorLogic
editingView: DataWarehouseSavedQuery | undefined // sqlEditorLogic
editorSource: SqlEditorSource // sqlEditorLogic
featureFlags: FeatureFlagsSet // sqlEditorLogic
@@ -192,9 +192,7 @@ export interface editorSceneLogicMeta {
__keaTypeGenInternalSelectorTypes: {
breadcrumbs: (activeTab: QueryTab | null) => Breadcrumb[]
titleSectionProps: (
- editingInsight: QueryBasedInsightModel<
- import('~/queries/schema/schema-general').Node<Record<string, any>>
- > | null,
+ editingInsight: InsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>> | null,
insightLoading: boolean,
editingView: DataWarehouseSavedQuery | undefined,
viewLoading: boolean,
@@ -236,9 +234,7 @@ export interface editorSceneLogicMeta {
updateInsightButtonEnabled: (
sourceQuery: DataVisualizationNode,
activeTab: QueryTab | null,
- editingInsight: QueryBasedInsightModel<
- import('~/queries/schema/schema-general').Node<Record<string, any>>
- > | null
+ editingInsight: InsightModel<import('~/queries/schema/schema-general').Node<Record<string, any>>> | null
) => boolean
}
}
@@ -347,7 +343,7 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
s.activeTab,
],
(
- editingInsight: null | import('~/types').QueryBasedInsightModel,
+ editingInsight: null | import('~/types').InsightModel,
insightLoading: boolean,
editingView: import('~/types').DataWarehouseSavedQuery | undefined,
viewLoading: boolean,
@@ -527,7 +523,7 @@ export const editorSceneLogic = kea<editorSceneLogicType>([
(
sourceQuery: DataVisualizationNode,
activeTab: null | import('./sqlEditorLogic').QueryTab,
- editingInsight: null | import('~/types').QueryBasedInsightModel
+ editingInsight: null | import('~/types').InsightModel
) => {
if (!editingInsight?.query) {
return false
diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
index 073588ffb5c0..54646d747f6e 100644
--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts
@@ -26,7 +26,7 @@ import {
NodeKind,
} from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
-import { ChartDisplayType, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { ChartDisplayType, InsightShortId, InsightModel } from '~/types'
import { BI_EDITOR_EVENTS } from './bi/biEditorAnalytics'
import { biEditorLogic } from './bi/biEditorLogic'
@@ -67,7 +67,7 @@ const MOCK_DATA_TABLE_INSIGHT_QUERY: DataTableNode = {
},
}
-const MOCK_DATA_TABLE_INSIGHT: QueryBasedInsightModel = {
+const MOCK_DATA_TABLE_INSIGHT: InsightModel = {
id: 2,
short_id: MOCK_DATA_TABLE_INSIGHT_SHORT_ID,
name: 'DataTable Insight',
@@ -94,9 +94,9 @@ const MOCK_DATA_TABLE_INSIGHT: QueryBasedInsightModel = {
layouts: {},
color: null,
user_access_level: 'none',
-} as QueryBasedInsightModel
+} as InsightModel
-const MOCK_INSIGHT: QueryBasedInsightModel = {
+const MOCK_INSIGHT: InsightModel = {
id: 1,
short_id: MOCK_INSIGHT_SHORT_ID,
name: 'Test Insight',
@@ -123,7 +123,7 @@ const MOCK_INSIGHT: QueryBasedInsightModel = {
layouts: {},
color: null,
user_access_level: 'none',
-} as QueryBasedInsightModel
+} as InsightModel
const MOCK_VIEW = {
id: 'test-view',
@@ -1347,7 +1347,7 @@ describe('sqlEditorLogic', () => {
editorRootLogic = editorSceneLogic({ tabId: TAB_ID })
editorRootLogic.mount()
- const insightWithEmptyName = { ...MOCK_INSIGHT, name: '' } as QueryBasedInsightModel
+ const insightWithEmptyName = { ...MOCK_INSIGHT, name: '' } as InsightModel
logic.actions.createTab(MOCK_INSIGHT_QUERY.source.query, undefined, insightWithEmptyName)
await expectLogic(logic).toDispatchActions(['createTab', 'updateTab'])
@@ -2869,7 +2869,7 @@ describe('sqlEditorLogic', () => {
...MOCK_INSIGHT,
dashboards,
dashboard_tiles: dashboardTiles,
- } as QueryBasedInsightModel
+ } as InsightModel
logic.actions.editInsight(MOCK_INSIGHT_QUERY.source.query, insightOnDashboards)
await expectLogic(logic)
.toDispatchActions(['createTab', 'updateTab'])
diff --git a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
index 96450dace718..bef6bab3d46f 100644
--- a/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
+++ b/frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.tsx
@@ -84,7 +84,7 @@ import {
DataWarehouseSavedQueryIncremental,
DataWarehouseSavedQueryIncrementalCheck,
ExportContext,
- QueryBasedInsightModel,
+ InsightModel,
} from '~/types'
import {
@@ -279,7 +279,7 @@ export interface QueryTab {
name: string
description?: string
sourceQuery?: DataVisualizationNode
- insight?: QueryBasedInsightModel
+ insight?: InsightModel
response?: Record<string, any>
draft?: DataWarehouseSavedQueryDraft
metricName?: string
@@ -384,7 +384,7 @@ function sanitizeSourceQuery(sourceQuery: DataVisualizationNode): DataVisualizat
}
export function toDataVisualizationNode(
- query: QueryBasedInsightModel['query'] | null | undefined
+ query: InsightModel['query'] | null | undefined
): DataVisualizationNode | undefined {
if (!query) {
return undefined
@@ -568,7 +568,7 @@ export interface sqlEditorLogicValues {
dataLogicKey: string
diffShowRunButton: boolean | undefined
editingAccessControlObject: DataWarehouseAccessControlModalProps | null
- editingInsight: QueryBasedInsightModel | null
+ editingInsight: InsightModel | null
editingMetricName: string | null
editingView: DataWarehouseSavedQuery | undefined
editorKey: string
@@ -795,14 +795,14 @@ export interface sqlEditorLogicActions {
createTab: (
query?: string,
view?: DataWarehouseSavedQuery,
- insight?: QueryBasedInsightModel,
+ insight?: InsightModel,
draft?: DataWarehouseSavedQueryDraft,
metricName?: string,
biEditorState?: BIEditorState
) => {
biEditorState: BIEditorState | undefined
draft: DataWarehouseSavedQueryDraft | undefined
- insight: QueryBasedInsightModel<Node<Record<string, any>>> | undefined
+ insight: InsightModel<Node<Record<string, any>>> | undefined
metricName: string | undefined
query: string | undefined
view: DataWarehouseSavedQuery | undefined
@@ -815,11 +815,11 @@ export interface sqlEditorLogicActions {
}
editInsight: (
query: string,
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
biEditorState?: BIEditorState
) => {
biEditorState: BIEditorState | undefined
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
query: string
}
editView: (
@@ -1258,7 +1258,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
createTab: (
query?: string,
view?: DataWarehouseSavedQuery,
- insight?: QueryBasedInsightModel,
+ insight?: InsightModel,
draft?: DataWarehouseSavedQueryDraft,
metricName?: string,
biEditorState?: BIEditorState
@@ -1340,7 +1340,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
view,
biEditorState,
}),
- editInsight: (query: string, insight: QueryBasedInsightModel, biEditorState?: BIEditorState) => ({
+ editInsight: (query: string, insight: InsightModel, biEditorState?: BIEditorState) => ({
query,
insight,
biEditorState,
@@ -1610,7 +1610,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
},
],
editingInsight: [
- null as QueryBasedInsightModel | null,
+ null as InsightModel | null,
{
updateTab: (_, { tab }) => tab.insight ?? null,
},
@@ -2763,7 +2763,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
const insightDescription = values.activeTab?.description
const currentVisualizationQuery = getCurrentVisualizationQuery(values.dataLogicKey, values.sourceQuery)
- const insightRequest: Partial<QueryBasedInsightModel> = {
+ const insightRequest: Partial<InsightModel> = {
name: insightName ?? values.editingInsight.name,
description: insightDescription ?? values.editingInsight.description ?? '',
query: currentVisualizationQuery,
@@ -2780,7 +2780,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
insightRequest.dashboards = Array.from(new Set([...existingDashboardIds, dashboardId]))
}
- let savedInsight: QueryBasedInsightModel
+ let savedInsight: InsightModel
try {
savedInsight = await insightsApi.update(values.editingInsight.id, insightRequest)
} catch (e) {
@@ -3558,7 +3558,7 @@ export const sqlEditorLogic = kea<sqlEditorLogicType>([
// Open Insight
actions.setInsightLoading(true)
- let insight: QueryBasedInsightModel | null
+ let insight: InsightModel | null
try {
insight = await insightsApi.getByShortId(shortId, undefined, 'async')
} catch {
diff --git a/frontend/src/scenes/experiments/utils.ts b/frontend/src/scenes/experiments/utils.ts
index 8e01fbd0cfdd..748535b2d7bd 100644
--- a/frontend/src/scenes/experiments/utils.ts
+++ b/frontend/src/scenes/experiments/utils.ts
@@ -43,7 +43,7 @@ import {
MultivariateFlagVariant,
PropertyFilterType,
PropertyOperator,
- type QueryBasedInsightModel,
+ type InsightModel,
UniversalFiltersGroupValue,
} from '~/types'
@@ -641,7 +641,7 @@ export function getDefaultExperimentMetric(metricType: ExperimentMetricType): Ex
}
}
-export function getExperimentMetricFromInsight(insight: QueryBasedInsightModel | null): ExperimentMetric | undefined {
+export function getExperimentMetricFromInsight(insight: InsightModel | null): ExperimentMetric | undefined {
if (!insight?.query || !isValidQueryForExperiment(insight?.query) || !isNodeWithSource(insight.query)) {
return undefined
}
diff --git a/frontend/src/scenes/feature-flags/FeatureFlag.tsx b/frontend/src/scenes/feature-flags/FeatureFlag.tsx
index 41ed69c06c38..4748b96250ce 100644
--- a/frontend/src/scenes/feature-flags/FeatureFlag.tsx
+++ b/frontend/src/scenes/feature-flags/FeatureFlag.tsx
@@ -76,7 +76,6 @@ import {
FeatureFlagType,
PropertyFilterType,
PropertyOperator,
- QueryBasedInsightModel,
} from '~/types'
import { FeatureFlagStaleBanner } from 'products/feature_flags/frontend/FeatureFlagStaleBanner'
@@ -667,7 +666,7 @@ function ConnectedUsageDashboard({
const { dashboard, error404 } = useValues(
dashboardLogic({ id: dashboardId, placement: DashboardPlacement.FeatureFlag })
) as {
- dashboard: DashboardType<QueryBasedInsightModel> | null
+ dashboard: DashboardType | null
error404: boolean
}
const { enrichUsageDashboard } = useActions(featureFlagLogic)
diff --git a/frontend/src/scenes/feature-flags/RecentFeatureFlagInsightsCard.tsx b/frontend/src/scenes/feature-flags/RecentFeatureFlagInsightsCard.tsx
index 76e24192b112..f96d455ee9df 100644
--- a/frontend/src/scenes/feature-flags/RecentFeatureFlagInsightsCard.tsx
+++ b/frontend/src/scenes/feature-flags/RecentFeatureFlagInsightsCard.tsx
@@ -6,7 +6,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { InsightVizNode, NodeKind, ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
-import { BaseMathType, QueryBasedInsightModel } from '~/types'
+import { BaseMathType, InsightModel } from '~/types'
import { featureFlagLogic } from './featureFlagLogic'
@@ -43,7 +43,7 @@ export function RecentFeatureFlagInsights(): JSX.Element {
},
}}
items={relatedInsights.slice(0, 5)}
- renderRow={(insight: QueryBasedInsightModel, index) => (
+ renderRow={(insight: InsightModel, index) => (
<InsightRow key={index} insight={insight} dataAttr="recent-feature-flag-insight-item" allowWrap />
)}
contentHeightBehavior="shrink"
diff --git a/frontend/src/scenes/feature-flags/featureFlagLogic.ts b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
index 8c7ecbd540cc..fd70930fba9f 100644
--- a/frontend/src/scenes/feature-flags/featureFlagLogic.ts
+++ b/frontend/src/scenes/feature-flags/featureFlagLogic.ts
@@ -79,7 +79,6 @@ import {
ProjectTreeRef,
PropertyFilterType,
PropertyOperator,
- QueryBasedInsightModel,
RecordingUniversalFilters,
RecurrenceInterval,
ScheduledChangeOperationType,
@@ -1032,7 +1031,7 @@ export interface featureFlagLogicValues {
props: any
recordingFilterForFlag: Partial<RecordingUniversalFilters>
recurrenceInterval: RecurrenceInterval | null
- relatedInsights: QueryBasedInsightModel[]
+ relatedInsights: InsightModel[]
relatedInsightsLoading: boolean
repeatsValue: RecurrenceInterval | 'cron' | 'none'
roleBasedAccessEnabled: boolean
@@ -1323,10 +1322,10 @@ export interface featureFlagLogicActions {
errorObject?: any
}
loadRelatedInsightsSuccess: (
- relatedInsights: QueryBasedInsightModel<Node<Record<string, any>>>[],
+ relatedInsights: InsightModel<Node<Record<string, any>>>[],
payload?: any
) => {
- relatedInsights: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ relatedInsights: InsightModel<Node<Record<string, any>>>[]
payload?: any
}
loadScheduledChanges: () => any
@@ -3295,7 +3294,7 @@ export const featureFlagLogic = kea<featureFlagLogicType>([
},
],
relatedInsights: [
- [] as QueryBasedInsightModel[],
+ [] as InsightModel[],
{
loadRelatedInsights: async () => {
if (props.id && props.id !== 'new' && values.featureFlag.key) {
diff --git a/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts b/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts
index daf26971d45e..d8b764b843ca 100644
--- a/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts
+++ b/frontend/src/scenes/insights/InsightNav/insightNavLogic.test.ts
@@ -33,7 +33,7 @@ import {
InsightType,
PropertyFilterType,
PropertyOperator,
- QueryBasedInsightModel,
+ InsightModel,
RetentionEntity,
StepOrderValue,
} from '~/types'
@@ -159,7 +159,7 @@ describe('insightNavLogic', () => {
await expectLogic(logic, () => {
builtInsightLogic.actions.loadInsightSuccess({
query: examples.InsightFunnels,
- } as QueryBasedInsightModel)
+ } as InsightModel)
}).toMatchValues({
activeView: InsightType.FUNNELS,
})
diff --git a/frontend/src/scenes/insights/InsightPageHeader.spec.tsx b/frontend/src/scenes/insights/InsightPageHeader.spec.tsx
index c81bb74ed0c5..c9e84f6772a0 100644
--- a/frontend/src/scenes/insights/InsightPageHeader.spec.tsx
+++ b/frontend/src/scenes/insights/InsightPageHeader.spec.tsx
@@ -10,7 +10,7 @@ import { urls } from 'scenes/urls'
import { useMocks } from '~/mocks/jest'
import { InsightVizNode, Node, NodeKind } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
-import { AccessControlLevel, InsightShortId, QueryBasedInsightModel, ItemMode } from '~/types'
+import { AccessControlLevel, InsightShortId, InsightModel, ItemMode } from '~/types'
import { insightDataLogic } from './insightDataLogic'
import { insightLogic } from './insightLogic'
@@ -27,7 +27,7 @@ jest.mock('scenes/max/useMaxTool', () => ({
const SAVED_INSIGHT_ID = 'abc123' as InsightShortId
-const MOCK_INSIGHT_BASE: QueryBasedInsightModel = {
+const MOCK_INSIGHT_BASE: InsightModel = {
id: 1,
short_id: SAVED_INSIGHT_ID,
name: 'Test Insight',
@@ -50,7 +50,7 @@ const MOCK_INSIGHT_BASE: QueryBasedInsightModel = {
user_access_level: AccessControlLevel.Editor,
}
-function makeInsight(overrides: Partial<QueryBasedInsightModel> = {}): QueryBasedInsightModel {
+function makeInsight(overrides: Partial<InsightModel> = {}): InsightModel {
return { ...MOCK_INSIGHT_BASE, ...overrides }
}
@@ -101,7 +101,7 @@ describe('InsightPageHeader', () => {
function renderHeader(opts: {
insightMode: ItemMode
dashboardItemId: InsightShortId | 'new'
- insight?: QueryBasedInsightModel
+ insight?: InsightModel
}): {
sceneLogic: ReturnType<typeof insightSceneLogic.build>
iLogic: ReturnType<typeof insightLogic.build>
diff --git a/frontend/src/scenes/insights/SidePanel/InsightPanelActions.tsx b/frontend/src/scenes/insights/SidePanel/InsightPanelActions.tsx
index a0ec78d18d0c..1b1f46ed8111 100644
--- a/frontend/src/scenes/insights/SidePanel/InsightPanelActions.tsx
+++ b/frontend/src/scenes/insights/SidePanel/InsightPanelActions.tsx
@@ -39,7 +39,7 @@ import {
ExporterFormat,
InsightLogicProps,
InsightShortId,
- QueryBasedInsightModel,
+ InsightModel,
} from '~/types'
import { metricsLogic } from 'products/data_catalog/frontend/metricsLogic'
@@ -103,7 +103,7 @@ export function InsightPanelActions({ insightLogicProps }: { insightLogicProps:
<SceneDuplicate
dataAttrKey={RESOURCE_TYPE}
loading={insightDuplicating}
- onClick={() => duplicateInsight(insight as QueryBasedInsightModel, true)}
+ onClick={() => duplicateInsight(insight as InsightModel, true)}
/>
{isSavedInsight && canCopyToProject && (
<ButtonPrimitive
diff --git a/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx b/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
index 286a64539cc1..8d8160b9ef50 100644
--- a/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
+++ b/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
@@ -66,7 +66,7 @@ import {
ExporterFormat,
InsightLogicProps,
ItemMode,
- QueryBasedInsightModel,
+ InsightModel,
SidePanelTab,
} from '~/types'
@@ -392,7 +392,7 @@ function InsightSceneMenuBarInner({ insightLogicProps }: { insightLogicProps: In
<SceneMenuBarItem
disabled={insightDuplicating}
tooltip={insightDuplicating ? 'Duplicating…' : undefined}
- onClick={() => duplicateInsight(insight as QueryBasedInsightModel, true)}
+ onClick={() => duplicateInsight(insight as InsightModel, true)}
data-attr={`${RESOURCE_TYPE}-menubar-duplicate`}
>
<IconCopy />
diff --git a/frontend/src/scenes/insights/__mocks__/createInsightScene.tsx b/frontend/src/scenes/insights/__mocks__/createInsightScene.tsx
index 094ea31c9b86..b1968c53a117 100644
--- a/frontend/src/scenes/insights/__mocks__/createInsightScene.tsx
+++ b/frontend/src/scenes/insights/__mocks__/createInsightScene.tsx
@@ -13,7 +13,7 @@ import { sceneLayoutLogic } from '~/layout/scenes/sceneLayoutLogic'
import { mswDecorator, useStorybookMocks } from '~/mocks/browser'
import { InsightVizNode, Node } from '~/queries/schema/schema-general'
import { isInsightVizNode, isLifecycleQuery, isStickinessQuery, isTrendsQuery } from '~/queries/utils'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
/** Spread into a `createInsightStory` story's `parameters`, merging `testOptions` for extra keys. */
export const insightSceneStoryParameters = {
@@ -122,7 +122,7 @@ interface InsightStoryOptions {
let shortCounter = 0
export function createInsightStory(
- insight: Partial<QueryBasedInsightModel>,
+ insight: Partial<InsightModel>,
mode: 'view' | 'edit' = 'view',
showLegend: boolean = false,
options: InsightStoryOptions = {}
diff --git a/frontend/src/scenes/insights/__mocks__/createInsightVizStory.tsx b/frontend/src/scenes/insights/__mocks__/createInsightVizStory.tsx
index c280942e4889..e49d90fba80a 100644
--- a/frontend/src/scenes/insights/__mocks__/createInsightVizStory.tsx
+++ b/frontend/src/scenes/insights/__mocks__/createInsightVizStory.tsx
@@ -8,14 +8,14 @@ import type { DataNodeLogicProps } from '~/queries/nodes/DataNode/dataNodeLogic'
import { insightVizDataNodeKey } from '~/queries/nodes/InsightViz/InsightViz'
import { getCachedResults } from '~/queries/nodes/InsightViz/utils'
import { InsightVizNode } from '~/queries/schema/schema-general'
-import { InsightLogicProps, InsightShortId, InsightType, QueryBasedInsightModel } from '~/types'
+import { InsightLogicProps, InsightShortId, InsightType, InsightModel } from '~/types'
import { TrendInsight } from 'products/product_analytics/frontend/insights/trends/Trends'
let uniqueNode = 0
interface InsightVizStoryProps {
- insight: Partial<QueryBasedInsightModel>
+ insight: Partial<InsightModel>
/** Wrapper width in pixels. @default 720 */
width?: number
/** Value for `--insight-viz-min-height`, which the chart height floors to. @default '32rem' */
diff --git a/frontend/src/scenes/insights/insightDataLogic.tsx b/frontend/src/scenes/insights/insightDataLogic.tsx
index 3a7a4681e1c2..4962fc4daf23 100644
--- a/frontend/src/scenes/insights/insightDataLogic.tsx
+++ b/frontend/src/scenes/insights/insightDataLogic.tsx
@@ -89,7 +89,7 @@ import type {
AccessControlLevel,
DashboardTileBasicType,
InsightShortId,
- QueryBasedInsightModel,
+ InsightModel,
SetInsightOptions,
UserBasicType,
} from '../../types'
@@ -145,8 +145,8 @@ export interface insightDataLogicValues {
insightQuery: DataNode<Record<string, any>> // dataNodeLogic
queryId: string | null // dataNodeLogic
filterTestAccountsDefault: boolean // filterTestAccountsDefaultsLogic
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> // insightLogic
- savedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> // insightLogic
+ insight: Partial<InsightModel<Node<Record<string, any>>>> // insightLogic
+ savedInsight: Partial<InsightModel<Node<Record<string, any>>>> // insightLogic
currentTeamId: number | null // teamLogic
canEditInSqlEditor: boolean
exportContext: ExportContext | undefined
@@ -374,23 +374,23 @@ export interface insightDataLogicActions {
}
} // insightLogic
setInsight: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ insight: Partial<InsightModel<Node<Record<string, any>>>>,
options: SetInsightOptions
) => {
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>
options: SetInsightOptions
} // insightLogic
setInsightMetadata: (
metadataUpdate: Partial<
- Pick<QueryBasedInsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
+ Pick<InsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
>
) => {
metadataUpdate: Partial<
- Pick<QueryBasedInsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
+ Pick<InsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
>
} // insightLogic
- renameInsightSuccess: (item: QueryBasedInsightModel<Node<Record<string, any>>>) => {
- item: QueryBasedInsightModel<Node<Record<string, any>>>
+ renameInsightSuccess: (item: InsightModel<Node<Record<string, any>>>) => {
+ item: InsightModel<Node<Record<string, any>>>
} // insightsModel
cancelChanges: () => {
value: true
@@ -458,7 +458,7 @@ export interface insightDataLogicMeta {
__keaTypeGenInternalSelectorTypes: {
query: (
propsQuery: QuerySchema | null | undefined,
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ insight: Partial<InsightModel<Node<Record<string, any>>>>,
internalQuery: Node<Record<string, any>> | null,
filterTestAccountsDefault: boolean,
isDataWarehouseQuery: boolean
@@ -467,11 +467,11 @@ export interface insightDataLogicMeta {
propsQuery: (arg: any) => QuerySchema | null | undefined
exportContext: (
query: Node<Record<string, any>> | null,
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>
) => ExportContext | undefined
queryChanged: (
query: Node<Record<string, any>> | null,
- savedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ savedInsight: Partial<InsightModel<Node<Record<string, any>>>>,
filterTestAccountsDefault: boolean
) => boolean
insightData: (
@@ -645,7 +645,7 @@ export const insightDataLogic = kea<insightDataLogicType>([
(s) => [s.propsQuery, s.insight, s.internalQuery, s.filterTestAccountsDefault, s.isDataWarehouseQuery],
(
propsQuery: null | import('~/queries/schema/schema-general').QuerySchema | undefined,
- insight: Partial<import('~/types').QueryBasedInsightModel<Node<Record<string, any>>>>,
+ insight: Partial<import('~/types').InsightModel<Node<Record<string, any>>>>,
internalQuery: Node | null,
filterTestAccountsDefault: boolean,
isDataWarehouseQuery: boolean
@@ -671,10 +671,7 @@ export const insightDataLogic = kea<insightDataLogicType>([
exportContext: [
(s) => [s.query, s.insight],
- (
- query: Node | null,
- insight: Partial<import('~/types').QueryBasedInsightModel<Node<Record<string, any>>>>
- ) => {
+ (query: Node | null, insight: Partial<import('~/types').InsightModel<Node<Record<string, any>>>>) => {
if (!query) {
// if we're here without a query then an empty query context is not the problem
return undefined
@@ -697,7 +694,7 @@ export const insightDataLogic = kea<insightDataLogicType>([
(s) => [s.query, s.savedInsight, s.filterTestAccountsDefault],
(
query: Node | null,
- savedInsight: Partial<import('~/types').QueryBasedInsightModel<Node<Record<string, any>>>>,
+ savedInsight: Partial<import('~/types').InsightModel<Node<Record<string, any>>>>,
filterTestAccountsDefault: boolean
) => {
let savedOrDefaultQuery
diff --git a/frontend/src/scenes/insights/insightLogic.test.ts b/frontend/src/scenes/insights/insightLogic.test.ts
index 83048e309f69..dcc1cbc0bd3a 100644
--- a/frontend/src/scenes/insights/insightLogic.test.ts
+++ b/frontend/src/scenes/insights/insightLogic.test.ts
@@ -34,7 +34,7 @@ import {
InsightType,
PropertyFilterType,
PropertyOperator,
- QueryBasedInsightModel,
+ InsightModel,
} from '~/types'
import { insightDataLogic } from './insightDataLogic'
@@ -105,7 +105,7 @@ const patchResponseFor = (
}
}
-function insightModelWith(properties: Record<string, any>): QueryBasedInsightModel {
+function insightModelWith(properties: Record<string, any>): InsightModel {
return {
id: 42,
short_id: Insight42,
@@ -134,7 +134,7 @@ function insightModelWith(properties: Record<string, any>): QueryBasedInsightMod
color: null,
user_access_level: AccessControlLevel.Editor,
...properties,
- } as QueryBasedInsightModel
+ } as InsightModel
}
const seenQueryIDs: string[] = []
@@ -374,7 +374,7 @@ describe('insightLogic', () => {
describe('props with filters, no cached results, respects doNotLoad', () => {
it('does not make a query', async () => {
- const insight: Partial<QueryBasedInsightModel<InsightVizNode>> = {
+ const insight: Partial<InsightModel<InsightVizNode>> = {
short_id: Insight42,
query: {
kind: NodeKind.InsightVizNode,
@@ -771,7 +771,7 @@ describe('insightLogic', () => {
it('reacts to removal from dashboard', async () => {
await expectLogic(logic, () => {
dashboardsModel.actions.tileRemovedFromDashboard({
- tile: { insight: { id: 42 } } as DashboardTile<QueryBasedInsightModel>,
+ tile: { insight: { id: 42 } } as DashboardTile,
dashboardId: 3,
})
})
@@ -784,7 +784,7 @@ describe('insightLogic', () => {
it('does not reacts to removal of a different tile from dashboard', async () => {
await expectLogic(logic, () => {
dashboardsModel.actions.tileRemovedFromDashboard({
- tile: { insight: { id: 12 } } as DashboardTile<QueryBasedInsightModel>,
+ tile: { insight: { id: 12 } } as DashboardTile,
dashboardId: 3,
})
})
@@ -796,7 +796,7 @@ describe('insightLogic', () => {
it('reacts to deletion of dashboard', async () => {
await expectLogic(logic, () => {
- dashboardsModel.actions.deleteDashboardSuccess({ id: 3 } as DashboardType<QueryBasedInsightModel>)
+ dashboardsModel.actions.deleteDashboardSuccess({ id: 3 } as DashboardType)
})
.toFinishAllListeners()
.toMatchValues({
@@ -806,7 +806,7 @@ describe('insightLogic', () => {
it('does not reacts to deletion of dashboard it is not on', async () => {
await expectLogic(logic, () => {
- dashboardsModel.actions.deleteDashboardSuccess({ id: 1034 } as DashboardType<QueryBasedInsightModel>)
+ dashboardsModel.actions.deleteDashboardSuccess({ id: 1034 } as DashboardType)
})
.toFinishAllListeners()
.toMatchValues({
@@ -1042,10 +1042,7 @@ describe('insightLogic', () => {
await expectLogic(dashboardsModel, () => {
dashboardsModel
.findMounted()
- ?.actions.updateDashboardInsight(
- { ...(logic.values.insight as QueryBasedInsightModel), deleted: false },
- [5]
- )
+ ?.actions.updateDashboardInsight({ ...(logic.values.insight as InsightModel), deleted: false }, [5])
}).toDispatchActions([
(action: any) =>
action.type === dashboardsModel.actionTypes.updateDashboardInsight &&
@@ -1070,7 +1067,7 @@ describe('insightLogic', () => {
it('fetches clean insight before duplicating', async () => {
jest.spyOn(api, 'create')
- logic.actions.duplicateInsight(logic.values.insight as QueryBasedInsightModel, true)
+ logic.actions.duplicateInsight(logic.values.insight as InsightModel, true)
await expectLogic(logic).toFinishAllListeners()
// The POST body should contain the clean insight fetched via getByShortId,
@@ -1086,7 +1083,7 @@ describe('insightLogic', () => {
jest.spyOn(api, 'create')
const insightWithBadShortId = {
- ...(logic.values.insight as QueryBasedInsightModel),
+ ...(logic.values.insight as InsightModel),
short_id: '500' as InsightShortId,
name: 'fallback name',
}
@@ -1103,13 +1100,13 @@ describe('insightLogic', () => {
it('with redirectToInsight=true navigates to edit URL', async () => {
// POST mock returns short_id: Insight12 — listen on router before dispatching
await expectLogic(router, () => {
- logic.actions.duplicateInsight(logic.values.insight as QueryBasedInsightModel, true)
+ logic.actions.duplicateInsight(logic.values.insight as InsightModel, true)
}).toDispatchActions([router.actionCreators.push(urls.insightEdit(Insight12))])
})
it('with redirectToInsight=false does not navigate', async () => {
await expectLogic(logic, () => {
- logic.actions.duplicateInsight(logic.values.insight as QueryBasedInsightModel, false)
+ logic.actions.duplicateInsight(logic.values.insight as InsightModel, false)
}).toFinishAllListeners()
await expectLogic(router).toNotHaveDispatchedActions(['push'])
@@ -1117,7 +1114,7 @@ describe('insightLogic', () => {
it('marks the insight as duplicating until the request settles', async () => {
await expectLogic(logic, () => {
- logic.actions.duplicateInsight(logic.values.insight as QueryBasedInsightModel, true)
+ logic.actions.duplicateInsight(logic.values.insight as InsightModel, true)
})
.toMatchValues({ insightDuplicating: true })
.toFinishAllListeners()
@@ -1148,7 +1145,7 @@ describe('insightLogic', () => {
jest.spyOn(posthog, 'captureException')
await expectLogic(logic, () => {
- logic.actions.duplicateInsight(logic.values.insight as QueryBasedInsightModel, true)
+ logic.actions.duplicateInsight(logic.values.insight as InsightModel, true)
})
.toFinishAllListeners()
.toMatchValues({ insightDuplicating: false })
diff --git a/frontend/src/scenes/insights/insightLogic.tsx b/frontend/src/scenes/insights/insightLogic.tsx
index 26c76a996dbd..35092c1c76ba 100644
--- a/frontend/src/scenes/insights/insightLogic.tsx
+++ b/frontend/src/scenes/insights/insightLogic.tsx
@@ -67,7 +67,7 @@ import {
InsightLogicProps,
InsightShortId,
ItemMode,
- QueryBasedInsightModel,
+ InsightModel,
SetInsightOptions,
} from '~/types'
@@ -91,9 +91,7 @@ import { insightsApi } from './utils/api'
export const UNSAVED_INSIGHT_MIN_REFRESH_INTERVAL_MINUTES = 3
-export const createEmptyInsight = (
- shortId: InsightShortId | `new-${string}` | 'new'
-): Partial<QueryBasedInsightModel> => ({
+export const createEmptyInsight = (shortId: InsightShortId | `new-${string}` | 'new'): Partial<InsightModel> => ({
short_id: shortId !== 'new' && !shortId.startsWith('new-') ? (shortId as InsightShortId) : undefined,
name: undefined,
description: '',
@@ -119,7 +117,7 @@ export interface insightLogicValues {
hasDashboardItemId: boolean
hasOverrides: boolean
highlightedSeries: IndexedTrendResult | null
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>
insightChanged: boolean
insightDuplicating: boolean
insightFeedback: 'disliked' | 'liked' | null
@@ -135,7 +133,7 @@ export interface insightLogicValues {
isSavingTags: boolean
previousQuery: Node | null
query: Node | null
- savedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ savedInsight: Partial<InsightModel<Node<Record<string, any>>>>
showPersonsModal: boolean
suggestedQuery: Node | null
supportsCreatingExperiment: boolean | null
@@ -154,10 +152,10 @@ export interface insightLogicActions {
dashboardId: number | null
}
duplicateInsight: (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
redirectToInsight?: any
) => {
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
redirectToInsight: any
}
duplicateInsightComplete: () => {
@@ -333,20 +331,20 @@ export interface insightLogicActions {
value: true
}
setInsight: (
- insight: Partial<QueryBasedInsightModel>,
+ insight: Partial<InsightModel>,
options: SetInsightOptions
) => {
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>
options: SetInsightOptions
}
setInsightFeedback: (feedback: 'disliked' | 'liked') => {
feedback: 'disliked' | 'liked'
}
setInsightMetadata: (
- metadataUpdate: Partial<Pick<QueryBasedInsightModel, 'description' | 'favorited' | 'name' | 'tags'>>
+ metadataUpdate: Partial<Pick<InsightModel, 'description' | 'favorited' | 'name' | 'tags'>>
) => {
metadataUpdate: Partial<
- Pick<QueryBasedInsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
+ Pick<InsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
>
}
setInsightMetadataFailure: (
@@ -357,10 +355,10 @@ export interface insightLogicActions {
errorObject?: any
}
setInsightMetadataLocal: (
- metadataUpdate: Partial<Pick<QueryBasedInsightModel, 'description' | 'favorited' | 'name' | 'tags'>>
+ metadataUpdate: Partial<Pick<InsightModel, 'description' | 'favorited' | 'name' | 'tags'>>
) => {
metadataUpdate: Partial<
- Pick<QueryBasedInsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
+ Pick<InsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
>
}
setInsightMetadataSuccess: (
@@ -407,7 +405,7 @@ export interface insightLogicActions {
},
payload?: {
metadataUpdate: Partial<
- Pick<QueryBasedInsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
+ Pick<InsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
>
}
) => {
@@ -454,7 +452,7 @@ export interface insightLogicActions {
}
payload?: {
metadataUpdate: Partial<
- Pick<QueryBasedInsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
+ Pick<InsightModel<Node<Record<string, any>>>, 'description' | 'favorited' | 'name' | 'tags'>
>
}
}
@@ -468,11 +466,11 @@ export interface insightLogicActions {
suggestedQuery: Node<Record<string, any>> | null
}
updateInsight: (
- insightUpdate: Partial<QueryBasedInsightModel>,
+ insightUpdate: Partial<InsightModel>,
callback?: () => void
) => {
callback: (() => void) | undefined
- insightUpdate: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insightUpdate: Partial<InsightModel<Node<Record<string, any>>>>
}
updateInsightFailure: (
error: string,
@@ -482,16 +480,16 @@ export interface insightLogicActions {
errorObject?: any
}
updateInsightSuccess: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ insight: Partial<InsightModel<Node<Record<string, any>>>>,
payload?: {
callback: (() => void) | undefined
- insightUpdate: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insightUpdate: Partial<InsightModel<Node<Record<string, any>>>>
}
) => {
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>
payload?: {
callback: (() => void) | undefined
- insightUpdate: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insightUpdate: Partial<InsightModel<Node<Record<string, any>>>>
}
}
}
@@ -512,15 +510,12 @@ export interface insightLogicMeta {
cohortsById: Partial<Record<number | string, CohortType>>,
mathDefinitions: Partial<Record<string, MathDefinition>>
) => string
- insightName: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
- derivedName: string
- ) => string
- insightId: (insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>) => number | null
- canEditInsight: (insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>) => boolean
+ insightName: (insight: Partial<InsightModel<Node<Record<string, any>>>>, derivedName: string) => string
+ insightId: (insight: Partial<InsightModel<Node<Record<string, any>>>>) => number | null
+ canEditInsight: (insight: Partial<InsightModel<Node<Record<string, any>>>>) => boolean
insightChanged: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
- savedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>,
+ savedInsight: Partial<InsightModel<Node<Record<string, any>>>>
) => boolean
showPersonsModal: (
query: Node<Record<string, any>> | null,
@@ -528,7 +523,7 @@ export interface insightLogicMeta {
featureFlags: FeatureFlagsSet
) => boolean
supportsCreatingExperiment: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ insight: Partial<InsightModel<Node<Record<string, any>>>>,
activeSceneId: string | null
) => boolean | null
hasOverrides: (arg: any, arg2: any, arg3: any) => boolean
@@ -581,7 +576,7 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
})),
actions({
- setInsight: (insight: Partial<QueryBasedInsightModel>, options: SetInsightOptions) => ({
+ setInsight: (insight: Partial<InsightModel>, options: SetInsightOptions) => ({
insight,
options,
}),
@@ -613,17 +608,17 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
variablesOverride,
tileFiltersOverride,
}),
- updateInsight: (insightUpdate: Partial<QueryBasedInsightModel>, callback?: () => void) => ({
+ updateInsight: (insightUpdate: Partial<InsightModel>, callback?: () => void) => ({
insightUpdate,
callback,
}),
setInsightMetadata: (
- metadataUpdate: Partial<Pick<QueryBasedInsightModel, 'name' | 'description' | 'tags' | 'favorited'>>
+ metadataUpdate: Partial<Pick<InsightModel, 'name' | 'description' | 'tags' | 'favorited'>>
) => ({
metadataUpdate,
}),
setInsightMetadataLocal: (
- metadataUpdate: Partial<Pick<QueryBasedInsightModel, 'name' | 'description' | 'tags' | 'favorited'>>
+ metadataUpdate: Partial<Pick<InsightModel, 'name' | 'description' | 'tags' | 'favorited'>>
) => ({
metadataUpdate,
}),
@@ -637,7 +632,7 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
setPreviousQuery: (previousQuery: Node | null) => ({ previousQuery }),
setSuggestedQuery: (suggestedQuery: Node | null) => ({ suggestedQuery }),
reloadSavedInsights: true,
- duplicateInsight: (insight: QueryBasedInsightModel, redirectToInsight = false) => ({
+ duplicateInsight: (insight: InsightModel, redirectToInsight = false) => ({
insight,
redirectToInsight,
}),
@@ -714,7 +709,7 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
// should run regardless.
callback?.()
breakpoint()
- const updatedInsight: QueryBasedInsightModel = {
+ const updatedInsight: InsightModel = {
...response,
result: response.result || values.insight.result,
}
@@ -734,7 +729,7 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
const beforeUpdates: Record<string, any> = {}
for (const key of Object.keys(metadataUpdate)) {
- beforeUpdates[key] = values.savedInsight[key as keyof QueryBasedInsightModel]
+ beforeUpdates[key] = values.savedInsight[key as keyof InsightModel]
}
const response = await insightsApi.update(values.insight.id as number, metadataUpdate)
@@ -806,12 +801,12 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
// Note: setInsightMetadata state updates are handled by the loader
setInsightMetadataLocal: (state, { metadataUpdate }) => ({ ...state, ...metadataUpdate }),
[dashboardsModel.actionTypes.updateDashboardInsight]: (
- state: Partial<QueryBasedInsightModel>,
+ state: Partial<InsightModel>,
{
insight,
extraDashboardIds,
sourceDashboardId,
- }: { insight: QueryBasedInsightModel; extraDashboardIds?: number[]; sourceDashboardId?: number }
+ }: { insight: InsightModel; extraDashboardIds?: number[]; sourceDashboardId?: number }
) => {
// Dashboard refresh responses merge that dashboard's filters into `query`; only the embedded
// insight for that dashboard (`props.dashboardId`) should apply them. Other dashboards or
@@ -838,8 +833,8 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
return state
},
[insightsModel.actionTypes.renameInsightSuccess]: (
- state: Partial<QueryBasedInsightModel>,
- { item }: { item: QueryBasedInsightModel }
+ state: Partial<InsightModel>,
+ { item }: { item: InsightModel }
) => {
if (item.id === state.id) {
// Also sync query (display-option saves); preserve result — bare PATCHes return result: null.
@@ -847,13 +842,13 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
...state,
name: item.name,
description: item.description,
- query: (item.query ?? state.query) as QueryBasedInsightModel['query'],
+ query: (item.query ?? state.query) as InsightModel['query'],
}
}
return state
},
[insightsModel.actionTypes.insightsAddedToDashboard]: (
- state: Partial<QueryBasedInsightModel>,
+ state: Partial<InsightModel>,
{ dashboardId, insightIds }: { dashboardId: number; insightIds: number[] }
) => {
if (state.id != null && insightIds.includes(state.id)) {
@@ -862,8 +857,8 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
return state
},
[dashboardsModel.actionTypes.tileRemovedFromDashboard]: (
- state: Partial<QueryBasedInsightModel>,
- { tile, dashboardId }: { tile?: DashboardTile<QueryBasedInsightModel>; dashboardId?: number }
+ state: Partial<InsightModel>,
+ { tile, dashboardId }: { tile?: DashboardTile; dashboardId?: number }
) => {
if (tile?.insight?.id === state.id) {
return { ...state, dashboards: state.dashboards?.filter((d: number) => d !== dashboardId) }
@@ -871,8 +866,8 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
return state
},
[dashboardsModel.actionTypes.deleteDashboardSuccess]: (
- state: Partial<QueryBasedInsightModel>,
- { dashboard }: { dashboard: DashboardType<QueryBasedInsightModel> }
+ state: Partial<InsightModel>,
+ { dashboard }: { dashboard: DashboardType }
) => {
const { id } = dashboard
return { ...state, dashboards: state.dashboards?.filter((d: number) => d !== id) }
@@ -882,7 +877,7 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
insightMissing: [false, { setInsightMissing: () => true, loadInsight: () => false }],
/** The insight's state as it is in the database. */
savedInsight: [
- () => props.cachedInsight || ({} as Partial<QueryBasedInsightModel>),
+ () => props.cachedInsight || ({} as Partial<InsightModel>),
{
setInsight: (state, { insight, options: { fromPersistentApi } }) =>
fromPersistentApi ? { ...insight, query: insight.query || null } : state,
@@ -902,8 +897,8 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
favorited: insight.favorited,
}),
[insightsModel.actionTypes.renameInsightSuccess]: (
- state: Partial<QueryBasedInsightModel>,
- { item }: { item: QueryBasedInsightModel }
+ state: Partial<InsightModel>,
+ { item }: { item: InsightModel }
) =>
item.id === state.id
? { ...state, name: item.name, description: item.description, query: item.query ?? state.query }
@@ -1004,16 +999,16 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
],
insightName: [
(s) => [s.insight, s.derivedName],
- (insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>, derivedName: string) =>
+ (insight: Partial<InsightModel<Node<Record<string, any>>>>, derivedName: string) =>
insight.name ?? derivedName,
],
insightId: [
(s) => [s.insight],
- (insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>) => insight?.id || null,
+ (insight: Partial<InsightModel<Node<Record<string, any>>>>) => insight?.id || null,
],
canEditInsight: [
(s) => [s.insight],
- (insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>) =>
+ (insight: Partial<InsightModel<Node<Record<string, any>>>>) =>
insight.user_access_level
? accessLevelSatisfied(
AccessControlResourceType.Insight,
@@ -1025,8 +1020,8 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
insightChanged: [
(s) => [s.insight, s.savedInsight],
(
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
- savedInsight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insight: Partial<InsightModel<Node<Record<string, any>>>>,
+ savedInsight: Partial<InsightModel<Node<Record<string, any>>>>
): boolean => {
return (
(insight.name || '') !== (savedInsight.name || '') ||
@@ -1044,7 +1039,7 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
],
supportsCreatingExperiment: [
(s) => [s.insight, s.activeSceneId],
- (insight: QueryBasedInsightModel, activeSceneId: Scene) =>
+ (insight: InsightModel, activeSceneId: Scene) =>
insight?.query &&
isValidQueryForExperiment(insight.query) &&
![
@@ -1079,11 +1074,11 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
values.insight.id || (values.insight.short_id ? await getInsightId(values.insight.short_id) : undefined)
const { name, description, favorited, deleted, dashboards, tags } = values.insight
- let savedInsight: QueryBasedInsightModel
+ let savedInsight: InsightModel
try {
// We don't want to send ALL the insight properties back to the API, so only grabbing fields that might have changed
- const insightRequest: Partial<QueryBasedInsightModel> = {
+ const insightRequest: Partial<InsightModel> = {
name,
derived_name: values.derivedName,
description,
@@ -1339,16 +1334,15 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
confirmDeleteInsight: async ({ dashboardId }) => {
const { insight, currentTeamId } = values
await deleteInsightWithUndo({
- object: insight as QueryBasedInsightModel,
+ object: insight as InsightModel,
endpoint: `projects/${currentTeamId}/insights`,
callback: (undo: boolean) => {
if (undo && dashboardId) {
dashboardsModel
.findMounted()
- ?.actions.updateDashboardInsight(
- { ...(insight as QueryBasedInsightModel), deleted: false },
- [dashboardId]
- )
+ ?.actions.updateDashboardInsight({ ...(insight as InsightModel), deleted: false }, [
+ dashboardId,
+ ])
}
actions.reloadSavedInsights()
},
@@ -1356,7 +1350,7 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
if (dashboardId) {
router.actions.push(urls.dashboard(dashboardId))
dashboardsModel.actions.updateDashboardInsight(
- { ...(insight as QueryBasedInsightModel), deleted: true, dashboards: [] },
+ { ...(insight as InsightModel), deleted: true, dashboards: [] },
[dashboardId]
)
} else {
diff --git a/frontend/src/scenes/insights/insightSceneLogic.tsx b/frontend/src/scenes/insights/insightSceneLogic.tsx
index 33d0137f6105..6e6a625cd863 100644
--- a/frontend/src/scenes/insights/insightSceneLogic.tsx
+++ b/frontend/src/scenes/insights/insightSceneLogic.tsx
@@ -66,7 +66,7 @@ import {
InsightType,
ItemMode,
ProjectTreeRef,
- QueryBasedInsightModel,
+ InsightModel,
SidePanelTab,
} from '~/types'
@@ -129,7 +129,7 @@ export interface insightSceneLogicValues {
filtersOverride: DashboardFilter | null
freshQuery: boolean
hasOverrides: boolean
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null | undefined
insightData: Record<string, any> | null | undefined
insightDataLogicRef: {
logic: BuiltLogic<insightDataLogicType>
@@ -152,7 +152,7 @@ export interface insightSceneLogicValues {
| ((
state: any,
props?: InsightLogicProps<QuerySchema> | undefined
- ) => Partial<QueryBasedInsightModel<Node<Record<string, any>>>>)
+ ) => Partial<InsightModel<Node<Record<string, any>>>>)
| undefined
isNewSubscription: boolean
itemId: number | null
@@ -265,11 +265,11 @@ export interface insightSceneLogicMeta {
| ((
state: any,
props?: InsightLogicProps<QuerySchema> | undefined
- ) => Partial<QueryBasedInsightModel<Node<Record<string, any>>>>)
+ ) => Partial<InsightModel<Node<Record<string, any>>>>)
| undefined
insight: (
- arg: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined
- ) => Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined
+ arg: Partial<InsightModel<Node<Record<string, any>>>> | null | undefined
+ ) => Partial<InsightModel<Node<Record<string, any>>>> | null | undefined
dashboardBackPath: (
dashboardId: number | null,
variablesOverride: Record<string, HogQLVariable> | null,
@@ -280,7 +280,7 @@ export interface insightSceneLogicMeta {
logic: BuiltLogic<insightLogicType>
unmount: () => void
} | null,
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined,
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null | undefined,
insightQuery: Node<Record<string, any>> | null | undefined,
dashboardId: number | null,
dashboardName: string | null,
@@ -290,10 +290,10 @@ export interface insightSceneLogicMeta {
) => Breadcrumb[]
projectTreeRef: (insightId: InsightId) => ProjectTreeRef
sidePanelContext: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null | undefined
) => SidePanelSceneContext | null
maxContext: (
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined,
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null | undefined,
filtersOverride: DashboardFilter | null,
variablesOverride: Record<string, HogQLVariable> | null
) => MaxContextInput[]
@@ -522,7 +522,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
}
},
],
- (insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined) => insight,
+ (insight: Partial<InsightModel<Node<Record<string, any>>>> | null | undefined) => insight,
],
// The insight and the dashboard name the same overrides differently, so a link back to the dashboard
// has to translate them. Take the filters from the url instead of from `filtersOverride`, because an
@@ -561,7 +561,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
logic: BuiltLogic<insightLogicType>
unmount: () => void
} | null,
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined,
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null | undefined,
insightQuery: Node<Record<string, any>> | null | undefined,
dashboardId: DashboardType['id'] | null,
dashboardName: DashboardType['name'] | null,
@@ -635,7 +635,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
[SIDE_PANEL_CONTEXT_KEY]: [
(s) => [s.insight],
(
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> | null | undefined
+ insight: Partial<InsightModel<Node<Record<string, any>>>> | null | undefined
): SidePanelSceneContext | null => {
if (!insight?.id) {
// An unsaved insight has no numeric id yet. Still declare the Insight scope so
@@ -663,7 +663,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
maxContext: [
(s) => [s.insight, s.filtersOverride, s.variablesOverride],
(
- insight: Partial<QueryBasedInsightModel>,
+ insight: Partial<InsightModel>,
filtersOverride: DashboardFilter | null,
variablesOverride: Record<string, HogQLVariable> | null
): MaxContextInput[] => {
diff --git a/frontend/src/scenes/insights/insightUsageLogic.ts b/frontend/src/scenes/insights/insightUsageLogic.ts
index 9f5c8075da7e..b0579fec5942 100644
--- a/frontend/src/scenes/insights/insightUsageLogic.ts
+++ b/frontend/src/scenes/insights/insightUsageLogic.ts
@@ -13,7 +13,7 @@ import { Node } from '~/queries/schema/schema-general'
import { InsightLogicProps } from '~/types'
import type { DataNode } from '../../queries/schema/schema-general'
-import type { QueryBasedInsightModel } from '../../types'
+import type { InsightModel } from '../../types'
import { insightLogic } from './insightLogic'
import { insightSceneLogic } from './insightSceneLogic'
import { keyForInsightLogicProps } from './sharedUtils'
@@ -23,7 +23,7 @@ const IS_TEST_MODE = process.env.NODE_ENV === 'test'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface insightUsageLogicValues {
query: DataNode<Record<string, any>> // dataNodeLogic
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> // insightLogic
+ insight: Partial<InsightModel<Node<Record<string, any>>>> // insightLogic
currentProjectId: number | null // projectLogic
isFirstLoad: boolean
}
@@ -31,13 +31,13 @@ export interface insightUsageLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface insightUsageLogicActions {
reportInsightViewed: (
- insightModel: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>,
+ insightModel: Partial<InsightModel<Node<Record<string, any>>>>,
query: Node<Record<string, any>> | null,
isFirstLoad: boolean,
delay?: number | undefined
) => {
delay: number | undefined
- insightModel: Partial<QueryBasedInsightModel<Node<Record<string, any>>>>
+ insightModel: Partial<InsightModel<Node<Record<string, any>>>>
isFirstLoad: boolean
query: Node<Record<string, any>> | null
} // eventUsageLogic
diff --git a/frontend/src/scenes/insights/insightVizDataLogic.test.ts b/frontend/src/scenes/insights/insightVizDataLogic.test.ts
index fadc09386847..72a26b5817d2 100644
--- a/frontend/src/scenes/insights/insightVizDataLogic.test.ts
+++ b/frontend/src/scenes/insights/insightVizDataLogic.test.ts
@@ -24,7 +24,6 @@ import {
FunnelVizType,
InsightModel,
InsightShortId,
- InsightType,
PropertyFilterType,
PropertyOperator,
} from '~/types'
@@ -913,9 +912,6 @@ describe('insightVizDataLogic', () => {
describe('validationError', () => {
it('for standard funnel', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
}
diff --git a/frontend/src/scenes/insights/utils/api.ts b/frontend/src/scenes/insights/utils/api.ts
index 97b9b196fa25..45afb338416c 100644
--- a/frontend/src/scenes/insights/utils/api.ts
+++ b/frontend/src/scenes/insights/utils/api.ts
@@ -2,14 +2,14 @@ import api, { ApiMethodOptions } from 'lib/api'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
import { DashboardFilter, HogQLVariable, RefreshType, TileFilters } from '~/queries/schema/schema-general'
-import { InsightShortId, QueryBasedInsightModel } from '~/types'
+import { InsightShortId, InsightModel } from '~/types'
async function _perform(
method: 'create' | 'update',
- insight: Partial<QueryBasedInsightModel>,
+ insight: Partial<InsightModel>,
id?: number,
options?: ApiMethodOptions
-): Promise<QueryBasedInsightModel> {
+): Promise<InsightModel> {
const legacyInsight =
method === 'create' ? await api.insights[method](insight) : await api.insights[method](id!, insight, options)
return getQueryBasedInsightModel(legacyInsight)
@@ -24,7 +24,7 @@ export const insightsApi = {
filtersOverride?: DashboardFilter | null,
variablesOverride?: Record<string, HogQLVariable> | null,
tileFiltersOverride?: TileFilters | null
- ): Promise<QueryBasedInsightModel | null> {
+ ): Promise<InsightModel | null> {
const legacyInsights = await api.insights.loadInsight(
shortId,
basic,
@@ -37,26 +37,22 @@ export const insightsApi = {
return null
}
const legacyInsight = legacyInsights.results[0]
- return getQueryBasedInsightModel(legacyInsight) as QueryBasedInsightModel
+ return getQueryBasedInsightModel(legacyInsight) as InsightModel
},
- async getByNumericId(numericId: number): Promise<QueryBasedInsightModel | null> {
+ async getByNumericId(numericId: number): Promise<InsightModel | null> {
const legacyInsight = await api.insights.get(numericId)
if (legacyInsight === null) {
return null
}
return getQueryBasedInsightModel(legacyInsight)
},
- async create(insight: Partial<QueryBasedInsightModel>): Promise<QueryBasedInsightModel> {
+ async create(insight: Partial<InsightModel>): Promise<InsightModel> {
return this._perform('create', insight)
},
- async update(
- id: number,
- insightUpdate: Partial<QueryBasedInsightModel>,
- options?: ApiMethodOptions
- ): Promise<QueryBasedInsightModel> {
+ async update(id: number, insightUpdate: Partial<InsightModel>, options?: ApiMethodOptions): Promise<InsightModel> {
return this._perform('update', insightUpdate, id, options)
},
- async duplicate(insight: QueryBasedInsightModel): Promise<QueryBasedInsightModel> {
+ async duplicate(insight: InsightModel): Promise<InsightModel> {
const { id, short_id, result, created_at, created_by, last_modified_at, last_modified_by, ...rest } = insight
return this.create({ ...rest, name: insight.name ? `${insight.name} (copy)` : insight.name })
},
diff --git a/frontend/src/scenes/max/maxContextLogic.test.ts b/frontend/src/scenes/max/maxContextLogic.test.ts
index b140f068a3aa..0088ab2fda35 100644
--- a/frontend/src/scenes/max/maxContextLogic.test.ts
+++ b/frontend/src/scenes/max/maxContextLogic.test.ts
@@ -12,14 +12,7 @@ import { sceneLogic } from 'scenes/sceneLogic'
import { useMocks } from '~/mocks/jest'
import { dashboardsModel } from '~/models/dashboardsModel'
import { initKeaTests } from '~/test/init'
-import {
- ActionType,
- DashboardType,
- EventDefinition,
- InsightShortId,
- QueryBasedInsightModel,
- SidePanelTab,
-} from '~/types'
+import { ActionType, DashboardType, EventDefinition, InsightShortId, InsightModel, SidePanelTab } from '~/types'
import { maxContextLogic } from './maxContextLogic'
import { createMaxContextHelpers } from './maxTypes'
@@ -29,7 +22,7 @@ import { dashboardToMaxContext } from './utils'
describe('maxContextLogic', () => {
let logic: ReturnType<typeof maxContextLogic.build>
- const mockInsight: Partial<QueryBasedInsightModel> = {
+ const mockInsight: Partial<InsightModel> = {
short_id: 'insight-1' as InsightShortId,
name: 'Test Insight',
description: 'Test insight description',
@@ -47,17 +40,17 @@ describe('maxContextLogic', () => {
type: 'insight',
}
- const mockDashboard: DashboardType<QueryBasedInsightModel> = {
+ const mockDashboard: DashboardType = {
id: 1,
name: 'Test Dashboard',
description: 'Test dashboard description',
tiles: [
{
id: 1,
- insight: mockInsight as QueryBasedInsightModel,
+ insight: mockInsight as InsightModel,
},
],
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
const mockEvent: EventDefinition = {
id: 'event-1',
@@ -614,7 +607,7 @@ describe('maxContextLogic', () => {
loadInsight: jest.fn(),
},
values: {
- insight: mockInsight as QueryBasedInsightModel,
+ insight: mockInsight as InsightModel,
},
}
@@ -628,7 +621,7 @@ describe('maxContextLogic', () => {
it('adds preloaded insight to context without loading', async () => {
const insightData = {
id: 'insight-1' as InsightShortId,
- preloaded: mockInsight as QueryBasedInsightModel,
+ preloaded: mockInsight as InsightModel,
}
await expectLogic(logic, () => {
@@ -647,7 +640,7 @@ describe('maxContextLogic', () => {
}
// Set the mock values that the function will read
- mockInsightLogicInstance.values.insight = mockInsight as QueryBasedInsightModel
+ mockInsightLogicInstance.values.insight = mockInsight as InsightModel
await expectLogic(logic, () => {
logic.actions.loadAndProcessInsight(insightData)
@@ -674,7 +667,7 @@ describe('maxContextLogic', () => {
}
// Set the mock values that the function will read
- mockInsightLogicInstance.values.insight = mockInsight as QueryBasedInsightModel
+ mockInsightLogicInstance.values.insight = mockInsight as InsightModel
await expectLogic(logic, () => {
logic.actions.loadAndProcessInsight(insightData)
@@ -693,7 +686,7 @@ describe('maxContextLogic', () => {
const dashboardWithoutTiles = {
...mockDashboard,
tiles: undefined,
- } as unknown as DashboardType<QueryBasedInsightModel>
+ } as unknown as DashboardType
afterEach(() => {
jest.restoreAllMocks()
diff --git a/frontend/src/scenes/max/maxContextLogic.ts b/frontend/src/scenes/max/maxContextLogic.ts
index a3e71ac519ce..d40f2b4d462e 100644
--- a/frontend/src/scenes/max/maxContextLogic.ts
+++ b/frontend/src/scenes/max/maxContextLogic.ts
@@ -16,14 +16,13 @@ import { sceneLogic } from 'scenes/sceneLogic'
import { dashboardsModel } from '~/models/dashboardsModel'
import { DashboardFilter, HogQLVariable } from '~/queries/schema/schema-general'
-import { ActionType, DashboardType, EventDefinition, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { ActionType, DashboardType, EventDefinition, InsightShortId, InsightModel } from '~/types'
import type { Node } from '../../queries/schema/schema-general'
import type { LoadedScene } from '../sceneTypes'
import type { ToolRegistration } from './max-constants'
import { maxGlobalLogic } from './maxGlobalLogic'
import {
- InsightWithQuery,
MaxActionContext,
MaxContextInput,
MaxContextItem,
@@ -52,14 +51,14 @@ import {
// Type definitions for better reusability
export type TaxonomicItem =
| DashboardType
- | QueryBasedInsightModel
+ | InsightModel
| EventDefinition
| ActionType
| NotebookListItemType
| MaxContextTaxonomicFilterOption
-export type DashboardItemInfo = { id: number; preloaded: DashboardType<QueryBasedInsightModel> | null }
-export type InsightItemInfo = { id: InsightShortId; preloaded: QueryBasedInsightModel | null }
+export type DashboardItemInfo = { id: number; preloaded: DashboardType | null }
+export type InsightItemInfo = { id: InsightShortId; preloaded: InsightModel | null }
type EntityWithIdAndType = { id: string | number; type: string }
@@ -150,8 +149,8 @@ export interface maxContextLogicActions {
addOrUpdateContextAction: (data: ActionType) => {
data: ActionType
}
- addOrUpdateContextDashboard: (data: DashboardType<QueryBasedInsightModel>) => {
- data: DashboardType<QueryBasedInsightModel<Node<Record<string, any>>>>
+ addOrUpdateContextDashboard: (data: DashboardType) => {
+ data: DashboardType
}
addOrUpdateContextErrorTrackingIssue: (data: { id: string; name?: string | null }) => {
data: {
@@ -178,11 +177,11 @@ export interface maxContextLogicActions {
data: EventDefinition
}
addOrUpdateContextInsight: (
- data: InsightWithQuery,
+ data: Partial<InsightModel>,
filtersOverride?: DashboardFilter,
variablesOverride?: Record<string, HogQLVariable>
) => {
- data: InsightWithQuery
+ data: Partial<InsightModel<Node<Record<string, any>>>>
filtersOverride: DashboardFilter | undefined
variablesOverride: Record<string, HogQLVariable> | undefined
}
@@ -296,11 +295,11 @@ export const maxContextLogic = kea<maxContextLogicType>([
})),
actions({
addOrUpdateContextInsight: (
- data: InsightWithQuery,
+ data: Partial<InsightModel>,
filtersOverride?: DashboardFilter,
variablesOverride?: Record<string, HogQLVariable>
) => ({ data, filtersOverride, variablesOverride }),
- addOrUpdateContextDashboard: (data: DashboardType<QueryBasedInsightModel>) => ({ data }),
+ addOrUpdateContextDashboard: (data: DashboardType) => ({ data }),
addOrUpdateContextEvent: (data: EventDefinition) => ({ data }),
addOrUpdateContextAction: (data: ActionType) => ({ data }),
addOrUpdateContextErrorTrackingIssue: (data: { id: string; name?: string | null }) => ({ data }),
@@ -361,10 +360,8 @@ export const maxContextLogic = kea<maxContextLogicType>([
contextDashboards: [
[] as MaxDashboardContext[],
{
- addOrUpdateContextDashboard: (
- state: MaxDashboardContext[],
- { data }: { data: DashboardType<QueryBasedInsightModel> }
- ) => addOrUpdateEntity(state, dashboardToMaxContext(data)),
+ addOrUpdateContextDashboard: (state: MaxDashboardContext[], { data }: { data: DashboardType }) =>
+ addOrUpdateEntity(state, dashboardToMaxContext(data)),
removeContextDashboard: (state: MaxDashboardContext[], { id }: { id: string | number }) =>
removeEntity(state, id),
resetContext: () => [],
@@ -549,7 +546,7 @@ export const maxContextLogic = kea<maxContextLogicType>([
await breakpoint(50)
}
- insight = insightLogicInstance.values.insight as QueryBasedInsightModel
+ insight = insightLogicInstance.values.insight as InsightModel
} finally {
insightLogicInstance.unmount()
}
@@ -625,12 +622,12 @@ export const maxContextLogic = kea<maxContextLogicType>([
return {
type: MaxContextType.DASHBOARD,
id: dashboard.id,
- preloaded: dashboard as DashboardType<QueryBasedInsightModel>,
+ preloaded: dashboard as DashboardType,
}
}
if (groupType === TaxonomicFilterGroupType.Insights) {
- const insight = item as QueryBasedInsightModel
+ const insight = item as InsightModel
return {
type: MaxContextType.INSIGHT,
id: insight.short_id,
@@ -649,7 +646,7 @@ export const maxContextLogic = kea<maxContextLogicType>([
if (itemInfo.type === MaxContextType.DASHBOARD) {
actions.loadAndProcessDashboard({
id: itemInfo.id as number,
- preloaded: itemInfo.preloaded as DashboardType<QueryBasedInsightModel> | null,
+ preloaded: itemInfo.preloaded as DashboardType | null,
})
}
@@ -670,7 +667,7 @@ export const maxContextLogic = kea<maxContextLogicType>([
actions.loadAndProcessInsight(
{
id: itemInfo.id as InsightShortId,
- preloaded: itemInfo.preloaded as QueryBasedInsightModel | null,
+ preloaded: itemInfo.preloaded as InsightModel | null,
},
filtersOverride,
variablesOverride
diff --git a/frontend/src/scenes/max/maxTypes.ts b/frontend/src/scenes/max/maxTypes.ts
index cf6b3b32b76a..8a78a1c201f1 100644
--- a/frontend/src/scenes/max/maxTypes.ts
+++ b/frontend/src/scenes/max/maxTypes.ts
@@ -1,7 +1,7 @@
import { AgentMode } from '~/queries/schema/schema-assistant-messages'
import { DashboardFilter, HogQLVariable, QuerySchema } from '~/queries/schema/schema-general'
import { integer } from '~/queries/schema/type-utils'
-import { ActionType, DashboardType, EventDefinition, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { ActionType, DashboardType, EventDefinition, InsightShortId, InsightModel } from '~/types'
export enum MaxContextType {
DASHBOARD = 'dashboard',
@@ -13,11 +13,6 @@ export enum MaxContextType {
NOTEBOOK = 'notebook',
}
-export type InsightWithQuery = Pick<
- Partial<QueryBasedInsightModel>,
- 'query' | 'short_id' | 'name' | 'derived_name' | 'description' | 'id'
->
-
export interface MaxInsightContext {
type: MaxContextType.INSIGHT
id: InsightShortId
@@ -112,15 +107,30 @@ export type MaxContextItem =
| MaxEvaluationContext
| MaxNotebookContext
+/**
+ * The insight fields Max's context needs. `rawSceneContext` deep-compares its whole value, so
+ * narrowing here keeps `result` out of that comparison. Pass the model whole and a refresh that
+ * changed only results reads as a context change.
+ */
+export type MaxContextInsight = Pick<
+ Partial<InsightModel>,
+ 'query' | 'short_id' | 'name' | 'derived_name' | 'description' | 'id'
+>
+
+/** A dashboard reduced to what Max reads from it, for the same reason as `MaxContextInsight`. */
+export type MaxContextDashboard = Pick<DashboardType, 'id' | 'name' | 'description' | 'filters'> & {
+ tiles: { insight?: MaxContextInsight }[]
+}
+
type MaxInsightContextInput = {
type: MaxContextType.INSIGHT
- data: InsightWithQuery
+ data: MaxContextInsight
filtersOverride?: DashboardFilter
variablesOverride?: Record<string, HogQLVariable>
}
type MaxDashboardContextInput = {
type: MaxContextType.DASHBOARD
- data: DashboardType<InsightWithQuery>
+ data: MaxContextDashboard
}
type MaxEventContextInput = {
type: MaxContextType.EVENT
@@ -157,7 +167,7 @@ export type MaxContextInput =
| MaxEvaluationContextInput
| MaxNotebookContextInput
-function pickInsightFields(insight: Partial<QueryBasedInsightModel>): InsightWithQuery {
+function pickInsightFields(insight: Partial<InsightModel>): MaxContextInsight {
return {
id: insight.id,
short_id: insight.short_id,
@@ -173,19 +183,22 @@ function pickInsightFields(insight: Partial<QueryBasedInsightModel>): InsightWit
* These ensure proper typing and consistent patterns across scene logics
*/
export const createMaxContextHelpers = {
- dashboard: (dashboard: DashboardType<QueryBasedInsightModel>): MaxDashboardContextInput => ({
+ dashboard: (dashboard: DashboardType): MaxDashboardContextInput => ({
type: MaxContextType.DASHBOARD,
data: {
- ...dashboard,
+ id: dashboard.id,
+ name: dashboard.name,
+ description: dashboard.description,
+ filters: dashboard.filters,
+ // A dashboard scene offers its context before its tiles load, so this can be unset.
tiles: (dashboard.tiles ?? []).map((tile) => ({
- ...tile,
insight: tile.insight ? pickInsightFields(tile.insight) : tile.insight,
})),
},
}),
insight: (
- insight: InsightWithQuery,
+ insight: Partial<InsightModel>,
{
filtersOverride,
variablesOverride,
diff --git a/frontend/src/scenes/max/utils.test.ts b/frontend/src/scenes/max/utils.test.ts
index 2a3becf01640..48a2637ca33f 100644
--- a/frontend/src/scenes/max/utils.test.ts
+++ b/frontend/src/scenes/max/utils.test.ts
@@ -7,7 +7,7 @@ import {
RootAssistantMessage,
} from '~/queries/schema/schema-assistant-messages'
import { DataVisualizationNode, NodeKind } from '~/queries/schema/schema-general'
-import { DashboardType, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { DashboardType, InsightShortId, InsightModel } from '~/types'
import { EnhancedToolCall } from './max-constants'
import {
@@ -29,7 +29,7 @@ describe('max/utils', () => {
response: { results: [[1]] },
values: { response: 'keep this query value' },
}
- const insight: Partial<QueryBasedInsightModel> = {
+ const insight: Partial<InsightModel> = {
short_id: 'test-query' as InsightShortId,
query: {
kind: NodeKind.DataVisualizationNode,
@@ -39,7 +39,7 @@ describe('max/utils', () => {
const dashboard = {
id: 1,
tiles: [{ id: 1, insight }],
- } as DashboardType<QueryBasedInsightModel>
+ } as DashboardType
const context =
contextType === 'insight' ? insightToMaxContext(insight) : dashboardToMaxContext(dashboard).insights[0]
diff --git a/frontend/src/scenes/max/utils.ts b/frontend/src/scenes/max/utils.ts
index 8dacb9dc217f..924100ac0567 100644
--- a/frontend/src/scenes/max/utils.ts
+++ b/frontend/src/scenes/max/utils.ts
@@ -35,7 +35,7 @@ import {
QuerySchemaRoot,
} from '~/queries/schema/schema-general'
import { isHogQLQuery, isInsightQueryNode } from '~/queries/utils'
-import { ActionType, DashboardType, EventDefinition, QueryBasedInsightModel } from '~/types'
+import { ActionType, EventDefinition, InsightModel } from '~/types'
import { Scene } from '../sceneTypes'
import { MODE_DEFINITIONS } from './max-constants'
@@ -43,9 +43,9 @@ import { EnhancedToolCall } from './max-constants'
import { SuggestionGroup } from './maxLogic'
import {
EvaluationRuntime,
- InsightWithQuery,
MaxActionContext,
MaxContextType,
+ MaxContextDashboard,
MaxDashboardContext,
MaxErrorTrackingIssueContext,
MaxEvaluationContext,
@@ -203,7 +203,7 @@ function stripQueryResponses<Value>(value: Value): Value {
// Utility functions for transforming data to max context
export const insightToMaxContext = (
- insight: Partial<QueryBasedInsightModel>,
+ insight: Partial<InsightModel>,
filtersOverride?: DashboardFilter,
variablesOverride?: Record<string, HogQLVariable>
): MaxInsightContext => {
@@ -221,7 +221,7 @@ export const insightToMaxContext = (
}
}
-export const dashboardToMaxContext = (dashboard: DashboardType<InsightWithQuery>): MaxDashboardContext => {
+export const dashboardToMaxContext = (dashboard: MaxContextDashboard): MaxDashboardContext => {
return {
type: MaxContextType.DASHBOARD,
id: dashboard.id,
diff --git a/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts b/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts
index 299cb41765e0..3a4b36452520 100644
--- a/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts
+++ b/frontend/src/scenes/notebooks/Notebook/notebookLogic.ts
@@ -68,6 +68,7 @@ import {
import { notebooksCollabPresenceCreate } from 'products/notebooks/frontend/generated/api'
import type { NotebookCollabCursorApi } from 'products/notebooks/frontend/generated/api.schemas'
+import type { Node } from '../../../queries/schema/schema-general'
import type { CommentType, UserType } from '../../../types'
import {
buildNotebookDependencyGraph,
@@ -308,7 +309,7 @@ export interface notebookLogicValues {
findNodeLogicById: (id: string) => BuiltLogic<notebookNodeLogicType> | null
frameNodeSummaries: NotebookFrameNodeSummary[]
getSharedCachedInlineQueryResults: (nodeId: string | null | undefined) => AnyResponseType | null
- getSharedCachedInsight: (shortId: string | null | undefined) => InsightModel | null
+ getSharedCachedInsight: (shortId: string | null | undefined) => InsightModel<Node<Record<string, any>>> | null
hasUnsavedVariables: boolean
isEditable: boolean
isLocalOnly: boolean
@@ -703,8 +704,8 @@ export interface notebookLogicMeta {
cachedInlineQueryResultsByNodeId: (arg: any) => Record<string, AnyResponseType>
getSharedCachedInsight: (
isShared: boolean,
- cachedInsightsByShortId: Record<string, InsightModel>
- ) => (shortId: string | null | undefined) => InsightModel | null
+ cachedInsightsByShortId: Record<string, InsightModel<Node<Record<string, any>>>>
+ ) => (shortId: string | null | undefined) => InsightModel<Node<Record<string, any>>> | null
getSharedCachedInlineQueryResults: (
isShared: boolean,
cachedInlineQueryResultsByNodeId: Record<string, AnyResponseType>
diff --git a/frontend/src/scenes/project-homepage/RecentInsights.tsx b/frontend/src/scenes/project-homepage/RecentInsights.tsx
index 9588a1aea470..03907fa86021 100644
--- a/frontend/src/scenes/project-homepage/RecentInsights.tsx
+++ b/frontend/src/scenes/project-homepage/RecentInsights.tsx
@@ -9,13 +9,13 @@ import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { InsightIcon } from 'scenes/saved-insights/SavedInsights'
import { urls } from 'scenes/urls'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { ProjectHomePageCompactListItem } from './ProjectHomePageCompactListItem'
import { projectHomepageLogic } from './projectHomepageLogic'
interface InsightRowProps {
- insight: QueryBasedInsightModel
+ insight: InsightModel
dataAttr?: string
/** When true, text wraps instead of truncating and the row height grows to fit. */
allowWrap?: boolean
@@ -57,7 +57,7 @@ export function RecentInsights(): JSX.Element {
buttonTo: urls.savedInsights(),
}}
items={recentInsights.slice(0, 5)}
- renderRow={(insight: QueryBasedInsightModel, index) => (
+ renderRow={(insight: InsightModel, index) => (
<InsightRow key={index} insight={insight} dataAttr="recent-insight-item" />
)}
/>
diff --git a/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx b/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
index b27fc937945b..1b6a4e764253 100644
--- a/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
+++ b/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
@@ -6,7 +6,7 @@ import { MaxContextInput } from 'scenes/max/maxTypes'
import { projectLogic } from 'scenes/projectLogic'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
-import { Breadcrumb, InsightModel, QueryBasedInsightModel } from '~/types'
+import { Breadcrumb, InsightModel } from '~/types'
import type { Node } from '../../queries/schema/schema-general'
@@ -16,7 +16,7 @@ export interface projectHomepageLogicValues {
breadcrumbs: Breadcrumb[]
expandedInsightIds: Set<string>
maxContext: MaxContextInput[]
- recentInsights: QueryBasedInsightModel[]
+ recentInsights: InsightModel[]
recentInsightsLoading: boolean
}
@@ -31,10 +31,10 @@ export interface projectHomepageLogicActions {
errorObject?: any
}
loadRecentInsightsSuccess: (
- recentInsights: QueryBasedInsightModel<Node<Record<string, any>>>[],
+ recentInsights: InsightModel<Node<Record<string, any>>>[],
payload?: any
) => {
- recentInsights: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ recentInsights: InsightModel<Node<Record<string, any>>>[]
payload?: any
}
toggleInsightExpanded: (insightShortId: string) => {
@@ -69,7 +69,7 @@ export const projectHomepageLogic = kea<projectHomepageLogicType>([
loaders(({ values }) => ({
recentInsights: [
- [] as QueryBasedInsightModel[],
+ [] as InsightModel[],
{
loadRecentInsights: async () => {
const insights = await api.get<InsightModel[]>(
diff --git a/frontend/src/scenes/saved-insights/AddSavedInsightsToDashboard.tsx b/frontend/src/scenes/saved-insights/AddSavedInsightsToDashboard.tsx
index 199a15f1d2d4..d20db1f1a0d7 100644
--- a/frontend/src/scenes/saved-insights/AddSavedInsightsToDashboard.tsx
+++ b/frontend/src/scenes/saved-insights/AddSavedInsightsToDashboard.tsx
@@ -3,7 +3,7 @@ import { useEffect } from 'react'
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { insightDashboardModalLogic } from './insightDashboardModalLogic'
import { SavedInsightsTable } from './SavedInsightsTable'
@@ -19,7 +19,7 @@ export function AddSavedInsightsToDashboard(): JSX.Element {
}
}, [dashboard?.tiles, syncOptimisticStateWithDashboard])
- const handleToggle = (insight: QueryBasedInsightModel): void => {
+ const handleToggle = (insight: InsightModel): void => {
if (!dashboard?.id) {
return
}
diff --git a/frontend/src/scenes/saved-insights/InsightRow.tsx b/frontend/src/scenes/saved-insights/InsightRow.tsx
index 474a5f64f32b..79d80e329cfd 100644
--- a/frontend/src/scenes/saved-insights/InsightRow.tsx
+++ b/frontend/src/scenes/saved-insights/InsightRow.tsx
@@ -10,12 +10,12 @@ import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { urls } from 'scenes/urls'
import { Query } from '~/queries/Query/Query'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { InsightIcon } from './SavedInsights'
interface InsightRowProps {
- insight: QueryBasedInsightModel
+ insight: InsightModel
isExpanded: boolean
onToggle: () => void
dataAttr?: string
diff --git a/frontend/src/scenes/saved-insights/RecentlyViewed.tsx b/frontend/src/scenes/saved-insights/RecentlyViewed.tsx
index ed97d9b5c2db..0238efe3f922 100644
--- a/frontend/src/scenes/saved-insights/RecentlyViewed.tsx
+++ b/frontend/src/scenes/saved-insights/RecentlyViewed.tsx
@@ -4,7 +4,7 @@ import { CompactList } from 'lib/components/CompactList/CompactList'
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { urls } from 'scenes/urls'
-import { QueryBasedInsightModel, SavedInsightsTabs } from '~/types'
+import { InsightModel, SavedInsightsTabs } from '~/types'
import { projectHomepageLogic } from '../project-homepage/projectHomepageLogic'
import { InsightRow } from './InsightRow'
@@ -27,7 +27,7 @@ export function RecentlyViewed(): JSX.Element {
buttonTo: urls.savedInsights(SavedInsightsTabs.All),
}}
items={recentInsights.slice(0, 5)}
- renderRow={(insight: QueryBasedInsightModel) => (
+ renderRow={(insight: InsightModel) => (
<InsightRow
key={insight.short_id}
insight={insight}
diff --git a/frontend/src/scenes/saved-insights/SavedInsights.tsx b/frontend/src/scenes/saved-insights/SavedInsights.tsx
index 4b9ea6cf506e..193612ac572a 100644
--- a/frontend/src/scenes/saved-insights/SavedInsights.tsx
+++ b/frontend/src/scenes/saved-insights/SavedInsights.tsx
@@ -39,13 +39,7 @@ import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
import { isNodeWithSource } from '~/queries/utils'
-import {
- AccessControlLevel,
- AccessControlResourceType,
- ActivityScope,
- QueryBasedInsightModel,
- SavedInsightsTabs,
-} from '~/types'
+import { AccessControlLevel, AccessControlResourceType, ActivityScope, InsightModel, SavedInsightsTabs } from '~/types'
import { productAnalyticsEmptyState } from 'products/product_analytics/frontend/emptyState/productAnalyticsEmptyState'
@@ -68,13 +62,7 @@ export const scene: SceneExport = {
emptyState: productAnalyticsEmptyState,
}
-export function InsightIcon({
- insight,
- className,
-}: {
- insight: QueryBasedInsightModel
- className?: string
-}): JSX.Element | null {
+export function InsightIcon({ insight, className }: { insight: InsightModel; className?: string }): JSX.Element | null {
let Icon: ComponentType<any> | null = null
if ('query' in insight && isNonEmptyObject(insight.query)) {
diff --git a/frontend/src/scenes/saved-insights/SavedInsightsTable.tsx b/frontend/src/scenes/saved-insights/SavedInsightsTable.tsx
index 30c9d192d1a2..d30458a42c61 100644
--- a/frontend/src/scenes/saved-insights/SavedInsightsTable.tsx
+++ b/frontend/src/scenes/saved-insights/SavedInsightsTable.tsx
@@ -14,17 +14,17 @@ import { SavedInsightsEmptyState } from 'scenes/insights/EmptyStates'
import { useSummarizeInsight } from 'scenes/insights/summarizeInsight'
import { SavedInsightsFilters } from 'scenes/saved-insights/SavedInsightsFilters'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { addSavedInsightsModalLogic } from './addSavedInsightsModalLogic'
import { InsightIcon } from './SavedInsights'
interface SavedInsightsTableProps {
- isSelected?: (insight: QueryBasedInsightModel) => boolean
- onToggle?: (insight: QueryBasedInsightModel) => void
- isToggling?: (insight: QueryBasedInsightModel) => boolean
+ isSelected?: (insight: InsightModel) => boolean
+ onToggle?: (insight: InsightModel) => void
+ isToggling?: (insight: InsightModel) => boolean
/** Optional filter to exclude insights from the table */
- filterFn?: (insight: QueryBasedInsightModel) => boolean
+ filterFn?: (insight: InsightModel) => boolean
}
export function SavedInsightsTable({
@@ -47,7 +47,7 @@ export function SavedInsightsTable({
const { setModalPage, setModalFilters } = useActions(addSavedInsightsModalLogic)
const summarizeInsight = useSummarizeInsight()
- const columns: LemonTableColumns<QueryBasedInsightModel> = [
+ const columns: LemonTableColumns<InsightModel> = [
{
key: 'id',
width: 32,
@@ -80,14 +80,14 @@ export function SavedInsightsTable({
},
{
title: 'Tags',
- dataIndex: 'tags' as keyof QueryBasedInsightModel,
+ dataIndex: 'tags' as keyof InsightModel,
key: 'tags',
width: 0,
render: function renderTags(tags: string[]) {
return <ObjectTags tags={tags} staticOnly />
},
},
- createdByColumn() as LemonTableColumn<QueryBasedInsightModel, keyof QueryBasedInsightModel | undefined>,
+ createdByColumn() as LemonTableColumn<InsightModel, keyof InsightModel | undefined>,
{
title: 'Last modified',
sorter: true,
@@ -104,7 +104,7 @@ export function SavedInsightsTable({
{
key: 'status',
width: 32,
- render: function renderStatus(_: unknown, insight: QueryBasedInsightModel) {
+ render: function renderStatus(_: unknown, insight: InsightModel) {
return isSelected(insight) ? (
<div className="group/status relative flex items-center justify-center">
<IconCheck className="text-success text-xl transition-opacity duration-150 group-hover/status:opacity-0" />
diff --git a/frontend/src/scenes/saved-insights/Trending.tsx b/frontend/src/scenes/saved-insights/Trending.tsx
index d6d9dc28d059..0987ccfdc740 100644
--- a/frontend/src/scenes/saved-insights/Trending.tsx
+++ b/frontend/src/scenes/saved-insights/Trending.tsx
@@ -6,7 +6,7 @@ import { CompactList } from 'lib/components/CompactList/CompactList'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { urls } from 'scenes/urls'
-import { QueryBasedInsightModel, SavedInsightsTabs } from '~/types'
+import { InsightModel, SavedInsightsTabs } from '~/types'
import { InsightRow } from './InsightRow'
import { trendingInsightsLogic } from './trendingInsightsLogic'
@@ -43,7 +43,7 @@ export function Trending(): JSX.Element {
buttonTo: urls.savedInsights(SavedInsightsTabs.All),
}}
items={trendingInsights.slice(0, 5)}
- renderRow={(insight: QueryBasedInsightModel) => (
+ renderRow={(insight: InsightModel) => (
<InsightRow
key={insight.short_id}
insight={insight}
diff --git a/frontend/src/scenes/saved-insights/activityDescriptions.tsx b/frontend/src/scenes/saved-insights/activityDescriptions.tsx
index 5fe5c4624823..623c6f7fca8b 100644
--- a/frontend/src/scenes/saved-insights/activityDescriptions.tsx
+++ b/frontend/src/scenes/saved-insights/activityDescriptions.tsx
@@ -88,8 +88,12 @@ function describeInsightRename(
}
}
+// `filters` is no longer a field on the insight model, but old log entries still record changes to
+// it, so the activity log reads a wider set of fields than the model now carries.
+type LoggedInsightField = keyof InsightModel | 'filters'
+
const insightActionsMapping: Record<
- keyof InsightModel,
+ LoggedInsightField,
(change?: ActivityChange, logItem?: ActivityLogItem, asNotification?: boolean) => ChangeMapping | null
> = {
name: describeInsightRename,
@@ -280,7 +284,7 @@ function describeInsightUpdate(logItem: ActivityLogItem, asNotification?: boolea
const mappings: ChangeMapping[] = []
try {
for (const change of logItem.detail.changes || []) {
- const handler = insightActionsMapping[change.field as keyof InsightModel]
+ const handler = insightActionsMapping[change.field as LoggedInsightField]
if (!change?.field || !handler) {
continue
}
diff --git a/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.test.ts b/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.test.ts
index 041db48152d5..ae5096ec5a22 100644
--- a/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.test.ts
+++ b/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.test.ts
@@ -12,11 +12,11 @@ import { insightsApi } from 'scenes/insights/utils/api'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { addSavedInsightsModalLogic, handleDashboardUpdateFailure } from './addSavedInsightsModalLogic'
-const createInsight = (id: number, name = 'test'): QueryBasedInsightModel =>
+const createInsight = (id: number, name = 'test'): InsightModel =>
({
id,
name: `${name} ${id}`,
@@ -35,7 +35,7 @@ const createInsight = (id: number, name = 'test'): QueryBasedInsightModel =>
deleted: false,
saved: true,
query: {},
- }) as any as QueryBasedInsightModel
+ }) as any as InsightModel
function enableVariant(variant: 'filtered' | 'smart-filtered'): void {
featureFlagLogic.mount()
@@ -272,7 +272,7 @@ describe('addSavedInsightsModalLogic', () => {
describe('dashboard membership updates', () => {
const MESSAGES = { timedOut: 'Timed out', failed: 'Failed to add' }
- const insightOnDashboards = (dashboardIds: number[]): QueryBasedInsightModel =>
+ const insightOnDashboards = (dashboardIds: number[]): InsightModel =>
({
...createInsight(53),
dashboard_tiles: dashboardIds.map((dashboardId, index) => ({
@@ -280,7 +280,7 @@ describe('addSavedInsightsModalLogic', () => {
dashboard_id: dashboardId,
deleted: false,
})),
- }) as QueryBasedInsightModel
+ }) as InsightModel
it('keeps the other dashboards when adding', async () => {
initKeaTests()
diff --git a/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.ts b/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.ts
index 16403e33e41e..78aafbf4d959 100644
--- a/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.ts
+++ b/frontend/src/scenes/saved-insights/addSavedInsightsModalLogic.ts
@@ -17,7 +17,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
-import type { QueryBasedInsightModel } from '~/types'
+import type { InsightModel } from '~/types'
import type { FeatureFlagsSet } from '../../lib/logic/featureFlagLogic'
import type { Node } from '../../queries/schema/schema-general'
@@ -46,7 +46,7 @@ export const INSIGHTS_PER_PAGE = 15
* `dashboards` field: a PATCH of `dashboards` replaces the whole membership, so the list has to come
* from something the API still serves the web app.
*/
-function currentDashboardIds(insight: QueryBasedInsightModel): number[] {
+function currentDashboardIds(insight: InsightModel): number[] {
return (insight.dashboard_tiles || []).filter((tile) => !tile.deleted).map((tile) => tile.dashboard_id)
}
@@ -86,7 +86,7 @@ export interface addSavedInsightsModalLogicValues {
hasSmartDefaults: boolean
insights: {
count: number
- results: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ results: InsightModel<Node<Record<string, any>>>[]
}
insightsLoading: boolean
insightsPerPage: number
@@ -102,11 +102,11 @@ export interface addSavedInsightsModalLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface addSavedInsightsModalLogicActions {
addInsightToDashboard: (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
dashboardId: number
) => {
dashboardId: number
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
}
dashboardUpdateFailed: (insightId: number) => {
insightId: number
@@ -124,7 +124,7 @@ export interface addSavedInsightsModalLogicActions {
loadInsightsSuccess: (
insights: {
count: number
- results: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ results: InsightModel<Node<Record<string, any>>>[]
},
payload?: {
value: true
@@ -132,7 +132,7 @@ export interface addSavedInsightsModalLogicActions {
) => {
insights: {
count: number
- results: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ results: InsightModel<Node<Record<string, any>>>[]
}
payload?: {
value: true
@@ -158,11 +158,11 @@ export interface addSavedInsightsModalLogicActions {
payload?: any
}
removeInsightFromDashboard: (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
dashboardId: number
) => {
dashboardId: number
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
}
setDashboardUpdateLoading: (
insightId: number,
@@ -181,8 +181,8 @@ export interface addSavedInsightsModalLogicActions {
setModalPage: (page: number) => {
page: number
}
- updateInsight: (insight: QueryBasedInsightModel) => {
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ updateInsight: (insight: InsightModel) => {
+ insight: InsightModel<Node<Record<string, any>>>
}
}
@@ -192,7 +192,7 @@ export interface addSavedInsightsModalLogicMeta {
filters: (rawModalFilters: Partial<SavedInsightFilters> | null) => SavedInsightFilters
hasFilteredUI: (featureFlags: FeatureFlagsSet) => boolean
hasSmartDefaults: (featureFlags: FeatureFlagsSet) => boolean
- count: (insights: { count: number; results: QueryBasedInsightModel<Node<Record<string, any>>>[] }) => number
+ count: (insights: { count: number; results: InsightModel<Node<Record<string, any>>>[] }) => number
sorting: (filters: SavedInsightFilters) => Sorting | null
modalPage: (filters: SavedInsightFilters) => number
}
@@ -220,18 +220,18 @@ export const addSavedInsightsModalLogic = kea<addSavedInsightsModalLogicType>([
setModalPage: (page: number) => ({ page }),
setDashboardUpdateLoading: (insightId: number, loading: boolean) => ({ insightId, loading }),
- addInsightToDashboard: (insight: QueryBasedInsightModel, dashboardId: number) => ({ insight, dashboardId }),
- removeInsightFromDashboard: (insight: QueryBasedInsightModel, dashboardId: number) => ({
+ addInsightToDashboard: (insight: InsightModel, dashboardId: number) => ({ insight, dashboardId }),
+ removeInsightFromDashboard: (insight: InsightModel, dashboardId: number) => ({
insight,
dashboardId,
}),
dashboardUpdateFailed: (insightId: number) => ({ insightId }),
- updateInsight: (insight: QueryBasedInsightModel) => ({ insight }),
+ updateInsight: (insight: InsightModel) => ({ insight }),
}),
loaders(({ values }) => ({
insights: {
- __default: { results: [] as QueryBasedInsightModel[], count: 0 },
+ __default: { results: [] as InsightModel[], count: 0 },
loadInsights: async (_, breakpoint) => {
await breakpoint(300)
@@ -352,7 +352,7 @@ export const addSavedInsightsModalLogic = kea<addSavedInsightsModalLogicType>([
(s) => [s.insights],
(insights: {
count: number
- results: QueryBasedInsightModel<import('../../queries/schema').Node<Record<string, any>>>[]
+ results: InsightModel<import('../../queries/schema').Node<Record<string, any>>>[]
}) => insights.count,
],
sorting: [
diff --git a/frontend/src/scenes/saved-insights/insightDashboardModalLogic.test.ts b/frontend/src/scenes/saved-insights/insightDashboardModalLogic.test.ts
index 1d625bc38a66..cea3629eed8a 100644
--- a/frontend/src/scenes/saved-insights/insightDashboardModalLogic.test.ts
+++ b/frontend/src/scenes/saved-insights/insightDashboardModalLogic.test.ts
@@ -2,12 +2,12 @@ import { expectLogic } from 'kea-test-utils'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { addSavedInsightsModalLogic } from './addSavedInsightsModalLogic'
import { insightDashboardModalLogic } from './insightDashboardModalLogic'
-const createInsight = (id: number, name = 'test'): QueryBasedInsightModel =>
+const createInsight = (id: number, name = 'test'): InsightModel =>
({
id,
name: `${name} ${id}`,
@@ -26,7 +26,7 @@ const createInsight = (id: number, name = 'test'): QueryBasedInsightModel =>
deleted: false,
saved: true,
query: {},
- }) as any as QueryBasedInsightModel
+ }) as any as InsightModel
describe('insightDashboardModalLogic', () => {
let logic: ReturnType<typeof insightDashboardModalLogic.build>
diff --git a/frontend/src/scenes/saved-insights/insightDashboardModalLogic.ts b/frontend/src/scenes/saved-insights/insightDashboardModalLogic.ts
index f58761861654..3f76f862edb3 100644
--- a/frontend/src/scenes/saved-insights/insightDashboardModalLogic.ts
+++ b/frontend/src/scenes/saved-insights/insightDashboardModalLogic.ts
@@ -1,6 +1,6 @@
import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
-import type { QueryBasedInsightModel } from '~/types'
+import type { InsightModel } from '~/types'
import type { Node } from '../../queries/schema/schema-general'
import { addSavedInsightsModalLogic } from './addSavedInsightsModalLogic'
@@ -11,7 +11,7 @@ export type OptimisticDashboardState = Record<number, boolean>
export interface insightDashboardModalLogicValues {
dashboardUpdatesInProgress: Record<number, boolean> // addSavedInsightsModalLogic
isInsightInDashboard: (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
dashboardTiles?: {
insight?: {
id: number
@@ -24,21 +24,21 @@ export interface insightDashboardModalLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface insightDashboardModalLogicActions {
addInsightToDashboard: (
- insight: QueryBasedInsightModel<Node<Record<string, any>>>,
+ insight: InsightModel<Node<Record<string, any>>>,
dashboardId: number
) => {
dashboardId: number
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
} // addSavedInsightsModalLogic
dashboardUpdateFailed: (insightId: number) => {
insightId: number
} // addSavedInsightsModalLogic
removeInsightFromDashboard: (
- insight: QueryBasedInsightModel<Node<Record<string, any>>>,
+ insight: InsightModel<Node<Record<string, any>>>,
dashboardId: number
) => {
dashboardId: number
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
} // addSavedInsightsModalLogic
clearOptimisticDashboardState: (insightId: number) => {
insightId: number
@@ -67,13 +67,13 @@ export interface insightDashboardModalLogicActions {
}[]
}
toggleInsightOnDashboard: (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
dashboardId: number,
currentlyInDashboard: boolean
) => {
currentlyInDashboard: boolean
dashboardId: number
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
}
}
@@ -81,7 +81,7 @@ export interface insightDashboardModalLogicActions {
export interface insightDashboardModalLogicMeta {
__keaTypeGenInternalSelectorTypes: {
isInsightInDashboard: (optimisticDashboardState: OptimisticDashboardState) => (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
dashboardTiles?: {
insight?: {
id: number
@@ -111,11 +111,7 @@ export const insightDashboardModalLogic = kea<insightDashboardModalLogicType>([
setOptimisticDashboardState: (insightId: number, inDashboard: boolean) => ({ insightId, inDashboard }),
clearOptimisticDashboardState: (insightId: number) => ({ insightId }),
syncOptimisticStateWithDashboard: (tiles: { insight?: { id: number } | null }[]) => ({ tiles }),
- toggleInsightOnDashboard: (
- insight: QueryBasedInsightModel,
- dashboardId: number,
- currentlyInDashboard: boolean
- ) => ({
+ toggleInsightOnDashboard: (insight: InsightModel, dashboardId: number, currentlyInDashboard: boolean) => ({
insight,
dashboardId,
currentlyInDashboard,
@@ -158,14 +154,8 @@ export const insightDashboardModalLogic = kea<insightDashboardModalLogicType>([
(s) => [s.optimisticDashboardState],
(
optimisticState: OptimisticDashboardState
- ): ((
- insight: QueryBasedInsightModel,
- dashboardTiles?: { insight?: { id: number } | null }[]
- ) => boolean) => {
- return (
- insight: QueryBasedInsightModel,
- dashboardTiles?: { insight?: { id: number } | null }[]
- ): boolean => {
+ ): ((insight: InsightModel, dashboardTiles?: { insight?: { id: number } | null }[]) => boolean) => {
+ return (insight: InsightModel, dashboardTiles?: { insight?: { id: number } | null }[]): boolean => {
if (insight.id in optimisticState) {
return optimisticState[insight.id]
}
diff --git a/frontend/src/scenes/saved-insights/savedInsightsLogic.test.ts b/frontend/src/scenes/saved-insights/savedInsightsLogic.test.ts
index 23e508b58412..c5560958e1ea 100644
--- a/frontend/src/scenes/saved-insights/savedInsightsLogic.test.ts
+++ b/frontend/src/scenes/saved-insights/savedInsightsLogic.test.ts
@@ -16,7 +16,7 @@ import { urls } from 'scenes/urls'
import { useMocks } from '~/mocks/jest'
import { dashboardsModel } from '~/models/dashboardsModel'
import { initKeaTests } from '~/test/init'
-import { QueryBasedInsightModel, SavedInsightsTabs } from '~/types'
+import { InsightModel, SavedInsightsTabs } from '~/types'
import {
INSIGHTS_PER_PAGE,
@@ -32,7 +32,7 @@ jest.spyOn(api, 'create')
const blankScene = (): any => ({ scene: { component: () => null, logic: null } })
const scenes: any = { [Scene.SavedInsights]: blankScene }
-const createInsight = (id: number, string = 'hi'): QueryBasedInsightModel =>
+const createInsight = (id: number, string = 'hi'): InsightModel =>
({
id: id || 1,
name: `${string} ${id || 1}`,
@@ -51,7 +51,7 @@ const createInsight = (id: number, string = 'hi'): QueryBasedInsightModel =>
deleted: false,
saved: true,
query: {},
- }) as any as QueryBasedInsightModel
+ }) as any as InsightModel
const createSavedInsights = (string = 'hello', offset: number): InsightsResult => ({
count: 3,
results: [createInsight(1, string), createInsight(2, string), createInsight(3, string)].slice(offset),
diff --git a/frontend/src/scenes/saved-insights/savedInsightsLogic.ts b/frontend/src/scenes/saved-insights/savedInsightsLogic.ts
index 63c4d91aadce..b8bc272c0038 100644
--- a/frontend/src/scenes/saved-insights/savedInsightsLogic.ts
+++ b/frontend/src/scenes/saved-insights/savedInsightsLogic.ts
@@ -27,7 +27,7 @@ import { SIDE_PANEL_CONTEXT_KEY, SidePanelSceneContext } from '~/layout/navigati
import { dashboardsModel } from '~/models/dashboardsModel'
import { insightsModel } from '~/models/insightsModel'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
-import { Breadcrumb, InsightModel, QueryBasedInsightModel, SavedInsightsTabs, UserType } from '~/types'
+import { Breadcrumb, InsightModel, SavedInsightsTabs, UserType } from '~/types'
import {
InsightBulkDeleteResponseApi,
@@ -42,7 +42,7 @@ import { DraftInsightQuery, draftInsightListItem, isValidDraftInsightQuery } fro
export const INSIGHTS_PER_PAGE = 30
-export interface SavedInsightListItem extends QueryBasedInsightModel {
+export interface SavedInsightListItem extends InsightModel {
search_match_type?: 'exact' | 'similar' | null
}
@@ -189,8 +189,8 @@ export interface savedInsightsLogicValues {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface savedInsightsLogicActions {
- addInsight: (insight: QueryBasedInsightModel) => {
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ addInsight: (insight: InsightModel) => {
+ insight: InsightModel<Node<Record<string, any>>>
}
bulkDeleteInsights: ({ ids }: { ids: number[] }) => {
ids: number[]
@@ -238,10 +238,10 @@ export interface savedInsightsLogicActions {
value: true
}
duplicateInsight: (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
redirectToInsight?: any
) => {
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
redirectToInsight: any
}
loadDraftQuery: () => {
@@ -268,8 +268,8 @@ export interface savedInsightsLogicActions {
debounce: boolean
}
}
- renameInsight: (insight: QueryBasedInsightModel) => {
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ renameInsight: (insight: InsightModel) => {
+ insight: InsightModel<Node<Record<string, any>>>
}
setDashboardUpdateLoading: (
insightId: number,
@@ -291,11 +291,11 @@ export interface savedInsightsLogicActions {
merge: boolean
}
updateFavoritedInsight: (
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
favorited: boolean
) => {
favorited: boolean
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
}
updateFavoritedInsightFailure: (
error: string,
@@ -311,11 +311,11 @@ export interface savedInsightsLogicActions {
next?: string | null | undefined
offset: number
previous?: string | null | undefined
- results: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ results: InsightModel<Node<Record<string, any>>>[]
},
payload?: {
favorited: boolean
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
}
) => {
insights: {
@@ -324,15 +324,15 @@ export interface savedInsightsLogicActions {
next?: string | null | undefined
offset: number
previous?: string | null | undefined
- results: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ results: InsightModel<Node<Record<string, any>>>[]
}
payload?: {
favorited: boolean
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ insight: InsightModel<Node<Record<string, any>>>
}
}
- updateInsight: (insight: QueryBasedInsightModel) => {
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ updateInsight: (insight: InsightModel) => {
+ insight: InsightModel<Node<Record<string, any>>>
}
}
@@ -382,15 +382,15 @@ export const savedInsightsLogic = kea<savedInsightsLogicType>([
merge: boolean = true,
debounce: boolean = true
) => ({ filters, merge, debounce }),
- updateFavoritedInsight: (insight: QueryBasedInsightModel, favorited: boolean) => ({ insight, favorited }),
- renameInsight: (insight: QueryBasedInsightModel) => ({ insight }),
- duplicateInsight: (insight: QueryBasedInsightModel, redirectToInsight = false) => ({
+ updateFavoritedInsight: (insight: InsightModel, favorited: boolean) => ({ insight, favorited }),
+ renameInsight: (insight: InsightModel) => ({ insight }),
+ duplicateInsight: (insight: InsightModel, redirectToInsight = false) => ({
insight,
redirectToInsight,
}),
loadInsights: (debounce: boolean = true) => ({ debounce }),
- updateInsight: (insight: QueryBasedInsightModel) => ({ insight }),
- addInsight: (insight: QueryBasedInsightModel) => ({ insight }),
+ updateInsight: (insight: InsightModel) => ({ insight }),
+ addInsight: (insight: InsightModel) => ({ insight }),
setDashboardUpdateLoading: (insightId: number, loading: boolean) => ({ insightId, loading }),
loadDraftQuery: true,
setDraftQuery: (draftQuery: DraftInsightQuery | null) => ({ draftQuery }),
@@ -656,14 +656,14 @@ export const savedInsightsLogic = kea<savedInsightsLogicType>([
setDates: () => {
actions.loadInsights()
},
- [insightsModel.actionTypes.renameInsightSuccess]: ({ item }: { item: QueryBasedInsightModel }) => {
+ [insightsModel.actionTypes.renameInsightSuccess]: ({ item }: { item: InsightModel }) => {
actions.updateInsight(item)
},
[dashboardsModel.actionTypes.updateDashboardInsight]: ({
insight,
sourceDashboardId,
}: {
- insight: QueryBasedInsightModel
+ insight: InsightModel
sourceDashboardId?: number
}) => {
if (sourceDashboardId != null) {
diff --git a/frontend/src/scenes/saved-insights/trendingInsightsLogic.ts b/frontend/src/scenes/saved-insights/trendingInsightsLogic.ts
index 143950d2ee9a..1c2cc8b77b02 100644
--- a/frontend/src/scenes/saved-insights/trendingInsightsLogic.ts
+++ b/frontend/src/scenes/saved-insights/trendingInsightsLogic.ts
@@ -4,11 +4,11 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
export interface trendingInsightsLogicValues {
expandedInsightIds: Set<string>
- trendingInsights: QueryBasedInsightModel[]
+ trendingInsights: InsightModel[]
trendingInsightsLoading: boolean
trendingInsightsLoadedError: boolean
}
@@ -17,11 +17,11 @@ export interface trendingInsightsLogicActions {
loadTrendingInsights: () => any
loadTrendingInsightsFailure: (error: string, errorObject?: any) => { error: string; errorObject?: any }
loadTrendingInsightsSuccess: (
- trendingInsights: QueryBasedInsightModel[],
+ trendingInsights: InsightModel[],
payload?: any
) => {
payload?: any
- trendingInsights: QueryBasedInsightModel[]
+ trendingInsights: InsightModel[]
}
toggleInsightExpanded: (insightShortId: string) => { insightShortId: string }
}
@@ -35,7 +35,7 @@ export const trendingInsightsLogic = kea<trendingInsightsLogicType>([
}),
loaders({
trendingInsights: {
- __default: [] as QueryBasedInsightModel[],
+ __default: [] as InsightModel[],
loadTrendingInsights: async () => {
const insights = await api.insights.trending({ days: 7, limit: 5 })
return insights.map(getQueryBasedInsightModel)
diff --git a/frontend/src/scenes/surveys/utils/opportunityDetection.ts b/frontend/src/scenes/surveys/utils/opportunityDetection.ts
index d1a473db8b23..94db78595dcf 100644
--- a/frontend/src/scenes/surveys/utils/opportunityDetection.ts
+++ b/frontend/src/scenes/surveys/utils/opportunityDetection.ts
@@ -6,7 +6,7 @@ import {
GroupNode,
InsightVizNode,
} from '~/queries/schema/schema-general'
-import { DashboardTile, QueryBasedInsightModel, SurveyEventsWithProperties } from '~/types'
+import { DashboardTile, InsightModel, SurveyEventsWithProperties } from '~/types'
export interface FunnelContext {
insightName: string
@@ -36,9 +36,9 @@ export interface SurveyableFunnelInsight {
* - Doesn't already have a linked survey
*/
export function getBestSurveyOpportunityFunnel(
- tiles: DashboardTile<QueryBasedInsightModel>[],
+ tiles: DashboardTile[],
linkedInsightIds: Set<number> = new Set()
-): DashboardTile<QueryBasedInsightModel> | null {
+): DashboardTile | null {
const candidates = tiles
.filter(
(tile) =>
@@ -59,7 +59,7 @@ export function getBestSurveyOpportunityFunnel(
* Returns true only if we have a valid funnel query with results.
*/
export function isSurveyableFunnelInsight(
- insight: Partial<QueryBasedInsightModel> | undefined
+ insight: Partial<InsightModel> | undefined
): insight is SurveyableFunnelInsight {
const query = insight?.query as InsightVizNode<FunnelsQuery> | undefined
const result = insight?.result
@@ -79,7 +79,7 @@ export function isSurveyableFunnelInsight(
* @param insight funnel insight to extract context from
* @returns funnel "context" object, or null if invalid
*/
-export function extractFunnelContext(insight: Partial<QueryBasedInsightModel> | undefined): FunnelContext | null {
+export function extractFunnelContext(insight: Partial<InsightModel> | undefined): FunnelContext | null {
if (!isSurveyableFunnelInsight(insight)) {
return null
}
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 3f3c23f690bd..09f19886d02f 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -2571,9 +2571,9 @@ export interface Tileable {
export type DashboardTileIdOrNew = number | null
-export interface DashboardTile<T = InsightModel> extends Tileable {
+export interface DashboardTile extends Tileable {
id: number
- insight?: T
+ insight?: InsightModel
text?: TextModel
button_tile?: ButtonTileModel
widget?: DashboardWidgetModel
@@ -2633,7 +2633,8 @@ export interface ButtonTileModel extends DashboardWidgetInterface {
team?: number
}
-export interface InsightModel extends Cacheable, WithAccessControl {
+export interface InsightModel<R extends Node<Record<string, any>> = Node<Record<string, any>>>
+ extends Cacheable, WithAccessControl {
/** The unique key we use when communicating with the user, e.g. in URLs */
short_id: InsightShortId
/** The primary key in the database, used as well in API endpoints */
@@ -2668,9 +2669,8 @@ export interface InsightModel extends Cacheable, WithAccessControl {
next?: string
/** Only used in the frontend to toggle showing Baseline in funnels or not */
disable_baseline?: boolean
- filters: Partial<FilterType>
alerts?: AlertType[]
- query?: Node | null
+ query: R | null
query_status?: QueryStatus
query_scan?: QueryScanSummary
is_cached?: boolean
@@ -2682,13 +2682,6 @@ export interface InsightModel extends Cacheable, WithAccessControl {
export type InsightFilterOverrideContext = InsightFilterOverrideContextApi
-export interface QueryBasedInsightModel<R extends Node<Record<string, any>> = Node<Record<string, any>>> extends Omit<
- InsightModel,
- 'filters'
-> {
- query: R | null
-}
-
export interface EndpointType extends WithAccessControl {
id: string
name: string
@@ -2776,8 +2769,8 @@ export interface DashboardTemplateListParams {
export type DashboardTemplateScope = 'team' | 'global' | 'feature_flag' | 'organization'
-export interface DashboardType<T = InsightModel> extends DashboardBasicType {
- tiles: DashboardTile<T>[]
+export interface DashboardType extends DashboardBasicType {
+ tiles: DashboardTile[]
filters: DashboardFilter
variables?: Record<string, HogQLVariable>
persisted_filters?: DashboardFilter | null
@@ -3079,9 +3072,9 @@ export interface RawAnnotationType {
created_at: string
updated_at: string
dashboard_item?: number | null
- insight_short_id?: QueryBasedInsightModel['short_id'] | null
- insight_name?: QueryBasedInsightModel['name'] | null
- insight_derived_name?: QueryBasedInsightModel['derived_name'] | null
+ insight_short_id?: InsightModel['short_id'] | null
+ insight_name?: InsightModel['name'] | null
+ insight_derived_name?: InsightModel['derived_name'] | null
dashboard_id?: DashboardBasicType['id'] | null
dashboard_name?: DashboardBasicType['name'] | null
deleted?: boolean
@@ -3742,7 +3735,7 @@ export interface InsightLogicProps<Q extends QuerySchema = QuerySchema> {
/** id of the dashboard the insight is on (when the insight is being displayed on a dashboard) **/
dashboardId?: DashboardType['id']
/** cached insight */
- cachedInsight?: Partial<QueryBasedInsightModel> | null
+ cachedInsight?: Partial<InsightModel> | null
/** enable this to avoid API requests */
doNotLoad?: boolean
loadPriority?: number
@@ -3750,7 +3743,7 @@ export interface InsightLogicProps<Q extends QuerySchema = QuerySchema> {
/** query when used as ad-hoc insight */
query?: Q
setQuery?: (node: Q) => void
- refreshAfterDisplayOptionsChange?: (insight: QueryBasedInsightModel) => void
+ refreshAfterDisplayOptionsChange?: (insight: InsightModel) => void
/** Used to group DataNodes into a collection for group operations like refreshAll **/
dataNodeCollectionId?: string
diff --git a/products/alerts/frontend/components/AlertsButton.tsx b/products/alerts/frontend/components/AlertsButton.tsx
index 0d1d3b58922b..bbd146804f7f 100644
--- a/products/alerts/frontend/components/AlertsButton.tsx
+++ b/products/alerts/frontend/components/AlertsButton.tsx
@@ -8,12 +8,12 @@ import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { IconWithCount } from 'lib/lemon-ui/icons'
import { urls } from 'scenes/urls'
-import { InsightLogicProps, QueryBasedInsightModel } from '~/types'
+import { InsightLogicProps, InsightModel } from '~/types'
import { alertsUnsupportedReason, areAlertsSupportedForInsight, insightAlertsLogic } from '../logic/insightAlertsLogic'
export type AlertsButtonProps = LemonButtonProps & {
- insight: Partial<QueryBasedInsightModel>
+ insight: Partial<InsightModel>
insightLogicProps: InsightLogicProps
text: string
}
diff --git a/products/alerts/frontend/logic/alertFormLogic.ts b/products/alerts/frontend/logic/alertFormLogic.ts
index c7141454b621..feda28a952b9 100644
--- a/products/alerts/frontend/logic/alertFormLogic.ts
+++ b/products/alerts/frontend/logic/alertFormLogic.ts
@@ -22,7 +22,7 @@ import {
InsightsThresholdBounds,
} from '~/queries/schema/schema-general'
import { containsHogQLQuery, isFunnelsQuery, isInsightVizNode, isMetricsQuery } from '~/queries/utils'
-import { AvailableFeature, InsightLogicProps, IntervalType, QueryBasedInsightModel } from '~/types'
+import { AvailableFeature, InsightLogicProps, IntervalType, InsightModel } from '~/types'
import {
blockSubmitWithoutEntitlement,
@@ -74,7 +74,7 @@ export type AlertFormType = Pick<
> & {
id?: AlertType['id']
created_by?: AlertType['created_by'] | null
- insight?: QueryBasedInsightModel['id']
+ insight?: InsightModel['id']
}
export function canCheckOngoingInterval(
@@ -143,7 +143,7 @@ export function insightAlertKindForQuery(query?: Record<string, any> | null): In
export interface AlertFormLogicProps {
alert: AlertType | null
- insightId: QueryBasedInsightModel['id']
+ insightId: InsightModel['id']
onEditSuccess: (alertId?: AlertType['id']) => void
insightVizDataLogicProps?: InsightLogicProps
insightInterval?: IntervalType
@@ -234,7 +234,7 @@ function insightIntervalToAlertInterval(interval?: IntervalType | null): AlertCa
}
}
-function alertToFormType(alert: AlertType, insightId: QueryBasedInsightModel['id']): AlertFormType {
+function alertToFormType(alert: AlertType, insightId: InsightModel['id']): AlertFormType {
return {
...alert,
insight: insightId,
diff --git a/products/alerts/frontend/logic/insightAlertsLogic.ts b/products/alerts/frontend/logic/insightAlertsLogic.ts
index d39c332cba0a..f6b9b5d32bc7 100644
--- a/products/alerts/frontend/logic/insightAlertsLogic.ts
+++ b/products/alerts/frontend/logic/insightAlertsLogic.ts
@@ -18,7 +18,7 @@ import {
import { FunnelVizType, InsightLogicProps } from '~/types'
import type { Node } from '../../../../frontend/src/queries/schema/schema-general'
-import type { QueryBasedInsightModel } from '../../../../frontend/src/types'
+import type { InsightModel } from '../../../../frontend/src/types'
import { AlertType, AnomalyPoint, isTrendsAlertConfig } from '../types'
import { buildAlertFilterConfig } from './alertNotifications'
@@ -130,7 +130,7 @@ export function alertsToThresholdGoalLines(alerts: AlertType[]): GoalLine[] {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface insightAlertsLogicValues {
- insight: Partial<QueryBasedInsightModel<Node<Record<string, any>>>> // insightLogic
+ insight: Partial<InsightModel<Node<Record<string, any>>>> // insightLogic
breakdownFilter: BreakdownFilter | null | undefined // insightVizDataLogic
showAlertThresholdLines: boolean | null | undefined // insightVizDataLogic
alertAnomalyPoints: AnomalyPoint[]
diff --git a/products/alerts/frontend/types.ts b/products/alerts/frontend/types.ts
index 36b8eae7bd40..dd24ee30f738 100644
--- a/products/alerts/frontend/types.ts
+++ b/products/alerts/frontend/types.ts
@@ -12,7 +12,7 @@ import {
MetricsAlertConfig,
TrendsAlertConfig,
} from '~/queries/schema/schema-general'
-import { QueryBasedInsightModel, UserBasicType } from '~/types'
+import { InsightModel, UserBasicType } from '~/types'
import type { AlertDeliveryApi } from './generated/api.schemas'
@@ -113,7 +113,7 @@ export interface AlertTypeBase {
condition: AlertCondition
threshold: { configuration: AlertThreshold }
enabled: boolean
- insight: QueryBasedInsightModel
+ insight: InsightModel
config: AlertConfig
skip_weekend?: boolean
schedule_restriction?: ScheduleRestriction | null
diff --git a/products/alerts/frontend/views/AlertHistoryChart.stories.tsx b/products/alerts/frontend/views/AlertHistoryChart.stories.tsx
index 6eb5863df831..ca4dbab083f6 100644
--- a/products/alerts/frontend/views/AlertHistoryChart.stories.tsx
+++ b/products/alerts/frontend/views/AlertHistoryChart.stories.tsx
@@ -8,7 +8,7 @@ import {
AlertState,
InsightThresholdType,
} from '~/queries/schema/schema-general'
-import type { QueryBasedInsightModel } from '~/types'
+import type { InsightModel } from '~/types'
import type { UserBasicType } from '~/types'
import { CHART_CHECKS_LIMIT } from '../logic/alertLogic'
@@ -23,7 +23,7 @@ const STORY_USER: UserBasicType = {
}
-const EMPTY_INSIGHT = {} as QueryBasedInsightModel
+const EMPTY_INSIGHT = {} as InsightModel
/**
* Point labels land on the x-axis, so a live clock moves the snapshot on every visual-regression
diff --git a/products/alerts/frontend/views/EditAlertModal.tsx b/products/alerts/frontend/views/EditAlertModal.tsx
index abe42ee385d0..08f4b69319e7 100644
--- a/products/alerts/frontend/views/EditAlertModal.tsx
+++ b/products/alerts/frontend/views/EditAlertModal.tsx
@@ -16,7 +16,7 @@ import { urls } from 'scenes/urls'
import { AlertCalculationInterval, AlertConditionType, InsightThresholdType } from '~/queries/schema/schema-general'
import { isFunnelsQuery, isInsightVizNode } from '~/queries/utils'
-import { FunnelVizType, InsightLogicProps, InsightShortId, QueryBasedInsightModel } from '~/types'
+import { FunnelVizType, InsightLogicProps, InsightShortId, InsightModel } from '~/types'
import { AlertAdvancedOptionsSection } from 'products/alerts/frontend/components/AlertAdvancedOptionsSection'
import { AlertErrorBanner, AlertStateIndicator } from 'products/alerts/frontend/components/AlertDefinition'
@@ -71,7 +71,7 @@ type AlertModalProps = AlertModalCommonProps &
| {
alert?: never
alertId?: AlertType['id']
- insightId: QueryBasedInsightModel['id']
+ insightId: InsightModel['id']
insightShortId: InsightShortId
insightLogicProps: InsightLogicProps
}
@@ -80,7 +80,7 @@ type AlertModalProps = AlertModalCommonProps &
interface ResolvedAlertModalProps extends AlertModalCommonProps {
initialAlert?: AlertType
alertId?: AlertType['id']
- insightId: QueryBasedInsightModel['id']
+ insightId: InsightModel['id']
insightShortId: InsightShortId
insightLogicProps: InsightLogicProps
}
diff --git a/products/annotations/frontend/logics/annotationModalLogic.ts b/products/annotations/frontend/logics/annotationModalLogic.ts
index 54c37e3e23bc..3c8da3c56d34 100644
--- a/products/annotations/frontend/logics/annotationModalLogic.ts
+++ b/products/annotations/frontend/logics/annotationModalLogic.ts
@@ -13,7 +13,7 @@ import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
import { annotationsModel, deserializeAnnotation } from '~/models/annotationsModel'
-import { AnnotationScope, AnnotationType, DashboardBasicType, QueryBasedInsightModel } from '~/types'
+import { AnnotationScope, AnnotationType, DashboardBasicType, InsightModel } from '~/types'
import type { UserType } from '../../../../frontend/src/types'
import type { RawAnnotationType } from '../../../../frontend/src/types'
@@ -91,7 +91,7 @@ export interface annotationModalLogicActions {
}
openModalToCreateAnnotation: (
initialDate?: Dayjs | null,
- insightId?: QueryBasedInsightModel['id'] | null,
+ insightId?: InsightModel['id'] | null,
dashboardId?: DashboardBasicType['id'] | null
) => {
dashboardId: number | null | undefined
@@ -100,7 +100,7 @@ export interface annotationModalLogicActions {
}
openModalToEditAnnotation: (
annotation: AnnotationType,
- insightId?: QueryBasedInsightModel['id'] | null,
+ insightId?: InsightModel['id'] | null,
dashboardId?: DashboardBasicType['id'] | null
) => {
annotation: AnnotationType
@@ -173,7 +173,7 @@ export const annotationModalLogic = kea<annotationModalLogicType>([
actions({
openModalToCreateAnnotation: (
initialDate?: Dayjs | null,
- insightId?: QueryBasedInsightModel['id'] | null,
+ insightId?: InsightModel['id'] | null,
dashboardId?: DashboardBasicType['id'] | null
) => ({
initialDate,
@@ -182,7 +182,7 @@ export const annotationModalLogic = kea<annotationModalLogicType>([
}),
openModalToEditAnnotation: (
annotation: AnnotationType,
- insightId?: QueryBasedInsightModel['id'] | null,
+ insightId?: InsightModel['id'] | null,
dashboardId?: DashboardBasicType['id'] | null
) => ({
annotation,
diff --git a/products/customer_analytics/frontend/components/Accounts/accountBillingLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountBillingLogic.test.ts
index 006d8c425dcc..1382226110e2 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountBillingLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountBillingLogic.test.ts
@@ -7,7 +7,7 @@ import { insightsApi } from 'scenes/insights/utils/api'
import { dataVisualizationLogic } from '~/queries/nodes/DataVisualization/dataVisualizationLogic'
import { DataVisualizationNode, NodeKind } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
-import { ChartDisplayType, type QueryBasedInsightModel } from '~/types'
+import { ChartDisplayType, type InsightModel } from '~/types'
import {
AccountBillingKind,
@@ -21,7 +21,7 @@ const ORG_VARIABLE_ID = 'var-org'
const START_VARIABLE_ID = 'var-start'
const END_VARIABLE_ID = 'var-end'
-const buildBillingInsight = (shortId: string): QueryBasedInsightModel =>
+const buildBillingInsight = (shortId: string): InsightModel =>
({
short_id: shortId,
query: {
@@ -42,7 +42,7 @@ const buildBillingInsight = (shortId: string): QueryBasedInsightModel =>
},
},
},
- }) as unknown as QueryBasedInsightModel
+ }) as unknown as InsightModel
describe('accountBillingLogic', () => {
let logic: ReturnType<typeof accountBillingLogic.build>
diff --git a/products/customer_analytics/frontend/components/Accounts/accountBillingLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountBillingLogic.ts
index 59d7aa84c96b..39a58f0c5e60 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountBillingLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountBillingLogic.ts
@@ -26,7 +26,7 @@ import {
ProductKey,
QueryLogTags,
} from '~/queries/schema/schema-general'
-import { InsightShortId, QueryBasedInsightModel } from '~/types'
+import { InsightShortId, InsightModel } from '~/types'
import type { Node } from '../../../../../frontend/src/queries/schema/schema-general'
import { BillingUsageInterval, billingUsageQuery, supportsUsageAggregation } from './billingUsageQuery'
@@ -50,7 +50,7 @@ const END_VARIABLE = 'billing_end_date'
// backend could attribute it by.
const BILLING_QUERY_TAGS: QueryLogTags = { productKey: ProductKey.CUSTOMER_ANALYTICS, scene: 'CustomerAnalytics' }
-function withBillingQueryTags(insight: QueryBasedInsightModel): QueryBasedInsightModel {
+function withBillingQueryTags(insight: InsightModel): InsightModel {
const query = insight.query
if (!query || query.kind !== NodeKind.DataVisualizationNode) {
return insight
@@ -60,7 +60,7 @@ function withBillingQueryTags(insight: QueryBasedInsightModel): QueryBasedInsigh
...dataViz,
source: { ...dataViz.source, tags: { ...BILLING_QUERY_TAGS, ...dataViz.source.tags } },
}
- return { ...insight, query: taggedQuery as QueryBasedInsightModel['query'] }
+ return { ...insight, query: taggedQuery as InsightModel['query'] }
}
export interface BillingDateRange {
@@ -87,7 +87,7 @@ export function getBillingDataVisualizationKey(queryKey: string): string {
// Inject the account's org and the chosen date range into the saved insight's SQL variables, keyed by their
// variableId as read from the fetched insight (so this works regardless of the variable UUIDs in each env).
function buildVariableOverrides(
- insight: QueryBasedInsightModel,
+ insight: InsightModel,
resolvedDateRange: BillingDateRange,
externalId: string
): Record<string, HogQLVariable> | undefined {
@@ -120,11 +120,11 @@ function buildVariableOverrides(
export interface accountBillingLogicValues {
canAggregateUsage: boolean
dateRange: BillingDateRange
- displayInsights: QueryBasedInsightModel[] | null
+ displayInsights: InsightModel[] | null
ephemeralHiddenSeriesKeysByShortId: Record<string, string[]>
queryKeyFor: (shortId: string) => string
resolvedDateRange: BillingDateRange
- savedInsights: QueryBasedInsightModel[] | null
+ savedInsights: InsightModel[] | null
savedInsightsLoading: boolean
usageInterval: BillingUsageInterval
variableOverridesByShortId: Record<string, Record<string, HogQLVariable>>
@@ -141,10 +141,10 @@ export interface accountBillingLogicActions {
errorObject?: any
}
loadSavedInsightsSuccess: (
- savedInsights: QueryBasedInsightModel<Node<Record<string, any>>>[],
+ savedInsights: InsightModel<Node<Record<string, any>>>[],
payload?: any
) => {
- savedInsights: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ savedInsights: InsightModel<Node<Record<string, any>>>[]
payload?: any
}
setAllSeriesHidden: (
@@ -181,18 +181,15 @@ export interface accountBillingLogicActions {
export interface accountBillingLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
- canAggregateUsage: (
- savedInsights: QueryBasedInsightModel<Node<Record<string, any>>>[] | null,
- arg: any
- ) => boolean
+ canAggregateUsage: (savedInsights: InsightModel<Node<Record<string, any>>>[] | null, arg: any) => boolean
displayInsights: (
- savedInsights: QueryBasedInsightModel<Node<Record<string, any>>>[] | null,
+ savedInsights: InsightModel<Node<Record<string, any>>>[] | null,
usageInterval: BillingUsageInterval,
canAggregateUsage: boolean
- ) => QueryBasedInsightModel[] | null
+ ) => InsightModel[] | null
resolvedDateRange: (dateRange: BillingDateRange) => BillingDateRange
variableOverridesByShortId: (
- savedInsights: QueryBasedInsightModel<Node<Record<string, any>>>[] | null,
+ savedInsights: InsightModel<Node<Record<string, any>>>[] | null,
resolvedDateRange: BillingDateRange,
arg: any
) => Record<string, Record<string, HogQLVariable>>
@@ -259,7 +256,7 @@ export const accountBillingLogic = kea<accountBillingLogicType>([
],
})),
listeners(({ props, values, cache }) => {
- const preloadSavedInsights = (savedInsights: QueryBasedInsightModel[]): void => {
+ const preloadSavedInsights = (savedInsights: InsightModel[]): void => {
for (const insight of savedInsights) {
if (!insight.query || insight.query.kind !== NodeKind.DataVisualizationNode) {
continue
@@ -309,7 +306,7 @@ export const accountBillingLogic = kea<accountBillingLogicType>([
}),
loaders(({ props }) => ({
savedInsights: [
- null as QueryBasedInsightModel[] | null,
+ null as InsightModel[] | null,
{
loadSavedInsights: async (_ = null, breakpoint) => {
const insights = await Promise.all(
@@ -330,7 +327,7 @@ export const accountBillingLogic = kea<accountBillingLogicType>([
)
breakpoint()
return insights
- .filter((insight): insight is QueryBasedInsightModel => insight !== null)
+ .filter((insight): insight is InsightModel => insight !== null)
.map(withBillingQueryTags)
},
},
@@ -339,7 +336,7 @@ export const accountBillingLogic = kea<accountBillingLogicType>([
selectors({
canAggregateUsage: [
(s) => [s.savedInsights, (_, p) => p.kind],
- (savedInsights: QueryBasedInsightModel[] | null, kind: AccountBillingKind): boolean =>
+ (savedInsights: InsightModel[] | null, kind: AccountBillingKind): boolean =>
kind === 'usage' &&
!!savedInsights?.length &&
savedInsights.every(({ query }) => supportsUsageAggregation(query)),
@@ -347,10 +344,10 @@ export const accountBillingLogic = kea<accountBillingLogicType>([
displayInsights: [
(s) => [s.savedInsights, s.usageInterval, s.canAggregateUsage],
(
- savedInsights: QueryBasedInsightModel[] | null,
+ savedInsights: InsightModel[] | null,
interval: BillingUsageInterval,
canAggregate: boolean
- ): QueryBasedInsightModel[] | null =>
+ ): InsightModel[] | null =>
canAggregate
? savedInsights!.map((insight) => ({
...insight,
@@ -373,7 +370,7 @@ export const accountBillingLogic = kea<accountBillingLogicType>([
variableOverridesByShortId: [
(s) => [s.savedInsights, s.resolvedDateRange, (_, p) => p.externalId],
(
- savedInsights: QueryBasedInsightModel[] | null,
+ savedInsights: InsightModel[] | null,
resolvedDateRange: BillingDateRange,
externalId
): Record<string, Record<string, HogQLVariable>> => {
diff --git a/products/customer_analytics/frontend/components/CustomerJourneys/customerJourneysLogic.ts b/products/customer_analytics/frontend/components/CustomerJourneys/customerJourneysLogic.ts
index 65a1042668d3..4924390bc3e1 100644
--- a/products/customer_analytics/frontend/components/CustomerJourneys/customerJourneysLogic.ts
+++ b/products/customer_analytics/frontend/components/CustomerJourneys/customerJourneysLogic.ts
@@ -11,7 +11,7 @@ import { isUUIDLike } from 'lib/utils/guards'
import { FunnelsQuery, InsightVizNode } from '~/queries/schema/schema-general'
import { isInsightVizNode } from '~/queries/utils'
import { insightsApi } from '~/scenes/insights/utils/api'
-import { FunnelVizType, PropertyFilterType, PropertyOperator, QueryBasedInsightModel } from '~/types'
+import { FunnelVizType, PropertyFilterType, PropertyOperator, InsightModel } from '~/types'
import { CustomerJourneyApi } from 'products/customer_analytics/frontend/generated/api.schemas'
@@ -26,7 +26,7 @@ export interface CustomerJourneysLogicProps {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface customerJourneysLogicValues {
- activeInsight: QueryBasedInsightModel | null
+ activeInsight: InsightModel | null
activeInsightLoading: boolean
activeJourney: CustomerJourneyApi | null
activeJourneyFullQuery: InsightVizNode<FunnelsQuery> | null
@@ -103,10 +103,10 @@ export interface customerJourneysLogicActions {
errorObject?: any
}
loadActiveInsightSuccess: (
- activeInsight: QueryBasedInsightModel<Node<Record<string, any>>> | null,
+ activeInsight: InsightModel<Node<Record<string, any>>> | null,
payload?: any
) => {
- activeInsight: QueryBasedInsightModel<Node<Record<string, any>>> | null
+ activeInsight: InsightModel<Node<Record<string, any>>> | null
payload?: any
}
loadJourneys: () => any
@@ -169,7 +169,7 @@ export interface customerJourneysLogicMeta {
journeyOptions: (journeys: CustomerJourneyApi[]) => LemonSelectOptions<string>
activeJourney: (journeys: CustomerJourneyApi[], activeJourneyId: string | null) => CustomerJourneyApi | null
activeJourneyFullQuery: (
- activeInsight: QueryBasedInsightModel<Node<Record<string, any>>> | null,
+ activeInsight: InsightModel<Node<Record<string, any>>> | null,
queryOverride: InsightVizNode<FunnelsQuery> | null
) => InsightVizNode<FunnelsQuery> | null
isProfileMode: (arg: any, arg2: any) => boolean
@@ -241,7 +241,7 @@ export const customerJourneysLogic = kea<customerJourneysLogicType>([
},
},
activeInsight: {
- __default: null as QueryBasedInsightModel | null,
+ __default: null as InsightModel | null,
loadActiveInsight: async () => {
const journey = values.activeJourney
if (!journey) {
@@ -340,7 +340,7 @@ export const customerJourneysLogic = kea<customerJourneysLogicType>([
activeJourneyFullQuery: [
(s) => [s.activeInsight, s.queryOverride],
(
- activeInsight: QueryBasedInsightModel | null,
+ activeInsight: InsightModel | null,
queryOverride: InsightVizNode<FunnelsQuery> | null
): InsightVizNode<FunnelsQuery> | null => {
if (queryOverride) {
diff --git a/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/JourneyTemplatePicker.tsx b/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/JourneyTemplatePicker.tsx
index b139e325c457..1d5bfb047568 100644
--- a/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/JourneyTemplatePicker.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/JourneyTemplatePicker.tsx
@@ -13,7 +13,7 @@ import { useSummarizeInsight } from 'scenes/insights/summarizeInsight'
import { InsightIcon } from 'scenes/saved-insights/SavedInsights'
import { urls } from 'scenes/urls'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { JourneyTemplateKey, journeyTemplatePickerLogic } from './journeyTemplatePickerLogic'
@@ -184,7 +184,7 @@ export function JourneyTemplatePicker(): JSX.Element {
},
{
title: 'Tags',
- dataIndex: 'tags' as keyof QueryBasedInsightModel,
+ dataIndex: 'tags' as keyof InsightModel,
key: 'tags',
render: function renderTags(tags: string[]) {
return <ObjectTags tags={tags} staticOnly />
diff --git a/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/journeyTemplatePickerLogic.ts b/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/journeyTemplatePickerLogic.ts
index 2ecedefec247..5d36cc65f470 100644
--- a/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/journeyTemplatePickerLogic.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerJourneyTemplatesScene/journeyTemplatePickerLogic.ts
@@ -8,7 +8,7 @@ import { isEmptyObject } from 'lib/utils/guards'
import { urls } from 'scenes/urls'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
-import { InsightType, QueryBasedInsightModel } from '~/types'
+import { InsightType, InsightModel } from '~/types'
import type { AnyEntityNode, Node } from '../../../../../frontend/src/queries/schema/schema-general'
import { customerAnalyticsConfigLogic } from '../../customerAnalyticsConfigLogic'
@@ -20,7 +20,7 @@ export interface journeyTemplatePickerLogicValues {
paymentEvent: AnyEntityNode // customerAnalyticsConfigLogic
signupEvent: AnyEntityNode // customerAnalyticsConfigLogic
signupPageviewEvent: AnyEntityNode // customerAnalyticsConfigLogic
- funnels: QueryBasedInsightModel[]
+ funnels: InsightModel[]
funnelsLoading: boolean
isFreeToPaidAvailable: boolean
isSignupConversionAvailable: boolean
@@ -47,12 +47,12 @@ export interface journeyTemplatePickerLogicActions {
errorObject?: any
}
loadFunnelsSuccess: (
- funnels: QueryBasedInsightModel<Node<Record<string, any>>>[],
+ funnels: InsightModel<Node<Record<string, any>>>[],
payload?: {
value: true
}
) => {
- funnels: QueryBasedInsightModel<Node<Record<string, any>>>[]
+ funnels: InsightModel<Node<Record<string, any>>>[]
payload?: {
value: true
}
@@ -118,7 +118,7 @@ export const journeyTemplatePickerLogic = kea<journeyTemplatePickerLogicType>([
lazyLoaders(({ values }) => ({
funnels: {
- __default: [] as QueryBasedInsightModel[],
+ __default: [] as InsightModel[],
loadFunnels: async (_, breakpoint) => {
await breakpoint(300)
const response = await api.insights.list({
diff --git a/products/dashboards/frontend/DashboardFilters.stories.tsx b/products/dashboards/frontend/DashboardFilters.stories.tsx
index 51b19a7aa441..648a10eefecc 100644
--- a/products/dashboards/frontend/DashboardFilters.stories.tsx
+++ b/products/dashboards/frontend/DashboardFilters.stories.tsx
@@ -11,13 +11,7 @@ import { encodeURLFilters, encodeURLVariables } from 'scenes/dashboard/dashboard
import { mswDecorator } from '~/mocks/browser'
import { variableDataLogic } from '~/queries/nodes/DataVisualization/Components/Variables/variableDataLogic'
import { NodeKind, type DashboardFilter } from '~/queries/schema/schema-general'
-import {
- AccessControlLevel,
- DashboardType,
- PropertyFilterType,
- PropertyOperator,
- QueryBasedInsightModel,
-} from '~/types'
+import { AccessControlLevel, DashboardType, PropertyFilterType, PropertyOperator, InsightModel } from '~/types'
type FilterBarState = 'saved' | 'unsaved'
type DashboardFilterKind = 'date' | 'properties' | 'breakdown' | 'interval' | 'testAccounts'
@@ -44,7 +38,7 @@ interface DashboardFilterBarStoryProps {
const DASHBOARD_ID = 955
-const dashboard: DashboardType<QueryBasedInsightModel> = {
+const dashboard: DashboardType = {
id: DASHBOARD_ID,
name: 'Dashboard filter states',
description: '',
@@ -66,7 +60,7 @@ const SQL_VARIABLE_ID = 'organization'
const SQL_VARIABLE_DEFAULT = 'Default organization'
const SQL_VARIABLE_OVERRIDE = 'Example organization'
-const sqlVariablesDashboard: DashboardType<QueryBasedInsightModel> = {
+const sqlVariablesDashboard: DashboardType = {
...dashboard,
tiles: [
{
@@ -87,7 +81,7 @@ const sqlVariablesDashboard: DashboardType<QueryBasedInsightModel> = {
chartSettings: {},
tableSettings: {},
},
- } as unknown as QueryBasedInsightModel,
+ } as unknown as InsightModel,
},
],
persisted_variables: {
diff --git a/products/dashboards/frontend/Tiles/DashboardImageTile.stories.tsx b/products/dashboards/frontend/Tiles/DashboardImageTile.stories.tsx
index 1379bfe92847..b2ffebba293c 100644
--- a/products/dashboards/frontend/Tiles/DashboardImageTile.stories.tsx
+++ b/products/dashboards/frontend/Tiles/DashboardImageTile.stories.tsx
@@ -1,12 +1,12 @@
import type { Meta, StoryObj } from '@storybook/react'
-import { DashboardPlacement, DashboardTile, InsightColor, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile, InsightColor } from '~/types'
import { DashboardImageTile } from 'products/dashboards/frontend/components/ImageTile/DashboardImageTile'
const IMAGE_URL = 'https://imagedelivery.net/lvc9lblm6_VvsB0sE7lLrg/70-s-dance-hog/md'
-const transparentTile: DashboardTile<QueryBasedInsightModel> = {
+const transparentTile: DashboardTile = {
id: 1,
color: InsightColor.White,
transparent_background: true,
diff --git a/products/dashboards/frontend/Tiles/ImageTileModal.stories.tsx b/products/dashboards/frontend/Tiles/ImageTileModal.stories.tsx
index 727969e72041..aec8109148a5 100644
--- a/products/dashboards/frontend/Tiles/ImageTileModal.stories.tsx
+++ b/products/dashboards/frontend/Tiles/ImageTileModal.stories.tsx
@@ -1,12 +1,12 @@
import type { Meta, StoryObj } from '@storybook/react'
-import { AccessControlLevel, DashboardType, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardType } from '~/types'
import { ImageTileModal } from 'products/dashboards/frontend/components/ImageTile/ImageTileModal'
const IMAGE_URL = 'https://imagedelivery.net/lvc9lblm6_VvsB0sE7lLrg/70-s-dance-hog/md'
-const makeDashboard = (body?: string): DashboardType<QueryBasedInsightModel> =>
+const makeDashboard = (body?: string): DashboardType =>
({
id: 123,
name: 'Image tile story',
@@ -31,7 +31,7 @@ const makeDashboard = (body?: string): DashboardType<QueryBasedInsightModel> =>
filters: {},
tags: [],
user_access_level: AccessControlLevel.Editor,
- }) as DashboardType<QueryBasedInsightModel>
+ }) as DashboardType
const meta: Meta<typeof ImageTileModal> = {
title: 'Products/Dashboards/Tiles/Image Tile Modal',
diff --git a/products/dashboards/frontend/components/DashboardTextItem/DashboardTextItem.tsx b/products/dashboards/frontend/components/DashboardTextItem/DashboardTextItem.tsx
index 39113dc0b1cf..11f45f6cced3 100644
--- a/products/dashboards/frontend/components/DashboardTextItem/DashboardTextItem.tsx
+++ b/products/dashboards/frontend/components/DashboardTextItem/DashboardTextItem.tsx
@@ -8,7 +8,7 @@ import { textCardConverter } from 'lib/components/Cards/TextCard/textCardMarkdow
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
-import { DashboardPlacement, DashboardTile, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile, DashboardType } from '~/types'
import { DashboardImageTile } from '../ImageTile/DashboardImageTile'
import { getImageOnlyTextCardImage } from '../ImageTile/imageTileUtils'
@@ -16,7 +16,7 @@ import { getImageOnlyTextCardImage } from '../ImageTile/imageTileUtils'
type BaseTextCardProps = React.ComponentProps<typeof TextCard>
interface DashboardTextItemProps extends Omit<BaseTextCardProps, 'textTile' | 'placement' | 'moreButtonOverlay'> {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
placement: DashboardPlacement
dashboardId?: number | null
onEdit: () => void
diff --git a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.test.tsx b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.test.tsx
index 6fd55041a4e6..ad0e61518813 100644
--- a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.test.tsx
+++ b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.test.tsx
@@ -9,13 +9,7 @@ import { dashboardWidgetMenusLogic } from 'lib/components/Cards/InsightCard/dash
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { initKeaTests } from '~/test/init'
-import {
- DashboardPlacement,
- DashboardTile,
- PropertyFilterType,
- PropertyOperator,
- QueryBasedInsightModel,
-} from '~/types'
+import { DashboardPlacement, DashboardTile, PropertyFilterType, PropertyOperator } from '~/types'
import { getDashboardWidgetCatalogEntry, tryGetDashboardWidgetCatalogEntry } from '../../widget_types/catalog'
import { userHasDashboardWidgetProductAccess } from '../../widgetProductAccess'
@@ -105,7 +99,7 @@ const tile = {
config: { limit: 10, dateRange: { date_from: '-7d' } },
dashboard_tiles: [],
},
-} as unknown as DashboardTile<QueryBasedInsightModel>
+} as unknown as DashboardTile
const tileWithoutDescription = {
...tile,
@@ -113,7 +107,7 @@ const tileWithoutDescription = {
...tile.widget!,
description: '',
},
-} as DashboardTile<QueryBasedInsightModel>
+} as DashboardTile
describe('DashboardWidgetItem', () => {
beforeEach(() => {
diff --git a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx
index 430dc0a11ef3..fbcec03197e7 100644
--- a/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx
+++ b/products/dashboards/frontend/components/DashboardWidgetItem/DashboardWidgetItem.tsx
@@ -12,7 +12,7 @@ import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { ErrorBoundary } from '~/layout/ErrorBoundary'
-import { DashboardPlacement, DashboardTile, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile, DashboardType } from '~/types'
import {
DEFAULT_SHARED_DASHBOARD_WIDGET_PLACEHOLDER,
@@ -44,7 +44,7 @@ import { WidgetCardHeader, widgetCardShouldHideMoreButton } from '../WidgetCard/
import { WidgetRuntimeAvailabilityGuard } from '../WidgetRuntimeAvailabilityGuard/WidgetRuntimeAvailabilityGuard'
type DashboardWidgetItemProps = {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
placement: DashboardPlacement
dashboardId?: number | null
canEditDashboard?: boolean
@@ -84,7 +84,7 @@ type DashboardWidgetItemContentProps = Omit<
DashboardWidgetItemProps,
'children' | 'className' | 'style' | 'showResizeHandles' | 'canEnterEditModeFromEdge' | 'onEnterEditModeFromEdge'
> & {
- widget: NonNullable<DashboardTile<QueryBasedInsightModel>['widget']>
+ widget: NonNullable<DashboardTile['widget']>
definition: DashboardWidgetDefinition | undefined
headerCatalogEntry: ResolvedDashboardWidgetCatalogEntry
isUnknownWidgetType: boolean
@@ -94,7 +94,7 @@ type DashboardWidgetItemContentProps = Omit<
}
type DashboardWidgetItemBodyProps = {
- widget: NonNullable<DashboardTile<QueryBasedInsightModel>['widget']>
+ widget: NonNullable<DashboardTile['widget']>
definition: DashboardWidgetDefinition | undefined
componentProps: DashboardWidgetComponentProps
dashboardId?: number | null
diff --git a/products/dashboards/frontend/components/ImageTile/DashboardImageTile.tsx b/products/dashboards/frontend/components/ImageTile/DashboardImageTile.tsx
index 2a24b462b592..92fb0165ce66 100644
--- a/products/dashboards/frontend/components/ImageTile/DashboardImageTile.tsx
+++ b/products/dashboards/frontend/components/ImageTile/DashboardImageTile.tsx
@@ -7,13 +7,13 @@ import { EditModeEdge, EditModeEdgeOverlay } from 'lib/components/Cards/InsightC
import { More, MoreProps } from 'lib/lemon-ui/LemonButton/More'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
-import { DashboardPlacement, DashboardTile, QueryBasedInsightModel } from '~/types'
+import { DashboardPlacement, DashboardTile } from '~/types'
import { imageTilePositionToCss } from './imageTileUtils'
import type { ImageTileImage } from './imageTileUtils'
interface DashboardImageTileProps extends React.HTMLAttributes<HTMLDivElement>, Resizeable {
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
image: ImageTileImage
placement: DashboardPlacement
children?: JSX.Element
diff --git a/products/dashboards/frontend/components/ImageTile/ImageTileModal.test.tsx b/products/dashboards/frontend/components/ImageTile/ImageTileModal.test.tsx
index e8532de70a61..5645f4f68eb8 100644
--- a/products/dashboards/frontend/components/ImageTile/ImageTileModal.test.tsx
+++ b/products/dashboards/frontend/components/ImageTile/ImageTileModal.test.tsx
@@ -9,13 +9,7 @@ import { useUploadFiles } from 'lib/hooks/useUploadFiles'
import { preflightLogic } from 'lib/logic/preflightLogic'
import { initKeaTests } from '~/test/init'
-import {
- AccessControlLevel,
- type DashboardTileIdOrNew,
- DashboardType,
- PreflightStatus,
- QueryBasedInsightModel,
-} from '~/types'
+import { AccessControlLevel, type DashboardTileIdOrNew, DashboardType, PreflightStatus } from '~/types'
import { ImageTileModal } from 'products/dashboards/frontend/components/ImageTile/ImageTileModal'
@@ -23,7 +17,7 @@ jest.mock('lib/hooks/useUploadFiles', () => ({
useUploadFiles: jest.fn(),
}))
-const makeDashboard = (body?: string): DashboardType<QueryBasedInsightModel> =>
+const makeDashboard = (body?: string): DashboardType =>
({
id: 123,
name: 'Test dashboard',
@@ -48,7 +42,7 @@ const makeDashboard = (body?: string): DashboardType<QueryBasedInsightModel> =>
filters: {},
tags: [],
user_access_level: AccessControlLevel.Editor,
- }) as DashboardType<QueryBasedInsightModel>
+ }) as DashboardType
const firePointerEvent = (
element: HTMLElement,
diff --git a/products/dashboards/frontend/components/ImageTile/ImageTileModal.tsx b/products/dashboards/frontend/components/ImageTile/ImageTileModal.tsx
index 804788c9e660..aeb9deff68f3 100644
--- a/products/dashboards/frontend/components/ImageTile/ImageTileModal.tsx
+++ b/products/dashboards/frontend/components/ImageTile/ImageTileModal.tsx
@@ -21,7 +21,7 @@ import { LemonSwitch } from 'lib/lemon-ui/LemonSwitch'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { preflightLogic } from 'lib/logic/preflightLogic'
-import { DashboardTileIdOrNew, DashboardType, QueryBasedInsightModel } from '~/types'
+import { DashboardTileIdOrNew, DashboardType } from '~/types'
import {
DEFAULT_IMAGE_TILE_POSITION,
@@ -63,7 +63,7 @@ export function ImageTileModal({
}: {
isOpen: boolean
onClose: () => void
- dashboard: DashboardType<QueryBasedInsightModel>
+ dashboard: DashboardType
imageTileId: DashboardTileIdOrNew
}): JSX.Element {
const isNewTile = imageTileId === null
diff --git a/products/dashboards/frontend/dashboardSettings/DashboardFilters.test.tsx b/products/dashboards/frontend/dashboardSettings/DashboardFilters.test.tsx
index c439323007eb..1f4cfa62a061 100644
--- a/products/dashboards/frontend/dashboardSettings/DashboardFilters.test.tsx
+++ b/products/dashboards/frontend/dashboardSettings/DashboardFilters.test.tsx
@@ -13,9 +13,9 @@ import { SEARCH_PARAM_FILTERS_KEY } from 'scenes/dashboard/dashboardUtils'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import { AccessControlLevel, DashboardPlacement, DashboardType, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardPlacement, DashboardType, InsightModel } from '~/types'
-const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {
+const MOCK_DASHBOARD: DashboardType = {
id: 5,
name: 'Test Dashboard',
description: 'A test dashboard',
@@ -68,7 +68,7 @@ describe('DashboardFilterBar', () => {
function renderFilterBar(
dashboardModeSource: DashboardEventSource,
- dashboard: DashboardType<QueryBasedInsightModel> = MOCK_DASHBOARD,
+ dashboard: DashboardType = MOCK_DASHBOARD,
placement: DashboardPlacement = DashboardPlacement.Dashboard
): ReturnType<typeof dashboardLogic.build> {
const logic = dashboardLogic({ id: dashboard.id, dashboard, placement })
@@ -118,7 +118,7 @@ describe('DashboardFilterBar', () => {
it('keeps Preview and Discard available, but hides Save filters, for viewers', async () => {
const autoPreviewLimit = jest.replaceProperty(dashboardUtils, 'AUTO_PREVIEW_TILE_LIMIT', 0)
- const viewerDashboard: DashboardType<QueryBasedInsightModel> = {
+ const viewerDashboard: DashboardType = {
...MOCK_DASHBOARD,
user_access_level: AccessControlLevel.Viewer,
tiles: [
@@ -126,7 +126,7 @@ describe('DashboardFilterBar', () => {
id: 1,
color: null,
layouts: {},
- insight: { id: 1, short_id: 'viewer', name: 'Viewer' } as QueryBasedInsightModel,
+ insight: { id: 1, short_id: 'viewer', name: 'Viewer' } as InsightModel,
},
],
}
@@ -148,23 +148,23 @@ describe('DashboardFilterBar', () => {
it('keeps Preview disabled until the dashboard settings change', async () => {
const autoPreviewLimit = jest.replaceProperty(dashboardUtils, 'AUTO_PREVIEW_TILE_LIMIT', 0)
- let finishPreview: (insight: QueryBasedInsightModel) => void = () => {
+ let finishPreview: (insight: InsightModel) => void = () => {
throw new Error('Preview resolver is unavailable')
}
- const preview = new Promise<QueryBasedInsightModel>((resolve) => {
+ const preview = new Promise<InsightModel>((resolve) => {
finishPreview = resolve
})
const getInsightSpy = jest
.spyOn(dashboardUtils, 'getInsightWithRetry')
.mockImplementation(async (_teamId, insight) => insight)
- const previewDashboard: DashboardType<QueryBasedInsightModel> = {
+ const previewDashboard: DashboardType = {
...MOCK_DASHBOARD,
tiles: [
{
id: 1,
color: null,
layouts: {},
- insight: { id: 1, short_id: 'preview', name: 'Preview' } as QueryBasedInsightModel,
+ insight: { id: 1, short_id: 'preview', name: 'Preview' } as InsightModel,
},
],
}
@@ -213,14 +213,14 @@ describe('DashboardFilterBar', () => {
const getInsightSpy = jest
.spyOn(dashboardUtils, 'getInsightWithRetry')
.mockRejectedValue(new Error('Preview request failed'))
- const previewDashboard: DashboardType<QueryBasedInsightModel> = {
+ const previewDashboard: DashboardType = {
...MOCK_DASHBOARD,
tiles: [
{
id: 1,
color: null,
layouts: {},
- insight: { id: 1, short_id: 'preview', name: 'Preview' } as QueryBasedInsightModel,
+ insight: { id: 1, short_id: 'preview', name: 'Preview' } as InsightModel,
},
],
}
diff --git a/products/dashboards/frontend/utils.ts b/products/dashboards/frontend/utils.ts
index b8d37735e000..cca35d89db7c 100644
--- a/products/dashboards/frontend/utils.ts
+++ b/products/dashboards/frontend/utils.ts
@@ -1,4 +1,4 @@
-import type { DashboardTile, QueryBasedInsightModel } from '~/types'
+import type { DashboardTile } from '~/types'
import { dashboardsPartialUpdate } from './generated/api'
import type { PatchedPatchedDashboardOpenApiApi } from './generated/api.schemas'
@@ -31,12 +31,12 @@ export async function updateDashboardWidgetTile({
}: {
teamId: number
dashboardId: number
- tile: DashboardTile<QueryBasedInsightModel>
+ tile: DashboardTile
config?: Record<string, unknown>
name?: string | null
description?: string
showDescription?: boolean
-}): Promise<DashboardTile<QueryBasedInsightModel>> {
+}): Promise<DashboardTile> {
if (!tile.widget) {
throw new Error('Tile has no widget')
}
@@ -73,7 +73,7 @@ export async function updateDashboardWidgetTile({
if (!updatedTile) {
throw new Error('Updated tile not found in dashboard response')
}
- return updatedTile as unknown as DashboardTile<QueryBasedInsightModel>
+ return updatedTile as unknown as DashboardTile
} catch (error) {
if (config !== undefined) {
const fieldErrors = parseDashboardWidgetConfigApiError(tile.widget.widget_type, error, config)
diff --git a/products/dashboards/frontend/widgets/AddWidgetModal.test.tsx b/products/dashboards/frontend/widgets/AddWidgetModal.test.tsx
index 274c7cc409ea..7ad4738a509b 100644
--- a/products/dashboards/frontend/widgets/AddWidgetModal.test.tsx
+++ b/products/dashboards/frontend/widgets/AddWidgetModal.test.tsx
@@ -9,7 +9,7 @@ import { BindLogic } from 'kea'
import { dashboardLogic } from 'scenes/dashboard/dashboardLogic'
import { initKeaTests } from '~/test/init'
-import { AccessControlLevel, DashboardType, QueryBasedInsightModel } from '~/types'
+import { AccessControlLevel, DashboardType } from '~/types'
import { AddWidgetModal } from './AddWidgetModal'
@@ -21,7 +21,7 @@ jest.mock('./previews/dashboardWidgetPreviews', () => ({
},
}))
-const MOCK_DASHBOARD: DashboardType<QueryBasedInsightModel> = {
+const MOCK_DASHBOARD: DashboardType = {
id: 5,
name: 'Test Dashboard',
description: 'A test dashboard',
diff --git a/products/endpoints/frontend/InsightPickerEndpointModal.tsx b/products/endpoints/frontend/InsightPickerEndpointModal.tsx
index 078aa97987d3..fd59038dd334 100644
--- a/products/endpoints/frontend/InsightPickerEndpointModal.tsx
+++ b/products/endpoints/frontend/InsightPickerEndpointModal.tsx
@@ -14,7 +14,7 @@ import { urls } from 'scenes/urls'
import { EndpointQueryNode, HogQLQuery, NodeKind } from '~/queries/schema/schema-general'
import { isNodeWithSource } from '~/queries/utils'
-import { InsightType, QueryBasedInsightModel } from '~/types'
+import { InsightType, InsightModel } from '~/types'
import { EndpointFromInsightModal } from './EndpointFromInsightModal'
import { endpointLogic } from './endpointLogic'
@@ -36,7 +36,7 @@ const UNSUPPORTED_QUERY_KINDS = new Set([
NodeKind.StickinessQuery,
])
-function isInsightSupported(insight: QueryBasedInsightModel): boolean {
+function isInsightSupported(insight: InsightModel): boolean {
const query = insight.query
if (!query) {
return true
@@ -142,7 +142,7 @@ export function InsightPickerEndpointModal(): JSX.Element {
Create an endpoint from an existing insight
</div>
<SavedInsightsTable
- onToggle={(insight: QueryBasedInsightModel) => {
+ onToggle={(insight: InsightModel) => {
selectInsight(insight)
openCreateFromInsightModal()
}}
diff --git a/products/endpoints/frontend/insightPickerEndpointModalLogic.ts b/products/endpoints/frontend/insightPickerEndpointModalLogic.ts
index 55656686191a..59eae4928141 100644
--- a/products/endpoints/frontend/insightPickerEndpointModalLogic.ts
+++ b/products/endpoints/frontend/insightPickerEndpointModalLogic.ts
@@ -4,14 +4,14 @@ import { actionToUrl, urlToAction } from 'kea-router'
import { addSavedInsightsModalLogic } from 'scenes/saved-insights/addSavedInsightsModalLogic'
import { urls } from 'scenes/urls'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import type { Node } from '../../../frontend/src/queries/schema/schema-general'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface insightPickerEndpointModalLogicValues {
isOpen: boolean
- selectedInsight: QueryBasedInsightModel | null
+ selectedInsight: InsightModel | null
showMoreInsightTypes: boolean
}
@@ -26,8 +26,8 @@ export interface insightPickerEndpointModalLogicActions {
openModal: () => {
value: true
}
- selectInsight: (insight: QueryBasedInsightModel) => {
- insight: QueryBasedInsightModel<Node<Record<string, any>>>
+ selectInsight: (insight: InsightModel) => {
+ insight: InsightModel<Node<Record<string, any>>>
}
toggleShowMoreInsightTypes: () => {
value: true
@@ -44,7 +44,7 @@ export const insightPickerEndpointModalLogic = kea<insightPickerEndpointModalLog
actions({
openModal: true,
closeModal: true,
- selectInsight: (insight: QueryBasedInsightModel) => ({ insight }),
+ selectInsight: (insight: InsightModel) => ({ insight }),
clearSelectedInsight: true,
toggleShowMoreInsightTypes: true,
}),
@@ -57,7 +57,7 @@ export const insightPickerEndpointModalLogic = kea<insightPickerEndpointModalLog
},
],
selectedInsight: [
- null as QueryBasedInsightModel | null,
+ null as InsightModel | null,
{
selectInsight: (_, { insight }) => insight,
clearSelectedInsight: () => null,
diff --git a/products/metrics/frontend/components/MetricsViewer.test.tsx b/products/metrics/frontend/components/MetricsViewer.test.tsx
index d1fd752bc1ef..311d21a35334 100644
--- a/products/metrics/frontend/components/MetricsViewer.test.tsx
+++ b/products/metrics/frontend/components/MetricsViewer.test.tsx
@@ -8,13 +8,7 @@ import { insightsApi } from 'scenes/insights/utils/api'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import {
- AccessControlLevel,
- AccessControlResourceType,
- AppContext,
- InsightShortId,
- QueryBasedInsightModel,
-} from '~/types'
+import { AccessControlLevel, AccessControlResourceType, AppContext, InsightShortId, InsightModel } from '~/types'
import {
metricsAttributesRetrieve,
@@ -42,7 +36,7 @@ jest.mock('scenes/insights/utils/api', () => ({
// picker binds to, and `id` is what a dashboard write would patch. Typed as a Partial — the
// shape `insightsApi.create` accepts — so these two fields are checked without padding the
// fixture with the rest of the model, which this flow never touches.
-const SAVED_INSIGHT: Partial<QueryBasedInsightModel> = { id: 7, short_id: 'insight7' as InsightShortId }
+const SAVED_INSIGHT: Partial<InsightModel> = { id: 7, short_id: 'insight7' as InsightShortId }
describe('MetricsViewer', () => {
let logic: ReturnType<typeof metricsViewerLogic.build>
@@ -61,7 +55,7 @@ describe('MetricsViewer', () => {
jest.mocked(metricsNamesRetrieve).mockResolvedValue({ results: [] })
jest.mocked(metricsQueryCreate).mockResolvedValue({ results: [] })
jest.mocked(metricsAttributesRetrieve).mockResolvedValue({ results: [], count: 0 })
- jest.mocked(insightsApi.create).mockResolvedValue(SAVED_INSIGHT as QueryBasedInsightModel)
+ jest.mocked(insightsApi.create).mockResolvedValue(SAVED_INSIGHT as InsightModel)
logic = metricsViewerLogic()
logic.mount()
})
diff --git a/products/metrics/frontend/components/metricsStarterDashboardLogic.tsx b/products/metrics/frontend/components/metricsStarterDashboardLogic.tsx
index 07070b991ade..3808366479fa 100644
--- a/products/metrics/frontend/components/metricsStarterDashboardLogic.tsx
+++ b/products/metrics/frontend/components/metricsStarterDashboardLogic.tsx
@@ -15,7 +15,6 @@ import type { DashboardType } from '~/types'
import { metricsAttributeValuesRetrieve, metricsNamesRetrieve } from 'products/metrics/frontend/generated/api'
import type { _MetricPickerNameApi } from 'products/metrics/frontend/generated/api.schemas'
-import type { InsightModel } from '../../../../frontend/src/types'
import { RECOMMENDED_AGGREGATION_BY_TYPE, nodeAggregationFields, toKnownMetricType } from './metricsViewerLogic'
// A metric name can appear under more than one OTel type, so option identity
@@ -51,7 +50,7 @@ export interface metricsStarterDashboardLogicActions {
createdDashboard: DashboardType,
warning?: string
) => {
- createdDashboard: DashboardType<InsightModel>
+ createdDashboard: DashboardType
warning: string | undefined
}
loadMetricOptions: (_: any) => any
diff --git a/products/metrics/frontend/components/metricsUsageTrackingLogic.ts b/products/metrics/frontend/components/metricsUsageTrackingLogic.ts
index f8148640584a..426374735396 100644
--- a/products/metrics/frontend/components/metricsUsageTrackingLogic.ts
+++ b/products/metrics/frontend/components/metricsUsageTrackingLogic.ts
@@ -10,7 +10,7 @@ import type { _MetricEventSampleApi } from 'products/metrics/frontend/generated/
import type { ProductIntentProperties } from '../../../../frontend/src/lib/utils/product-intents'
import type { Node } from '../../../../frontend/src/queries/schema/schema-general'
-import type { QueryBasedInsightModel, UniversalFiltersGroup } from '../../../../frontend/src/types'
+import type { InsightModel, UniversalFiltersGroup } from '../../../../frontend/src/types'
import type { _MetricFilterApi, _MetricSeriesApi } from '../generated/api.schemas'
import { metricsSceneLogic } from '../metricsSceneLogic'
import type { MetricsSceneActiveTab } from '../metricsSceneLogic'
@@ -67,11 +67,11 @@ export interface metricsUsageTrackingLogicActions {
queryResults: _MetricSeriesApi[]
} // metricsViewerLogic
saveAsInsightSuccess: (
- savedInsight: QueryBasedInsightModel<Node<Record<string, any>>> | null,
+ savedInsight: InsightModel<Node<Record<string, any>>> | null,
payload?: any
) => {
payload?: any
- savedInsight: QueryBasedInsightModel<Node<Record<string, any>>> | null
+ savedInsight: InsightModel<Node<Record<string, any>>> | null
} // metricsViewerLogic
setAggregation: (aggregation: MetricAggregation) => {
aggregation: MetricAggregation
diff --git a/products/metrics/frontend/components/metricsViewerLogic.tsx b/products/metrics/frontend/components/metricsViewerLogic.tsx
index 3b0704bbbd9b..b5b841f9eace 100644
--- a/products/metrics/frontend/components/metricsViewerLogic.tsx
+++ b/products/metrics/frontend/components/metricsViewerLogic.tsx
@@ -29,7 +29,7 @@ import {
MetricsYAxisSettings,
NodeKind,
} from '~/queries/schema/schema-general'
-import { QueryBasedInsightModel } from '~/types'
+import { InsightModel } from '~/types'
import { PropertyFilterType, PropertyOperator, UniversalFilterValue, UniversalFiltersGroup } from '~/types'
import {
@@ -385,7 +385,7 @@ export interface metricsViewerLogicValues {
queryResults: MetricsViewerSeries[]
queryResultsLoading: boolean
queryState: MetricsViewerQueryState
- savedInsight: QueryBasedInsightModel | null
+ savedInsight: InsightModel | null
savedInsightLoading: boolean
selectedMetricType: OtelMetricTypeEnumApi | null
selectedServices: string[]
@@ -534,10 +534,10 @@ export interface metricsViewerLogicActions {
errorObject?: any
}
saveAsInsightSuccess: (
- savedInsight: QueryBasedInsightModel<Node<Record<string, any>>> | null,
+ savedInsight: InsightModel<Node<Record<string, any>>> | null,
payload?: any
) => {
- savedInsight: QueryBasedInsightModel<Node<Record<string, any>>> | null
+ savedInsight: InsightModel<Node<Record<string, any>>> | null
payload?: any
}
setActiveClauseIndex: (index: number) => {
@@ -1172,7 +1172,7 @@ export const metricsViewerLogic = kea<metricsViewerLogicType>([
},
],
savedInsight: [
- null as QueryBasedInsightModel | null,
+ null as InsightModel | null,
{
saveAsInsight: async () => {
if (!canCreateMetricsInsight()) {
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelCanvasLabel.tsx b/products/product_analytics/frontend/insights/funnels/FunnelCanvasLabel.tsx
index 4d0bf0deba31..042c5422c29e 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelCanvasLabel.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelCanvasLabel.tsx
@@ -13,7 +13,7 @@ import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
-import { FunnelVizType, type QueryBasedInsightModel } from '~/types'
+import { FunnelVizType, type InsightModel } from '~/types'
import { FunnelStepsPicker } from './filters/FunnelStepsPicker'
import { funnelDataLogic } from './funnelDataLogic'
@@ -92,7 +92,7 @@ export function FunnelCanvasLabel(): JSX.Element | null {
})
}
to={urls.experiment('new', null, {
- metric: getExperimentMetricFromInsight(insight as QueryBasedInsightModel),
+ metric: getExperimentMetricFromInsight(insight as InsightModel),
name: insight.name || insight.derived_name || derivedName,
})}
>
diff --git a/products/product_analytics/frontend/insights/funnels/funnelDataLogic.test.ts b/products/product_analytics/frontend/insights/funnels/funnelDataLogic.test.ts
index 5b79175c5d54..402c3596494c 100644
--- a/products/product_analytics/frontend/insights/funnels/funnelDataLogic.test.ts
+++ b/products/product_analytics/frontend/insights/funnels/funnelDataLogic.test.ts
@@ -17,7 +17,6 @@ import {
FunnelVizType,
InsightLogicProps,
InsightModel,
- InsightType,
StepOrderValue,
} from '~/types'
@@ -57,6 +56,10 @@ async function initFunnelDataLogic(): Promise<void> {
await expectLogic(logic).toFinishAllListeners()
}
+// The selectors under test only shape a result once the query source is a funnel, so tests that
+// assert on result shaping alone still have to set one.
+const FUNNELS_QUERY: FunnelsQuery = { kind: NodeKind.FunnelsQuery, series: [] }
+
describe('funnelDataLogic', () => {
beforeEach(async () => {
initKeaTests(false)
@@ -272,7 +275,6 @@ describe('funnelDataLogic', () => {
],
}
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: (funnelResult.result as FunnelStep[]).map((step) => ({
...step,
custom_name: 'Removed name',
@@ -300,7 +302,6 @@ describe('funnelDataLogic', () => {
breakdownFilter: { breakdown: '$browser', breakdown_type: 'event' },
}
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: funnelResultWithBreakdown.result,
}
@@ -378,9 +379,6 @@ describe('funnelDataLogic', () => {
},
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTimeToConvert.result,
}
@@ -394,13 +392,11 @@ describe('funnelDataLogic', () => {
it('for standard funnel', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
steps: funnelResult.result,
@@ -421,7 +417,6 @@ describe('funnelDataLogic', () => {
funnelsFilter: { funnelOrderType },
}
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: funnelResult.result,
}
@@ -449,7 +444,6 @@ describe('funnelDataLogic', () => {
funnelsFilter: { funnelOrderType },
}
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: funnelResult.result,
}
@@ -552,7 +546,6 @@ describe('funnelDataLogic', () => {
result[0] = { ...step, order: 0 }
}
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result,
}
@@ -576,7 +569,6 @@ describe('funnelDataLogic', () => {
],
}
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: funnelResult.result,
}
@@ -614,7 +606,6 @@ describe('funnelDataLogic', () => {
const result = [...(funnelResult.result as FunnelStep[])]
result[0] = { ...result[0], action_id: null as unknown as string, name: null as unknown as string }
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result,
}
@@ -642,13 +633,11 @@ describe('funnelDataLogic', () => {
it('with breakdown', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultWithBreakdown.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
steps: expect.arrayContaining([
@@ -674,13 +663,11 @@ describe('funnelDataLogic', () => {
it('with multi breakdown', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultWithMultiBreakdown.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
steps: expect.arrayContaining([
@@ -708,13 +695,11 @@ describe('funnelDataLogic', () => {
describe('stepsWithConversionMetrics', () => {
it('for standard funnel', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
stepsWithConversionMetrics: expect.arrayContaining([
@@ -740,13 +725,11 @@ describe('funnelDataLogic', () => {
it('with breakdown', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultWithBreakdown.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
stepsWithConversionMetrics: expect.arrayContaining([
@@ -788,13 +771,11 @@ describe('funnelDataLogic', () => {
it('with multi breakdown', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultWithMultiBreakdown.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
stepsWithConversionMetrics: expect.arrayContaining([
@@ -841,13 +822,11 @@ describe('funnelDataLogic', () => {
describe('flattenedBreakdowns', () => {
it('for standard funnel', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
flattenedBreakdowns: [
@@ -883,13 +862,11 @@ describe('funnelDataLogic', () => {
it('with breakdown', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultWithBreakdown.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
flattenedBreakdowns: [
@@ -929,13 +906,11 @@ describe('funnelDataLogic', () => {
it('with multi breakdown', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultWithMultiBreakdown.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
flattenedBreakdowns: [
@@ -977,13 +952,11 @@ describe('funnelDataLogic', () => {
describe('visibleStepsWithConversionMetrics', () => {
it('for standard funnel', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
visibleStepsWithConversionMetrics: [
@@ -1012,9 +985,6 @@ describe('funnelDataLogic', () => {
it('with breakdown', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultWithBreakdown.result,
}
const query: FunnelsQuery = {
@@ -1064,9 +1034,6 @@ describe('funnelDataLogic', () => {
it('with multi breakdown', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultWithMultiBreakdown.result,
}
const query: FunnelsQuery = {
@@ -1119,7 +1086,6 @@ describe('funnelDataLogic', () => {
describe('breakdownSorting', () => {
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: funnelResultWithBreakdown.result,
}
@@ -1201,9 +1167,6 @@ describe('funnelDataLogic', () => {
},
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTimeToConvert.result,
}
@@ -1217,9 +1180,6 @@ describe('funnelDataLogic', () => {
it('with other funnel', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
}
@@ -1241,9 +1201,6 @@ describe('funnelDataLogic', () => {
},
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: {
...funnelResultTimeToConvert.result,
bins: [],
@@ -1267,9 +1224,6 @@ describe('funnelDataLogic', () => {
},
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTimeToConvertWithoutConversions.result,
}
@@ -1290,9 +1244,6 @@ describe('funnelDataLogic', () => {
},
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTimeToConvert.result,
}
@@ -1322,9 +1273,6 @@ describe('funnelDataLogic', () => {
compareFilter: { compare: true },
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTimeToConvertCompare.result,
}
@@ -1356,9 +1304,6 @@ describe('funnelDataLogic', () => {
},
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTimeToConvert.result,
}
@@ -1383,9 +1328,6 @@ describe('funnelDataLogic', () => {
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
}
@@ -1407,9 +1349,6 @@ describe('funnelDataLogic', () => {
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTimeToConvert.result,
}
@@ -1431,9 +1370,6 @@ describe('funnelDataLogic', () => {
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTrends.result,
}
@@ -1457,9 +1393,6 @@ describe('funnelDataLogic', () => {
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
// Funnel-level median is carried as a top-level field on the response, not summed from steps.
total_median_conversion_time: 208.75,
@@ -1486,9 +1419,6 @@ describe('funnelDataLogic', () => {
},
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTimeToConvert.result,
}
@@ -1514,9 +1444,6 @@ describe('funnelDataLogic', () => {
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTrends.result,
}
@@ -1543,9 +1470,6 @@ describe('funnelDataLogic', () => {
// No total_median_conversion_time — mirrors a result cached before the field existed.
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResult.result,
}
@@ -1570,9 +1494,6 @@ describe('funnelDataLogic', () => {
},
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: {
bins: (funnelResultTimeToConvert.result as any).bins,
average_conversion_time: (funnelResultTimeToConvert.result as any).average_conversion_time,
@@ -1764,13 +1685,11 @@ describe('funnelDataLogic', () => {
it('with defaults', async () => {
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTrends.result,
}
await expectLogic(logic, () => {
+ logic.actions.updateQuerySource(FUNNELS_QUERY)
builtDataNodeLogic.actions.loadDataSuccess(insight)
}).toMatchValues({
incompletenessOffsetFromEnd: -7,
@@ -1788,9 +1707,6 @@ describe('funnelDataLogic', () => {
}
const insight: Partial<InsightModel> = {
- filters: {
- insight: InsightType.FUNNELS,
- },
result: funnelResultTrends.result,
}
@@ -1814,7 +1730,6 @@ describe('funnelDataLogic', () => {
async function loadResult(result: unknown): Promise<void> {
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: result as InsightModel['result'],
}
await expectLogic(logic, () => {
@@ -1880,7 +1795,6 @@ describe('funnelDataLogic', () => {
async function loadStepsCompare(result: unknown): Promise<void> {
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: result as InsightModel['result'],
}
await expectLogic(logic, () => {
@@ -1975,7 +1889,6 @@ describe('funnelDataLogic', () => {
funnelsFilter: { funnelVizType: FunnelVizType.Steps },
}
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: funnelResult.result,
}
await expectLogic(logic, () => {
@@ -2004,7 +1917,6 @@ describe('funnelDataLogic', () => {
async function loadBreakdownCompare(result: unknown): Promise<void> {
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: result as InsightModel['result'],
}
await expectLogic(logic, () => {
@@ -2121,7 +2033,6 @@ describe('funnelDataLogic', () => {
it('hides both periods of a breakdown value when its legend entry is hidden', async () => {
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: funnelResultStepsBreakdownCompare.result as InsightModel['result'],
}
await expectLogic(logic, () => {
@@ -2155,7 +2066,6 @@ describe('funnelDataLogic', () => {
it('hides both periods of the baseline when its legend entry is hidden', async () => {
const insight: Partial<InsightModel> = {
- filters: { insight: InsightType.FUNNELS },
result: funnelResultStepsBreakdownCompare.result as InsightModel['result'],
}
await expectLogic(logic, () => {
diff --git a/products/product_analytics/frontend/insights/funnels/funnelDataLogic.ts b/products/product_analytics/frontend/insights/funnels/funnelDataLogic.ts
index 49213ed85dd7..6a776412a6cb 100644
--- a/products/product_analytics/frontend/insights/funnels/funnelDataLogic.ts
+++ b/products/product_analytics/frontend/insights/funnels/funnelDataLogic.ts
@@ -30,7 +30,7 @@ import {
import { Noun, groupsModel } from '~/models/groupsModel'
import { seriesNodeToFilter } from '~/queries/nodes/InsightQuery/utils/queryNodeToFilter'
-import { FunnelExclusionSteps, InsightQueryNode } from '~/queries/schema/schema-general'
+import { FunnelExclusionSteps } from '~/queries/schema/schema-general'
import { FunnelsFilter, FunnelsQuery, FunnelsQueryResponse, NodeKind } from '~/queries/schema/schema-general'
import type {
AnyDataWarehouseNode,
@@ -66,8 +66,6 @@ import {
FunnelsTimeConversionBins,
HistogramGraphDatum,
InsightLogicProps,
- InsightModel,
- InsightType,
StepOrderValue,
TrendResult,
FilterType,
@@ -179,20 +177,6 @@ function compareBreakdownsByColumnKey(
return 0
}
-function isFunnelsQueryOrLegacyFilter(
- insightData: Partial<InsightModel> | null | undefined,
- querySource: InsightQueryNode | null
-): boolean {
- /**
- * TODO: Remove legacy filter check once all tests are migrated to query-based format.
- * There are still multiple tests relying on the legacy format in funnelDataLogic.test.ts.
- */
- if (insightData?.filters?.insight === InsightType.FUNNELS) {
- return true
- }
- return isFunnelsQuery(querySource)
-}
-
/**
* The display override a series carries. `custom_name` is set by the "Rename graph series" modal; a
* `name` that differs from the raw label is a rename applied through the query editor or the API.
@@ -450,7 +434,7 @@ export interface funnelDataLogicMeta {
funnelVizType: (funnelsFilter: FunnelsFilter | null | undefined) => FunnelVizType
aggregationTargetLabel: (
querySource: FunnelsQuery | null,
- aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun
+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel
) => Noun
results: (
insightData: Record<string, any>,
@@ -468,7 +452,6 @@ export interface funnelDataLogicMeta {
querySource: FunnelsQuery | null
) => FunnelResultType
steps: (
- insightData: Record<string, any>,
vizQuerySource:
| FunnelsQuery
| LifecycleQuery
@@ -528,7 +511,6 @@ export interface funnelDataLogicMeta {
timeConversionResultsPrevious: FunnelsTimeConversionBins | null
) => HistogramGraphDatum[] | null
hasFunnelResults: (
- insightData: Record<string, any>,
funnelsFilter: FunnelsFilter | null | undefined,
steps: FunnelStepWithNestedBreakdown[],
histogramGraphData: HistogramGraphDatum[] | null,
@@ -579,7 +561,7 @@ export interface funnelDataLogicMeta {
}[]
getFunnelsColorToken: (
resultCustomizations: Record<string, ResultCustomizationByValue> | undefined,
- getTheme: (themeId: number | string | null | undefined) => DataColorTheme | null,
+ getTheme: (themeId: number | string | null | undefined) => DataColorTheme | null, // insightVizDataLogic
breakdownFilter: BreakdownFilter | null | undefined,
querySource: FunnelsQuery | null,
flattenedBreakdowns: FlattenedFunnelStepByBreakdown[],
@@ -807,14 +789,7 @@ export const funnelDataLogic = kea<funnelDataLogicType>([
}
// TODO: after hooking up data manager, check that we have a funnels result here
- // We check both the legacy filter approach (insightData.filters.insight) and the new
- // query-based approach (querySource.kind) because tests still use the legacy approach.
- // This pattern matches the checks in the 'steps' and 'hasFunnelResults' selectors.
- if (
- insightData?.filters?.insight !== InsightType.FUNNELS &&
- querySource &&
- querySource?.kind !== NodeKind.FunnelsQuery
- ) {
+ if (querySource && querySource.kind !== NodeKind.FunnelsQuery) {
return []
}
@@ -837,7 +812,6 @@ export const funnelDataLogic = kea<funnelDataLogicType>([
],
steps: [
(s) => [
- s.insightData,
s.vizQuerySource,
s.querySource,
s.breakdownFilter,
@@ -846,7 +820,6 @@ export const funnelDataLogic = kea<funnelDataLogicType>([
s.isStepsFunnel,
],
(
- insightData: Record<string, any>,
_vizQuerySource:
| FunnelsQuery
| null
@@ -863,12 +836,12 @@ export const funnelDataLogic = kea<funnelDataLogicType>([
isTimeToConvertFunnel: boolean | null,
isStepsFunnel: boolean | null
): FunnelStepWithNestedBreakdown[] => {
- if (!isFunnelsQueryOrLegacyFilter(insightData, querySource)) {
+ if (!isFunnelsQuery(querySource)) {
return []
}
// we need to check whether results are an array, since isTimeToConvertFunnel can be false,
- // while still having "time-to-convert" results in insightData
+ // while the results are still "time-to-convert" shaped
if (!isTimeToConvertFunnel && Array.isArray(results) && results.length > 0) {
// STEPS compare: the runner returns both periods' steps as a flat tagged list.
// Reshape into one step per order with current+previous as nested bars. Trends
@@ -1184,16 +1157,15 @@ export const funnelDataLogic = kea<funnelDataLogicType>([
timeConversionBinsToHistogramData(timeConversionResultsPrevious),
],
hasFunnelResults: [
- (s) => [s.insightData, s.funnelsFilter, s.steps, s.histogramGraphData, s.querySource, s.stepNames],
+ (s) => [s.funnelsFilter, s.steps, s.histogramGraphData, s.querySource, s.stepNames],
(
- insightData: Record<string, any>,
funnelsFilter: FunnelsFilter | null | undefined,
steps: FunnelStepWithNestedBreakdown[],
histogramGraphData: HistogramGraphDatum[] | null,
querySource: FunnelsQuery | null,
stepNames: FunnelStepWithNestedBreakdown[]
) => {
- if (!isFunnelsQueryOrLegacyFilter(insightData, querySource)) {
+ if (!isFunnelsQuery(querySource)) {
return false
}
diff --git a/products/subscriptions/frontend/components/Subscriptions/SubscriptionWizard.tsx b/products/subscriptions/frontend/components/Subscriptions/SubscriptionWizard.tsx
index 20436f66164b..c9bedfd5e42d 100644
--- a/products/subscriptions/frontend/components/Subscriptions/SubscriptionWizard.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/SubscriptionWizard.tsx
@@ -61,7 +61,7 @@ import { SubscriptionCreationGate, SubscriptionFormSkeleton } from './views/Edit
interface SubscriptionWizardProps {
insightShortId?: InsightShortId
insightName?: string
- dashboard?: DashboardType<any> | null
+ dashboard?: DashboardType | null
onCancel: () => void
}
@@ -477,7 +477,7 @@ function SubscriptionContentStep({
aiSubscriptionBlocked,
}: {
logicProps: SubscriptionLogicProps
- dashboard?: DashboardType<any> | null
+ dashboard?: DashboardType | null
insightName?: string
subscription: SubscriptionType
aiSubscriptionBlocked: boolean
@@ -714,7 +714,7 @@ function SubscriptionReviewStep({
}: {
logicProps: SubscriptionLogicProps
subscription: SubscriptionType
- dashboard?: DashboardType<any> | null
+ dashboard?: DashboardType | null
insightShortId?: InsightShortId
}): JSX.Element {
const { previewLoading, previewError, previewImageUrl } = useValues(subscriptionLogic(logicProps))
diff --git a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx
index 9b9b844e8b7a..d0286114d9e0 100644
--- a/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/SubscriptionsModal.tsx
@@ -27,7 +27,7 @@ export interface SubscriptionsModalProps {
inline?: boolean
insightShortId?: InsightShortId
insightName?: string
- dashboard?: DashboardType<any> | null
+ dashboard?: DashboardType | null
'data-attr'?: string
}
diff --git a/products/subscriptions/frontend/components/Subscriptions/insightSelectorLogic.ts b/products/subscriptions/frontend/components/Subscriptions/insightSelectorLogic.ts
index 27da477fd11b..03a32ec8814c 100644
--- a/products/subscriptions/frontend/components/Subscriptions/insightSelectorLogic.ts
+++ b/products/subscriptions/frontend/components/Subscriptions/insightSelectorLogic.ts
@@ -1,6 +1,6 @@
import { MakeLogicType, actions, kea, path, props, reducers, selectors } from 'kea'
-import { DashboardTile, InsightModel } from '~/types'
+import { DashboardTile } from '~/types'
// Keep in sync with MAX_INSIGHTS in ee/tasks/subscriptions/subscription_utils.py
export const MAX_INSIGHTS = 10
@@ -11,8 +11,8 @@ export interface InsightSelectorLogicProps {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface insightSelectorLogicValues {
- filteredTiles: DashboardTile<InsightModel>[]
- insightTiles: DashboardTile<InsightModel>[]
+ filteredTiles: DashboardTile[]
+ insightTiles: DashboardTile[]
searchTerm: string
showSearch: boolean
userHasInteracted: boolean
@@ -31,12 +31,9 @@ export interface insightSelectorLogicActions {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface insightSelectorLogicMeta {
__keaTypeGenInternalSelectorTypes: {
- insightTiles: (tiles: DashboardTile<InsightModel>[]) => DashboardTile<InsightModel>[]
- filteredTiles: (
- insightTiles: DashboardTile<InsightModel>[],
- searchTerm: string
- ) => DashboardTile<InsightModel>[]
- showSearch: (insightTiles: DashboardTile<InsightModel>[]) => boolean
+ insightTiles: (tiles: DashboardTile[]) => DashboardTile[]
+ filteredTiles: (insightTiles: DashboardTile[], searchTerm: string) => DashboardTile[]
+ showSearch: (insightTiles: DashboardTile[]) => boolean
}
}
@@ -64,12 +61,9 @@ export const insightSelectorLogic = kea<insightSelectorLogicType>([
selectors({
insightTiles: [
(_, p) => [p.tiles],
- (tiles: DashboardTile<InsightModel>[]): DashboardTile<InsightModel>[] =>
- ((tiles || []) as DashboardTile<InsightModel>[])
- .filter(
- (tile): tile is DashboardTile<InsightModel> =>
- !!tile.insight && !tile.deleted && !tile.insight.deleted
- )
+ (tiles: DashboardTile[]): DashboardTile[] =>
+ ((tiles || []) as DashboardTile[])
+ .filter((tile): tile is DashboardTile => !!tile.insight && !tile.deleted && !tile.insight.deleted)
.sort(
(a, b) =>
(a.layouts?.sm?.y ?? 100) - (b.layouts?.sm?.y ?? 100) ||
@@ -78,7 +72,7 @@ export const insightSelectorLogic = kea<insightSelectorLogicType>([
],
filteredTiles: [
(s) => [s.insightTiles, s.searchTerm],
- (insightTiles: DashboardTile<InsightModel>[], searchTerm: string): DashboardTile<InsightModel>[] => {
+ (insightTiles: DashboardTile[], searchTerm: string): DashboardTile[] => {
if (!searchTerm.trim()) {
return insightTiles
}
@@ -89,9 +83,6 @@ export const insightSelectorLogic = kea<insightSelectorLogicType>([
})
},
],
- showSearch: [
- (s) => [s.insightTiles],
- (insightTiles: DashboardTile<InsightModel>[]) => insightTiles.length > 10,
- ],
+ showSearch: [(s) => [s.insightTiles], (insightTiles: DashboardTile[]) => insightTiles.length > 10],
}),
])
diff --git a/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.test.ts b/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.test.ts
index 6efd94892bc4..64fae15fa59a 100644
--- a/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.test.ts
+++ b/products/subscriptions/frontend/components/Subscriptions/subscriptionsLogic.test.ts
@@ -2,15 +2,7 @@ import { expectLogic } from 'kea-test-utils'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
-import {
- FilterType,
- InsightModel,
- InsightShortId,
- InsightType,
- PropertyFilterType,
- PropertyOperator,
- SubscriptionType,
-} from '~/types'
+import { InsightModel, InsightShortId, SubscriptionType } from '~/types'
import { subscriptionsLogic } from './subscriptionsLogic'
@@ -31,18 +23,12 @@ export const fixtureSubscriptionResponse = (id: number, args: Partial<Subscripti
...args,
}) as SubscriptionType
-const API_FILTERS: Partial<FilterType> = {
- insight: InsightType.TRENDS as InsightType,
- events: [{ id: 3 }],
- properties: [{ value: 'a', operator: PropertyOperator.Exact, key: 'a', type: PropertyFilterType.Person }],
-}
function fixtureInsightResponse(id: number, data?: Partial<InsightModel>): Partial<InsightModel> {
return {
id: id,
short_id: id.toString() as InsightShortId,
name: 'insight',
result: [`result ${id}`],
- filters: API_FILTERS,
...data,
}
}
diff --git a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
index 5e69e2cc5885..ef71ffe513a3 100644
--- a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
@@ -114,7 +114,7 @@ function LastDeliveryStatus({
interface EditSubscriptionProps {
id: number
insightShortId?: InsightShortId
- dashboard?: DashboardType<any> | null
+ dashboard?: DashboardType | null
onCancel: () => void
onDelete: () => void
}
@@ -207,7 +207,7 @@ function DashboardInsightsField({
dashboard,
onDefaultsApplied,
}: {
- dashboard: DashboardType<any>
+ dashboard: DashboardType
onDefaultsApplied: (selectedIds: number[]) => void
}): JSX.Element {
return (
diff --git a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.unsavedChanges.test.tsx b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.unsavedChanges.test.tsx
index c7ed9bbc37d3..1a3d8840d74d 100644
--- a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.unsavedChanges.test.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.unsavedChanges.test.tsx
@@ -22,7 +22,7 @@ const DASHBOARD = {
{ id: 1, insight: { id: 11, short_id: 'ins11', name: 'Pageviews' }, layouts: { sm: { x: 0, y: 0 } } },
{ id: 2, insight: { id: 12, short_id: 'ins12', name: 'Sessions' }, layouts: { sm: { x: 0, y: 1 } } },
],
-} as unknown as DashboardType<any>
+} as unknown as DashboardType
const SLACK_INTEGRATION = {
id: 7,
diff --git a/products/subscriptions/frontend/scenes/newSubscriptionTargetLogic.ts b/products/subscriptions/frontend/scenes/newSubscriptionTargetLogic.ts
index aead927b1555..1c23294a467d 100644
--- a/products/subscriptions/frontend/scenes/newSubscriptionTargetLogic.ts
+++ b/products/subscriptions/frontend/scenes/newSubscriptionTargetLogic.ts
@@ -9,8 +9,6 @@ import { DashboardType, InsightShortId } from '~/types'
import { insightsList } from 'products/product_analytics/frontend/generated/api'
-import type { InsightModel } from '../../../../frontend/src/types'
-
/** How many saved insights the picker offers before the user narrows them by search. */
const INSIGHT_OPTIONS_LIMIT = 100
@@ -69,10 +67,10 @@ export interface newSubscriptionTargetLogicActions {
errorObject?: any
}
loadDashboardSuccess: (
- dashboard: DashboardType<InsightModel>,
+ dashboard: DashboardType,
payload?: number
) => {
- dashboard: DashboardType<InsightModel>
+ dashboard: DashboardType
payload?: number
}
loadInsightOptions: (_: any) => any