posthog icon indicating copy to clipboard operation
posthog copied to clipboard

feat(hog): fix elements matching

Open mariusandra opened this issue 1 year 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

Size Change: 0 B

Total Size: 1.12 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.12 MB

compressed-size-action

github-actions[bot] avatar Aug 13 '24 10:08 github-actions[bot]

📸 UI snapshots have been updated

2 snapshot changes in total. 0 added, 2 modified, 0 deleted:

  • chromium: 0 added, 2 modified, 0 deleted (wasn't pushed!)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

posthog-bot avatar Aug 13 '24 15:08 posthog-bot

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week. If you want to permanentely keep it open, use the waiting label.

posthog-bot avatar Aug 21 '24 07:08 posthog-bot

Ready for a re-review

mariusandra avatar Sep 04 '24 21:09 mariusandra