Commit Graph

445 Commits

Author SHA1 Message Date
RobertJoonas 12d818af8a
Refactoring preparation for DashboardQueryParser (#5929)
* rename QueryParser to ApiQueryParser

* move utc_time_range construction to querybuilder

* input_date_range format

* rename 30m atom to realtime_30m

* move build_comparison_date_range into do_build
2025-12-03 15:09:17 +00:00
Adam Rutkowski 111a8b9462
Enforce max limit for goals per site (#5917)
* Limit preloading goals

* Enforce max limit for goals per site

* typo

* credo

* Remove logger call

* Integrate #5916

* Add a test

* Add test

* Unignore opts
2025-11-27 10:19:13 +00:00
RobertJoonas 7a11f5ec40
Refactor building the Query struct (#5893)
* rename Query.build -> Query.parse_and_build

* rename two test files and move 4 %Query{} building functions into subfolder

* rename StatsAPIFilterParser to LegacyStatsAPIFilterParser

* rename Filters.QueryParser to QueryParser

* turn QueryParserTest into QueryParseAndBuildTest

* move query_parser.ex out of filters directory

* separate build from parse

* disable sample_threshold in the new intermediate build function, for now

* remove now redundant test util functions

* remove unused import

* address todo from earlier

* credo

* Make module names in sync with paths in tests

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2025-11-24 09:16:05 +00:00
Adrian Gruntkowski a2ba1256d2
Show revenue data in all breakdowns (#5767)
* Include revenue data for all detailed API responses except entry/exit pages

* Expose revenue data in all breakdown modals except entry/exit pages

* Add revenue metrics to breakdown response only on EE

* Change query builder to enable querying event metrics \w session dimension

* Add revenue metrics to entry and exit pages breakdowns

* Expose revenue data in entry and exit pages breakdowns

* Use `argMax` for `exit_page` and `exit_page_hostname` dimensions (h/t @ukutaht)

* Don't handle event-only dimensions with session-only metrics for now

* Add tests for all breakdowns

* Add clarifying comments in code

* Mark revenue tests as EE-only
2025-11-18 11:24:54 +00:00
Adrian Gruntkowski 3d1f1eca8e
Ensure `conn` from `Plug.Conn.read_body` is always passed down the pipeline (#5814)
* Ensure `conn` from `Plug.Conn.read_body` is always passed down the pipeline

* Alter persistor related histogram metrics for better view of timings

* Update typespec
2025-10-20 11:54:52 +00:00
Uku Taht 07c7270481
Fix Sentry error in filter suggestions (#5741)
* Fix Sentry error in filter suggestions

* Update existing tests
2025-09-24 09:55:49 +00:00
Adrian Gruntkowski 49cff303f4
Show bounce rate in Detail view of Top Entry Pages (#5747)
* Show bounce rate in Detail view of Top Entry Pages

* Update tests and test fixtures

* Update CHANGELOG.md
2025-09-23 11:38:20 +00:00
Adrian Gruntkowski 8d6d828d1d
Reduce reliance on `Timex` and use native time API where feasible (#5712)
* Replace usages of `Timex.to_unix` with native API

* Wrap call to `Timex.is_valid_timezone?`

* Wrap calls to `Timex.today(tz)`

* Replace `Timex.today()` with `Date.utc_today()`

* Replace `Timex.now()` with `DateTime.utc_now()`

* Replace `Timex.compare` with `Date.compare`

* Wrap `Timex.diff` calls

* Replace `Timex.Timezone.convert` with `DateTime.shift_zone!`

* Wrap `Timex.parse!`

* Replace `Timex.to_date` with native API calls

* Replace `Timex.beginning|end_of...` with native API calls for Date

* Wrap `Timex.beginning|end_of...` for DateTimes and Dates for years

* Replace `Timex.format(!)` with native API calls

* Replace `Timex.to_naive_datetime` with native API calls

* Wrap time humanizing routines using Timex

* Remove unnecessary `use Timex` instances

* Replace `Timex.shift` with native API calls

* Make `QueryParser.parse_date` handle gaps and ambiguities gracefully

* Replace `Timex.now(tz)` with `DateTime.now!(tz)`

* Use a more suitable Date function for comparison (h/t @aerosol)
2025-09-10 10:21:36 +00:00
Karl-Aksel Puulmann 9af40a278d
Trim month, year, day periods to local now on main graph (#5698)
* Revert "Revert "Trim `month`, `year`, `day` periods to local now on main graph (#5668)" (#5684)"

This reverts commit 2d11681f25.

* Does not trim for comparisons

* Include the current hour in the trimmed time range
2025-09-04 09:13:17 +00:00
Adrian Gruntkowski 2d11681f25
Revert "Trim `month`, `year`, `day` periods to local now on main graph (#5668)" (#5684)
This reverts commit 563c3d22ba.
2025-08-28 14:58:57 +00:00
Adam Rutkowski 563c3d22ba
Trim `month`, `year`, `day` periods to local now on main graph (#5668)
* Trim `month`, `year`, `day` periods to now on main graph

* Revert "Trim `month`, `year`, `day` periods to now on main graph"

This reverts commit 4f3930111d3a2737a51686e067d9b64f0d85ad58.

* Re-implement trimming in query optimizer instead

* Update JS types

* This is getting confusing

* Trim in stats_controller

* Set `query.now` based on query_praser and date results

* query.period -> query.input_date_range

* Changelog

* Test for response query.date_range

---------

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2025-08-28 09:51:56 +00:00
Karl-Aksel Puulmann cf423dbf99
ScriptV2: TrackerScriptCache on ee (#5648)
* Leverage TrackerScriptCache on ee

On ee, TrackerScriptCache only stores valid ids. This is then leveraged
to do no database queries when looking up tracker scripts for
non-existing ids.

For smoother onboarding purposes, refresh frequency for the script is also
reduced.

Note that the cache layout is not optimal (storing 'true' booleans) but
being more optimal would require changing the underlying cache
implementation significantly.

I tested out the cache - with 1M tracker script configs, it seems to be
~12MB in size.

* Wait on cache

* Add telemetry

* Remove cleverness in trying to reuse code
2025-08-19 11:41:19 +00:00
RobertJoonas cb465511bb
Streamline creating/updating/deleting subscriptions in development (#5328)
* streamline dev subscriptions

* spawn -> Task

* fix button alignment

* do not define routes in test env

* remove explicit mentions of dev env when deciding whether to sandbox paddle

* decide checkout behaviour at compile time

* Timex -> Date

* hum

* make it work for enterprise plans too

* allow convenient subscription status change

* fix ci warnings

* remove redundant commented out code

* fix crash + review suggestion

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2025-04-16 13:43:17 +00:00
ruslandoga 9bfb1992d9
Sessions transfer (#5229)
* sessions transfer

* took on ignore

* add slow test

* more tests

* allow BIG messages

* update tests

* continue

* continue

* cleanup

* fewer changes

* add config tests

* todo

* use less app env

* oops

* fixes

* cleanup

* update tests

* remove useless tests

* more buckets

* Update lib/plausible/session/transfer.ex

* Update transfer.ex

* Update lib/plausible/session/transfer.ex

* avoid calling into ConCache directly

* cleanup, add docs

* Update lib/plausible/session/transfer.ex

* fewer options

* there is no loop

* force deploy

* force deploy again

* individual puts

* fewer changes in cache/adapter.ex

* oops

* use existing atom names

* Cosmetic changes

* Bring back slow tag

---------

Co-authored-by: hq1 <hq@mtod.org>
2025-04-16 09:56:39 +00:00
RobertJoonas 4eb4b68b99
Sort by exit rate (#5289)
* WIP

* Works, maybe

* More tests

* format + slight refactor special_metrics

* implement exit_rate equivalent to current dashboard metric

* add validations to query_parser

* implement comparisons for exit_rate

* merge imported exit rate

* plug in the new metric

* make exit_rate sortable

* changelog

* generate types

* rename tests

* changelog

* maintain order of special metrics

* move exit_rate to the bottom as the less significant special metric

* capitalize null + query assign tweaks

* add comment

* Update lib/plausible/stats/sql/special_metrics.ex

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

---------

Co-authored-by: Artur Pata <artur.pata@gmail.com>
Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
2025-04-09 09:47:12 +00:00
Adrian Gruntkowski 659cae50aa
Set current_team when user has team membership in viewed site (#5284)
* Make `site_role/2` return whether real is team or site scoped

* Rename `has_admin_access?` => `has_editor_access?`

* Switch current team if user is a team member in site's team
2025-04-08 08:09:47 +00:00
Karl-Aksel Puulmann 0fcbcc3a8c
time-on-page: csv import/export support, preparation for release (#5274)
* CSV import/export support for time-on-page

Note only the new time-on-page metric is exported this way

* visibility check for graphing of time_on_page

* FE no longer receives/sends legacy_time_on_page_cutoff

* Remove current_user from exports

* Remove legacy_time_on_page_cutoff from query.include, make behavior work off of site.legacy_time_on_page_cutoff explicitly

* Remove dead function

* More current_user_id removals
2025-04-08 06:25:11 +00:00
hq1 98ffeca6a6
Stack bump: Elixir 1.18, OTP 27.3.1, Node 23.2.0, (#5264)
* Update tool versions

* Update deps

* Address runtime/compilation warnings

* Format

* Update Dockerfile

* wip

* Simpler

* oof

* hum

* format

* Bump cache vsn

* oops

* Fixup

* Fix dockerfile

* Try bumping node too 🤷

* Revert "Try bumping node too 🤷"

This reverts commit cdbe8d4a78.

* Reapply "Try bumping node too 🤷"

This reverts commit 12cafae22b.

* Welp
2025-04-02 12:39:22 +00:00
RobertJoonas c32cf24823
Search Terms dashboard report follow-up (#5223)
* search terms: stop returning unused fields

* fix Details link positioning
2025-03-20 13:33:41 +00:00
RobertJoonas 08d865b214
Google Search Terms error message: too recent period (#5212)
* consider too recent period erroneous + missing tests

* to typescript + center loading spinner
2025-03-20 07:38:33 +00:00
RobertJoonas c8ba6d918c
Scroll depth flag cleanup (#5195)
* Backend: get rid of scroll_depth.ex

This commit starts treating the scroll depth feature as *always visible*,
removing the ClickHouse queries on dashboard loads and starting to always
include scroll_depth in dashboard reports and export queries.

* Frontend: remove site.scrollDepthVisible

* adjust csv_importer_test

* remove site.scroll_depth_visible_at
2025-03-13 13:39:38 +00:00
Artur Pata f7b535df4b
Fix dashboard report behavior when goals are in segments - variant C (#5175)
* Replace GET /segments and GET /segments/:segment_id with server-rendered list, fix issue with dashboard report columns

* Remove WIP comments and throw earlier for invalid dashboard state

* Fix Segments details issue on public / shared link sites, add tests
2025-03-13 13:02:14 +00:00
Karl-Aksel Puulmann 0514a6db18
time-on-page: dashboard + timeseries support (#5174)
* Support passing `include` as a query parameter for dashboard APIs

* Mark time-on-page metric sortable

It now is thanks to the changed query

* new-time-on-page flag with cutoff being sent to the frontend

* Add correct tooltip title

* Implement metric warning for when legacy and new time_on_page metrics are mixed

* Send legacy_time_on_page_cutoff to backend

* Make time-on-page graphable with the new metric

* Only show metric warnings for time_on_page if flag is enabled

* Changelog

* Solve an clickhouse error when querying timeseries with only legacy time-on-page

* Add tests for timeseries of new time-on-page

Along the way fix an issue with comparisons not working properly

* Solve a typing issue

* Allow toggling legacy_time_on_page_cutoff off in dashboard

* Slightly better workaround

* Solve typing issue

* Prettier

* Guard against no warning

* Solve warning
2025-03-12 09:51:53 +00:00
Karl-Aksel Puulmann e9b30e0ba5
time-on-page: query (#5159)
* Default to time_on_page

* Add new columns to schema

* Read from new column in legacy query

* Read/write new imported_pages columns

* Remove time_on_page column from imported_pages

* Simple, stupid new_time_on_page metric

* Update csv_importer schema

* Refactor: consistent __internal helpers, this will help with joining the query

* Refactor select_joined_metrics

* Refactor: pass `query` to event_metric

* Refactor: remove needless site argument from various calls

* Legacy joining query attempt

* Move test around

* Add more tests for both legacy and new time_on_page metrics in query API

* time_on_page reported in seconds

* timeseries test for metric

* WIP

* Wrap main query in subquery - without this run into trouble performing the join

* Calculate time_on_page in main query, no more new_time_on_page

* Add some TODOs

* Return NULL over 0 when no visits with time-on-page data

* Update moduledoc

* Update some tests that were not expecting integers

* Add a TODO

* Update tests

* Make graphing time series with combined metrics work.

* Slightly more consistent approach to flag updating in APIv2

* Seeds with engagement data

* Make graphing time series when cutoff is in the middle work

Bakes less assumptions into everything as well.

* Rename to legacy_time_on_page_cutoff

* Fixup lib/plausible_web/controllers/api/external_query_api_controller.ex

* Remove a todo and dead/misleading code

* Remove a resolved todo

* Remove needless rounding

* gen types

* Update pages test

* Remove needless columns from select

* Update tests: timestamps and remove comment

* Flip branches
2025-03-11 11:19:58 +00:00
Artur Pata 2db60c90af
Provide top stats graphable metrics from BE (#5160)
* Provide top stats graphable metrics from BE

* Update changelog
2025-03-07 12:08:25 +00:00
Karl-Aksel Puulmann 694bd6fae2
Improve dashboard main graph - revenue metrics, nulls (#5153)
* Main graph: Graph revenue metrics as zeroes instead of nils.

This has no effect on existing APIs as:
- Comparisons/empty data point logic only affects APIv1 which does not expose revenue metrics

Also changes semantics for visit_duration to be more in-line with the
rest.

* Improve dashboard main graph

- Graph tooltip for revenue metrics now shows revenue with the relevant
  monetary unit.
- Graph tooltips for scroll depth, visit duration and so on now shows `-`
  instead of 0 on dates where no relevant visits occurred.

* Remove business logic duplication
2025-03-06 12:11:01 +00:00
Artur Pata 47b8553ca1
Implement Site Segments billing feature (#5129)
* Implement Site Segments billing feature

* Make sure Site Segments benefit appears only when feature flag is present

* Add site_segments flag to v3 plans

* Refactor new filter menu back to ghost button

* Stop error state from persisting (#5131)

* Refactor how Segments appear on Choose Plan page

* Limit to 500 segments per site
2025-03-04 10:09:40 +00:00
Artur Pata 5ae2fd89f0
Resolve segment owner names and dates in site timezone in the BE (#5119)
* Resolve segment owner names and dates in site timezone in the BE

* Fix SegmentAuthorship

* Fix issue with updating dangling segment

* Refactor flaky PATCH segment test

* Unify segment type label logic

* Refactor SegmentOwnership type definitions for clarity
2025-02-28 07:06:20 +00:00
Artur Pata 421e7d2766
Add Saved Segments UI (variant D) (#4891)
* WIP

* Load members

* Assert that we know has_not_done will not work without changes

* Add tests

* Assert that dates are in the expected format

* Add tests, better authorship dates, api.js -> api.ts

* Add error panels

* Flatten errors on the API side

* Stop name copy from getting too long

* Make comparison mode and edit segment modes exclusive

* Fix flicker calculating space

* Fix issue with definite state not persisting

* Unhitch modals from query-context

* Separate API format and dashboard format of segment_data

* Clarify purpose of useDefiniteLocationState

* Tweak UI: site switcher, save as segment

* Fix issues with modals

* Remove commented and unnecessary code, better query context

* Fix too permissive site members dataset

* Make sure Segment doesn't show up as an option to customer without the FF

* Fix issue with 'See more' menu being present when it should not be

* Permit :has_not_done filter in segments

* Refactor to matching on filter list structure

* Flatten :and stemming from segment filters on first level

* Update test
2025-02-26 12:32:25 +00:00
Adrian Gruntkowski bf010a1537
Implement support for multiple team owners and multiple teams per user (#5008)
* Add tests for `Teams.get_or_create/1` and `Teams.get_by_owner/1`

* Start populating `current_team` in assigns fetching value from session

* Clean up team passing in invitation services

* Make site transfer service handle multi-team scenario

* Handle multi-team and permission transfer errors on controller level

* Handle multi-teams in site creation on service and controller level

* Drop validation limiting full membership to a single team

* Make user deletion account for public team ownership

* Adjust feature availability checks for Stats API key

* Use current_team when determining limits on site transfer invitation

* Adjust trial upgrade email submission to account for multiple owners

* Remove unnecessary `Teams.load_for_site/1`

* Spike renaming `owner` and `ownership` relationships to plural versions

* Make HelpScout integration handle owner of multiple teams gracefully

* Add FIXME note

* Resolve paddle callback issue by always provisioning a new team when none passed

* Set `current_team` as `my_team` only when user is an owner

* Implement basics of Teams CRM

* Extend Teams CRM

* Further adjust User and Site CRM and refine Team CRM

* Convert Enterprise Plan CRM to refer to team directly and not via user

* Remove unused virtual fields from User schema

* Add note to HelpScout integration

* Allow listing multiple owners under Site Settings / People

* Remove unused User schema relations

* Fix current team fetch in auth plug and context

* Implement basic team switcher

* Ensure (site) editor role is properly handled in site actions auth

* Don't set `site_limit_exceeded` error marker on `permission_denied` error

* Link from HS integration to Team CRM instead of User CRM when available

* Ensure consistent ordering of preloaded owners

* Add `with_subscription` preload for optimisitation

* Add ability to search sites by team identifier

* Add ability to pick team when transferring ownership directly

* Fix failing HelpScout tests

* Scope by team when listing sites in dashboard and via API (optional)

* Add ability to search by team identifier in plans CRM lookup widget

* Add subscription plan, status and grace period to team status info

* Expose teams list in user CRM edit form and fix team details CRM view

* Fix Team Switcher styling

* Reorganise header nav menu

* Avoid additional queries when authenticating user

* Hide the pay/site transfer message on lock screen when teams FF is on

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2025-02-19 09:33:25 +00:00
RobertJoonas 51a6ca6654
Refactor comparison query & including imported data (#5068)
* write comparison_utc_time_range into query

* write site_imports into query

* use struct! over Query.set

* variable to module attr

* remove redundant comment

* reject over filter

* Map.reject over Enum.reject
2025-02-17 10:44:48 +00:00
Uku Taht d762795979
Separate liveness and readiness checks (#5048)
* Separate liveness and readiness checks

* Changelog

* Make sure /api/health uses readiness check

* Do not expose internal error

* Make healthcheck repo calls parallel
2025-02-10 16:34:30 +00:00
RobertJoonas 269430281d
Scroll depth dashboard warnings (imported data) (#5051)
* add migration

* add schema field

* mark site_imports with has_scroll_depth

* add function to get imports in query range

* add scroll_depth metric warning in QueryResult

* return scroll_depth warning in top stats

* render minimalistic warning in top stats

* minimalistic warning in Top Pages breakdown

* prettier format

* silence credo

* add test

* use a snapshot of SiteImport schema in data migration

* also use a snapshot list of imported_* tables

* moduledoc (credo)

* change tooltip message

* change metric warnings structure in top stats response

* pass meta from queryresult directly

* revert top_stats_entry refactor

* prettier

* stop using SiteImport module in data migration
2025-02-10 14:50:54 +00:00
Karl-Aksel Puulmann 7c6ba04a3c
Handle missing scroll depth #2 (#5017)
* add migration

* move scroll_depth_enabled? fn

* maybe set engagement_metrics_enabled_at when requesting dashboard

* maybe set engagement_metrics_enabled_at in shared_link action

* maybe set engagement_metrics_enabled_at on full export

* fix tests

* feature gate scroll depth on the dashboard with site.engagement_metrics_enabled_at

* feature gate scroll depth in full export too

* fix npm ci

* Rename things into FE, remove unneccessary flag checks

* Continue with renaming

* Rename site flag to be more descriptive

* Move business logic, calculate based on scroll depth, make more precalculatable

* Some docs

* Rename to site.scrollDepthVisible in frontend

* Update migration

* Fix template

* Remove boilerplate from tests

* Update tests

* More straight-forward test

* Update condition

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2025-01-29 09:47:49 +00:00
Karl-Aksel Puulmann 4c68010dd9
Proposal: Remove `unique users` from dashboard when filtering by goal (#4999) 2025-01-28 10:41:43 +00:00
RobertJoonas 00deb05d64
Refactor including imports in stats queries (#5011)
* preload completed site_imports for site when needed

* remove unused field from top stats response

* refactor imports meta

* remove redundant function clause

* fix ordering in queryresult

* preload completed_imports in plugs

* write code more short
2025-01-27 10:23:58 +00:00
Karl-Aksel Puulmann 9a4969e105
APIv2: Behavioral filtering (#4980)
* Expose site_id and site_native_stats_start_at via query

This allows to do more query-building without exposing and passing `site` directly.

* Very basic has_done/has_done_not operator support

No event:goal support yet, no validations

* Add validations that only event: dimensions can be used within has_done/has_done_not

* Allow event:goal filters nested within has_done/has_done_not behavioral filters

* Minor fix for do_decide_custom_prop_table

* has_done support for goals

Minor changes along the way:
- preloaded_goals structure changes
- event:goal restrictions were loosened within has_done
- we don't allow nesting has_done anymore

* Dont query imports when behavioral filters are present

* Update callsites of filtering_on_dimension? to work with new behavioral filters

* has_done_not -> has_not_done

* Changelog entry

* Typegen

* credo cleanup

* Fix changelog

* Remove changelog

* Mark has_done as internal-only

* combine two validations into a single loop

* has_done is now session-based not user-based

* Update a test

* Update transform_tree
2025-01-21 12:03:26 +00:00
Artur Pata 5af43a93d5
Refactor Segments controller to be thinner (#4981)
* Refactor segments model

* Fix inconsistent code

* Remove superfluous error case

* Beautify Plausible.Segments module
2025-01-20 09:58:31 +00:00
Artur Pata f169f0caff
Establish saved segments API (#4899)
* Implement segments endpoint controllers

* Refactor endpoint controllers to be based on capabilities

* Add saved_segments feature flag check

* Fix issue when querying all segments on Growth plans

* Validate segment

* Refactor naming to permissions

* Add some permission based tests

* Give more info to compiler about expected args shape

* Implement centralized permission checking module

* Refactor to conventional rights validation

* Update tests

* Add name and segment_data length and filter depth validation

* Refactor route names and add tests for FF check plug

* Refactor mixed segments query name

* Remove inconsistent strict not equals

* Use a different format for result is Map case

* Remove newline between spec and def

* Fix issue with too deep nesting

* Verify in tests that segment is actually removed/not removed from DB

* Fix typo in fn name
2025-01-14 10:12:36 +00:00
RobertJoonas 8741de7b9d
fix bug (#4946) 2025-01-07 12:42:51 +00:00
RobertJoonas 3473910c97
Average Scroll Depth Metric: imported data (#4915)
* include scroll_depth in full pages export

* import scroll_depth from CSV

* query scroll depth from imported data

* fix ordering by scroll depth with imported data

* fix imported scroll depth query + more tests

* enable scroll depth in top stats with imported data

* add main graph test

* fix test and native scroll depth sum select

* Update lib/plausible/exports.ex

Co-authored-by: ruslandoga <doga.ruslan@gmail.com>

* adjust test

* adjust test to catch error

* export/import/count pageleave_visitors

* extract base_q in export_pages_q

* rename total_visitors to pageleave_visitors

---------

Co-authored-by: ruslandoga <doga.ruslan@gmail.com>
2025-01-07 10:59:26 +00:00
RobertJoonas 7f3e91e1cc
[FF] Average Scroll Depth Metric: dashboard CSV export (#4898)
* extract test util function

* add scroll depth to pages.csv

* add scroll_depth to (page-filtered) visitors.csv

* silence credo
2024-12-16 16:07:43 +00:00
Adrian Gruntkowski 729a32e610
Teams writes switch (#4883)
* Comment out legacy fields and relationships

* WIP

* WIP 2

* WIP 3

* wip

* Remove teams backfill and consistency check scripts

* WIP 3

* Fix CheckUsage tests

* Update billing/subscription tests

* WIP 4

* Make site transfer fail if some invitation already exists

* Fixup: do symmetric invitation/site transfer check

* Update UI bugs: make listing sites/inviting admins work like before

* Fix Sites test

* Fix external sites controller test

* Fix live sites tests

* Fix props availability lookup

* Fix site controller tests

* Fix billing controller tests

* WIP - accept invitation tests

* Another round of test fixes + invitations logic bugs

* users_test -> teams_test

* Update registration via invitation

Here, we still rely on "polymorphic" invitation structures,
hence the "unified by id" helper.

For now, it'll remain local unless we discover it's
needed in the broader `Teams.Invitations` context.

cc @zoldar

* Yet another round of test and bugfixes along the way

* Include team in site setup success e-mail

* Fix send_site_setup_emails worker

* Fixed almost all tests except CRM ones

* Update enterprise plan admin test

* Fix CRM + remaining tests

* Address credo warnings (modulo one FIXME)

* Remove last FIXME and rephrase the invitation test case description

* Set Team fields via User CRM transparently

* Map user reference in Enterprise Plan CRM via team owner

* Fix resource actions in user CRM

* Get rid of warning when opening create form in API keys CRM

* Stop emitting warnings when editing Enterprise Plans via CRM

* Tests: Bump await_clickhouse_count interval

* Remove XXX marker

* Fix register from invitation link in email sent for ownership transfer

* Simplify fetching all pending site ownership site IDs

* Remove commented out schema fields

* Remove unused functions

* Address flakiness in ingest counter tests

* Remove unused `Teams.Sites.create`

* Don't restart trial on team with subscription when creating site

* Account for cases of legacy teams with empty trial expiry date

* Revert "Address flakiness in ingest counter tests"

This reverts commit 60dc1e4115.

* Fix flaky ingest counters tests under load

* Attempt 2

* Pre-emptively hardcode site ids in sampling cache test

to avoid supplying the same IDs alongside with counters test,
that inserts through another repo (async).
what we're observing is, clickhouse not summing mergetree columns fast
enough, even though we wait quite a bit.

* Fix ingest counter tests by accounting for delayed summation

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-12-16 11:11:14 +00:00
Karl-Aksel Puulmann 5b7b5434c5
Remove LegacyDashboardFilterParser (#4882)
* Remove LegacyDashboardFilterParser usage in stats_controller

* Update tests to avoid legacy dashboard parsing

* Update top stats tests

Note a few behavioral test changes since dashboard doesn't do wildcards anymore

* Update test/plausible_web/controllers/stats_controller_test.exs

* Update sources_test

Removed test was dead functionality

* Update countries_test.exs

* Update test/plausible_web/controllers/api/stats_controller/browsers_test.exs

* Update test/plausible_web/controllers/api/stats_controller/custom_prop_breakdown_test.exs

* Update test/plausible_web/controllers/api/stats_controller/suggestions_test.exs

* Remove dead tests

* Update pages_test

* Update conversions_test.exs

* Update funnels_test.exs

* Update test/plausible_web/controllers/api/stats_controller/main_graph_test.exs

* Update test/plausible_web/controllers/api/stats_controller/suggestions_test.exs

* Update test/plausible/stats/query_test.exs

* Remove legacy parsing code

* Changelog

* Inline utils
2024-12-09 09:00:07 +00:00
Karl-Aksel Puulmann a38eacfed5
APIv2: Case insensitive search (#4863)
* WIP: Optional modifiers to queries

* WIP: Modifiers v2

* Use preloaded_goals when determining whether imports can be included

This was previously broken with conversion_rate totals metrics since it removed event:goal
filters but did not update preloaded_goals

* Preload goals according to modifiers

* Make case_sensitive: false work for is/contains operators

* Make modals send { case_sensitive: false } to backend for search

* CHANGELOG.md

* Typegen

* Prettier

* Refactor: more DRY where_builder for case sensitivity

* Support case_sensitive modifier for is_not/contains_not

* Cleanup

* credo

* remove defaults

* negating a previously set filter
2024-12-03 10:32:16 +00:00
RobertJoonas 6822b29016
Average Scroll Depth Metric: put scroll depth on the dashboard under a feature flag (#4832)
* migration: add scroll_depth to events_v2

* (cherry-pick) ingest scroll depth

* replace convoluted test with more concise ones

* QueryParser: parse internal scroll_depth metric + validation

* turn QueryComparisonsTest into QueryInternalTest

* rename file

* (cherry pick) query scroll depth 15b14d3

...and move the tests into `internal_query_test.exs`

* review feedback

* Get rid of unnecessary separation between aggregate and group scroll depth
* Drop irrelevant other metrics in tests

* add test ensuring scroll depth unavailable in Stats API v1

* Put scroll depth on the dashboard

* Top Stats
* Main Graph
* Top Pages > Details

* feature flag for dashboard scroll depth access

* ignore credo warning

* enable scroll_depth flag in tests

* remove duplication

* write timestamps explicitly in a test

* revert moving tests around

* Add query_comparisons_test back
* Move scroll_depth tests into query_test
* Delete query_internal_test

* rename setup util (got updated on master)

* use pageleave_factory where applicable

* Use the correct generated query-api.d.ts

* npm format
2024-11-20 13:13:04 +00:00
Adrian Gruntkowski c2a95a142d
Make feature toggle work with teams schema and adjust affected tests (#4825) 2024-11-18 08:52:03 +00:00
Uku Taht 98bc3e7554
Channels in dashboard CSV export (#4787)
* Add channels.csv to dashboard CSV export

* Feature flag channels in CSV

* Disable credo
2024-11-11 09:31:57 +00:00
Karl-Aksel Puulmann b5d48a7347
Breakdown comparisons: Tooltip UX, arrows (#4719)
* Revert "Revert "Remove no change icon, better alignment""

This reverts commit a69d0a14a7fe038fe110907571240ad99a2ba6a4.

* different arrows

* Render graph tooltips in react

* Use ChangeArrow in graph tooltips

* Only display a single date if viewing a single date

* Tests for breakdown responses with labels

* Simplify code a bit

* strokeClass

* refactor ChangeArrow

* Play with stroke widths

* jest tests

* Silence logging in jest tests

* not variable stroke width

* prettier

* Conversion rate widths

* Update a test

* Trim trailing dates for label when comparing running month

* Reformat file

* Update expect.toHaveTextContent for multiline

* Update date range labelling to be more consistent with the frontend

* reformat
2024-10-30 10:19:47 +00:00
RobertJoonas 0f93328b6f
Fix custom property value filter suggestions (#4720)
* new endpoint for custom prop value filter suggestions

* add test coverage for searching prop suggestions

* plug the new endpoint into FE

* update changelog

* format JS

* Update CHANGELOG.md

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

---------

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
2024-10-23 12:24:23 +00:00