-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(hogql): test account filters for EventsQuery and HogQLQuery (#20308
- Loading branch information
1 parent
535e5e6
commit ca20bac
Showing
16 changed files
with
176 additions
and
9 deletions.
There are no files selected for viewing
Binary file modified
BIN
+2.62 KB
(100%)
frontend/__snapshots__/scenes-app-events--event-explorer--dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+2.51 KB
(100%)
frontend/__snapshots__/scenes-app-events--event-explorer--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+19 Bytes
(100%)
...insights-error-empty-states--estimated-query-execution-time-too-long--light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions
77
frontend/src/queries/nodes/DataNode/TestAccountFilters.tsx
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { useActions, useValues } from 'kea' | ||
import { IconSettings } from 'lib/lemon-ui/icons' | ||
import { LemonButton } from 'lib/lemon-ui/LemonButton' | ||
import { LemonSwitch } from 'lib/lemon-ui/LemonSwitch' | ||
import { filterTestAccountsDefaultsLogic } from 'scenes/settings/project/filterTestAccountDefaultsLogic' | ||
import { teamLogic } from 'scenes/teamLogic' | ||
import { urls } from 'scenes/urls' | ||
|
||
import { DataNode, EventsQuery, HogQLQuery } from '~/queries/schema' | ||
import { isEventsQuery, isHogQLQuery } from '~/queries/utils' | ||
|
||
interface TestAccountFiltersProps { | ||
query: DataNode | ||
setQuery?: (query: EventsQuery | HogQLQuery) => void | ||
} | ||
export function TestAccountFilters({ query, setQuery }: TestAccountFiltersProps): JSX.Element | null { | ||
const { currentTeam } = useValues(teamLogic) | ||
const hasFilters = (currentTeam?.test_account_filters || []).length > 0 | ||
const { setLocalDefault } = useActions(filterTestAccountsDefaultsLogic) | ||
|
||
if (!isEventsQuery(query) && !isHogQLQuery(query)) { | ||
return null | ||
} | ||
const checked = hasFilters | ||
? !!(isHogQLQuery(query) | ||
? query.filters?.filterTestAccounts | ||
: isEventsQuery(query) | ||
? query.filterTestAccounts | ||
: false) | ||
: false | ||
const onChange = isHogQLQuery(query) | ||
? (checked: boolean) => { | ||
const newQuery: HogQLQuery = { | ||
...query, | ||
filters: { | ||
...query.filters, | ||
filterTestAccounts: checked, | ||
}, | ||
} | ||
setQuery?.(newQuery) | ||
} | ||
: isEventsQuery(query) | ||
? (checked: boolean) => { | ||
const newQuery: EventsQuery = { | ||
...query, | ||
filterTestAccounts: checked, | ||
} | ||
setQuery?.(newQuery) | ||
} | ||
: undefined | ||
|
||
return ( | ||
<LemonSwitch | ||
checked={checked} | ||
onChange={(checked: boolean) => { | ||
onChange?.(checked) | ||
setLocalDefault(checked) | ||
}} | ||
id="test-account-filter" | ||
bordered | ||
label={ | ||
<div className="flex items-center"> | ||
<span>Filter out internal and test users</span> | ||
<LemonButton | ||
icon={<IconSettings />} | ||
to={urls.settings('project-product-analytics', 'internal-user-filtering')} | ||
size="small" | ||
noPadding | ||
className="ml-1" | ||
/> | ||
</div> | ||
} | ||
disabledReason={!hasFilters ? "You haven't set any internal and test filters" : null} | ||
/> | ||
) | ||
return null | ||
} |
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
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
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
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
Oops, something went wrong.