Commit Graph

1328 Commits

Author SHA1 Message Date
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
hq1
78a95eb8fc
Extract schema transitions under delegated namespace (#4788)
* Extract schema transitions under delegated namespace

* fixup
2024-11-07 11:27:27 +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
af5eb720db
Release breakdown_comparisons_ui flag (#4774) 2024-11-05 09:13:22 +00:00
ruslandoga
40f28ed151
rm Timex.diff/3 (#4695) 2024-11-04 09:18:04 +00:00
Artur Pata
13ad279820
Add second line for Filters (if saved_segments enabled) (#4729) 2024-11-04 08:22:48 +00:00
Adrian Gruntkowski
7ff1a16ae3
Fix sites list for needs to upgrade condition check (#4758) 2024-10-31 09:20:29 +00:00
Adrian Gruntkowski
fc92ed5018
Switch Sites.list[_with_invitations] to use teams schemas (#4747)
* Simplify "needs_to_upgrade" check in Sites LV

* Use new schema for listing sites (WIP)

* wip: trying to filter out redundant site entries

* Move site listing logic around and continue fixing tests

* Fix Plausible.SiteTest

Expectations in some tests were adjusted. For instance,
we do not show invitations for sites where user is already
a member or owner.

* 1st stab at high-level factories covering old/new models

* Switch live /sites tests to transitional factories

* Improve prosthetics and make the remaining /sites tests pass

* Put new sites list logic behind a feature flag

* Fix listing pinned sites

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2024-10-31 08:53:02 +00:00
Uku Taht
c3a06caa97
Channel and source data updates (#4599)
* Channel and source data updates

* Update source mappings for migration

* Fix codespell

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

* Update lib/plausible/ingestion/acquisition.ex

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

* Standardize access to utm params

* Add wikipedia as "known" source

* Move custom sources to json file

* Add some advertising utm_sources

* Move source mapping logic to refinspector file

* Rename PlausibleWeb.RefInspector -> Plausible.Ingestion.Source

* Move mapping overrides to custom_sources.json

* More robust detection of paid sources

* Add missing utm_sources to migration

* Codespell

* Add moduledoc for Plausible.Ingestion.Source

* Fix dialyzer

* Remove migration

* Add more custom favicons

* Re-generate referrer favicons file

* Add doctest for sources

---------

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
2024-10-30 13:41:51 +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
hq1
8bd32b68c9
Bring back premium feature notices in tiles (#4742)
* Lost tapes: bring back premium feature notices in tiles

* Ensure that e-mail CTA is only presented to business/enterprise customers

* Format

* Fix typespecs

* Add t() type to EnterprisePlan

* Reduce Plan.t() definition

Found no reason for it to be there.
2024-10-28 09:07:18 +00:00
Adrian Gruntkowski
2ec9e32557
Extend team consistency checks and improve syncing team and memberships (#4735)
* Extend team consistency checks

* Sync team against user right after creating the site

* Prune orphaned team guest memberships and invitations on site removal
2024-10-24 13:38:58 +00:00
hq1
1234cbf2c1
Enable teams sync (#4726) 2024-10-23 12:25:46 +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
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
hq1
4bb8b44cad
Fix docs URL slug (#4707) 2024-10-21 08:27:34 +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
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
4188b79217
Fix form field name disabling 2FA (#4688) 2024-10-16 08:56:35 +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
Adrian Gruntkowski
f9477c7ff4
Properly interpolate site name in site setup success email (#4681) 2024-10-15 13:45:01 +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
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
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
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
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
Artur Pata
cac4ad20c9
Allow configuring AuthorizeSiteAccess plug site param (#4597)
* Stop typescript command clearing previous server start output in dev

* Allow auth site access plug to specify that domain is found in request body at some key

* Fix init order

* Make domain retrieval part of the role pipeline

* Add tests

* Refactor how is_binary is applied in get_domain/2

* Make plug tests rely on dedicated test routes for more stability

* Consistently treat empty `allowed_roles` list as permitting all roles

* Fix async test param, add extra case for init

* Make `DocsQueryTest` async again

* Improve a bit and document plug configuration

* Make docs more legible when viewed from source directly

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-26 09:52:45 +00:00
Adrian Gruntkowski
2d7943aec8
Use :domain uniformly for all routes instead of :website (#4598)
* Replace :website with :domain in routes uniformly

* Remove support for :website parameter from `AuthorizeSiteAccess` plug
2024-09-26 08:20:35 +00:00
ruslandoga
356f50e9c8
Change cookie key in CE (#4621)
* use default sessions options in ce

* there is no RuntimeSessionAdapter anymore
2024-09-26 07:43:47 +00:00
ruslandoga
0094e8a20f
rm unnecessary reject (#4615) 2024-09-24 18:50:53 +00:00
ruslandoga
71fa38709f
skip verification in ce (#4604) 2024-09-23 12:17:32 +00:00
ruslandoga
1b912240e3
fix link (#4605) 2024-09-23 09:39:06 +00:00
ruslandoga
5766478887
don't render empty list element in ce (#4596) 2024-09-19 07:11:02 +00:00
Artur Pata
59c7ce2ef1
Fix auth issue with POST /api/docs/query (#4593) 2024-09-18 15:46:05 +00:00
Uku Taht
7a77ebf9bf
Add feature-flagged channels UI (#4585)
* Add feature-flagged channels UI

* Implement channels modal

* Channel -> Channels tab
2024-09-18 08:34:12 +00:00
Adrian Gruntkowski
6769ebdc24
Refactor AuthorizeSiteAccess (#4583)
* Refactor and fix `AuthorizeSiteAccess` plug shared link case handling

* Make plug module name more consistent

* Add moduledoc

* Add regression test for shared link auth case

* Adjust failing case test to account for different response

* Further restrict accepted input and configuration

* Extend plug-specific tests

* Tag EE-only test properly

* Remove one DB roundtrip from AuthorizeSiteAccess

* Improve naming slightly

* Filter shared link by site ID on query level already

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
2024-09-17 12:52:20 +00:00
Adrian Gruntkowski
f7bbbf8c33
Remove support for legacy user sessions (#4540)
* Remove support for legacy user sessions

* Implement revoking all sessions for a given user

* Revoke all user sessions on password reset

* Add tests for revoking all user sessions on password reset

* Reload page when dashboard API request fails with 404

* Revert "Reload page when dashboard API request fails with 404"

This reverts commit 77d1a1035658915f9afe538afc5fb9a3da0ec905.
2024-09-17 07:31:41 +00:00
Marko Saric
68e03c2112
Update to the copy (#4558)
* Update to the copy

Update to the copy to include a note about billable pageviews. hopefully it doesn't make the copy too long...

* Don't show tooltip on small/mobile screens

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2024-09-16 13:50:36 +00:00
ruslandoga
e9ced986ce
prepare for wiki (#4512) 2024-09-13 11:32:39 +00: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
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