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

Flatten ?filters=(...)&labels=(...) to ?f=...&f=...&l=...&l=... #4810

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

apata
Copy link
Contributor

@apata apata commented Nov 12, 2024

Changes

  • Moves current URL params parsing logic to legacy-jsonurl-url-search-params.ts
  • Adds custom serialization logic for labels and filters in url-search-params.ts and encodeURIComponent based logic for other simple params.
  • Adds redirect logic from jsonurl search params to new search params.

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

Documentation

  • This change does not need a documentation update

Dark mode

  • This PR does not change the UI

@apata apata added the preview label Nov 12, 2024
Copy link

Preview environment👷🏼‍♀️🏗️
PR-4810

@ruslandoga
Copy link
Contributor

ruslandoga commented Nov 20, 2024

👋

Sorry for a drive-by comment on a draft PR, but if you set the attribute key to f[]= then it would get automatically decoded into a list in Plug / Phoenix. Otherwise a custom decoder for query strings would need to be implemented.

More info: https://hexdocs.pm/plug/Plug.Conn.Query.html

@apata apata changed the title WIP: flatten ?filters=(...) to ?f=...&f=... [WIP] Flatten ?filters=(...) to ?f=...&f=... Dec 2, 2024
@apata apata force-pushed the fix-links-by-flattening branch from 0f16e70 to caf00fe Compare December 11, 2024 15:07
@apata
Copy link
Contributor Author

apata commented Dec 11, 2024

👋

Sorry for a drive-by comment on a draft PR, but if you set the attribute key to f[]= then it would get automatically decoded into a list in Plug / Phoenix. Otherwise a custom decoder for query strings would need to be implemented.

More info: https://hexdocs.pm/plug/Plug.Conn.Query.html

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).

@apata apata force-pushed the fix-links-by-flattening branch from 8c0fb42 to 6f83914 Compare December 11, 2024 16:16
@apata apata force-pushed the fix-links-by-flattening branch from 6f83914 to cd6b053 Compare December 11, 2024 16:20
@apata apata changed the title [WIP] Flatten ?filters=(...) to ?f=...&f=... Flatten ?filters=(...)&labels=(...) to ?f=...&f=...&l=...&l=... Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants