diff --git a/frontend/src/scenes/data-management/events/EventDefinitionsTable.tsx b/frontend/src/scenes/data-management/events/EventDefinitionsTable.tsx index 201e411121644..ab8f3338cda70 100644 --- a/frontend/src/scenes/data-management/events/EventDefinitionsTable.tsx +++ b/frontend/src/scenes/data-management/events/EventDefinitionsTable.tsx @@ -126,14 +126,15 @@ export function EventDefinitionsTable(): JSX.Element { to={urls.insightNewHogQL( 'SELECT event, count()\n' + 'FROM events\n' + - 'WHERE timestamp > now() - interval 1 month\n' + + 'WHERE {filters}\n' + (filters.event_type === 'event_custom' ? "AND event NOT LIKE '$%'\n" : filters.event_type === 'event_posthog' ? "AND event LIKE '$%'\n" : '') + 'GROUP BY event\n' + - 'ORDER BY count() DESC' + 'ORDER BY count() DESC', + { dateRange: { date_from: '-24h' } } )} > Click here! diff --git a/frontend/src/scenes/data-management/properties/PropertyDefinitionsTable.tsx b/frontend/src/scenes/data-management/properties/PropertyDefinitionsTable.tsx index 1c5c75897b9b2..78cd7693a37e0 100644 --- a/frontend/src/scenes/data-management/properties/PropertyDefinitionsTable.tsx +++ b/frontend/src/scenes/data-management/properties/PropertyDefinitionsTable.tsx @@ -70,9 +70,10 @@ export function PropertyDefinitionsTable(): JSX.Element { to={urls.insightNewHogQL( 'SELECT arrayJoin(JSONExtractKeys(properties)) AS property_key, count()\n' + (filters.type === 'person' ? 'FROM persons\n' : 'FROM events\n') + - (filters.type === 'person' ? '' : 'WHERE timestamp > now() - interval 1 month\n') + + (filters.type === 'person' ? '' : 'WHERE {filters}\n') + 'GROUP BY property_key\n' + - 'ORDER BY count() DESC' + 'ORDER BY count() DESC', + { dateRange: { date_from: '-24h' } } )} > Click here! diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.ts index 3d7b54a846065..71d35f9da6781 100644 --- a/frontend/src/scenes/urls.ts +++ b/frontend/src/scenes/urls.ts @@ -2,6 +2,7 @@ import { combineUrl } from 'kea-router' import { toParams } from 'lib/utils' import { ExportOptions } from '~/exporter/types' +import { HogQLFilters } from '~/queries/schema' import { ActionType, AnnotationType, @@ -76,14 +77,14 @@ export const urls = { ...(filters ? { filters } : {}), ...(query ? { q: typeof query === 'string' ? query : JSON.stringify(query) } : {}), }).url, - insightNewHogQL: (query: string): string => + insightNewHogQL: (query: string, filters?: HogQLFilters): string => urls.insightNew( undefined, undefined, JSON.stringify({ kind: 'DataTableNode', full: true, - source: { kind: 'HogQLQuery', query }, + source: { kind: 'HogQLQuery', query, filters }, }) ), insightEdit: (id: InsightShortId): string => `/insights/${id}/edit`,