Commit Graph

3057 Commits

Author SHA1 Message Date
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
Adrian Gruntkowski
6695f2d7a0
Fix backfilling teams for users without sites but with subscriptions (#4725) 2024-10-23 11:59:33 +00:00
Adrian Gruntkowski
7d6f10f0cb
Ensure team is present before use in sync logic (#4709)
* Ensure team is present before use in sync logic

* Ensure teams backfill works against partially assigned sites

* Associate site with team on creation

* Associate site with team on sync

* Reuse alias

* Add tests for invitation creation sync

* Move team assertions to a helper module

* Format

* Test team creation on site creation via Sites context module

* Add tests for teams sync on subscription changes

* Tag tests

* Test grace period start syncing up with teams

* Test grace period manual lock sycning w/ teams

* Test grace period end sycing up w/ teams

* Test clearing grace period sync with teams

* Update moduledoc

* Fix missing preloads and wrong result pattern matching in sync logic

* Test sync on accepting invites and site transfers

* Test sync on membership role update and member removal

* transfer async fix WIP

* Stop privisioning team in site factory

* Remove unused relationship from Site schema

* Ensure consistent parsing of `passthrough` from Paddle webhook

* Update team passthrough notification tests & logic

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-10-23 11:29:15 +00:00
Karl-Aksel Puulmann
7794ff1417
Fix bounce_rate metric causing 500s with comparisons (#4723) 2024-10-23 10:18:23 +00:00
Karl-Aksel Puulmann
296b3e53d9
Make time-on-page ungraphable (#4721)
This was marked as graphable in FE but not in BE previously. After removing the BE check,
this started throwing errors:

https://sentry.plausible.io/organizations/plausible/issues/626/?project=2&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=14d&stream_index=0
2024-10-23 09:56:47 +00:00
Karl-Aksel Puulmann
d648505a9b
Fix money values on graphs and conversions graph tooltips (#4717)
* Fix conversions graph tooltips

* Show revenue value instead of `undefined` in graph

This broke due to the unification of formatters. Not sure if this is the best fix
2024-10-22 12:43:49 +00:00
Karl-Aksel Puulmann
d727ba5ed5
Restore average/total revenue to top stats (#4716)
* Restore average/total revenue to top stats

These werent being graphed due to incorrect conditional

* prefer ternary
2024-10-22 11:47:29 +00:00
Adrian Gruntkowski
be83b7829d
Improve GA4 import error handling (#4714)
* Log warnings on HTTP GA4 import errors and add Sentry context on socket errors

* Treat socket and 5xx errors as recoverable (up for retry in ~1hr) in GA4 imports
2024-10-22 10:57:29 +00:00
Karl-Aksel Puulmann
472f4f181c
Comparisons pagination fixes (#4697)
* Add filter clauses for each main result filter

This handles the case where main query has a limit and results change. Doesnt handle metrics like percentage.

* Fix percentage calculations by ignoring breakdown-related filters in totals queries

* Refactor comparisons test suite

* Move comparisons logic to comparisons module

* New route for internal query tests

Only to be used in testing

* Support comparison queries with imports/breakdowns

* time dimension predicate extraction

* Clean up a test

* Update docstring

* Update route test

* fix a typo
2024-10-22 10:23:40 +00:00
Karl-Aksel Puulmann
aec0318c3b
Dashboard: show comparison for breakdowns (#4692)
* Comparisons: Move code to LegacyQueryBuilder

* WIP: Return comparison results to frontend

* refactor: remove useless param

* Different result format

* Pass object to metric.renderValue

* remove dead code

* Fixup response format

* Comparison in a tooltip

Not perfect at all, but a good start. Problems arise with money etc.

* Simple change arrow

* Extract metric entry to ts

* popper attempt WIP

* Slightly nicer content

* Solve warning

* Unified changeArrow in app

* Remove needless spanning

* Always set `graph_metric` in top stats.

FE already has business logic around whether a given metric is graphable

* Remove dead code

* Move Money module under dashboard utils, keep in build

* change <Metric /> definition to take in a `formatter` and store default formatters in another (typed) const

* Use standard system for formatting numbers

* Arrows only in table

* remove dead import

* Inline renderValue

* Render metric name in tooltip

* numberFormatter -> numberShortFormatter

* numberShortFormatter update

* Separate long/short formatters

* Use long vs short formatters

* Put column name into tooltip

* Slightly improved label handling for percentages, conversion rate

* Improved boundary handling in tooltip.js

* Iterate tooltips, no tooltip for - revenue

* Update top stats tests after graph_metric change

* Change revenue metrics stats API return structure

Conversion now happens earlier in query pipeline, we return float for comparison purposes

* useQueryContext in a component

* graph_metric for current visitors to fix realtime view

* No tooltips if fully - row

* renderValue as a proper function

* Simplify MetricEntry

* Use common const

* tooltip to typescript

* More explicit return structure

* metric-entry -> metric-value

* Restore some files

* ChangeArrow

* Restore MoreLink

* Fix typing in MoreLink

* <MetricValue />

* Tests for MetricValue and ChangeArrow

* details modal fixups

* re-add space between arrow and percentage

* Solve stylelint issues

* Update test

* Format

* Add flag `breakdown_comparisons_ui`

* reformat

* Remove no change icon, better alignment

* Revert "Remove no change icon, better alignment"

This reverts commit a8d62b6383.

* number-formatter.ts

* numberLongFormatter refactor

* useMemo dependency

* Handle nulls/undefined in top stats

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
2024-10-22 09:02:13 +00:00
ruslandoga
0e4e614d4c
Remove eex artifact (#4712)
fixes #4710
2024-10-22 07:20:39 +00:00
Adrian Gruntkowski
3023d322d4
Limit resource usage in teams backfill data migration (#4708) 2024-10-21 08:52:07 +00:00
hq1
4bb8b44cad
Fix docs URL slug (#4707) 2024-10-21 08:27:34 +00:00
Adrian Gruntkowski
076d7509e6
Fix with_teams (#4706) 2024-10-21 08:11:49 +00:00
Adrian Gruntkowski
17b12ddaeb
Implement basics of Teams (#4658)
* Extend schemas with new fields and relationships for teams

* Implement listing sites and sites with invitations with teams

* Implement creating invitations with teams

* Implement accepting invites with teams

* Add `Teams.SiteTransfer` schema

* Implement creating ownership transfers

* Implement accepting site transfer between teams

* Make results shapes from `Teams.Memberships` role functions more consistent

* Remove :team relation from ApiKey schema

* Pass and provision team on subscription creation

* Pass and provision team on enterprise plan creation

* Implement creating site for a team

* Keep team in sync during legacy ownership transfer and invitations

* Resolve conflict in `Teams.get_or_create` without transaction

* Abstract `GracePeriod` manipulation behind `Plausible.Users`

* Put `User.start_trial` behind `Plausible.Users` API

* Sync team fields on user update, if team exists

* Sync cleaning invitations, updating and removing members

* Transfer invitations too

* Implement backfill script

* Allow separate pg repo for backfill script

* Rollback purposefully at the end

* Update backfill script with parallel processing

* Use `IS DISTINCT FROM` when comparing nullable fields

* Handle no teams to backfill case gracefully when reporting

* Parallelize guest memberships backfill

* Remove transaction wrapping and query timeouts

* Make team sync check more granular and fix formatting

* Wrap single team backfill in a transatction for consistent restarts

* Make invitation and site transfer backfills preserve invitation ID

* Update migration repo config for easier dev access

* Backfill teams for users with subscriptions without sites

* Log timestamps

* Put teams sync behind a compile-time flag

* Keep timestamps in sync and fix subscriptions backfill

* Fix formatting

* Make credo happy

* Don't `use Plausible.Migration` to avoid dialyzer complaining

None of the tooling from there is used anywhere and `@repo` can
be defined directly in the migration script.

* Drop SSL workarounds in the backfill script

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-10-21 07:35:23 +00:00
Adrian Gruntkowski
1e38bd8771
Add fields and tables for teams (#4696)
* Add migration adding team related tables and fields

* Add `team_site_transfers` table to the teams migration

* Remove team_id FK from api_keys table

* Change new FK constraints on existing tables to `nilify_all` on delete

* Ensure unique indexes on invitation_id and transfer_id fields
2024-10-17 11:28:56 +00:00
ruslandoga
7a91ff1f5a
Use anchor tags in email templates (#4690)
* replace styled_link and unstyled_link components with plan anchor tag in email templates

* format

* change formatting for better whitespace

* use phx-no-format on bad anchor
2024-10-17 06:48:26 +00:00
hq1
7458d729ed
Allow me deletions with enterprise plans test (#4685)
* Add test for user deletion with enterprise plan attached

* Format
2024-10-16 09:01:38 +00:00
hq1
4188b79217
Fix form field name disabling 2FA (#4688) 2024-10-16 08:56:35 +00:00
hq1
67e35fa1d2
Migration: cascade delete enterprise plans on user removal (#4684) 2024-10-16 08:43:16 +00:00
ruslandoga
69949e9a16
Remove bracket from welcome email (#4686)
* remove bracket from welcome email

* remove another bracket from welcome email
2024-10-16 07:53:44 +00:00
ruslandoga
ff3ee1ca3b
Improve boolean environment variables reading (#4632)
* improve bool env var reading

* add yes/no and tests
2024-10-16 07:11:53 +00:00
ruslandoga
509dde7edf
rm Timex.before? and Timex.after? (#4552) 2024-10-16 07:11:10 +00:00
Adrian Gruntkowski
f9477c7ff4
Properly interpolate site name in site setup success email (#4681) 2024-10-15 13:45:01 +00:00
Karl-Aksel Puulmann
82b60365a1
fix(revenue): Fix selecting and graphing revenue goals with comparisons (#4680)
* Support graphing revenue goals in dashboard again

This has been broken since the introduction of display names

* Support graphing revenue metrics timeseries with comparisons

This was previously broken with an ArithmeticError and didn't have any coverage.

Related sentry report: https://sentry.plausible.io/organizations/plausible/issues/560/?project=2&query=is%3Aunresolved+issue.priority%3A%5Bhigh%2C+medium%5D&referrer=issue-stream&statsPeriod=14d&stream_index=1

* Simplify

* NPM test update

* Update goals test
2024-10-15 08:33:38 +00:00
Artur Pata
80fa21a865
Remove duplication related to nav menu (#4666) 2024-10-15 08:13:07 +00:00
hq1
023e2041fb
Set root domain (none) for ingests without hostname (#4678)
* Set root domain `(none)` for ingests without hostname

* No `nil` hostname should be allowed to enter ingestion

* Invoke `sanitize_hostname` only when applicable
2024-10-15 07:06:30 +00:00
hq1
0099164cdc
Add explicit order by to a flaky test (#4679)
otherwise it falls back to `visitors` descending,
which AFAIU is 2 for both metrics leading to random
order effectively.
2024-10-15 05:42:00 +00:00
hq1
70997abfc7
Reduce Phoenix.HTML usage (#4675)
* Turn .eex templates into .heex

* Add new compile-time presets to `PlausibleWeb`

* Fix remaining templates

* Update static components

* Update live components

* Update live views

* Update rest of the owl

* Update mjml template

* Format

* Format

* Revert MJML stuff, it's coupled with EEx

* yawn at test

* Get rid of `FormHelpers` module

* Ensure YOU label shows up first on IP rules list

* Update lib/plausible_web/templates/email/welcome_email.html.heex

Co-authored-by: Artur Pata <artur.pata@gmail.com>

* Fix create site email link

* Fix server error markup (and turn thanks into heex)

* Format

---------

Co-authored-by: Artur Pata <artur.pata@gmail.com>
2024-10-15 03:55:14 +00:00
Cenk Kücük
9de6d3d5fc
add monitoring for websocket endpoint (#4676) 2024-10-14 16:57:43 +01:00
RobertJoonas
af94f01310
Fix experimental pageleaves script (SPAs) (#4667)
* bugfix: make sure to send pageleave with current URL

* another bugfix: avoid triggering pageleaves in SPAs unless listeningPageLeave is true

* revert behavioural change in manual extension

* test manual script extension
2024-10-14 09:34:47 +00:00
Cenk Kücük
0c40042d8e
Update Clickhouse version in CI (#4617)
* Update Clickhouse version in CI

* update order

* Update clickhouse image

* Update Makefile
2024-10-11 00:13:59 +01:00
Karl-Aksel Puulmann
141eea88ff
APIv2: Revenue metrics (#4659)
* WIP: Start refactoring revenue metrics

* Hacks to make things work

* Remove old revenue code, remove revenue metrics if needed

* Update query_optimizer docs

* Minor fixes

* Add tests around average/total revenue when non-revenue goal filtering going on

* Optimize, calculate filters as expected (OR-ing clauses)

* Revenue: Handle cases where revenue metrics should not be returned or nil

* Expose revenue metrics in internal schema, add tests

* Docstring

* Remove TODO

* Typegen

* Solve warnings

* Remove nesting

* ce_test fix

* Tag tests as ee_only

* Fix: When filtering by revenue goal and no conversions, return 0.0 instead of nil

* More straight-forward preloading logic
2024-10-09 10:18:48 +00:00
ruslandoga
5fec52ab36
Release v2.1.4 (#4660) 2024-10-09 07:45:17 +00:00
ruslandoga
f28a1b8086
Log Oban errors (and still report them to Sentry) (#4657)
* log oban errors in CE

* update changelog

* not just ce

* add comment
2024-10-08 10:26:35 +00:00
Karl-Aksel Puulmann
5ad743c8d3
APIv2: Comparisons for breakdowns, timeseries, time_on_page (#4647)
* Refactor comparisons to a new options format

Prerequisite for APIv2 comparison work

* Experiment with default include deduplication

* WIP

Oops, breaks `include.total_rows`

* WIP

* Refactor breakdown.ex

* Pagination fix: dont paginate split subqueries

* Timeseries tests pass

* Aggregate tests use QueryExecutor

* Simplify QueryExecutor

* Handle legacy time-on-page metric in query_executor.ex

No behavioral changes

* Remove keep_requested_metrics

* Clean up imports

* Refactor aggregate.ex to be more straight-forward in output format building

* top stats: compute comparison via apiv2

* Minor cleanups

* WIP: Pipelines

* WIP: refactor for code cleanliness

* QueryExecutor to QueryRunner

* Make compilable

* Comparisons for timeseries works

Except for comparisons where comparison window is bigger than source query window

* Add special case for timeseries

* JSON schema tests for comparisons

* Test comparisons with the new API

* comparison date range parsing improvement

* Make comparisons api internal-only

* typegen

* credo

* Different schemata

* get_comparison_query

* Add comment on timeseries result format

* comparisons typegen

* Percent change for revenue metrics fix

* Use defstruct for query_runner over map

* Remove preloading atoms
2024-10-08 10:13:04 +00:00
Marko Saric
e7332d95b2
Change the "outgrown" copy (#4652)
* Update notice.ex

* Format

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-10-08 09:27:50 +00:00
RobertJoonas
799edec81c
Trigger pageviews on pages loaded from bfcache (#4656)
* trigger pageview on pageshow with event.persisted

* update _tracking.html to do the same
2024-10-08 09:11:03 +00:00
hq1
2359cb920c
Account settings w sidebar (#4654)
* Outline /settings/v2 fundamentals

* Add setting tiles stubs

* Bootstrap name change

* Bootstrap theme change

* Bootstrap security settings

* Use table component for listing sessions

* Disable current e-mail field

* Implement Danger Zone

* Deal with compilation warnings

* Implement "Subscription" section

* Implement invoices list

* Fix invoices empty state & add API keys

* Fix headings in Subscription section

* Fix API keys mobile view

* Fix subscription boxes width

* Fix formatting

* Move tests for settings WIP

* Adjust remaining tests and router placement

Include docs links in tiles, where applicable.

* Fix remaining routes and remove dead code

* Fix route in a live view where no @conn is available

* Update mobile view settings picker

* Format

* Fix subscription section headings

* Fix account e-mail on dark mode

* Delete unused template

* Fix mobile setting section picker

* Optimize Login Management tile for mobile

* Update invoices section with docs link

* Update copy

* Remove trailing dots from (sub)titles

* Fix CSV export padding for "exporting" state

* Align subscription status to the right

* Fix failing test

* Fix subscription status alignment once again

* Improve subscription mobile view a little

* Fixup test compilation 🙈

* Add extra margin to subscription status box

* Make cancel button in 2FA modals expand in mobile view

* Stats API only

* Capitalize "Current session" indicator

* Show "Show More" invoices button only when there's >12

* tiny change

* Update changelog

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
Co-authored-by: Marko Saric <34340819+metmarkosaric@users.noreply.github.com>
2024-10-08 08:30:01 +00:00
Karl-Aksel Puulmann
4224f9d187
Fix revenue metrics for custom named goals (#4653)
Since https://github.com/plausible/analytics/pull/4415, revenue metrics
have not been correctly displayed on the dashboard if the goal name has
been renamed.
2024-10-07 08:18:46 +00:00
ruslandoga
c8291639e5
default to invite_only in ce (#4616) 2024-10-04 04:29:13 +00:00
hq1
6940281d66
Settings password reset (#4649)
* Enable exceptions when revoking all user sessions

* Add `User` changeset for changing password

* Make button in `2fa_input` component optional

* Implement password change from User Settings

* Add tests

* Fix 2FA modal cancel button formatting

* Update changelog

* Don't pass redundant params to `render_settings` and clean up code a bit

* Render one error per field in password reset form

* Refactor inline form 2FA validation

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-10-03 06:39:32 +00:00
Adrian Gruntkowski
35c8010078
Improve CheckUsage query perf (#4650) 2024-10-02 15:02:35 +00:00
hq1
ec2a560016
Rework settings UI (#4626)
* Update generic components library

* Import generic components via `PlausibleWeb`

* Update Settings/Danger Zone

* Update new shared link template and convert to heex

* Update site settings layout

* Update site settings sidebar tab layout

* Update Settings/Email Reports

* Update Funnels

* Update ComboBox

* Extend/update form components

* Update Modal live component

* Update Settings/Goals

* Update Shields

* Update Settings/Props

* Update Settings/Import & Export

* Update flow progress

* Import Routes in settings

* Update Billing components

* Update Billing notice component

* Update feature toggle component

* Update 2fa component

* Update verification markup

* Update installation

* Update Settings/Integrations/Plugins

* Update domain change markup

* Update Settings/General

* Update Settings/Integrations

* Update Settings/People

* Update Settings/Integrations/GSC

* Update Settings/Visiblity

* ukuwip

* ukuwip

* Tables & paddings

* Imports exports

* Brighten disabled input text color for dark mode

* Tune down table border/divider in dark mode

* Format

* Fix goal list on mobile

* Fix IP Shields table on mobile

* Fix country shields list on mobile

* Fix country shield list on mobile

* Fix page shields list on mobile

* Fix import/export settings on mobile

* Fix combobox dropdown background in dark mode

* Fix filter bar search input on mobile

* Revert @ukutaht's changes to goal list

* Maybe maybe maybe

* Revert the current prod goal list + fix mobile issues

* Format

* Revert tests change

cc @ukutaht

* Fix markup expectation in a test

* Set autocomplete="off" again

* Bring back `text-sm` where previously removed

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
2024-10-02 09:05:21 +00:00
hq1
de04f222fd
Update con_cache (#4642) 2024-10-01 09:11:46 +00:00
dependabot[bot]
6822a4c54b
Bump phoenix_live_reload from 1.4.1 to 1.5.3 (#4551)
Bumps [phoenix_live_reload](https://github.com/phoenixframework/phoenix_live_reload) from 1.4.1 to 1.5.3.
- [Changelog](https://github.com/phoenixframework/phoenix_live_reload/blob/main/CHANGELOG.md)
- [Commits](https://github.com/phoenixframework/phoenix_live_reload/compare/v1.4.1...v1.5.3)

---
updated-dependencies:
- dependency-name: phoenix_live_reload
  dependency-type: direct:development
  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>
Co-authored-by: hq1 <hq@mtod.org>
2024-10-01 06:50:31 +00:00
ruslandoga
52437e8df0
Handle cross-device file move (#4640)
* handle cross-device file move

* don't change tests

* rm all the time

* no need to rm if rename succeeds

* don't raise in after
2024-09-30 16:16:36 +00:00
RobertJoonas
5c72de0155
Experimental pageleave events (#4624)
* add experimental pageleave script variant

* also send pageleave events on SPA navigation

* disallow goals with 'pageleave' event name

* do not count pageleaves towards the event metric

* remove duplication in test file

* do not update sessions on pageleave events

* ignore pageleaves in the current time_on_page implementation

* make pageleave events not billable

* rename function

* Prevent multiple pageleaves being sent at the same time
2024-09-30 12:52:40 +00:00
Adrian Gruntkowski
714c036757
Implement listing user sessions in user settings (#4588)
* Implement listing user sessions in user settings

* Make copy adjustments (h/t @metmarkosaric)

* Make warning button text color more consistent across user settings

* Add tests for `UserAuth.revoke_user_session/2`

* Test and improve `Auth.UserSessions`

* Test and improve controller actions

* Update CHANGELOG.md
2024-09-30 11:03:08 +00:00
Karl-Aksel Puulmann
7f361cf018
Make countries/regions/cities tooltips work (#4580)
Previously these tooltips said `Add filter: Country is undefined`
because new labels were yet to be in `query`.
2024-09-30 06:56:20 +00:00