Commit Graph

3143 Commits

Author SHA1 Message Date
hq1
4d9ea15e9e
Switch reads in invitation creation logic to teams behind FF + loosely related fixes 🍌 (#4845)
* Reduce "choose plan" reliance on the old schema

* Fix team members usage computation on teams schema

* Switch CreateInvitation to reading from team schemas behind FF (WIP)

* Allow test-inviting one guest into multiple sites

* Convert another test case where team members count is wrong

cc @zoldar

* WIP: support site transfer notification e-mails

* Even more strict SiteTransfer fetching

* Make skipping permissions work

* Make CreateInvitation read from team schemas behind FF fully

* Fix passing options to `check_invitation_permissions`

* Fix allowance check for pageview usage for active or recently ended trial case

* Fix `check_invitation_permissions`

* Remove no longer relevant invite implementations for Teams

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-11-21 11:12:51 +00:00
Marko Saric
5072613c4f
Change the copy when switching a plan (#4796)
* Update plan_box.ex

* Fix test assertions

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-11-21 05:28:28 +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
a29eb3d3ca
Switch billing controller action to teams schema behind FF (#4843)
* Switch upgrade to enterprise plan view to teams schema behind FF

* Switch change plan preview action to teams schema behind FF

* Switch remaining billing controller actions to teams schema behind FF
2024-11-20 10:10:54 +00:00
Adrian Gruntkowski
380dc00d1a
Switch on teams schema in choose plan view behind FF (#4838)
* Switch on teams schema in choose plan view behind FF

* Proxy via Read adapter where applicable for billing context

* Proxy remaining plan-related functions

* Switch enterprise_configured?/1 tests to use the adapter

* Format

* Update SiteLocker tests

* Actually use `has_active_subscription?/1` billing adapter

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-11-20 08:35:18 +00:00
hq1
7b49dd33c7
Remove DebugReplayInfo (#4842)
We have now better tools to debug queries 😈
2024-11-20 08:20:35 +00:00
RobertJoonas
7f783920f3
Average Scroll Depth Metric: extracted ingestion changes (#4828)
* migration: add scroll_depth to events_v2

* (cherry-pick) ingest scroll depth

* replace convoluted test with more concise ones
2024-11-19 11:38:34 +00:00
RobertJoonas
e93c97de1e
migration: add scroll_depth to events_v2 (#4827) 2024-11-19 09:59:23 +00:00
Adrian Gruntkowski
4ff2a66548
Switch on team schema in site settings controller actions and LVs (#4834)
* Populate `current_team` to site's team and make site and subscription preloads consistent

* Accept only full `User` struct in `Users.get_for_user(!)`

* Make all uses of `Sites.get_for_user(!)` switch on team schema

* Remove redundant preloads for funnel/props settings

* Use adapter transitions in subscription settings

* Use team's schema subscription when listing invoices

* Fix typespec

* Turn owned site IDs into a specific query

* Add clauses for when FF is on but no team has been created

* Fix formatting

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-11-19 09:49:37 +00:00
Karl-Aksel Puulmann
9af498833e
Channels: backfill utm_medium based on click_param_id (#4833)
* Backfill utm_medium

Follow-up to https://github.com/plausible/analytics/pull/4817

* Update backfill
2024-11-19 08:12:39 +00:00
Uku Taht
73166774e0
Infer medium from click id if not present (#4817) 2024-11-18 11:19:11 +00:00
RobertJoonas
916c2bb4c5
Stop suggesting pageleave as a custom event goal name (#4829)
* stop suggestions pageleave as a custom event goal name

* add missing test
2024-11-18 10:16:33 +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
Karl-Aksel Puulmann
07a3436fa2
Follow-up to Solve noisy warnings about a negative range was inferred for Date.range/2 (#4816)
* Clamp dates on both directions

We could still get warnings about negative date ranges when the date
being queried is in the future.

This could happen if the users local time is in the future for some
reason or they manually edit the url.

* Update cond
2024-11-18 08:00:18 +00:00
Artur Pata
d187e59049
Fix routes not opening that take dynamic route params when the param contains forward slash (#4824) 2024-11-14 22:20:06 +00:00
Uku Taht
b0933e1730
Import acquisiton channel from GA4 (#4814)
* Import acquisiton channel from GA4

* Remove unnecessary step

* Fix spelling

* Remove migration

* Show empty channel in imported data as (not set)

* Revert "Remove migration"

This reverts commit da0b9403e4.

* Fix channel suggestions with imported data

* Merge group field entries

* Add note about channel mappings

* Revert "Revert "Remove migration""

This reverts commit 7958a46c5c.
2024-11-14 18:22:14 +00:00
Uku Taht
738db2df98
Channels UI polish (#4820)
* Make top sources UI hierarchical

* Display report title as card title in top sources

* Manage useEffect deps properly
2024-11-14 17:13:05 +00:00
Uku Taht
0bbdbc9f42
Imported channel migration (#4815) 2024-11-14 17:12:18 +00:00
Uku Taht
daa42cbc9d
Update acquisition channel UDF to prioritize display over paid search (#4818)
* Update acquisition channel UDF to prioritize display over paid search

* Remove migration

Will run this manually together with a backfill, self-hosted will get this for free.

* Add test

---------

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2024-11-14 16:01:34 +00:00
RobertJoonas
b42ab94a14
Make BreakdownModal dimension column use up all remaining width (#4809) 2024-11-14 14:16:33 +00:00
Uku Taht
cf4ba664ed
Tiny source data update (#4821)
* Merge teams.microsoft.com -> Microsoft Teams

* Display favicon for Linkedin
2024-11-14 13:28:45 +00:00
hq1
0d6bec1bbe
Switch sites creation to read teams schemas (#4823)
* Expose site limit, usage, ensure_can_add_new_site via Adapter

* Print to stdout if TEST_READ_TEAM_SCHEMAS is enabled

* Add factory wrappers for remaining subscription types

* Ensure consistent ordering when fetching latest subscription

* Switch creating new site to read team schemas

* Dedup code based on read team schemas switching

* Switch to transitional factory where necessary

* Update yet another test requiring transitional factory
2024-11-14 11:03:10 +00:00
Adrian Gruntkowski
9b6961ce9b
Try to make ingest lock timeout tests less flaky (#4628) 2024-11-13 12:49:08 +00:00
hq1
86b3bf4f24
Set guest_invitations.invitation_id not null (#4812)
Once https://github.com/plausible/analytics/pull/4811/files
is migrated.
2024-11-13 12:48:55 +00:00
Adrian Gruntkowski
74dcd3d29b
Switch listing team members view to read from Teams schemas (#4802)
* Modify test utils to use teams test factories

* Implement alternative routes for updating and removing membership

* Implement teams read adapter for listing site members and invitees

* Use new teams read adapter for Settings > People view

* Add `invitation_id` column to `guest_invitations` schema

* Add `invitation_id` to `GuestInvitation` schema and populate it

* Sync guest invitation's invitation ID instead of team invitation

* Expose guest invitation's invitation ID in sites list

* Sync guest invitation invitation ID instead of team invitation in backfill

* Update team consistency check to account for guest invitation IDs

* Remove workaround for no invitation ID on guest invitation in `list_people`

* Test listing pending invitations

* Test listing memberships

* Format

* Test membership changes via new routes

* Remove old membership altering routes

* Clean up

* Revert "Modify test utils to use teams test factories"

This reverts commit 5eb8754782.

* Ensure test setup provisions teams for people listing

* See if we can avoid exposing user id

* Revert "See if we can avoid exposing user id"

This reverts commit 672429b9d1.

* Fix faulty member label in people list

* Fix sites listing for a case of pending invite with existing pin

---------

Co-authored-by: hq1 <hq@mtod.org>
2024-11-13 12:32:57 +00:00
Adrian Gruntkowski
c932a25fd6
Fix team sync on ownership transfer removal (#4813) 2024-11-12 15:08:42 +00:00
hq1
7cf61c9590
Add invitation_id column to guest_invitations schema (#4811)
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-11-12 14:27:13 +00:00
Karl-Aksel Puulmann
3809ebf4ba
Channels: Read from new column, don't write (#4800)
* Read and write channels from `acquisition_channel` column

* Update csv tests
2024-11-12 12:30:11 +00:00
Adrian Gruntkowski
9004a02f30
Set NOT NULL on teams.allow_next_upgrade_override (#4807) 2024-11-12 10:04:30 +00:00
hq1
fbafa9534f
Set default: false on allow_next_upgrade_override in Team and User scheams (#4808)
Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-11-12 09:51:25 +00:00
Adrian Gruntkowski
e31aeff721
Set default for teams.allow_next_upgrade_override schema column (#4799) 2024-11-12 09:05:16 +00:00
Karl-Aksel Puulmann
d84fab805c
Solve noisy warnings about a negative range was inferred for Date.range/2 (#4803)
* Solve noisy warnings about `a negative range was inferred for Date.range/2`

query.now is in utc but the date range was in the querys timezone

This is visible in the pattern on the graph:

* Add tests
2024-11-12 07:50:51 +00:00
Karl-Aksel Puulmann
fc83040ec1
Channels: Run TRUNCATE with alter_sync=2 (#4804)
ON CLUSTER fails since it tries to create conflicting
dll entries on each node.

Error:
```Cannot execute replicated DDL query, maximum retries exceeded.
(UNFINISHED)```
2024-11-12 07:24:23 +00:00
Karl-Aksel Puulmann
4aa7dec301
Channels: Migration to add materialized column, backfill code (#4798)
* Channels: Migration to add column, backfill code

This change adds `acqusition_channel` columns to events_v2 and
sessions_v2 tables. These columns are materialized - we don't ingest
into them directly. Instead they're calculated based on other columns.

The data migration changes now allow to also backfill the column.

Tested the ability to change definitions by changing the function
definitions and re-running the migration with backfill. Confirmed that
the underlying data changed as expected.

* quiet option

* Exclude data migrations from validation

* Migration consistency
2024-11-12 06:41:34 +00:00
Karl-Aksel Puulmann
3759db9b8c
Channels: Fix ON CLUSTER behavior (#4801)
* Channels: Fix cluster behavior

CREATE TABLE AS SELECT syntax did not work on cluster.

Instead, let's do a normal insert. For safety and to avoid timing
issues, ensure that INSERT waits for data to be inserted on all active
replicas.

* Proper replicated tables
2024-11-11 19:59:16 +00:00
Artur Pata
b22b35793c
Saved segments/create table (#4797)
* Add migration for Saved Segments

* Remove premature optimisation

* Format

* Refactor to explicit segment type
2024-11-11 16:31:43 +00:00
Karl-Aksel Puulmann
d620432227
Channels: Speed up clickhouse calculations (#4789)
* Fix interpolation in data_migration.ex

* Speed up calculating acquisition_channel in clickhouse

The previous `has` queries proved to be problematic and causing a lot of
CPU overhead.

Benchmarked via this query:

```sql
SELECT
  channel,
  count(),
  countIf(acquisition_channel(referrer_source, utm_medium, utm_campaign, utm_source, click_id_param) = channel) AS matches
FROM events_v2
WHERE timestamp > now() - toIntervalHour(48)
GROUP BY channel
ORDER BY count() desc
```

Before this fix:
```
query_duration_ms:                                                57960
DiskReadElapsedMs:                                                374.712
RealTimeMs:                                                       2891200.667
UserTimeMs:                                                       2704024.783
SystemTimeMs:                                                     1693.265
OSCPUWaitMs:                                                      90.253
OSCPUVirtualTimeMs:                                               2705709.58
```

After this fix:
```
query_duration_ms:                                                4367
DiskReadElapsedMs:                                                454.356
RealTimeMs:                                                       213892.207
UserTimeMs:                                                       199363.485
SystemTimeMs:                                                     1479.364
OSCPUWaitMs:                                                      13.739
OSCPUVirtualTimeMs:                                               200837.37
```

Note that the new tables are not tracked in our schema as usual as
they're pretty much temporary tables to create the dictionary without
needing to upload files to clickhouse servers.

* CREATE OR REPLACE table with SELECT
2024-11-11 10:39:51 +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
ruslandoga
3af8f24d34
update mua (#4794) 2024-11-11 07:06:48 +00:00
hq1
78a95eb8fc
Extract schema transitions under delegated namespace (#4788)
* Extract schema transitions under delegated namespace

* fixup
2024-11-07 11:27:27 +00:00
Adrian Gruntkowski
799e163eef
Do not attempt preloading user on guest invitation (#4790) 2024-11-07 11:24:42 +00:00
Adrian Gruntkowski
e1cdbfb9ac
Fix team struct sync and pruning team memberships/invitations on site transfer (#4786)
* Ensure `accept_traffic_until` is set with `trial_expiry_date` for teams

* Fix pruning guest memberships and invitations during site transfer
2024-11-07 10:53:42 +00:00
dependabot[bot]
58ad39b5cc
Bump poseidon/wait-for-status-checks from 0.5.0 to 0.6.0 (#4741)
Bumps [poseidon/wait-for-status-checks](https://github.com/poseidon/wait-for-status-checks) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/poseidon/wait-for-status-checks/releases)
- [Commits](https://github.com/poseidon/wait-for-status-checks/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: poseidon/wait-for-status-checks
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-11-06 18:48:51 +00:00
dependabot[bot]
c763709588
Bump thollander/actions-comment-pull-request from 2.5.0 to 3.0.1 (#4770)
Bumps [thollander/actions-comment-pull-request](https://github.com/thollander/actions-comment-pull-request) from 2.5.0 to 3.0.1.
- [Release notes](https://github.com/thollander/actions-comment-pull-request/releases)
- [Commits](https://github.com/thollander/actions-comment-pull-request/compare/v2.5.0...v3.0.1)

---
updated-dependencies:
- dependency-name: thollander/actions-comment-pull-request
  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>
2024-11-06 18:39:44 +00:00
MorgeMoensch
fb45e64539
Add missing question mark on login page (#4783)
* Fix typo on login form to unify login and register

* Update CHANGELOG.md
2024-11-06 16:10:34 +00:00
Adrian Gruntkowski
342c3e5513
Finish moving /sites LV reads to team schemas behind FF (#4777)
* Implement user owning existing and pending sites check for teams

* Add predicate checking whether user has any existin or pending sites via teams

* Check need to upgrade for sites list via teams when FF is up

* Backfill teams for users on trial without a team

* Create team for users who register with trial started

* Replicate trial start logic on user create in team factories

* Make `ensure_can_take_ownership` in sites LV work via teams too

* Dispatch feature access check from `/sites` to Teams-schema reads

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-11-06 13:12:34 +00:00
Karl-Aksel Puulmann
eed21a0138
APIv2: Remove cruft (v2 flag, experimental_reduced_joins) (#4780)
* Remove query.v2 flag

This was originally used for making sure queries use the right table as
migrating to APIv2. This is no longer needed

* Remove experimental_reduced_joins flag
2024-11-06 12:08:20 +00:00
Karl-Aksel Puulmann
dbf7a099a3
Acquisition channels: Functions to calculate channels in clickhouse (#4701)
* Expose a few data migration functions, add quiet option to do_run

* Create functions and test acquisition channel logic in clickhouse

Tests were lifted from test/plausible_web/controllers/api/external_controller_test.exs

* Clean up test code a bit

* Property test for acquisition channels

* Handle empty strings properly in reference implementation

* Fix spelling, minor issues

* Revert "Property test for acquisition channels"

This reverts commit 3fa0e0e4eb.

* Only test clickhouse functions

* Solve minor code issue

* update channels logic

* Revert "Only test clickhouse functions"

This reverts commit e12784031a.

* Add more tests

* Add small result assertion

* Make query options explicit in data migrations

* Move multi-query running logic to within datamigration lib

* Unbreak numeric ids migration

* Named params directly to Clickhouse

* Update reference test implementation

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
2024-11-06 11:27:02 +00:00
Uku Taht
c130c2a751
Fixes for ?source and ?ref params (#4781)
* Store `?source` and `?ref` params in `utm_source` field

* Remove dead code
2024-11-06 11:12:41 +00:00
Adrian Gruntkowski
c0a8aa025c
Clean up guest invitations selectively after accepting (#4778) 2024-11-06 08:56:48 +00:00