Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(data-exploration): fix event table regressions #13251

Closed
wants to merge 116 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
13a943c
add a big reload button
mariusandra Nov 23, 2022
d32744a
Merge branch 'master' into events-table-parity
mariusandra Nov 24, 2022
ab15ffd
reload button
mariusandra Nov 24, 2022
6262de6
load next data
mariusandra Nov 24, 2022
46d3e71
rename "more" to "actions"
mariusandra Nov 25, 2022
442ef35
new events that load
mariusandra Nov 25, 2022
b1d6577
refactor new/next loading
mariusandra Nov 25, 2022
7ab3888
bug
mariusandra Nov 25, 2022
4ac98bd
autoload
mariusandra Nov 25, 2022
a5d7d8f
Merge branch 'master' into events-table-parity
mariusandra Nov 29, 2022
edab9b6
new scene with a flag
mariusandra Nov 30, 2022
3c2e539
use only string columns
mariusandra Dec 1, 2022
832311a
move around
mariusandra Dec 1, 2022
ff576da
configurator
mariusandra Dec 1, 2022
2b4b05e
refactor again
mariusandra Dec 2, 2022
5757766
column config
mariusandra Dec 2, 2022
b2ec7ab
actually select them
mariusandra Dec 2, 2022
cb9ad0f
actually select them
mariusandra Dec 2, 2022
68c28da
hide on save
mariusandra Dec 2, 2022
c27e8cc
Merge branch 'master' into events-table-parity
mariusandra Dec 2, 2022
32d8e91
make the old events table work with the new events format
mariusandra Dec 2, 2022
079bc13
configure columns
mariusandra Dec 2, 2022
509dbff
clean up, add test
mariusandra Dec 2, 2022
cfb22eb
move away from antd
mariusandra Dec 2, 2022
e043ad0
less ants, move move
mariusandra Dec 2, 2022
f487f42
more cleanup
mariusandra Dec 2, 2022
448a6c5
export
mariusandra Dec 2, 2022
6ff3d47
show icon, store person properties
mariusandra Dec 2, 2022
d34f4a4
delete old code
mariusandra Dec 3, 2022
7d160c3
add readme
mariusandra Dec 3, 2022
32c6281
link properties
mariusandra Dec 3, 2022
691f86a
make it look closer to the old page
mariusandra Dec 3, 2022
a3f54ce
url
mariusandra Dec 3, 2022
8b2b616
show buffer warning
mariusandra Dec 3, 2022
24edb28
rename
mariusandra Dec 3, 2022
27484ed
autoload spinner, fix load order
mariusandra Dec 3, 2022
79250ab
add automatic row highlighting
mariusandra Dec 3, 2022
6c552fe
scope down
mariusandra Dec 3, 2022
bdf36e2
comment
mariusandra Dec 3, 2022
66e5221
more comments
mariusandra Dec 4, 2022
95d63b3
add link to session player
mariusandra Dec 4, 2022
1f138a5
move defaults to logic
mariusandra Dec 4, 2022
b817b2c
enable autoload
mariusandra Dec 4, 2022
6dc3079
sanitize old columns
mariusandra Dec 4, 2022
67c0202
cleanup
mariusandra Dec 4, 2022
dd048e9
refactor
mariusandra Dec 4, 2022
b0c1128
key cleanup
mariusandra Dec 4, 2022
91a9327
kea localstorage with global key
mariusandra Dec 4, 2022
4fc3083
query editor new look
mariusandra Dec 4, 2022
feb6273
empty datatable stories
mariusandra Dec 4, 2022
a5bb236
query edit modal
mariusandra Dec 4, 2022
befb97e
inline editor
mariusandra Dec 5, 2022
4740db0
times of plenty
mariusandra Dec 5, 2022
f483e19
add stories
mariusandra Dec 5, 2022
bf4cbde
add stories
mariusandra Dec 5, 2022
04b66c5
add more stories
mariusandra Dec 5, 2022
f2650e4
friendly hint
mariusandra Dec 5, 2022
686b8e6
update snapshot
mariusandra Dec 5, 2022
467b54c
replace a few more events tables
mariusandra Dec 5, 2022
f650ff1
add custom columns, add web performance table
mariusandra Dec 5, 2022
9a2b18a
set query locally
mariusandra Dec 5, 2022
7f28785
persons page
mariusandra Dec 5, 2022
0ec6f68
fix person id types
mariusandra Dec 5, 2022
f547132
basic persons table
mariusandra Dec 5, 2022
3a69083
persons search
mariusandra Dec 5, 2022
ec213ff
data table on persons scene
mariusandra Dec 5, 2022
8edb48b
default columns depend on source node kind
mariusandra Dec 5, 2022
ad7f21d
add to storybook
mariusandra Dec 5, 2022
ca801a1
enable "load more" on persons
mariusandra Dec 5, 2022
d083292
copy distinct id
mariusandra Dec 5, 2022
7ea159a
inline editor for data nodes
mariusandra Dec 5, 2022
4b48315
replace a few more events tables
mariusandra Dec 5, 2022
f888dc2
add custom columns, add web performance table
mariusandra Dec 5, 2022
98cde37
set query locally
mariusandra Dec 5, 2022
2bf89f9
persons page
mariusandra Dec 5, 2022
2a2c464
fix person id types
mariusandra Dec 5, 2022
38727fe
make all queries locally editable if no setQuery and no readOnly
mariusandra Dec 6, 2022
25bcf66
these are uuids
mariusandra Dec 6, 2022
cd120ce
rename "custom" to "context"
mariusandra Dec 6, 2022
c3101f0
Merge branch 'replace-event-tables' into person-data-tables
mariusandra Dec 7, 2022
0317966
Merge branch 'master' into person-data-tables
mariusandra Dec 7, 2022
0a0f03f
refactor stories
mariusandra Dec 7, 2022
1c24926
rename InlineEditor to InlineEditorButton to avoid confusion
mariusandra Dec 7, 2022
3b39dd5
not in use
mariusandra Dec 7, 2022
fc8cf02
fix wrong filters
mariusandra Dec 7, 2022
eb09509
add more hints
mariusandra Dec 7, 2022
fcc3f0f
persons scene url
mariusandra Dec 7, 2022
44a935f
extract person deletion modal
mariusandra Dec 7, 2022
dc9d581
Merge branch 'master' into person-data-tables
mariusandra Dec 9, 2022
61a16be
backport few fixes
mariusandra Dec 9, 2022
72beda4
fix a few issues
mariusandra Dec 9, 2022
3f10a71
remove delete from export
mariusandra Dec 9, 2022
65dc0f7
export limit
mariusandra Dec 9, 2022
8389f76
show filter count
mariusandra Dec 9, 2022
3f01667
few fixes
mariusandra Dec 9, 2022
eaa0504
call live_events_columns what it is
mariusandra Dec 9, 2022
71bd093
hide columns
mariusandra Dec 9, 2022
2a2ce79
no width for some columns
mariusandra Dec 9, 2022
8f62aac
Merge branch 'master' into event-data-table-fixr
mariusandra Dec 13, 2022
93b319e
file not needed
mariusandra Dec 13, 2022
0f5bdb3
add comment
mariusandra Dec 13, 2022
f0d2da8
fix property filter clearing event filter (props in logic were pointi…
mariusandra Dec 13, 2022
360b0a4
show events buffer warning on person page
mariusandra Dec 13, 2022
524ebe5
Merge branch 'master' into event-data-table-fixr
mariusandra Dec 13, 2022
d6de56c
lockfile
mariusandra Dec 13, 2022
58778f6
Revert "show events buffer warning on person page"
mariusandra Dec 13, 2022
0e1085c
fetch events table in two parts
mariusandra Dec 13, 2022
93a92c7
Merge branch 'master' into event-data-table-fixr
mariusandra Dec 13, 2022
b43a2c5
put it back for the tests
mariusandra Dec 13, 2022
c7f05a7
Merge branch 'master' into event-data-table-fixr
Twixes Dec 13, 2022
f08f684
Merge branch 'master' into event-data-table-fixr
Twixes Dec 13, 2022
46b2493
Try to fix Cypress problem
Twixes Dec 13, 2022
adcc218
Update Cypress to v11
Twixes Dec 13, 2022
bcc7d19
move now around
mariusandra Dec 13, 2022
5e82549
Merge branch 'event-data-table-fixr' of github.com:PostHog/posthog in…
mariusandra Dec 13, 2022
c696f60
it's a string!
mariusandra Dec 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,15 @@ jobs:
node-version: 18
cache: pnpm

- name: Restore Cypress binary from cache # actions/setup-node can only cache pnpm's global store
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: ${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml') }}

- name: Install package.json dependencies with pnpm
run: pnpm install --frozen-lockfile # This is primarily for Cypress

- name: Stop/Start stack with Docker Compose
run: |
docker compose -f docker-compose.dev.yml down
Expand Down
27 changes: 13 additions & 14 deletions frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { kea } from 'kea'
import { actions, kea, key, listeners, path, props, reducers, selectors } from 'kea'

import type { propertyFilterLogicType } from './propertyFilterLogicType'
import { AnyPropertyFilter } from '~/types'
import { isValidPropertyFilter, parseProperties } from 'lib/components/PropertyFilters/utils'
import { PropertyFilterLogicProps } from 'lib/components/PropertyFilters/types'

export const propertyFilterLogic = kea<propertyFilterLogicType>({
path: (key) => ['lib', 'components', 'PropertyFilters', 'propertyFilterLogic', key],
props: {} as PropertyFilterLogicProps,
key: (props) => props.pageKey,
export const propertyFilterLogic = kea<propertyFilterLogicType>([
path((key) => ['lib', 'components', 'PropertyFilters', 'propertyFilterLogic', key]),
props({} as PropertyFilterLogicProps),
key((props) => props.pageKey),

actions: () => ({
actions({
update: true,
setFilter: (index: number, property: AnyPropertyFilter) => ({ index, property }),
setFilters: (filters: AnyPropertyFilter[]) => ({ filters }),
remove: (index: number) => ({ index }),
}),

reducers: ({ props }) => ({
reducers(({ props }) => ({
filters: [
props.propertyFilters ? parseProperties(props.propertyFilters) : ([] as AnyPropertyFilter[]),
{
Expand All @@ -39,9 +39,9 @@ export const propertyFilterLogic = kea<propertyFilterLogicType>({
},
},
],
}),
})),

listeners: ({ actions, props, values }) => ({
listeners(({ actions, props, values }) => ({
// Only send update if value is set to something
setFilter: ({ property }) => {
if (props.sendAllKeyUpdates) {
Expand All @@ -53,12 +53,11 @@ export const propertyFilterLogic = kea<propertyFilterLogicType>({
remove: () => actions.update(),
update: () => {
const cleanedFilters = [...values.filters].filter(isValidPropertyFilter)

props.onChange(cleanedFilters)
},
}),
})),

selectors: {
selectors({
filledFilters: [(s) => [s.filters], (filters) => filters.filter(isValidPropertyFilter)],
filtersWithNew: [
(s) => [s.filters],
Expand All @@ -70,5 +69,5 @@ export const propertyFilterLogic = kea<propertyFilterLogicType>({
}
},
],
},
})
}),
])
5 changes: 3 additions & 2 deletions frontend/src/queries/nodes/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { EventRowActions } from '~/queries/nodes/DataTable/EventRowActions'
import { DataTableExport } from '~/queries/nodes/DataTable/DataTableExport'
import { Reload } from '~/queries/nodes/DataNode/Reload'
import { LoadNext } from '~/queries/nodes/DataNode/LoadNext'
import { renderTitle } from '~/queries/nodes/DataTable/renderTitle'
import { renderColumnMeta } from '~/queries/nodes/DataTable/renderColumnMeta'
import { renderColumn } from '~/queries/nodes/DataTable/renderColumn'
import { AutoLoad } from '~/queries/nodes/DataNode/AutoLoad'
import { dataTableLogic, DataTableLogicProps } from '~/queries/nodes/DataTable/dataTableLogic'
Expand Down Expand Up @@ -72,7 +72,7 @@ export function DataTable({ query, setQuery, context }: DataTableProps): JSX.Ele
const lemonColumns: LemonTableColumn<EventType, keyof EventType | undefined>[] = [
...columns.map((key) => ({
dataIndex: key as any,
title: renderTitle(key, context),
...renderColumnMeta(key, context),
render: function RenderDataTableColumn(_: any, record: EventType) {
return renderColumn(key, record, query, setQuery, context)
},
Expand All @@ -85,6 +85,7 @@ export function DataTable({ query, setQuery, context }: DataTableProps): JSX.Ele
render: function RenderMore(_: any, record: EventType) {
return <EventRowActions event={record} />
},
width: 0,
},
]
: []),
Expand Down
1 change: 1 addition & 0 deletions frontend/src/queries/nodes/DataTable/dataTableLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const dataTableLogic = kea<dataTableLogicType>([
return {
kind,
columns: columns,
hiddenColumns: [],
source,
...sortedKeys({
...rest,
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/queries/nodes/DataTable/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ export function defaultDataTableColumns(query: DataNode): DataTableColumn[] {
}

export function defaultsForDataTable(query: DataTableNode, defaultColumns?: DataTableColumn[]): DataTableColumn[] {
return (
let columns =
query.columns ?? (isEventsNode(query.source) ? defaultColumns : null) ?? defaultDataTableColumns(query.source)
)

if (query.hiddenColumns) {
columns = columns.filter((column) => !query.hiddenColumns?.includes(column))
}

return columns
}
33 changes: 33 additions & 0 deletions frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { PropertyFilterType } from '~/types'
import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'
import { QueryContext } from '~/queries/schema'

export interface ColumnMeta {
title?: JSX.Element | string
width?: number
}

export function renderColumnMeta(key: string, context?: QueryContext): ColumnMeta {
if (key === 'timestamp') {
return { title: 'Time' }
} else if (key === 'created_at') {
return { title: 'First seen' }
} else if (key === 'event') {
return { title: 'Event' }
} else if (key === 'person') {
return { title: 'Person' }
} else if (key === 'url') {
return { title: 'URL / Screen' }
} else if (key.startsWith('properties.')) {
return { title: <PropertyKeyInfo value={key.substring(11)} type={PropertyFilterType.Event} disableIcon /> }
} else if (key.startsWith('context.columns.')) {
return { title: context?.columns?.[key.substring(16)]?.title ?? key.substring(16).replace('_', ' ') }
} else if (key === 'person.$delete') {
return { title: '', width: 0 }
} else if (key.startsWith('person.properties.')) {
// NOTE: PropertyFilterType.Event is not a mistake. PropertyKeyInfo only knows events vs elements ¯\_(ツ)_/¯
return { title: <PropertyKeyInfo value={key.substring(18)} type={PropertyFilterType.Event} disableIcon /> }
} else {
return { title: key }
}
}
28 changes: 0 additions & 28 deletions frontend/src/queries/nodes/DataTable/renderTitle.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface EventPropertyFiltersProps {

let uniqueNode = 0
export function EventPropertyFilters({ query, setQuery }: EventPropertyFiltersProps): JSX.Element {
const [id] = useState(uniqueNode++)
const [id] = useState(() => uniqueNode++)
return !query.properties || Array.isArray(query.properties) ? (
<PropertyFilters
propertyFilters={query.properties || []}
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/queries/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,25 @@ import {
isTrendsFilter,
} from 'scenes/insights/sharedUtils'
import { toParams } from 'lib/utils'
import { now } from 'lib/dayjs'

const EVENTS_DAYS_FIRST_FETCH = 5

// Return data for a given query
export async function query<N extends DataNode = DataNode>(
query: N,
methodOptions?: ApiMethodOptions
): Promise<N['response']> {
if (isEventsNode(query)) {
return await api.get(getEventsEndpoint(query))
if (!query.before && !query.after) {
const earlyResults = await api.get(
getEventsEndpoint({ ...query, after: now().subtract(EVENTS_DAYS_FIRST_FETCH, 'day').toISOString() })
)
if (earlyResults.results.length > 0) {
return earlyResults
}
}
return await api.get(getEventsEndpoint({ after: now().subtract(1, 'year').toISOString(), ...query }))
} else if (isPersonsNode(query)) {
return await api.get(getPersonsEndpoint(query))
} else if (isLegacyQuery(query)) {
Expand All @@ -44,7 +55,7 @@ export function getEventsEndpoint(query: EventsNode): string {
...(query.before ? { before: query.before } : {}),
...(query.after ? { after: query.after } : {}),
},
query.limit ?? 3500
query.limit ?? 100
)
}

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/queries/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ export interface DataTableNode extends Node {
source: EventsNode | PersonsNode
/** Columns shown in the table */
columns?: DataTableColumn[]
/** Columns that aren't shown in the table, even if in columns */
hiddenColumns?: DataTableColumn[]
/** Include an event filter above the table (EventsNode only) */
showEventFilter?: boolean
/** Include a free text search field (PersonsNode only) */
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/cohorts/CohortEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export function CohortEdit({ id }: CohortLogicProps): JSX.Element {
</>
)}

{/* The typeof here is needed to pass the cohort id to the query below. Using `isNewCohort` won't work */}
{typeof cohort.id === 'number' && (
<>
<Divider />
Expand Down
1 change: 1 addition & 0 deletions frontend/src/scenes/persons/Person.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export function Person(): JSX.Element | null {
<Query
query={{
kind: NodeKind.DataTableNode,
hiddenColumns: ['person'],
source: {
kind: NodeKind.EventsNode,
personId: person.id,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"expr-eval": "^2.0.2",
"fast-deep-equal": "^3.1.3",
"fuse.js": "^6.4.1",
"kea": "^3.0.4",
"kea": "^3.1.0",
"kea-forms": "^3.0.3",
"kea-loaders": "^3.0.0",
"kea-localstorage": "^3.1.0",
Expand Down Expand Up @@ -192,8 +192,8 @@
"cors": "^2.8.5",
"css-loader": "^3.4.2",
"cssnano": "^4.1.10",
"cypress": "^10.11.0",
"cypress-axe": "^1.0.0",
"cypress": "^11.0.0",
"cypress-axe": "^1.1.0",
"cypress-terminal-report": "^4.1.2",
"esbuild": "^0.14.54",
"esbuild-jest": "^0.5.0",
Expand Down
Loading