-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Always show event stats and add warnings #3908
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8109c03
Always show event stats and add warnings
timgl 58e0558
add warning count
timgl 8d9734e
fix ts
timgl 559453d
Merge branch 'master' into always-show-event-stats-and-warnings
paolodamico b526d81
post-merge fix
paolodamico 30c6153
tweaks
paolodamico 068f93d
UI, copy & TS adjustments
paolodamico f7391e5
merge warnings into single column & add filtering
paolodamico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,26 @@ | ||
import React, { useState } from 'react' | ||
import React from 'react' | ||
import { useValues } from 'kea' | ||
import { Alert, Button, Table, Tooltip } from 'antd' | ||
import { userLogic } from 'scenes/userLogic' | ||
import { InfoCircleOutlined } from '@ant-design/icons' | ||
import { PropertyUsageType } from '~/types' | ||
import { keyMapping, PropertyKeyInfo } from 'lib/components/PropertyKeyInfo' | ||
import { humanizeNumber } from 'lib/utils' | ||
import { VolumeTable, UsageDisabledWarning, EventOrPropType } from './EventsVolumeTable' | ||
import { Alert } from 'antd' | ||
|
||
const columns = [ | ||
{ | ||
title: 'Property', | ||
render: function PropName(item: PropertyUsageType) { | ||
return <PropertyKeyInfo value={item.key} /> | ||
}, | ||
sorter: (a: PropertyUsageType, b: PropertyUsageType) => { | ||
// If PostHog property, put at end of list | ||
if (keyMapping.event[a.key] && !keyMapping.event[b.key]) { | ||
return 1 | ||
} | ||
if (!keyMapping.event[a.key] && keyMapping.event[b.key]) { | ||
return -1 | ||
} | ||
return ('' + a.key).localeCompare(b.key) | ||
}, | ||
defaultSortOrder: 'ascend', | ||
}, | ||
{ | ||
title: function VolumeTitle() { | ||
return ( | ||
<Tooltip | ||
placement="right" | ||
title="Total number of events that included this property in the last 30 days. Can be delayed by up to an hour." | ||
> | ||
30 day volume (delayed by up to an hour) | ||
<InfoCircleOutlined className="info-indicator" /> | ||
</Tooltip> | ||
) | ||
}, | ||
render: (item: PropertyUsageType) => humanizeNumber(item.volume), | ||
sorter: (a: PropertyUsageType, b: PropertyUsageType) => | ||
a.volume == b.volume ? a.usage_count - b.usage_count : a.volume - b.volume, | ||
}, | ||
{ | ||
title: function QueriesTitle() { | ||
return ( | ||
<Tooltip | ||
placement="right" | ||
title="Number of queries in PostHog that included a filter on this property." | ||
> | ||
30 day queries (delayed by up to an hour) | ||
<InfoCircleOutlined className="info-indicator" /> | ||
</Tooltip> | ||
) | ||
}, | ||
render: (item: PropertyUsageType) => humanizeNumber(item.usage_count), | ||
sorter: (a: PropertyUsageType, b: PropertyUsageType) => | ||
a.usage_count == b.usage_count ? a.volume - b.volume : a.usage_count - b.usage_count, | ||
}, | ||
] | ||
|
||
export function PropertiesVolumeTable(): JSX.Element { | ||
export function PropertiesVolumeTable(): JSX.Element | null { | ||
const { user } = useValues(userLogic) | ||
const [showPostHogProps, setShowPostHogProps] = useState(true) | ||
return ( | ||
<div> | ||
<Button size="small" type="default" onClick={() => setShowPostHogProps(!showPostHogProps)}> | ||
{showPostHogProps ? 'Hide' : 'Show'} PostHog properties | ||
</Button> | ||
<br /> | ||
<br /> | ||
{user?.team.event_properties_with_usage[0]?.volume === null && ( | ||
<> | ||
<Alert | ||
type="warning" | ||
description="We haven't been able to get usage and volume data yet. Please check back later" | ||
/> | ||
<br /> | ||
</> | ||
return user?.team?.event_properties_with_usage ? ( | ||
<> | ||
{!user?.is_event_property_usage_enabled ? ( | ||
<UsageDisabledWarning tab="Properties Stats" /> | ||
) : ( | ||
user?.team?.event_properties_with_usage[0]?.volume === null && ( | ||
<> | ||
<Alert | ||
type="warning" | ||
message="We haven't been able to get usage and volume data yet. Please check back later" | ||
/> | ||
</> | ||
) | ||
)} | ||
<Table | ||
dataSource={user?.team.event_properties_with_usage | ||
.filter((item: PropertyUsageType) => (keyMapping.event[item.key] ? showPostHogProps : true)) | ||
.filter((item: PropertyUsageType) => | ||
keyMapping.event[item.key] && keyMapping.event[item.key].hide ? false : true | ||
)} | ||
rowKey="event" | ||
columns={columns} | ||
style={{ marginBottom: '4rem' }} | ||
size="small" | ||
pagination={{ pageSize: 99999, hideOnSinglePage: true }} | ||
/> | ||
</div> | ||
) | ||
<VolumeTable data={user?.team?.event_properties_with_usage as EventOrPropType[]} type="key" /> | ||
</> | ||
) : null | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a small improvement for later, I think this logic can be moved to a selector.