Commit Graph

2989 Commits

Author SHA1 Message Date
Adrian Gruntkowski
9db87fc267 Filter shared link by site ID on query level already 2024-09-17 12:07:21 +02:00
Adrian Gruntkowski
d81ac4f89c Improve naming slightly 2024-09-17 12:03:21 +02:00
Uku Taht
67c6f873f8 Remove one DB roundtrip from AuthorizeSiteAccess 2024-09-17 11:49:57 +02:00
Adrian Gruntkowski
8659883511 Tag EE-only test properly 2024-09-16 15:41:23 +02:00
Adrian Gruntkowski
9927bfc381 Extend plug-specific tests 2024-09-16 12:51:35 +02:00
Adrian Gruntkowski
112e1865af Further restrict accepted input and configuration 2024-09-16 12:51:35 +02:00
Adrian Gruntkowski
5570228d3c Adjust failing case test to account for different response 2024-09-16 12:51:35 +02:00
Adrian Gruntkowski
c1bb70f68c Add regression test for shared link auth case 2024-09-16 12:51:35 +02:00
Adrian Gruntkowski
5fc90a074f Add moduledoc 2024-09-16 12:51:35 +02:00
Adrian Gruntkowski
2634da62f3 Make plug module name more consistent 2024-09-16 12:51:35 +02:00
Adrian Gruntkowski
56c96356e8 Refactor and fix AuthorizeSiteAccess plug shared link case handling 2024-09-16 12:51:35 +02:00
Adrian Gruntkowski
ae0c5a173d
Drop event explicitly on session lock timeout (#4582)
* Drop event explicitly on session lock timeout

* Make session `user_id` more random in tests to avoid excess locking

* Improve testability to event ingestion

* Test lock timeout in ingestion
2024-09-16 10:36:53 +00:00
hq1
9f1017e2b4
Set postgres pool size to 2*cores for test env (#4581)
This should help with random pool timeouts, at least
on AMD Linux with 24 cores.
2024-09-16 10:20:02 +00:00
RobertJoonas
b1152fc351
Breakdown modal search shortcut (#4559)
* add keyboard shortcut

* pass setSearch as undefined when searchEnabled is false
2024-09-16 07:24:06 +00:00
Karl-Aksel Puulmann
748e0d902f
APIv2: Make imports_skip_reason flag not appear when imports not requested (#4565)
* APIv2: Make imports_skip_reason flag not appear when imports not requested

* Update lib/plausible/stats/query_result.ex

Co-authored-by: hq1 <hq@mtod.org>

---------

Co-authored-by: hq1 <hq@mtod.org>
2024-09-16 06:13:32 +00:00
hq1
f979ca938a
Fix race condition merging session data when cache returns (#4579)
`persist_session/1` is used in `populate_native_stats/1` test helper
to merge session data. It sometimes gets `:ok` instead of the actual
session data so that tests randomly fail with:

```
** (BadMapError) expected a map, got: :ok
code: populate_stats(site, [build(:pageview)])
stacktrace:
(elixir 1.17.1) lib/map.ex:486: Map.take/2
(plausible 0.0.1) lib/plausible/clickhouse_event_v2.ex:92: Plausible.ClickhouseEventV2.merge_session/2
(plausible 0.0.1) test/support/test_utils.ex:188: anonymous fn/2 in Plausible.TestUtils.populate_native_stats/1
(elixir 1.17.1) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3
(plausible 0.0.1) test/support/test_utils.ex:184: Plausible.TestUtils.populate_native_stats/1
(plausible 0.0.1) test/support/test_utils.ex:179: Plausible.TestUtils.populate_stats/1
test/workers/send_site_setup_emails_test.exs:46: (test)
```
2024-09-16 06:12:18 +00:00
ruslandoga
e9ced986ce
prepare for wiki (#4512) 2024-09-13 11:32:39 +00:00
ruslandoga
0a962e20a9
Make CE HTTPS use current Mozilla recommendations (#4568)
* allow configurable cipher suites in CE

* just use intermediate compatibility

* configure eccs like mozilla

* drop ciphers with rsa
2024-09-12 15:11:30 +00:00
Cenk Kücük
606248d2af
prepare CI for merge queues (#4576) 2024-09-12 16:05:34 +01:00
Karl-Aksel Puulmann
ef57502854
APIv2: Implement pagination and include.total_rows (#4575)
Offset-based pagination is used to make sure Looker integration
is able to work as efficiently as possible. To know how many
requests users need to do `include.total_rows` option was added.
2024-09-12 15:51:18 +03:00
Artur Pata
9fcb76d8e6
Allow sorting breakdown lists by some metrics (#4513)
* On the dashboard, allow Metrics (aka column configurations) to
  * specify width they need
  * specify if they are sortable
* Default sort order for breakdown endpoints is hardcoded on the dashboard (needed to show what column the report is sorted by)
* Unifies Google Keywords modal with other breakdowns
2024-09-12 14:49:43 +03:00
Karl-Aksel Puulmann
dd1021eff3
Limit docs query API, return 401 for API routes (#4570)
* Limit docs query API, return 401 for API routes

* Changelog entry

* Use 404 with changed error message

* Update changelog
2024-09-12 14:11:22 +03:00
ruslandoga
28f20bba3b
tzdata works with 2024b now (#4569) 2024-09-11 14:22:40 +07:00
Karl-Aksel Puulmann
bd11b4cf67
APIv2: Standard iso8601 timestamps, operate on UTC (#4563)
* query.date_range is now in UTC instead of user timezone

This simplifies things down the line and fixes several bugs where
query.date_range is cast to naivedatetime for ecto purposes

Many places still remain broken:
- comparison queries
- `to_date_range` calls

* Make default_for_date_range not care about time zones

* Make timezone parameter mandatory for to_date_range

* Simplify utc_date_range, update legacy query builder

* Fix more cases where query date range is needed

* query.date_range -> query.utc_time_range

* Query.date_range/1 function

* ensure_include_imported update

* Clean up send_email_report
2024-09-11 09:21:59 +03:00
Artur Pata
52b94842c0
Assert filters are tuples, simplify schema (#4541) 2024-09-10 18:01:42 +03:00
Karl-Aksel Puulmann
e8d544c841
Remove does_not_contain support (#4564)
It only needed to be live until users have reload. This has been live
for >24h.
2024-09-10 15:38:04 +03:00
ruslandoga
2180ab4764
Auto HTTPS in CE (#4491)
* auto https

* changelog

* enable auto-tls only when http_port is 80

* make erlang ssl less verbose

* simplify config

* simplify config

* fix ce_dev typo

* fix another typo

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-10 14:15:43 +02:00
Adrian Gruntkowski
8ba5f7d32f
Safeguard queries relying on sign from faulty old session entries (#4555)
* Safeguard session queries relying on `sign` from faulty old session entries

* Comment updated metric

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>

* Apply safeguards to `bounce_rate` metric only

* Add note to bounce rate definition in SQL fragments as well

* Add test for graceful bounce rate handling in breakdown

* Make user_id more unique

* Add a note to the test

* Move regression test to APIv2 tests

---------

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
2024-09-10 13:22:49 +02:00
Adrian Gruntkowski
c105ebceaf
Fix test failing due to timestamp setup (#4562) 2024-09-10 12:30:49 +02:00
RobertJoonas
e6993b1f8b
Filter modal fixes (#4553)
* fix deciding whether a filter operation is freeChoice

* fix displaying loading spinner when loading combobox options

* extract lastLoadTimestamp into a separate context

* prettier
2024-09-09 13:49:17 +03:00
ruslandoga
c536af0df0
Don't attempt to create a database if it already exists (#4498)
* don't attempt to create a database if already created

* add tests

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-09 11:55:39 +02:00
ruslandoga
d17ac82058
Remove Timex.now (#4546)
* rm Timex.now

* fix test

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-09 11:40:15 +02:00
ruslandoga
8ee4827fea
Run migrations in order across repos (#4466)
* order migrations

* migrate in 'streaks'

* cleanup

* docs

* tests

* add comment

* changelog

* continue

* run migrations tests in ci

* add pending_streams cmd

* fix ci

* add docs

* fix test

* simplify test

* only test v2+

* fix test

* return async: true

* cleanup

* add 'no pending migration'

* drop migrate/0 and pending_migrations/0

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-09 11:27:11 +02:00
ruslandoga
9ba9e2abc5
Make ClickhouseRepo task timeouts configurable in CE (#4494)
* remove ch timeouts from ce

* just infinity

* make timeout configurable

* quadruple

* add test

* improve test

* fix test filtering in ci

* just don't compile the test in ee

* fix test in ee

* maybe this would work

* rm test

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-09 11:20:06 +02:00
hq1
0031d1487d
Verification: Add super-admin report displaying diagnostics (#4554)
* Verification: Add super-admin report displaying diagnostics

* Revert LSP not catching up with formatter rules on time

* Remove redundant condition
2024-09-09 10:49:29 +02:00
Karl-Aksel Puulmann
604dde99fd
APIv2: Regex operations, consistent operators (#4488)
* Rename matches/does_not_match filters internally

These have never been exposed to the frontend/user directly, only via
APIv1 filtering syntax. As such we are free to rename these without
breaking things

* Rename function arguments for consistency, simplify

* Add support for `match`/`not_match` operators for query apiv2

These match the string against a regular expression, as defined in
https://github.com/google/re2/wiki/Syntax

* not_match -> match_not

* does_not_contain -> contains_not

Note that for backwards compatibility:
- Browser handles does_not_contain in URL
- Backend will handle does_not_contain in queries for a day where we will remove it for better autocompletion

* not_matches_wildcard -> matches_wildcard_not

* prettier

* match -> matches

* Fix and test fix for matches_wildcard against prop when prop is missing

* Custom properties support for matches/matches_not

* Restore contains_not

* Test contains and contains_not behavior for custom properties
2024-09-09 10:05:24 +03:00
ruslandoga
67d7c6522c
Change SMTP defaults (#4538)
* default smtp config updates

* tests

* improve SMTP_MIDDLEBOX_COMP_MODE decoding

* changelog

* format

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-06 10:31:23 +02:00
dependabot[bot]
4864a2c30e
Bump req from 0.5.0 to 0.5.6 (#4537)
Bumps [req](https://github.com/wojtekmach/req) from 0.5.0 to 0.5.6.
- [Release notes](https://github.com/wojtekmach/req/releases)
- [Changelog](https://github.com/wojtekmach/req/blob/main/CHANGELOG.md)
- [Commits](https://github.com/wojtekmach/req/compare/v0.5.0...v0.5.6)

---
updated-dependencies:
- dependency-name: req
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-06 10:22:52 +02:00
ruslandoga
b6859352cb
Fix tzdata (#4539)
* fix tzdata 2024b

* 2024b is buggy, use 2024a instead

* fix comma
2024-09-06 10:06:38 +02:00
hq1
b9493f687c
Replace native tooltips with simplified, generic component (#4528)
* Replace native tooltips with simplified, generic component

* Make tooltip a button?

* Revert "Make tooltip a button?"

This reverts commit adacc560f9.
2024-09-05 12:18:16 +02:00
ruslandoga
e7ac60c067
Return domain-less cookies in CE (#4482) 2024-09-05 12:05:40 +02:00
ruslandoga
654558dbf9
Remove Timex from Plausible.Timezones (#3899)
* use stdlib for timezones

* Remove unused `Timezones.to_utc_datetime/2`

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-05 11:48:07 +02:00
dependabot[bot]
3deca86201
Bump mjml from 1.5.0 to 3.1.0 (#4484)
Bumps [mjml](https://github.com/adoptoposs/mjml_nif) from 1.5.0 to 3.1.0.
- [Release notes](https://github.com/adoptoposs/mjml_nif/releases)
- [Changelog](https://github.com/adoptoposs/mjml_nif/blob/main/CHANGELOG.md)
- [Commits](https://github.com/adoptoposs/mjml_nif/compare/v1.5.0...v3.1.0)

---
updated-dependencies:
- dependency-name: mjml
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-05 11:20:30 +02:00
Uku Taht
d56d6998df
Acquisition channel (#4489)
* WIP

* Add acquisition channel

* Add detection for gclid and msclkid

* Add GA4 source categories file as external resource
2024-09-05 12:02:15 +03:00
Uku Taht
90b81b615f
Add migration for acquisition channel (#4531) 2024-09-05 11:51:16 +03:00
Karl-Aksel Puulmann
8fa3a83129
APIv2: and/or/not support (#4480)
* First approximation of AND/OR/NOT support

Broken by this:
- Goal filtering
- Table deciding
- Imports

* TableDecider handle nesting

* Query.remove_top_level_filters

* Plausible.Stats.Imported.SQL.Expression

* Handle AND/OR/NOT with imported data, create Plausible.Stats.Imported.SQL.WhereBuilder

* Add parser validations for event:goal, event:hostname and event:props:x filters top level constraints

* Move module around

* Query.get_filter -> Filters.filtering_on_dimension? in some callsites

* Filters.get_toplevel_filter

* TableDecider.sessions_join_events?, remove old method

* Transforming filters in query_optimizer

* Query API tests for and/or/not

* Reorder parser steps

* Post-merge test fixups

* Solve merge issue

* Simplify filtering_on_dimension?

* Update transformer code

* dimensions_used_in_filters min_depth option, simplify parser validations

* rename_dimensions_used_in_filter

* fix rename_dimensions_used_in_filter

* Rename a test
2024-09-04 15:44:03 +03:00
Karl-Aksel Puulmann
3310006337
Update 20240801091615_capitalize_known_sources.exs migration (#4525)
Previous migration took forever on prod, likely because Map lookups are linear time in complexity.
`transform/3` helps achieve the same functionality with the help of a hash table and updated
WHERE clause allows skipping most rows which dont need updating

Co-authored-by: Uku Taht <Uku.taht@gmail.com>
2024-09-04 13:57:28 +03:00
hq1
09999f8b0c
Disguise dogfooding LV URLs (#4529) 2024-09-04 11:36:00 +02:00
Karl-Aksel Puulmann
059b5e0cdd
Dont include imports for time:hour and time:minute dimensions (#4504)
* Dont include imports for time:hour and time:minute dimensions

Also include more information about import warnings in query results

* Update lib/plausible/stats/query_result.ex

Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>

* Revert patch

* Imported disabled graph notice (#4522)

* add explicit skip_imported_reason for unsupported interval

* stop returning information about imports from main_graph

* return warning about interval in Stats API Timeseries

* display warning bubble about interval too short for imported data

* update changelog

* improve styling of the exclamation circle icon

* return tuple from timeseries instead of map

* rename variable

* Update CHANGELOG.md

---------

Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
2024-09-04 10:53:00 +03:00
Adrian Gruntkowski
d0619aaea0
Redirect to login on expired legacy session (#4523)
After refactor, it turned out that when the _legacy_ session times out,
the conn is halted but no body is sent. This results in 500 error (`Plug.Conn.NotSentError`).

This PR fixes it by redirecting to login page.
2024-09-03 21:48:05 +02:00