posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat(hog): fix elements matching

Open mariusandra opened this issue 6 months ago • 3 comments

Problem

It started from this: image

This exposes two problems:

  • we don't have the new materialized elements_chain_* columns in Hog globals
  • we can't run functions that use lambdas, like arrayExists

Changes

  • Add the 4 new fields elements_chain_href, elements_chain_texts, elements_chain_ids, elements_chain_elements into Hog filter matching. They're added lazily (calculated only when accessed). This wouldn't work with async functions (all lazy vars would get evaluated when serializing), but seems to work just fine for sync filter matching.

Future work

  • I tried using has instead of arrayExists for exact element text matching. This would make the simple "element text equals X" filter work, while not fixing contains/regex matches. Unfortunately this would behave differently whether the filter was added via an action or directly, and fixing it would introduce too many hacks.

  • We might want to add elements_chain or all its variants into the Hog functions globals as well. elements_chain is a field in the events table, so I don't see a reason to pass it via properties. Best to stick to the documented schema?

  • I'll make arrayExists work with lambdas next. It might be easier than expected.

How did you test this code?

WIP

mariusandra avatar Aug 13 '24 09:08 mariusandra