-
-
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
Flatten ?filters=(...)&labels=(...) to ?f=...&f=...&l=...&l=... #4810
base: master
Are you sure you want to change the base?
Conversation
|
👋 Sorry for a drive-by comment on a draft PR, but if you set the attribute key to More info: https://hexdocs.pm/plug/Plug.Conn.Query.html |
0f16e70
to
caf00fe
Compare
Thanks for bringing it up @ruslandoga ! At the moment, this format must be recognizable only to the FE and ideally humans, though. I think of it as URL-stored dashboard state. Currently, the BE receives applied dashboard filters in URL-encoded stringified JSON, and there's an extra transform taking place https://github.com/plausible/analytics/blob/master/assets/js/dashboard/util/filters.js#L231 before that, which we're not planning to get rid of (in the interest of readable URLs). |
8c0fb42
to
6f83914
Compare
6f83914
to
cd6b053
Compare
The idea with the new filters format was to also support nesting in case we need it in the future. Stuff like:
This format seems to make that a bit harder. Did you consider that as well @apata ? |
Good question, @ukutaht! I expect there to be a bunch of ways to do this because we know the key words: and, or, not, all operators and all operator options. [
[
"or",
[
[
"and",
[
[
"is",
"visit:source",
["Google", "Bing"],
{ "case_sensitive": false }
],
["is", "visit:utm_medium", "is", ["cpc"]]
]
],
[
"and",
[
["is", "visit:source", ["Facebook"], { "case_sensitive": false }],
["is", "visit:utm_medium", ["paid_social"]]
]
]
]
],
["not", ["is", "visit:country", ["Estonia"]]],
["contains", "event:goal", ["trial"], { "case_sensitive": false }]
] For this edgy filter tree, an URL in the new style might be
This would be reconstructable thanks to fixed order of f= in the URL and known group lengths. // url.split("&").map(i => i.split("=")).filter(i => i[0] === "f").map(i => i[1]) -->
[
"or/2",
"and/2",
"is/i,source,Google,Bing",
"is,utm_medium,cpc",
"and/2",
"is/i,source,Facebook",
"is,utm_medium,paid_social",
"not/1",
"is,country,Estonia",
"contains/i,goal,trial",
]
// reconstruct recursively |
Changes
Tests
Changelog
Documentation
Dark mode