Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Match actions to events on the fly #235

Description

@mariusandra

We should probably match actions to events on the fly in the plugin server.

At the highest level:

  1. On the plugin server, keep in memory all actions and all action steps for all teams.
  2. After an event is ingested, see if any of the action steps apply to it. If so, create the action.

There are three different types of ActionSteps that we can match directly:

  • Autocapture: event == '$autocapture' && match elements via selector && url contains/regex && ...
  • Custom Event: event == 'custom event'
  • Pageview: event == '$pageview' && url contains/regex

Filters on all three of them add some complexity:

  • Event property equals/contains/etc something --> we have the event's properties, so easy to do all possible comparisons
  • User property contains something --> we need the Person for this. We are selecting it for all posthog-js events due to some automatic $set properties, so it's probably fine to also fetch the person (if not already fetched) to match a property for an action
  • User belongs to a cohort --> add one extra query to get all cohorts for a person? ... or inlined in the fetch above?

In addition:

  • We will need a system to keep all these ActionSteps in memory in the plugin server and reload them when changed. Similar to PluginConfigs now.

However:

  • We still need the django async action-event mapping code to clean up after changes to actions (calculating action...)
  • Should we find a way to run webhooks on late-matched or back-matched actions?

Shouldn't be that hard to pull off?


Next step after this: automatically update cohorts after ingesting events.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions