-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Adds same glob patterns as exclusions for pageview goals #750
Conversation
Code looks good. This should be thoroughly tested for sure. |
Huh, honestly a bit surprised there. I guess my Elixir has gotten pretty decent after all - this felt a bit hacky to me at first to be honest, but doing it any other way than a separate CH query-per-goal was causing significant issues with counting uniques correctly, so I settled for this setup. (This code is technically v3, heh)
100%. I'll write significant tests for this, partially because my elixir string replacement/regex is weak anyways, and that I had multiple instances of the clickhouse As a note here actually, do you know of an easy (or not easy, if needed, I suppose) way for me to have |
Ah, I didn't actually notice the N+1 query here. Would be good to combine it all back into a single query in case there are a lot of goals. There seem to be loads of functions designed for searching multiple different regex patterns in CH: https://clickhouse.tech/docs/en/sql-reference/functions/string-search-functions/#multimatchanyhaystack-pattern1-pattern2-patternn
You can try setting a Then you can run arbitrary Elixir or connect to your CH with their client. |
Hmm some of those CH functions actually seem promising now that I think about it. The hard part here (and the problem with v1 and v2 of my code) were that I could really only group over the basic pathname effectively, which made unique user_id's be double counted per every basic pathname. I wonder if there's a way to group by something other than a basic column; I'll look into it. |
Yes we'd need to find a way to group over the matching regex basically. I wonder if you could use |
Yeah that sounds good, I was thinking about pretty much the same, but with the actual regexes. Doing it just over the index might be better and cleaner though. Will poke around and see what I can get 👍 |
value && value != "" | ||
defp validate_page_path(changeset) do | ||
value = get_field(changeset, :page_path) | ||
value && String.match?(value, ~r/^\/.*/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to do better validation of pathnames here, and add good validation for preventing duplicate goals; but I didn't want to make a disgusting regex if you knew of an easy Elixir helper for validating URLs (this may not work I guess because of the globs), and I couldn't get the latter to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about it to extract this regex and put in the module attribute? And use a better name to describe the intentions of what this regex do...
Alright, I think this should be ready for review now. I do again still need to do more testing across the board, but I figure if you see any issues off the bat I can handle them beforehand. I did just add the one main test, adding more tests, or more specific tests would need a lot more detailed events added to test that out effectively. If you think those should be added, I can do that, I just didn't want to immediately add a bunch of events there for this one test alone unless necessary. I'll do docs later. |
value && value != "" | ||
defp validate_page_path(changeset) do | ||
value = get_field(changeset, :page_path) | ||
value && String.match?(value, ~r/^\/.*/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's OK as is.
test/plausible_web/controllers/api/stats_controller/conversions_test.exs
Show resolved
Hide resolved
Thanks @Vigasaurus ! |
The goals seem to work OK but it also needs to be implemented as a filter. Currently, when you click on the goal you land on a broken dashboard: |
Yeah, when you click on the goal, all metrics show 0 and "no data yet", You can see it on our live demo for "Visit /blog/**". @Vigasaurus: This feature could be very cool to add to our "Top Pages" report to make it easier to use. When you click on "details" in Top Pages you could get a search box at the top which allows you to type whatever you want to filter the pages by that. I could type "blog" which should only list pages that include "blog" in their paths. And then we could add one header to that table that summarizes the numbers of the pages you searched for:
Will solve the thing we've been asked for recently in #774 |
Oh yeah huh I never even thought to test for it being used as a filter. Fixing that should be not that terrible though, maybe. I'll look into it. |
Changes
Addresses #241
Tests
Changelog
Documentation
Although I must say, I sometimes feel bad with how many PRs I've forced you to review recently heh, this should be the last one for a bit though