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: Action filtering for webhook apps #22056

Merged
merged 154 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
bfd5e3d
Refactoring action manager
benjackwhite Apr 22, 2024
beb5f35
Moved code around to potentially support filtering plugins by action …
benjackwhite Apr 22, 2024
ed7b016
Changes
benjackwhite Apr 26, 2024
51655b4
Changes
benjackwhite Apr 26, 2024
5ed3e5b
comment
benjackwhite Apr 26, 2024
a927d17
Merge branch 'master' into feat/actions-webhooks-v2
benjackwhite Apr 26, 2024
5b2ed4e
Added migration
benjackwhite Apr 26, 2024
41c7623
Started reworking it
benjackwhite Apr 26, 2024
39a42f9
More changes
benjackwhite Apr 29, 2024
c03d606
Fix up tests
benjackwhite Apr 29, 2024
301938e
Fixed up action matching
benjackwhite Apr 29, 2024
431ccb6
Fixes
benjackwhite Apr 29, 2024
7e7bb3c
Added match action to plugin config api
benjackwhite Apr 29, 2024
39658d8
Started adding action select
benjackwhite Apr 29, 2024
12f4a31
Added api and UI for filtering by action
benjackwhite Apr 29, 2024
b1a7d56
Fixes
benjackwhite Apr 29, 2024
2e2f88c
tidy
benjackwhite Apr 29, 2024
f8796dd
Fixed flagging
benjackwhite Apr 29, 2024
1eb825c
Merge branch 'master' into feat/actions-webhooks-v2
benjackwhite Apr 29, 2024
58dc55a
Fix tests
benjackwhite Apr 29, 2024
638f58b
Fixes
benjackwhite Apr 29, 2024
21382bb
Fix
benjackwhite Apr 29, 2024
128caa2
Fixes
benjackwhite Apr 29, 2024
53368ab
Fixes
benjackwhite Apr 29, 2024
e444701
Added comment
benjackwhite Apr 29, 2024
e13baa0
Fixes
benjackwhite Apr 29, 2024
fb63170
Fix test?
benjackwhite Apr 29, 2024
7c946e3
Fixed migration
benjackwhite Apr 30, 2024
2474361
Fixes?
benjackwhite Apr 30, 2024
32de6b5
Fix tests
benjackwhite Apr 30, 2024
5bd0c25
Fixes
benjackwhite Apr 30, 2024
f6b3d47
Merge branch 'master' into feat/actions-webhooks-v2
benjackwhite Apr 30, 2024
3e2f4bb
Added stop command
benjackwhite Apr 30, 2024
43fc9cf
Refactoring
benjackwhite Apr 30, 2024
1793f12
Fix up
benjackwhite Apr 30, 2024
1565a0f
Merge branch 'master' into feat/actions-webhooks-v2
benjackwhite Apr 30, 2024
0da1939
Refactor processing to make allow lazy loading of elementsList
benjackwhite Apr 30, 2024
631007b
Fix
benjackwhite Apr 30, 2024
6cd462c
fix merge mistakes
benjackwhite Apr 30, 2024
163288f
Fix
benjackwhite Apr 30, 2024
09b1e19
chore: Refactor running of event processing
benjackwhite Apr 30, 2024
355f3e1
Fix
benjackwhite Apr 30, 2024
da7ddd4
Fix some tests
benjackwhite Apr 30, 2024
6e7a4d9
Fix?
benjackwhite Apr 30, 2024
d746c8e
Move elements parsing lower
benjackwhite May 2, 2024
0ae38ab
Moved tests
benjackwhite May 2, 2024
63e6626
Fix
benjackwhite May 2, 2024
28c27e7
Merge branch 'feat/action-refactor-1' into feat/action-refactor-2
benjackwhite May 2, 2024
27e00e3
Fixes
benjackwhite May 2, 2024
3b7cf4e
Fixes
benjackwhite May 2, 2024
d1ed49c
Fix
benjackwhite May 2, 2024
40a4e2c
Merge branch 'feat/action-refactor-1' into feat/action-refactor-2
benjackwhite May 2, 2024
ea3e624
Merge branch 'feat/action-refactor-2' into feat/actions-webhooks-v2
benjackwhite May 2, 2024
c7a067b
Fix
benjackwhite May 2, 2024
83f8adb
Removed plugins deferred
benjackwhite May 2, 2024
e28da5a
Merge branch 'feat/action-refactor-2' into feat/actions-webhooks-v2
benjackwhite May 2, 2024
eb0bc29
Fix up webhook parsing
benjackwhite May 2, 2024
d7c749c
Fixes?
benjackwhite May 2, 2024
2169ebb
Fixes
benjackwhite May 2, 2024
0dfc6c4
Fix tests
benjackwhite May 2, 2024
4f248f6
Merge branch 'feat/action-refactor-1' into feat/action-refactor-2
benjackwhite May 2, 2024
4682aeb
come on now...
benjackwhite May 2, 2024
63c7bc0
Merge branch 'feat/action-refactor-1' into feat/action-refactor-2
benjackwhite May 3, 2024
160adb3
Merge branch 'feat/action-refactor-2' into feat/actions-webhooks-v2
benjackwhite May 3, 2024
ef9e3f7
Fix
benjackwhite May 3, 2024
65ed743
Added tests
benjackwhite May 3, 2024
288ffe5
Merge branch 'master' into feat/action-refactor-1
benjackwhite May 3, 2024
1ae27ce
Merge branch 'feat/action-refactor-1' into feat/action-refactor-2
benjackwhite May 3, 2024
aaef5f0
Merge branch 'feat/action-refactor-2' into feat/actions-webhooks-part1
benjackwhite May 3, 2024
30c960b
Update UI snapshots for `chromium` (1)
github-actions[bot] May 3, 2024
7012efb
Update UI snapshots for `chromium` (1)
github-actions[bot] May 3, 2024
2697a68
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 6, 2024
1260452
Fix up
benjackwhite May 6, 2024
ebe3ef2
Added list to the actions
benjackwhite May 6, 2024
e51602a
Fix
benjackwhite May 6, 2024
788800c
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 6, 2024
63ef190
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 6, 2024
538e2eb
Fix
benjackwhite May 6, 2024
af494f6
Fix up
benjackwhite May 6, 2024
3f69c5e
Fix
benjackwhite May 6, 2024
490c388
Update UI snapshots for `chromium` (1)
github-actions[bot] May 6, 2024
9744e5c
Remove redundant list method
benjackwhite May 6, 2024
fb752dd
Merge branch 'feat/actions-webhooks-part1' of github.com:PostHog/post…
benjackwhite May 6, 2024
a456487
Update query snapshots
github-actions[bot] May 6, 2024
54fffc3
Update UI snapshots for `chromium` (1)
github-actions[bot] May 6, 2024
f6c3626
Fix
benjackwhite May 6, 2024
40d6415
Fix
benjackwhite May 6, 2024
241bd04
Fix
benjackwhite May 6, 2024
4ab0280
Fix
benjackwhite May 6, 2024
a5c4aef
Fixes
benjackwhite May 7, 2024
5fd3417
Fix up
benjackwhite May 7, 2024
d7f5959
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 7, 2024
63b6327
Update query snapshots
github-actions[bot] May 7, 2024
5677f53
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 7, 2024
4189223
Update UI snapshots for `chromium` (1)
github-actions[bot] May 7, 2024
07f40f9
Update query snapshots
github-actions[bot] May 7, 2024
7b4780f
Update UI snapshots for `chromium` (1)
github-actions[bot] May 7, 2024
a36da65
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 7, 2024
a26dfa9
Update query snapshots
github-actions[bot] May 7, 2024
58d770f
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 7, 2024
a0c1f49
Update query snapshots
github-actions[bot] May 7, 2024
a74b6a9
Fix tests
benjackwhite May 7, 2024
c536863
Fix
benjackwhite May 7, 2024
f130bdc
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 7, 2024
aba3c40
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 8, 2024
fc1591a
Update UI snapshots for `chromium` (1)
github-actions[bot] May 8, 2024
94f08dd
Update query snapshots
github-actions[bot] May 8, 2024
f419ada
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 8, 2024
b4652e0
Merge branch 'feat/actions-webhooks-part1' of github.com:PostHog/post…
benjackwhite May 8, 2024
421d58d
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 8, 2024
eb47125
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 8, 2024
94af88f
Added migration
benjackwhite May 8, 2024
844d217
Merge branch 'feat/action-webhooks-migration' into feat/actions-webho…
benjackwhite May 8, 2024
4ecaa96
Merge branch 'feat/actions-webhooks-part1' of github.com:PostHog/post…
benjackwhite May 8, 2024
8eb1676
Fix migration
benjackwhite May 9, 2024
cae5513
Fix comment
benjackwhite May 9, 2024
2dc0fc7
Fix
benjackwhite May 9, 2024
26502d5
Fix
benjackwhite May 9, 2024
1c46b13
Merge branch 'master' into feat/action-webhooks-migration
benjackwhite May 10, 2024
40e8c41
Merge branch 'feat/action-webhooks-migration' into feat/actions-webho…
benjackwhite May 10, 2024
69cc4a7
Update query snapshots
github-actions[bot] May 10, 2024
eaefa24
Fixes
benjackwhite May 10, 2024
abbb552
Fixes
benjackwhite May 10, 2024
5b92a3f
Fixes
benjackwhite May 10, 2024
05a0b68
feat: Action webhooks part 2 (#22066)
benjackwhite May 10, 2024
2ae6ddc
Merge branch 'master' into feat/action-webhooks-migration
benjackwhite May 21, 2024
6f95082
merge
benjackwhite May 21, 2024
a9db770
Merge branch 'feat/action-webhooks-migration' into feat/actions-webho…
benjackwhite May 21, 2024
5db05e3
Update UI snapshots for `chromium` (1)
github-actions[bot] May 21, 2024
21c9db9
Update query snapshots
github-actions[bot] May 21, 2024
9d03ba0
Update UI snapshots for `chromium` (1)
github-actions[bot] May 21, 2024
b10aa10
Merge branch 'master' into feat/action-webhooks-migration
benjackwhite May 22, 2024
4a9d2d5
Merge branch 'feat/action-webhooks-migration' into feat/actions-webho…
benjackwhite May 22, 2024
27771aa
Fix
benjackwhite May 22, 2024
9e1fe30
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 22, 2024
3df8bd1
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 22, 2024
6105fd8
Update UI snapshots for `chromium` (1)
github-actions[bot] May 22, 2024
025da1d
Fix up actions
benjackwhite May 22, 2024
dfce472
Merge branch 'feat/actions-webhooks-part1' of github.com:PostHog/post…
benjackwhite May 22, 2024
c48061f
Update UI snapshots for `chromium` (1)
github-actions[bot] May 22, 2024
2f3cc68
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 23, 2024
31fce23
Update UI snapshots for `chromium` (1)
github-actions[bot] May 23, 2024
2cc4471
Update query snapshots
github-actions[bot] May 23, 2024
1e37870
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 23, 2024
7b85833
Update UI snapshots for `chromium` (1)
github-actions[bot] May 23, 2024
e7d6136
Update UI snapshots for `chromium` (1)
github-actions[bot] May 23, 2024
0f7d977
Update UI snapshots for `chromium` (1)
github-actions[bot] May 23, 2024
f187c1f
Update UI snapshots for `chromium` (1)
github-actions[bot] May 23, 2024
5f9d7b3
Update UI snapshots for `chromium` (2)
github-actions[bot] May 23, 2024
63400a7
Update UI snapshots for `chromium` (2)
github-actions[bot] May 23, 2024
ae4ae7c
Merge branch 'master' into feat/actions-webhooks-part1
benjackwhite May 28, 2024
ac003ae
Fix test
benjackwhite May 28, 2024
fba3769
feat: Design updates for pipeline editing (#22389)
benjackwhite May 28, 2024
dc29d04
Update UI snapshots for `chromium` (1)
github-actions[bot] May 28, 2024
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
4 changes: 2 additions & 2 deletions ee/api/test/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def test_actions_does_not_nplus1(self):
action.tagged_items.create(tag=tag)

# django_session + user + team + look up if rate limit is enabled (cached after first lookup)
# + organizationmembership + organization + action + taggeditem
with self.assertNumQueries(8):
# + organizationmembership + organization + action + taggeditem + plugin_configs
with self.assertNumQueries(10):
response = self.client.get(f"/api/projects/{self.team.id}/actions")
self.assertEqual(response.json()["results"][0]["tags"][0], "tag")
self.assertEqual(response.status_code, status.HTTP_200_OK)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions frontend/src/lib/components/ActionSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { LemonButtonProps } from '@posthog/lemon-ui'
import { useValues } from 'kea'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { TaxonomicPopover } from 'lib/components/TaxonomicPopover/TaxonomicPopover'
import { actionLogic } from 'scenes/actions/actionLogic'

interface LemonSelectActionProps {
value?: number | null
onChange?: (value: number | null) => void
disabled?: boolean
placeholder?: string
allowClear?: boolean
size?: LemonButtonProps['size']
fullWidth?: boolean
}

export function LemonSelectAction({
value,
onChange = () => {},
disabled,
placeholder = 'Select an action',
allowClear,
size,
}: LemonSelectActionProps): JSX.Element {
const { action } = useValues(actionLogic({ id: value ?? undefined }))

return (
<TaxonomicPopover
groupType={TaxonomicFilterGroupType.Actions}
onChange={onChange}
disabled={disabled}
value={value}
type="secondary"
placeholder={placeholder}
data-attr="event-name-box"
renderValue={(v) =>
v !== null ? (
<>
<span>{value} - </span>
<span>{action?.name ?? 'Loading...'}</span>
</>
) : null
}
allowClear={allowClear}
size={size}
fullWidth
/>
)
}
1 change: 1 addition & 0 deletions frontend/src/lib/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export const FEATURE_FLAGS = {
HEATMAPS_UI: 'heatmaps-ui', // owner: @benjackwhite
THEME: 'theme', // owner: @aprilfools
SESSION_TABLE_PROPERTY_FILTERS: 'session-table-property-filters', // owner: @robbie-c
PLUGINS_ACTION_MATCHING: 'plugins-action-matching', // owner: @benjackwhite
SESSION_REPLAY_HOG_QL_FILTERING: 'session-replay-hogql-filtering', // owner: #team-replay
INSIGHT_LOADING_BAR: 'insight-loading-bar', // owner: @aspicer
SESSION_REPLAY_ARTIFICIAL_LAG: 'artificial-lag-query-performance', // owner: #team-replay
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/scenes/actions/Action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { NodeKind } from '~/queries/schema'
import { ActionType } from '~/types'

import { ActionEdit } from './ActionEdit'
import { ActionPlugins } from './ActionPlugins'

export const scene: SceneExport = {
logic: actionLogic,
Expand Down Expand Up @@ -46,6 +47,8 @@ export function Action({ id }: { id?: ActionType['id'] } = {}): JSX.Element {
<ActionEdit id={id} action={action} />
{id && (
<>
<ActionPlugins />

{isComplete ? (
<div className="mt-8">
<h2 className="subtitle">Matching events</h2>
Expand Down
49 changes: 49 additions & 0 deletions frontend/src/scenes/actions/ActionPlugins.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { LemonButton } from '@posthog/lemon-ui'
import { useValues } from 'kea'
import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'
import { actionLogic } from 'scenes/actions/actionLogic'
import { PluginImage } from 'scenes/plugins/plugin/PluginImage'
import { urls } from 'scenes/urls'

import { PipelineNodeTab, PipelineStage } from '~/types'

export function ActionPlugins(): JSX.Element | null {
const { action } = useValues(actionLogic)

if (!action?.plugin_configs?.length) {
return null
}

return (
<>
<h2 className="subtitle">Connected apps</h2>

{action.plugin_configs.map((pluginConfig) => (
<div key={pluginConfig.id} className="flex items-center gap-2 border rounded bg-bg-light p-2">
<PluginImage plugin={pluginConfig.plugin_info} size="small" />
<LemonTableLink
title={pluginConfig.plugin_info.name}
to={urls.pipelineNode(
PipelineStage.Destination,
pluginConfig.id,
PipelineNodeTab.Configuration
)}
/>
<span className="flex-1" />

<LemonButton
type="secondary"
size="small"
to={urls.pipelineNode(
PipelineStage.Destination,
pluginConfig.id,
PipelineNodeTab.Configuration
)}
>
Configure
</LemonButton>
</div>
))}
</>
)
}
54 changes: 28 additions & 26 deletions frontend/src/scenes/actions/actionEditLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ import { ActionStepType, ActionType } from '~/types'
import type { actionEditLogicType } from './actionEditLogicType'
import { actionLogic } from './actionLogic'

export type NewActionType = Partial<ActionType> &
Pick<ActionType, 'name' | 'post_to_slack' | 'slack_message_format' | 'steps'>
export type ActionEditType = ActionType | NewActionType

export interface SetActionProps {
merge?: boolean
}

export interface ActionEditLogicProps {
id?: number
action?: ActionEditType
action?: ActionType | null
}

export const DEFAULT_ACTION_STEP: ActionStepType = {
Expand All @@ -36,7 +32,7 @@ export const DEFAULT_ACTION_STEP: ActionStepType = {
}

export const actionEditLogic = kea<actionEditLogicType>([
path(['scenes', 'actions', 'actionEditLogic']),
path((key) => ['scenes', 'actions', 'actionEditLogic', key]),
props({} as ActionEditLogicProps),
key((props) => props.id || 'new'),
connect({
Expand All @@ -51,7 +47,7 @@ export const actionEditLogic = kea<actionEditLogicType>([
values: [sceneLogic, ['activeScene']],
}),
actions({
setAction: (action: Partial<ActionEditType>, options: SetActionProps = { merge: true }) => ({
setAction: (action: Partial<ActionType>, options: SetActionProps = { merge: true }) => ({
action,
options,
}),
Expand All @@ -70,10 +66,12 @@ export const actionEditLogic = kea<actionEditLogicType>([

forms(({ actions, props }) => ({
action: {
defaults: props.action ?? {
name: '',
steps: [{ event: '$pageview' }],
},
defaults:
props.action ??
({
name: '',
steps: [DEFAULT_ACTION_STEP],
} as ActionType),

submit: async (updatedAction, breakpoint) => {
let action: ActionType
Expand Down Expand Up @@ -122,10 +120,10 @@ export const actionEditLogic = kea<actionEditLogicType>([

loaders(({ props, values }) => ({
action: [
{ ...props.action } as ActionEditType,
{ ...props.action } as ActionType,
{
setAction: ({ action, options: { merge } }) =>
(merge ? { ...values.action, ...action } : action) as ActionEditType,
(merge ? { ...values.action, ...action } : action) as ActionType,
},
],
})),
Expand All @@ -136,19 +134,23 @@ export const actionEditLogic = kea<actionEditLogicType>([
if (!actionId) {
return
}
await deleteWithUndo({
endpoint: api.actions.determineDeleteEndpoint(),
object: values.action,
callback: (undo: boolean) => {
if (undo) {
router.actions.push(urls.action(actionId))
} else {
actions.resetAction()
router.actions.push(urls.actions())
actions.loadActions()
}
},
})
try {
await deleteWithUndo({
endpoint: api.actions.determineDeleteEndpoint(),
object: values.action,
callback: (undo: boolean) => {
if (undo) {
router.actions.push(urls.action(actionId))
} else {
actions.resetAction()
router.actions.push(urls.actions())
actions.loadActions()
}
},
})
} catch (e: any) {
lemonToast.error(`Error deleting action: ${e.detail}`)
}
},
})),

Expand Down
17 changes: 10 additions & 7 deletions frontend/src/scenes/actions/actionLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ export const actionLogic = kea<actionLogicType>([
setIsComplete: (isComplete) => ({ isComplete }),
})),
loaders(({ props }) => ({
action: {
loadAction: async () => {
if (!props.id) {
throw new Error('Cannot fetch an unsaved action from the API.')
}
return await api.actions.get(props.id)
action: [
null as ActionType | null,
{
loadAction: async () => {
if (!props.id) {
throw new Error('Cannot fetch an unsaved action from the API.')
}
return await api.actions.get(props.id)
},
},
},
],
})),
reducers(() => ({
pollTimeout: [
Expand Down
1 change: 0 additions & 1 deletion frontend/src/scenes/pipeline/Destinations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export function Destinations(): JSX.Element {

export function DestinationsTable({ inOverview = false }: { inOverview?: boolean }): JSX.Element {
const { loading, destinations } = useValues(pipelineDestinationsLogic)

const data = inOverview ? destinations.filter((destination) => destination.enabled) : destinations

return (
Expand Down
Loading
Loading