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

Adds manual, editable, auto-suggested filters, and negated&globbed path-based filters #1121

Merged
merged 4 commits into from
Jun 21, 2021

Conversation

Vigasaurus
Copy link
Contributor

@Vigasaurus Vigasaurus commented Jun 11, 2021

Changes

Remade version of #1089 as the revert + the conflicts + something weird while resolving broke it

Notes:

  • I still need to go back and verify that everything merged in correctly, but it should be okay
  • I currently have package-lock.json deleted, because npm i was throwing me a peer dependency error between tailwind 2.1.2 and aspect-ratio 0.2.1, but I think that's present in master too (or it could just be my version of npm, I dunno)

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

Documentation

  • Docs have been updated

commit 3081920
Merge: 39287ab a299fab
Author: Vignesh Joglekar <[email protected]>
Date:   Fri Jun 11 03:40:55 2021 -0500

    Merge branch 'manual-filters' into manual-filters-2

commit a299fab
Author: Vignesh Joglekar <[email protected]>
Date:   Fri Jun 11 02:20:26 2021 -0500

    Changes to split and pattern matched function for time_on_page

commit 10f10c9
Author: Vignesh Joglekar <[email protected]>
Date:   Fri Jun 11 01:53:18 2021 -0500

    Fixes a couple of minor UX issues

commit f2e5ce8
Author: Vignesh Joglekar <[email protected]>
Date:   Fri Jun 11 01:49:10 2021 -0500

    Fixes time on page for globbed and negated page paths

commit bb18af6
Author: Vignesh Joglekar <[email protected]>
Date:   Thu Jun 10 05:24:05 2021 -0500

    Close to finalized version of updated version

    Just needs some additional testing + potentially code cleanup

commit d0b7bfe
Author: Vignesh Joglekar <[email protected]>
Date:   Fri May 28 04:21:21 2021 -0500

    Real Dialyzer Fix

commit 296a76a
Author: Vignesh Joglekar <[email protected]>
Date:   Fri May 28 03:44:29 2021 -0500

    Dialyzer fix

commit 91f3b44
Author: Vignesh Joglekar <[email protected]>
Date:   Thu May 27 17:11:24 2021 -0500

    Changelog

commit e041f75
Author: Vignesh Joglekar <[email protected]>
Date:   Thu May 27 17:09:52 2021 -0500

    Formatting

commit f689642
Merge: e00929b 4ff25f6
Author: Vignesh Joglekar <[email protected]>
Date:   Thu May 27 17:08:47 2021 -0500

    Merge branch 'master' into manual-filters

commit e00929b
Merge: 83887c4 806975e
Author: Vignesh Joglekar <[email protected]>
Date:   Thu May 27 17:01:48 2021 -0500

    Merge branch 'manual-filters' of github.com:Vigasaurus/plausible-analytics into manual-filters

commit 83887c4
Author: Vignesh Joglekar <[email protected]>
Date:   Thu May 27 16:59:32 2021 -0500

    Adds tests for suggestions, formats goals suggestion query

commit 1cb7732
Author: Vignesh Joglekar <[email protected]>
Date:   Thu May 27 16:36:31 2021 -0500

    Adds goals as auto-complete capable filter

commit 4ca39cc
Author: Vignesh Joglekar <[email protected]>
Date:   Thu May 27 16:08:22 2021 -0500

    95% completed auto-complete setup

    Still needs:
    - tests
    - goals added as filter

commit 22d38c4
Author: Vignesh Joglekar <[email protected]>
Date:   Thu May 27 03:47:19 2021 -0500

    80% of auto-complete filters progress

    Still needs
    - countries and screen into new format
    - re-style dropdown and background
    - drop debounce time
    - tests

commit 806975e
Merge: 81c5e05 1a93542
Author: Vignesh Joglekar <[email protected]>
Date:   Tue May 25 15:28:21 2021 -0500

    Merge branch 'master' into manual-filters

commit 81c5e05
Author: Vignesh Joglekar <[email protected]>
Date:   Tue May 25 15:21:03 2021 -0500

    Makes colorings on top bar elements consistent

commit fa7f6c2
Author: Vignesh Joglekar <[email protected]>
Date:   Tue May 25 14:58:25 2021 -0500

    Makes requested changes, adds different version of filter button

commit 7dc65b9
Author: Vignesh Joglekar <[email protected]>
Date:   Sat May 22 04:29:01 2021 -0500

    Changelog

commit c684f1c
Author: Vignesh Joglekar <[email protected]>
Date:   Sat May 22 04:26:14 2021 -0500

    Various UI Improvements

    - Makes edit buttons full-length & properly sized
    - Adds remove filter button in edit menu

commit a632e7a
Author: Vignesh Joglekar <[email protected]>
Date:   Sat May 22 03:11:50 2021 -0500

    Adds tests for exclusions and wildcards

commit eb91a79
Author: Vignesh Joglekar <[email protected]>
Date:   Sat May 22 03:02:23 2021 -0500

    Fixes editing UX on list view

commit 6209d72
Author: Vignesh Joglekar <[email protected]>
Date:   Fri May 21 04:01:17 2021 -0500

    Bugfix in realtime view, formatting

commit 007d44d
Author: Vignesh Joglekar <[email protected]>
Date:   Fri May 21 03:23:16 2021 -0500

    Second pass - mostly everything user-facing is done

    Still needs:
    - Tests
    - Potentially negating other filters
    - Potentially some code cleanup

commit cb7b5b9
Author: Vignesh Joglekar <[email protected]>
Date:   Fri May 21 01:49:52 2021 -0500

    First pass on manual filter & path regex/negated filters

    Still needs:
    - Form structure on filter modal
    - Edit filter button
    - Filter dropdown UI improvement
    - Filter modal mount data collection
    - Tests
    - Potentially negating other filters
@Vigasaurus Vigasaurus changed the title Adds auto-suggestions + validation for manual filters Adds manual, editable, auto-suggested filters, and negated&globbed path-based filters Jun 11, 2021
@Vigasaurus Vigasaurus marked this pull request as ready for review June 11, 2021 09:36
…owing up

Reverting to v16 was the simplest fix without diving into the issue upstream with Flatpickr
Copy link
Contributor

@ukutaht ukutaht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall, it's getting very close. I left a couple small style comments in the code. Here are my comment about the overall behaviour:

Screenshot from 2021-06-11 16-12-23@2x

I like how the select box works now. However, I am very much annoyed by the slight differences in border radius, border color, font size, padding, chevron color etc between these two inputs. They should be consistent.

The loading indicator is nice 👌. A small thing I noticed is when you select a value from the dropdown, the loading indicator will flash for a second. I can also see a call to the suggestions endpoint. This seems unnecessary after the user has already made a choice.

Personally I don't like the focus style on the dropdown (in light mode, at least). I think it's bg-indigo-300 with dark text. I've created a JS dropdown for the invitations UI and I used bg-indigo-600 text-white as the hover/focus style which I think fits much better. Thoughts?

Screenshot from 2021-06-11 16-19-00@2x

}

if (selectedFilter) this.fetchSuggestions('', (defaultOptions) => this.setState({ defaultOptions }))
this.setState({ updatedValue, inputValue: updatedValue, negated, forceReloadSuggestions: forceReloadSuggestions + 1 })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done in a single setState? The current flow seems to be:

setState({selectedFilter}) -> componentDidUpdate() -> setState({updateValue, inputValue, negated, forceReloadSuggestions})

Why can't it be just:

setState({selectedFilter, updateValue, inputValue, negated, forceReloadSuggestions})

when the filter input changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly wrote it like this to make it a bit more DRY - because the selectedFilter could change both via the dropdown onChange, or from componentDidMount when loading from the URL param - it could theoretically be brought out, but would end up being duplicated.

negated: false,
updatedValue: "",
inputValue: "",
forceReloadSuggestions: 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this variable doing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to force react-select to re-fetch the suggestions when the input changed externally (when loading from the currently set filter, primarily), using the key to force it to do so. They don't expose a way to do this directly, but it's well documented that changing the key of the component forces it to re-fetch them.

@@ -691,6 +679,55 @@ defmodule Plausible.Stats.Clickhouse do
|> Enum.into(%{})
end

def page_times_by_page_url(site, query, page_list \\ nil)

def page_times_by_page_url(site, query, _page_list = nil) do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for adding this new definition for page_times_by_page_url?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for the negated and/or globbed versions of the page filter - because the old version relied on a static list of page paths from top_pages to pick which times to keep - this version is for the top stat, which passes in nil as the page_list, then the filter is used to decide which pages to keep, then they're averaged into the time on page top stat for a negated or globbed page path (since this type of filter can't be represented in a static page_list, whereas from top_pages` it's always just the up to 100 pages being returned at that call).

@ukutaht
Copy link
Contributor

ukutaht commented Jun 11, 2021

I did a trial with downshift instead of react-select and it seems pretty neat. Small win in bundle size but the big win I think is that it's headless so we have full control over the DOM and we can use Tailwind directly for rendering instead of !important classes.

selectedFilter: "",
negated: false,
updatedValue: "",
inputValue: "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of tracking inputValue and updatedValue in the state? Isn't react-select already tracking the input value? Can this be removed from the state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disparity between updatedValue and inputValue is a remnant of an old implementation that I've now combined into just updatedValue, but we keep track of that (and pass it into react-select as a prop) instead of letting react-select do so, because we need to update the input manually at times (to help it not be blank when re-editing, when using the filter edit flow), otherwise it'd always default to blank when going into the input.

@Vigasaurus
Copy link
Contributor Author

However, I am very much annoyed by the slight differences in border radius, border color, font size, padding, chevron color etc between these two inputs. They should be consistent.

👍 These should be all good now.

image
image

I noticed is when you select a value from the dropdown, the loading indicator will flash for a second. I can also see a call to the suggestions endpoint. This seems unnecessary after the user has already made a choice.

Yeah this is because it pre-fetches results as soon as we set the inputValue prop (you'll notice this if you go directly into the edit filter flow too, it searches for suggestions before you even enter the field) - there's not a whole lot I could do about it, we could potentially add some styles to hide the loader when someone makes a selection from the menu, but I think having the results pre-fetched is more often beneficial than worse.

Personally I don't like the focus style on the dropdown (in light mode, at least). I think it's bg-indigo-300 with dark text. I've created a JS dropdown for the invitations UI and I used bg-indigo-600 text-white as the hover/focus style which I think fits much better. Thoughts?

Yeah I like the styles you chose there (it's indigo 500 as per your current PR for it, so I just used that).

I did a trial with downshift instead of react-select and it seems pretty neat. Small win in bundle size but the big win I think is that it's headless so we have full control over the DOM and we can use Tailwind directly for rendering instead of !important classes.

Yeah it looks interesting - I hadn't seen it before. It might be nice, but also maybe something to look into down the line once there's some feedback on this version, and we can decide if re-implementing it is time well spent.

@Vigasaurus Vigasaurus requested a review from ukutaht June 11, 2021 21:25
@ukutaht ukutaht merged commit 30ac901 into plausible:master Jun 21, 2021
@ukutaht
Copy link
Contributor

ukutaht commented Jun 21, 2021

Thanks @Vigasaurus! Putting this on staging for further testing

@metmarkosaric
Copy link
Contributor

It's so much better now, great work @Vigasaurus! loads very fast too! few notes from me here:

  • Could you try to remove the word "add" from the button to make it smaller so it takes less space?

  • Is it possible to add keyboard shortcut for filter popup to show up? Perhaps F?

  • Can you make Page the default filter that shows up to save people a click? that first click to "select a filter" might become too cumbersome for people that use this often

  • We should add info on how to search better for pages with those * and other tricks in order to for instance exclude all pages with blog in them. right now for instance i don't know how to get that result without digging through our github. there's a lot of space underneath the page filter to place a trick or two

  • If I search for germany it gives me error not found, i need to search for Germany with capital G. this case sensitivity doesn't seem to be happening on other filters, it's only a problem in countries

  • like discussed earlier, for second version of this, i think we should consider to merge source+referrer, browser+browser versions, os+os version to make it more user friendly

@ukutaht
Copy link
Contributor

ukutaht commented Jun 22, 2021

Good points @metmarkosaric. I'll work on these

@ukutaht ukutaht mentioned this pull request Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants