Commit Graph

1540 Commits

Author SHA1 Message Date
Artur Pata 6a9fe4573c
Script v2: Rate limit tech detection (#5701)
* Rate limit tech detection

* Add tests

* Fix tests

* Unify rate limit key format

* Move capture log to tags
2025-09-08 11:14:07 +00:00
Karl-Aksel Puulmann db448d7404
Stats: Rebuild session smearing for timeseries (#5694)
* Refactor table_decider#partition_metrics

* Refactor query pipeline to return a list of subqueries after splitting

* Move order_by out of join logic

* Refactor joining logic in query_builder

1. JOIN type is now set in QueryOptimizer
2. JOIN logic is now table and list-size agnostic

* Comment an edge case

* Rebuild session/visit smearing

Previously, whenever graphing any visit metric hourly/realtime, visit_duration and other
visit metrics would be way higher than expected, due to long sessions
dragging each bucket up and up. Now visits/visitors metrics are still
smeared and other visit metrics are counted under last bucket user was
active in.

visits metric was also overcounted (see new tests).

* Remove unneeded case

* Unit test for smearing in tabledecider
2025-09-08 06:21:12 +00:00
Karl-Aksel Puulmann 6216ade4ee
Trim comparisons for year/month (#5702) 2025-09-04 10:28:04 +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
Artur Pata 88fccb6972
Script v2: Show "Plausible not detected" errors with installation type specific recommendations (#5693)
* Show Plausible not detected errors with installation type specific recommendations

* Update diagnostics and diagnostics tests for verification

* Format

* Stop calling statuses between 200..299 as errors

* Remove function that populates diagnostics randomly
2025-09-04 06:24:37 +00:00
RobertJoonas 110f97d442
CE: Fix v2 onboarding, review installation, and domain change flows (#5692)
* fix seeds.exs for CE

* unified FF function

* remove gtm tab on ce

* CE change domain flow: remove detection logic

* CE installationv2 (review & provisioning flows) + tests

* change domain tests

* fix tests

* FF for user too

* small improvements (review comments)

* keep the CE and EE versions of the same function together
2025-09-03 17:22:18 +00:00
Adrian Gruntkowski 40ff36a4fb
Implement dedicated persistence service (#5653)
* Implement a very crude HTTP relay to persistor service

* Temporarily disable local session and event persistence

* Temporarily disable Promex in dev

* Setup dedicated Finch pool for persistor

* Temporarily adjust load script parameters

* Fiddle with pool opts

* Only log errors

* Bump rate

* Put persistor configuration in runtime config

* Move persistor client code to a separate module

* Move event and session persistence behind a switchable adapter

* Add scaffolding of relaying persistor

* Instrument relayed persistence

* Adjust persistor API to accept full ingest event

* Fix persistor URL in config defaults

* Switch local dev env of embedded_with_relay backend

* Revert "Temporarily disable Promex in dev"

This reverts commit d9c9e9075d130cc5177a2a7559b98a2026077327.

* Lower default `PERSISTOR_COUNT`

* Refactor payload encoding and decoding slightly

* Test and slightly improve persistor logic
2025-09-01 09:13:41 +00:00
Artur Pata af06df806b
Script v2: Verifier accepts cookies (#5669)
* Accept cookies (WIP)

* Make resolving Plausible function call a priority

* Update tracker script version

* Remove cookieBannerLikely, replace with debug-only cookiesConsentResult

* Use compact rules

* Make verifier tests less flaky

* Add fixtures for accepting cookies

* Limit CMPs

* Fix dep position
2025-09-01 05:54:19 +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
Adrian Gruntkowski 70c9a55bf8
Add custom props to full export (#5666)
* Add custom props to full export

* Pass full `site` struct to `export_queries`

* Export only internal props if plan lacks custom props

* Add changelog entry

* Add spot check test for custom props

* Do not generate cartesian product of prop/value pairs 🤦
2025-08-28 13:13:01 +00:00
RobertJoonas 4548e3acc5
Verification: new interpretation case for non-200 page responses (#5683)
* allow http scheme in verification url

* skip dns lookups on localhost URLs in dev env

* handle non-200 page responses

* fix test

* Update lib/plausible/installation_support/verification/diagnostics.ex

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

* shorten_url fn

* remove dot

* fix assertions

---------

Co-authored-by: Artur Pata <artur.pata@gmail.com>
2025-08-28 11:54:03 +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
Adrian Gruntkowski f94aebc00b
Make "last N months" return date ranges consistent with "last N days" (#5677)
* Make "last N months" return date ranges consistent with "last N days"

* Make goal suggestions not rely on predefined period

* Use native `Date` API for calculating beginning and end of months
2025-08-28 09:10:49 +00:00
Adrian Gruntkowski eed90a343e
Refactor free billing features logic (#5682) 2025-08-27 17:29:05 +00:00
Adam Rutkowski b48463ca65
CRM: Expose Team SSO Policy (#5681)
* CRM: Expose Team SSO Policy

* Flip ordering for audit log entries
2025-08-27 12:20:27 +00:00
RobertJoonas c3af79a115
Verification v2: Better Browserless error handling + verify custom URL option (#5673)
* interpret browserless network errors better

* refactor: split verification component render fn

* Custom URL input + render attempted URL in error message

* move socket assign around

* add tests

* drop redundant else branch + guard

* socket assigns out of launch_delayed

* template strings and define error structs at compile time

* typo in test comment

* fix function args
2025-08-27 11:25:47 +00:00
Adrian Gruntkowski a2c863b2cc
Ignore `visit:channel` when transforming filters for GSC (#5678) 2025-08-27 11:08:15 +00:00
Adam Rutkowski 69206475f9
Instrument missing mock to mute expectation error (#5675)
* Instrument missing mock to mute expectation error

* Format
2025-08-27 05:57:42 +00:00
Adam Rutkowski ecfea36bd9
Avoid slowdowns in tests due to code server waits (#5674)
This is supposed to be taken care of
by d05731194e
but not quite it seems.

The first test with a fairly involved exunit template
(ConnCase) is usually 700ms vs 60ms whichever comes second.
(48-core Threadripper, but similar results on macs AFAIU).
This makes --trace / --slowest flags produce misleading results.

h/t @zoldar
2025-08-27 05:42:49 +00:00
Adrian Gruntkowski 0c9d42daf3
Handle team policy update on empty default struct gracefully (#5671)
* Reproduce policy update error

* Fix `update_policy` and `force_sso` to handle default empty value gracefully
2025-08-26 09:49:55 +00:00
Adam Rutkowski a5a71f7828
CRM: Expose 2FA user status & allow CS to force disable it (#5670)
* CRM: Expose 2FA user status & allow CS to force disable it

* !fixup
2025-08-26 08:01:24 +00:00
Karl-Aksel Puulmann 619a9ed57b
ScriptV2: Use async instead of defer, new snippet (#5655)
* async -> defer

* Run legacy tests using async instead of defer
2025-08-25 07:12:11 +00:00
Karl-Aksel Puulmann b36a92fb45
ScriptV2: snippet structure change (#5662)
* Remove dead code

* Use a new snippet style

* Allow plausible to be on window
2025-08-25 05:35:06 +00:00
Karl-Aksel Puulmann bcf8b422e1
ScriptV2: Domain change refinement (#5657)
* Improve "back to settings" button

* Dark mode support for change domain

* Purge CDN cache on domain change

* Allow npm installation_type

* Detect npm installation type in detector

* Support npm installation type in onboarding

* Show warning in change domain flow for npm

* Make CE tests happy

* Cleanup

* npm_likely -> npm

* Cleanup
2025-08-21 09:25:39 +00:00
RobertJoonas a3d8226705
fix CE warning in tests (#5661) 2025-08-20 15:30:00 +00:00
Adam Rutkowski 3a720b5d60
Keep google auth deletions idempotent (#5656) 2025-08-20 08:11:02 +00:00
Adam Rutkowski ac739da694
Mute automated login attempts (#5658) 2025-08-20 07:52:50 +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
Artur Pata 276f95cda2
Script v2: Make detection take less time (#5635)
* Add fast failing dns check to verification

* Convert Detection to a checks pipeline

* Convert detection to checks pipeline

* Unify browserless checks, set retry policy, timeouts

* Fix spelling

* Update change domain v2

* Fix issue with handling errors with detection

* Include timeoutMs in detector function args

* Allow saving npm installation type (#5639)

* small code style/comment improvements

---------

Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2025-08-19 10:16:27 +00:00
RobertJoonas 17675af4d0
Clean up old upgrade page (dead code) (#5652)
* remove deprecated modules/fns

* get rid of starter_tier flag

* remove legacy? arg from plans
2025-08-19 09:12:48 +00:00
Adam Rutkowski e3bef74cde
Preserve query params for authenticated shared links (#5640) 2025-08-18 13:44:34 +00:00
Karl-Aksel Puulmann 6a6a195812
CE-friendly tracker_url support (#5643) 2025-08-18 09:02:08 +00:00
Adam Rutkowski 1d135d4a74
Exclude pages already added in page shields suggestions (#5637) 2025-08-13 10:02:49 +00:00
Uku Taht a32e9ee53d
Change domain 2-step flow (#5630)
* Make change-domain-v2 a two-step process

* Cleanup

* Make change domain a 2-step process

* Refactor installationv2 tests to use render_async

* Increase timeout in render_async

* Refactor to please credo

* Also increase timeout for render_async in installationv2 tests
2025-08-13 09:50:16 +00:00
Adam Rutkowski b786fba147
Include "Direct / None" in source filter suggestions (#5636)
* Include "Direct / None" in source filter suggestions

* Refactor
2025-08-13 08:52:39 +00:00
Adam Rutkowski c0abbe6432
Only display "Invoices" on sidebar when subscription is present (#5634)
* Only display "Invoices" on sidebar when subscription is present

* Add a note per @macobo's request

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

---------

Co-authored-by: Karl-Aksel Puulmann <macobo@users.noreply.github.com>
2025-08-13 08:50:43 +00:00
Adam Rutkowski 4c89ffc263
CRM: Bring back site/member counters in Team tabs; revert search results changes (#5633)
* CRM: Bring back site/member counters in Team tabs

* Test `unlimited` display

* Tweak how search results are displayed

* Format
2025-08-13 06:41:37 +00:00
Artur Pata 4b0fa1f1af
Remove fallbacks for /js/s-... urls (#5629) 2025-08-13 05:41:47 +00:00
Artur Pata a2df9a986c
Script v2: Add more diagnostics cases to verifier v2, more tests for verifier v2 (#5620)
* Add more diagnostics cases to verifier v2, more tests for verifier v2

* Remove extraneous text from CSP in tests
2025-08-11 10:43:59 +00:00
Artur Pata 70eb552132
Script v2: Include prefix "pa-" in tracker_script_config.id (#5621)
* Refactor tracker config IDs to contain prefix 'pa-' in the DB

* Test

* Add NanoidBase behaviour

* Refactor to case

* Verify that only the ID changes

* Fix broken if block, add test
2025-08-11 09:44:24 +00:00
Uku Taht e52bbb5bb9
Create 404 goal always in onboarding (#5618) 2025-08-07 07:48:10 +00:00
Artur Pata e8ef3f83d0
Script v2: Allow changing tracker config over Sites API site endpoints (#5607)
* Support getting and setting tracker_script_config with Sites API POST/PUT/GET site endpoints

* Fix singular with

* refactor

* Fix conditionally used function

* Format

* Fix regression with should_purge_cache?

* Check feature flag

* Add user to scriptv2 flag checks
2025-08-07 06:49:54 +00:00
Adam Rutkowski ce428cda08
CRM: split into dedicated live views with per-tab components (#5611)
* Add reusable customer support components

Extract search, layout and search result components to enable
reuse across different customer support views.

* Add dedicated Team live view with modular components

Replace inline team details with dedicated live view that includes
separate components for overview, billing, members, audit, sites and SSO
functionality.

* Add dedicated User live view with components

Replace inline user details with dedicated live view including
overview and API keys components.

* Add dedicated Site live view with components

Replace inline site details with dedicated live view including
overview, people and rescue zone components.

* Add base live view helper for customer support

* Remove old monolithic live view files

Remove shared.ex, site.ex, team.ex and user.ex from the live/ directory
as they are replaced by dedicated live views.

* Update routing for dedicated customer support live views

Add specific routes for teams, users and sites instead of generic
resource routing pattern.

* Refactor main customer support live view to use components

Simplify the main live view to act as a router, using shared search
and layout components instead of handling all resource types inline.

* Update customer support resource modules

Adjust resource modules to work with the new dedicated live view
layout instead of inline rendering.

* Update HelpScout integration and endpoint configuration

Adjust HelpScout module and endpoint settings to support the
new customer support interface layout.

* Update customer support tests for new module layout

Adjust tests to work with dedicated live views instead of
inline resource rendering.

* Format

* Clean up URI building & module headers

* Test site deletion

* Test user deletions

* Test team deletions

* Include "Go back" links in the common layout

* Remove debugging artifact 😅

* Remove old route remnant

* Remove unused code - there was an attempt

* Remove cruft as per @zoldar's comments

* Fix moduledoc

* Abstract away flashes/redirect messages sending

* Format

* Simplify CRM resource commons

* Update moduledoc

* Clean up remaining raw URIs in favour of route helpers

* Revert header.html.heex change to stop complaints on MIX_ENV=ce_dev

* Update test to work with both CE/EE

* Prevent test m/f unavailable errors on ce build
2025-08-06 15:49:51 +00:00
Uku Taht 00f24bfcd6
Use new Detection module in installation screen (#5604)
* Use new Detection module in installationv2

* Update tests

* Simplify mount function
2025-08-04 13:42:51 +00:00
Marko Saric 797a5bf4c1
clarifying the suggested plan (#5598)
* clarifying the suggested plan

* Update over_limit.html.heex

* Update dashboard_locked.html.heex

* fix tests

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
2025-07-29 07:33:22 +00:00
Adam Rutkowski 1e54949241
CRM Audit browser: implement basic pagination (#5592)
* CRM Audit browser: implement basic pagination

* Make ESC close audit entry details
2025-07-28 07:55:58 +00:00
Adam Rutkowski 01e801942e
Don't crash audit browser with weak user association missing (#5589)
* Don't crash audit browser with weak user association missing

* Use N/A to indicate failed lookups
2025-07-23 19:42:30 +00:00
Adam Rutkowski afbc350b8d
CRM: implement basic SSO audit browser (#5586)
* Allow storing audit entry "change" raw

* Modify audit test helpers so they return actual audit entries

* Accept optional `rows` in input textarea component

* Instrument SAML consumption with audit entries

* :nail-care: EE-only modules don't need `on_ee`

* Derive audit encoder for SSO Identity

* Implement Audit tab in CRM

* Fix typo

* Instrument domain removal with audit entries

* Preload `sso_integration` for domain removal

* Use two else clauses for SAML consume errors
2025-07-23 16:45:33 +00:00
Adrian Gruntkowski 144b58e508
Put SSO among plan features, replacing "Technical onboarding" (#5587) 2025-07-23 11:07:04 +00:00
RobertJoonas dffb698fa2
Change log level from info to notice on relevant logs (#5585)
* change log level from info to notice on relevant logs

* bump log level to notice for everything except request logger

* format

* fix choose_plan_test.exs for good (starter tier launch)
2025-07-23 08:47:01 +00:00
Adrian Gruntkowski 5d71ab9234
Implement CTA for SSO (#5582) 2025-07-22 11:31:54 +00:00
Adam Rutkowski adf39ca7a8
Audit trail for SSO (#5560)
* 

* wip

* wip

* Moduledoc false

* wip

* Update extra/lib/plausible/auth/sso/saml_config.ex

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Include only data keys present in changes

* Improve audit logging for SSO domain verification

Make it more compact and hopefully more readable to CS

* Harden existing tests

* Use consistent naming

* Update audit entries migration: use UUIDs for primary keys

* Fix up tests

* Format

* Only test audit for EE

* Remove temporary String.Chars implementation

* Always log keys as per `derive` directive; include changes for inserts

* Write `actor_type` to audit entries

* Extract Audit.Repo functions

* Moduledocs

* Include change in audited deletions

* Make audit available only in EE build

A bit clunky? cc @zoldar

* Put test behind ee compilation flag

* Pin user e-mail in test

* Ensure encoder opts are passed for nested calls

* Carry `__allow_not_loaded__` even if no extractor defined

* Turn `actor_type` into an ecto enum type

* Remove unused function

* s/sso_forced/sso_force_mode_changed

* Unwrap single item list for protocol implementation

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Migration: audit entries (#5581)

* Migration: audit entries

* Put migration behind EE conditional

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2025-07-22 10:53:24 +00:00
RobertJoonas 9be0b71233
Add `window.plausible` to NPM + `window.plausible.v2` (#5580)
* setWindowFlag

* bindToWindow

* set window.plausiuble.v2 flag

* chore: Bump tracker_script_version to 24

* fix billing test

* tracker changlog

* Update tracker/test/plausible-npm.spec.js

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

* update npm tracker changelog

* flattened window.plausible fields with more info

* remove unused function + readme update

---------

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
Co-authored-by: RobertJoonas <RobertJoonas@users.noreply.github.com>
Co-authored-by: Artur Pata <artur.pata@gmail.com>
2025-07-22 10:06:46 +00:00
Adrian Gruntkowski a3c4d06fce
Use integration from identity during verification (#5578)
* Pass integration ID from SAML session in trusted identity struct

* Use integration from identity during verification
2025-07-21 15:26:37 +00:00
Adrian Gruntkowski 08b4b0be07
Update plan calculator to account for SSO (#5577)
* Update plan calculator to account for SSO

* Adjust team member pricing in calculator

* Fix test
2025-07-21 10:05:07 +00:00
Adrian Gruntkowski 8da98fb26e
Safeguard sign-dependent metrics from negative values (#5569)
* Safeguard sign-dependent metrics from negative values

* Test graceful visits calculation for invalid sessions data
2025-07-17 12:45:14 +00:00
RobertJoonas e357569b91
Add "Managed Proxy" to the upgrade page under Enterprise benefits (#5574)
* add managed proxy to enterprise plan benefits

* silence logs from verification liveview tests too
2025-07-17 10:00:18 +00:00
Adrian Gruntkowski 832c767d91
Improve SSO naming and setup (#5558)
* Use 2FA (and not MFA) uniformly across messaging and code

* Parse PEM certificates without boundary markers (Okta)

* Update SAML configuration form labels

* Revise intro SSO copy slightly

* Upcase button label

* Make Single-Sign On casing consistent

* Fix formatting

* Implement rate limiting for SSO login endpoint

* Update docs links

* Update docs links

* Fix formatting
2025-07-17 08:52:53 +00:00
RobertJoonas 02eeb0aea6
silence logger warnings in tests (#5573) 2025-07-16 10:28:12 +00:00
Uku Taht b7f8ed4607
Scriptv2 - change domain (#5565)
* Add a new domain change flow when scriptv2 flag is enabled

* Use liveview for change domain flow

* Move additional steps to notice, include general info about domain change

* Format

---------

Co-authored-by: Artur Pata <artur.pata@gmail.com>
2025-07-15 14:10:45 +00:00
RobertJoonas 97dcc3fe7c
Refactor Verification module structure (#5570)
* detector.js

* refactor: organize modules better

* Renaming (Elixir + JS)

* lib/plausible/verification -> lib/plausible/installation_support
* test/plausible/verification -> test/plausible/installation_support
* priv/tracker/verifier -> priv/tracker/installation_support
* tracker/verifier -> tracker/installation_support
* tracker/test/verifier -> tracker/test/installation-support

* rename remaining test modules

* add documentation

* dialyzer: remove module refs that do not exist yet

* Fix CI

* fix tracker CI

* fix tracker CI for good
2025-07-15 10:50:34 +00:00
RobertJoonas b76996b3a4
Verification v2 (#5549)
* new verifier script with tests + telemetry

* dataDomainMismatch tests

* more tests for callbackStatus and plausibleInstalled

* create priv/verifier subfolder + fix Elixir CI

* bump CI cache version

* organize verifier tests

* Remove accidentally committed verifier

* Rework compilation: Make it a variant, always return new verifier code in tests

* Make priv/tracker/verifier/ exist

* Handle static checks with grace

* Fix paths

* Fix paths

* Add some tests

* Add one more test

* split up the JS

* proxyLikely + code structure refactor + unit tests

* fix telemetry fields

* move most telemetry to logs

* run verifier tests only on chromium

* detect wordpressPlugin and wordpressLikely

* detect GTM

* rename JS checks

* detect cookiebot

* include new fields in logs

* different logs for browserless request vs js failures

* detect manual extension

* detect unknown attrs + fix logging

* stick to Elixir checks for snippet detection

* fix codespell

* fix IO.inspect

* remove unnecessary fields from test mock

* cookiebot doc

* move test into verifier subfolder

* do not duplicate ts types

* comma -> semicolon in log

* test dynamically loaded snippet

* improve logging on Browserless error

---------

Co-authored-by: Karl-Aksel Puulmann <oxymaccy@gmail.com>
2025-07-14 14:32:21 +00:00
Artur Pata 3bdbe83383
Script v2: Sync event.props.path for special path-based events from event.pathname (#5559)
* Sync pathname to event.props.path for special path-based goals

* Stop adding event.props.path for 'Form: Submission' events

* Update tracker script version

* Fix test expectations

* Fix format

* Simplify maybe_put_props_path with 'with'

* Add specs, fix factory

* Update tracker changelog

* Update EE/CE changelog

* Remove business logic from factory

* Refactor event.props.path sync result to be validated with the rest of the custom props

* Clarify doctests and update function name
2025-07-14 08:39:25 +00:00
Adrian Gruntkowski 359438a899
Implement ability to leave team (#5555)
* Implement ability to leave team

* Add changelog entry

* Fix button copy

* Alter "Delete my account" button label to "Delete My Account"
2025-07-09 12:41:59 +00:00
Uku Taht 1f9457992d
Add test suite for installationv2 (#5561) 2025-07-09 08:50:06 +00:00
RobertJoonas de1ada93a9
increase trial team member limit to 10 (#5553) 2025-07-08 07:01:03 +00:00
RobertJoonas ef86d358e2
remove starter tier assertions in test (#5544) 2025-07-02 07:27:58 +00:00
Adrian Gruntkowski fc24db4281
Exclude Owner from default SSO roles and improve PEM certificate validation (#5540)
* Do not allow setting Owner as default SSO role

* Make PEM certificate validation more robust
2025-06-30 13:33:59 +00:00
Adam Rutkowski ce1bd2d4c4
CRM: allow forceful SSO domain deprovisioning + integration removal (#5539)
* CRM: allow forceful SSO domain deprovisioning + integration removal

* Refresh members whenever the tab contents might change

* Use live redirect when removing integration
2025-06-30 13:02:37 +00:00
Adam Rutkowski 528693889d
CRM: add ability to deprovision individual users (#5537)
* CRM: add ability to deprovision individual users

* Use existing user fetching interface

* Remove unused table column

* Deprovision with proper refresh afterwards
2025-06-30 08:40:17 +00:00
Karl-Aksel Puulmann dd812f48ba
ScriptV2: Remove hashBasedRouting from server-interpolated config (#5532)
New onboarding _does not_ have a checkbox for hash based routing, so remove it from server-interpolated config
2025-06-26 10:01:25 +00:00
Adam Rutkowski 8ef02c0a4d
CRM: New default site limit: 10; remove growth estimation (#5533) 2025-06-26 09:46:31 +00:00
Adam Rutkowski 3068abd211
CRM: edit enterprise plan (#5528)
* CRM: allow custom plan editing

* Use standard edit button

* Update extra/lib/plausible_web/live/customer_support/live/team.ex

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2025-06-26 09:21:39 +00:00
Adrian Gruntkowski 39656f782c
Implement listing and revoking of SSO sessions from team settings (#5529)
* Refactor and unify logic for account and site settings sidebars

* Implement listing and revoking of SSO sessions from team settings
2025-06-26 08:48:25 +00:00
RobertJoonas 6369d0efad
Dogfood script v2 (#5504)
* dogfood with script v2 + disable tracking in tests

* remove endpoint override

* disable dogfood tracking on localhost

* track pageviews from details views and filter modals
2025-06-25 10:56:02 +00:00
Adrian Gruntkowski 7490828e71
Implement automatic re-login on SSO session expiration (#5525)
* Implement automatic re-login on SSO session expiration

* Adjust allowed range of `sso_session_timeout_minutes` in team policy

* Test autosubmit rendering

* Test `UserSessions.get_by_token/1`

* Test expired session case for `AuthPlug`

* Test `UserAuth.get_user_session` case for expired session

* Test `HandleExpiredSession` plug
2025-06-25 09:41:47 +00:00
Adam Rutkowski ef11425693
Calmer multiple teams experience (#5526)
* Offer team switcher on /sites if applicable

- in case of empty My Personal Sites view, and with
  another team with sites being available
- redirect straight to first team upon invoking team
  switcher, if there's only one available
- redirect to /sites from team switcher, if there
  are no set-up teams available

* Remove unused test helper

* Store and use last team identifier

* Remove alert about starting trial when adding first site

* Format

* Update lib/plausible_web/live/sites.ex

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2025-06-24 16:11:27 +00:00
Adrian Gruntkowski cf34850a13
Add "SSO" billing plan feature and hide SSO setup behind it (#5524)
* Add SSO plan feature

* Gate SSO configuration with plan feature

* Don't preselect SSO feature when creating new custom plan
2025-06-24 11:51:32 +00:00
Adrian Gruntkowski 307d6b004b
Implement plug for checking SSO team access (#5522)
* Implement plug for checking SSO team access

* Add the new plug to the `browser` pipeline and adjust routes

* Don't log in on failed provisioning and display issue notice instead

* Require user to be provisioned as SSO before toggling "Force SSO"

* Label SSO members explicitly in team management LV

* Make slight layout and copy adjustments in provision issue view

* Improve copy (h/t @aerosol)
2025-06-24 08:25:24 +00:00
Adam Rutkowski e56baeb272
Persist login type preference (SSO/standard) (#5520)
* First pass: store login preference

* Only set login preference if SSO is used

* Change mock DNS to use port 5354 and `domain_id` for parameter

* Make login forms use flash message for error passing

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2025-06-23 10:28:27 +00:00
Adrian Gruntkowski a2ed1e04b1
Revise system behaviour for SSO users (#5506)
* Setup MFA properly in SSO tests

* Move `new_identity` test helper to common helpers

* Make standard login only allow Owner SSO users

* Implement `Plausible.Users.type/1` for determining user type

* Implement plug restricting action based on user type

* Restrict or adjust access to settings actions to SSO users

* Make a very small refactor to `Auth.SSO` helper

* Prevent SSO users from acceptig team invitations

* Prevent SSO users from adding websites under "My Presonal Sites"

* Prevent implicit team creation by SSO users

* Add workaround for compiler warning under CE

* Remove SSO user on removing membership

* Prevent changing role to owner when 2FA not enabled

* Prevent provisioning from standard user with active personal team

* Fix `Auth.lookup/1` to not break for standard users on multiple teams

* Use `Plausible.always/1` (h/t @aerosol)

* Revert "Use `Plausible.always/1` (h/t @aerosol)"

This reverts commit 0ee7dd84d3.

* Rename `RestrictType` -> `RestrictUserType`

* Make the configuration intent more explicit in `RestrictUserType` plug

* Rename plug file
2025-06-23 08:19:12 +00:00
Karl-Aksel Puulmann 6ade93bf86
ScriptV2: Self hosted tracker script cache (#5502)
* Allow caching tracker script on CE

Open questions with this approach:
- `ingestion_url`: Using `PlausibleWeb.Endpoint.url()` requires that endpoint has started, but we
  want to pre-warm the cache _before_ the endpoint starts. To work around this, a different approach
  is used to get the right url.
- caching: Other caches currently cache database models, this caches a string. Will this cause issues?

* Slightly better workaround

* Lazier timers
2025-06-20 06:59:18 +00:00
Adam Rutkowski 4387d42409
CRM: First pass SSO support (#5517)
* CRM: First pass SSO support

* Put `sso_integration` association behind `ee` check
2025-06-19 11:52:15 +00:00
Uku Taht 973b626625
Onboarding review flow (#5491)
* Scriptv2 onboarding: review flow

* Make sure bundled features are enabled by default in v2 onboarding

* Call get_or_create correctly

* Refactor custom plan form to use boolean-based checkboxes
2025-06-19 11:34:41 +00:00
Karl-Aksel Puulmann 7da74b3031
Experiment: Adjust sampling minimum and by filters (#5515)
* Experiment: Adjust sampling minimum and by filters

(All new logic is feature flagged)

* Adjust min rate a bit
2025-06-19 08:36:28 +00:00
Adam Rutkowski 37e718db40
End-to-end sso domain verification (#5513)
* wip

* Fix up typespcs

* Extract domain status enum to module macros

* Cancel verification jobs when integration is removed

* Revisit verification interface

* Supply local DNS server for domain ownership testing

* Rename a test

* 👾

* Use identifier when submitting domain verification

* Disallow re-verification of already verified domains
2025-06-18 09:52:48 +00:00
Adam Rutkowski 70902bbc5a
SSO: phrasing; settle on domain verification, not validation (#5508)
* SSO domains: s/validation/verification

* Fix careless search&replaces
2025-06-16 18:44:57 +00:00
Adam Rutkowski b86e4eea7e
SSO: implement domain validation background service (#5505)
* SSO: implement domain validation background service

* Put tests behind `ee`

* Fix up typespecs
2025-06-16 11:56:59 +00:00
Adrian Gruntkowski 605447cd61
Implement real SAML authentication adapter (#5482)
* Add dependencies necessary for implementing real SAML adapter

* Implement real SAML adapter

* Add make target for easily provisioning local IdP service

* Implement a separate cookie for storing mid-auth SAML state

* Test and improve validation in `RealSAMLAdapater`

* Rename `extra/fixtures` to `extra/fixture` in consistency with `fixture`

* Avoid warnings when running test in CE mode

* Hard match on `integration_id` in `RealSAMLAdapter.signin/2`

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

* Improve relay state validation

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

* Require `integration_id` parameter in `sso` make target (#5501)

* Fix formatting

* Store assertion fixtures as XMLs instead of Base64 encoded strings

* Switch to upstream `main` branch of `simple_saml`

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2025-06-16 08:19:00 +00:00
Adam Rutkowski dad00d26c2
Periodically refresh salts so that non-rotating nodes catch up (#5496)
* Periodically refresh salts so that non-rotating nodes catch up

* Remove Logger ref 0a2ed563dd & facf743670

* typo
2025-06-16 05:23:46 +00:00
Cenk Kücük bbbe5949e7
Increase check frequency for /api/event and /api/health (#5497) 2025-06-13 13:28:30 +01:00
Karl-Aksel Puulmann d215e50982
ScriptV2: Rework WordPress plugin token adding flow (#5493)
* Remove dead code

* Rework plugin API token flow

* Changelog

* Redundant code

* Remove onfocus
2025-06-12 08:18:58 +00:00
RobertJoonas d00dde183e
Starter Tier: Getting ready for release (#5489)
* make starter tier flag team based not user

* old upgrade page for active or recently ended trials

* adjustments to plan benefits

* mention losing grandfathering when on v4

* extract plan benefits into separate module

* unit tests for plan benefits + fix enterprise site/team_member benefits

* hide Starter tier from grandfathered Growth

Also get rid of the grandfathered notice in Growth plan box

* choose_plan_test.exs to ee_only

* fix ci

* actually fix ci

* stop displaying new starter features for grandfathered teams

* bump starter tier launch date

* Revert "stop displaying new starter features for grandfathered teams"

This reverts commit e024a82d14.
2025-06-11 12:48:22 +00:00
Adrian Gruntkowski 153702c20f
Implement SSO setup UI (#5473)
* Extend core APIs for better insight into SSO state during setup

* Adjust `toggle_switch` compoenent to accept global attributes

* Improve textarea variant of input component

* Make first very crude pass on SSO setup UI

* Display "Single Sign-On" settings option only when enabled

* Extract SP identity ID function to SAMLConfig as a public one

* Move SAML controller logic behind an adapter

* Don't apply CSRF protection to SAML consume endpoint

* Make copy adjustments

* Change SSO sidebar icon

* Fix `fake_domain_verify` handling before integration is set up

* Tweak configuration markup

* Sanitize PEM input

* Tweak SSO settings sections + prevent domain deletion if applicable

* Minor tweaks to SSO settings tiles

* Bootstrap basic test suite

* Ensure SSO settings are guarded by env var

* Make sure to retry fake domain validation on integration-less cycle

* Trim idp entity id input

* Dedup assertions

* Fix domain identifier interpolation

* Tidy up integration fetching

* Expand tests for SSOManagement LV with fixes

---------

Co-authored-by: Adam Rutkowski <hq@mtod.org>
2025-06-11 10:52:20 +00:00
RobertJoonas 4e5093f86c
Starter Tier: Shared Link Feature Gates (#5474)
* feature gate creating shared links

* feature gate GET shared_link

* stop granting shared links access in code + organize tests

* allow GET shared_link for WP

* prevent shared link creation with special name

unless created by the Plugins API, the name WordPress - Shared Dashboard
will be considered reserved.

* do not render special shared links in site settings > visibility

* remove hardcoded special name from test

* add function doc for special names

* prevent updates to special name as well

* warn about losing access to shared links

* make features_usage return empty list on ce

* Update lib/plausible/sites.ex

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

* move special name check to changeset

* fix tests

---------

Co-authored-by: hq1 <hq@mtod.org>
2025-06-10 06:43:40 +00:00
hq1 efc55e323d
Remove kaffy (#5423)
* Deal with `FeatruesList` proxy

* Remove kaffy: first pass

* Remove admin controller

* Remove kaffy: last batch

* unlock dependency

* Remove kaffy links

* !fixup
2025-06-10 06:24:47 +00:00
hq1 bdc44d1d33
CRM: Refund lock (#5480)
* Redefine what `on_trial?` means

No subscription combined with
non-zero trial_days_left designates an ongoing trial.
Conversely, any subscription in any state means
the trial is inactive.

* Fix cancellation notices

We now show the cancellation warning
when the subscription is about to expire.

* Implement the ability to lock cancelled subscriptions

in case a refund is made

* Dedup notice body

* Spawn confirmation alert before locking
2025-06-09 13:53:40 +00:00
hq1 1e03374544
CRM: UX tweaks (#5481)
* Assign input types to team related date fields

* Custom plans: additional previews for number inputs

* Zero instead of error

* Fix dark mode
2025-06-09 13:04:26 +00:00
hq1 df8727f414
CRM: revert #5440; implement lock/unlock for grace period (#5475)
* Revert "CRM: team (un)lock regardless of grace period (#5440)"

This reverts commit bb63c0d0e4.

* Implement grace period (un)lock just like in kaffy

* Test grace period handling
2025-06-06 08:01:29 +00:00
hq1 d5fe22e97f
CRM: Add quick links section to site view (#5466) 2025-06-04 09:24:34 +00:00
Adrian Gruntkowski 0968ed7f2c
Implement `SSO.Domains.remove/1,2` and `SSO.Domains.check_can_remove/1` (#5461)
* Implement `SSO.Domains.remove/1,2` and `SSO.Domains.check_can_remove/1`

* Add `sso_domain` relation to `Auth.User` schema

* Populate `user.sso_domain` on provisioning and validate identity domain

* Simplify lookup by domain in `SSO.Domains.remove/1,2`

* Extend tests

* Derive user name from email in fake SAML controller

* Fix formatting
2025-06-04 08:56:50 +00:00
hq1 6040bed54b
SSO Domain Validation chain: dns_txt, url, meta_tag (#5414)
* Implement SSO Domain validation chain

* Use iolists 🆒

* Use aliases

* Update moduledoc

* Update test/plausible/auth/sso/domain/validation_test.exs

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Update test/plausible/auth/sso/domain/validation_test.exs

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Update test/plausible/auth/sso/domain/validation_test.exs

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>

* Match non-empty list for meta tag check

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2025-06-03 15:07:57 +00:00
hq1 92367f193f
CRM: List API keys per user (#5463)
* List API keys per user

* !fixup
2025-06-03 13:07:30 +00:00
RobertJoonas 38f1de6ecd
Starter Tier: Teams UI follow-ups (#5456)
* keep teams feature explicitly for UI

* keep devsubscriptions in sync with prod

On prod, when a subscription is created without a current team in assings,
a new team is force created for that user.

* disable team creation when no point to create it

* fix ce_test compile warning

* fix tests on CE

* Update lib/plausible/teams/billing.ex

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

* add solo team in seeds

* fix top border blur + stop autofocusing input when blurred

---------

Co-authored-by: hq1 <hq@mtod.org>
2025-06-03 10:14:50 +00:00
Adrian Gruntkowski 4a587e2a6e
Implement remaining `SSO` functions needed for setup (#5444)
* Move data mgmt logic from `UserAuth` to `Auth.UserSessions`

* Implement remaining SSO code API needed for setup

* Change `deprovision_user` -> `deprovision_user!`

* Change `UserSessions.create` -> `UserSessions.create!`

* Change `any_verified_domain?` -> `no_verified_domains?` (h/t @aerosol)
2025-06-03 06:21:51 +00:00
Adrian Gruntkowski bca78169bb
Implement SSO login against fake SAML endpoints (#5434)
* Add SSO user as a team member on provisioning

* Implement fake SSO actions and basic login form

* Handle team member limit error and adjust login redirect in `UserAuth`

* Always switch to related SSO team on SSO user login

* Ensure `timeout_at` is set when creating new standard user session

* Add env var flag for gating SSO

* Hide SSO login link when SSO disabled

* Hide SSO routes when SSO disabled

* Implement nonce-based allowance for js in SSO content security policy

* Test controller actions

* Add more tests for UserAuth

* Add sync tests for `GateSSO` plug and env var flag in disabled state

* Add test for SSO owner logging in via standard login
2025-06-02 12:13:56 +00:00
Adrian Gruntkowski 9ec7864f44
Ensure team locked state is updated on site creation and removal (#5451)
* Ensure team locked state is updated on site creation and removal

* Do not lock team when there are no sites

* Ensure SiteLocker is only run on EE

* Get rid of troublesome alias
2025-06-02 10:45:20 +00:00
Uku Taht 9a7cb6cc26
Update tracker config in scriptv2 onboarding (#5443)
* Update tracker config in scriptv2 onboarding

* Use actual scriptv2 installation script

* Unwrap result from transaction

* Only run cache purge tests on ee
2025-06-02 10:39:31 +00:00
RobertJoonas adfcd0f584
for now allow teams and shared links for everyone (#5446) 2025-05-30 16:45:57 +00:00
RobertJoonas e38bda6d00
Starter feature gates (UI) (#5426)
* replace yellow warning notice with more inviting cta (funnels)

* align VAT notice with /year on the upgrade page

* improve tooltip component

do not hide the tooltip when the mouse enters the tooltip itself directly
from the trigger element. This allows clicking links in tooltips.

* improve site segments feature gate UI

Disable the save button when site segment option is selected in create or
edit form. Also render a different upgrade notice if the user is not the owner.

* replace upgrade notices with blur UI

To fully get rid of Notice.premium_feature, we will also display a
"not allowed" cursor with tooltips asking to upgrade where necessary.

* extract toggle switch component

* Hide currency toggle from goal edit form

The currency field cannot be changed for an existing goal anyway. Therefore
it makes sense not to show it at all. This commit makes the currency picker
always visible when editing a revenue goal, and always hidden for custom
event edit form.

* simplify api key creation form

Turn "Sites API access" into a toggle switch identical to "Enable revenue
tracking" in goal creation form.

* remove team setup CTAs for Starter tier

* fix team member limit for starter

* adjust v5 plan limits and limit exceeded notices

* do not display global notices on upgrade-success page

* fix settings/subscription monthly quota boxes alignment

* fix CI

* use tailwind backdrop-blur

* remove dangling log + avoid passing setSaveDisabled

* remove duplicate function clauses revenue goals

* revert create api key UI change but disable button still

* optimize for darkmode

* blur team settings > team members for Starter

* rename team accounts to team management
2025-05-30 13:34:19 +00:00
hq1 bb63c0d0e4
CRM: team (un)lock regardless of grace period (#5440)
* Add `locked_by_admin` to teams schema

* Implement team locking

* Look up `teams.locked_by_admin` in relevant background services

* Add background servive tests

* Type faster than think!
2025-05-28 11:28:59 +00:00
Karl-Aksel Puulmann 6a06020ba7
ScriptV2: BunnyCDN cache purging (#5435)
* Purge bunny cdn cache when tracker script config is updated

* Only allow one purge task scheduled per site

Tested by adding logging and toggling a checkbox a few times. Only one job got executed.

* Typo
2025-05-28 10:08:33 +00:00
Adrian Gruntkowski b341f2735a
Always expire SSO User sessions after `identity.expires_at` (#5429)
* Always expire SSO User sessions after `identity.expires_at`

* Refactor

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

---------

Co-authored-by: hq1 <hq@mtod.org>
2025-05-28 06:59:39 +00:00
Karl-Aksel Puulmann 98cdeb23dd
ScriptV2: Configuration renames, iteration (#5427)
* plausible-main -> plausible-web

* Change elixir workflow

* Update tracker option names in tracker.ex

* config.hash -> config.hashBasedRouting

* Enable revenue by default for plausible-web

* Enable taggedEvents by default

* config.local -> config.captureOnLocalhost

* manual -> autoCapturePageviews

* Update playwright tests

* Support adding/editing file types for download in plausible-web

Original docs: https://plausible.io/docs/file-downloads-tracking#what-if-i-want-to-track-a-different-file-type

* rebase: initialize-page-dynamically update

* chore: Bump tracker_script_version to 12

* Ignore pageviews in file-downloads.spec

* Phrasing in tests

* Remove unneeded conditional
2025-05-27 11:28:17 +00:00
hq1 1de10b7867
CRM: Fix sites rate + from float crashing (#5430)
* Fix sites rate + from float crashing

* FOrmat
2025-05-27 10:48:28 +00:00
hq1 825e5a73e5
CRM: Handle "unlimited" team members + fix defaults + price estimations (#5428)
* Handle "unlimited" team members + fix defaults

* Change how custom plan price estimation works

Ref: https://3.basecamp.com/5308029/buckets/26383192/card_tables/cards/8506177450

* Tier=>Plan

* Fixup calculations

* !fixup
2025-05-27 10:18:55 +00:00
Adrian Gruntkowski 4ffdfe3f69
Implement `SSO.provision_user/1` and extend `UserAuth.log_in_user/3` (#5424)
* Add `SSO.Identity` struct

* Ensure timestamps are set to second resolution to avoid issues

* Implement `SSO.provision_user/1`

* Implement `UserAuth.log_in_user/3` clause accepting identity

* Fix type declaration in `UserAuth`
2025-05-27 07:55:23 +00:00
Karl-Aksel Puulmann b5bd623cf1
tracker_script_configuration: plugins API (step 5) (#5410)
* Plugins API for tracker script configuration

* no support for track_404_pages in plugins api

* Update lib/plausible_web/plugins/api/controllers/tracker_script_configuration.ex

Co-authored-by: Uku Taht <Uku.taht@gmail.com>

* Restructure update code

* Remove dead code

---------

Co-authored-by: Uku Taht <Uku.taht@gmail.com>
2025-05-27 06:05:27 +00:00
Karl-Aksel Puulmann 8bbb4408da
tracker_script_configuration: drop writes and reads to `installation_meta` (step 4) (#5409)
* Read and write only new schema

* add cdn_tag header

* Remove default thats not needed
2025-05-27 05:36:36 +00:00
Karl-Aksel Puulmann b972817782
tracker_script_configuration: schema, double-writes (step 2) (#5407)
* tracker_script_configuration table migration

* tracker_script_configuration schema + upsert tests

* TrackerScriptConfiguration: read from installation_meta, double-write, refactor installation flow to work off of new model

* Fix a test
2025-05-26 11:50:22 +00:00
hq1 9bad32eaf3
CRM: Render price estimation in enterprise plans (#5422) 2025-05-26 08:29:09 +00:00
Adrian Gruntkowski 0b7bccd6a5
Implement `SSO.Domains.lookup` and `SSO.Domains.add` (#5419) 2025-05-26 06:47:33 +00:00
Adrian Gruntkowski d7fe32000a
Implement `SSO.initiate_saml_integration` and `SSO.update_integration` (#5416)
* Add X509 as explicit project dependency

* Implement `initiate_saml_integration` and `update_integration`

* Remove redundant tests

* Refactor SSO.SAMLConfig slightly
2025-05-26 06:35:21 +00:00
hq1 27933d0045
CRM: Expose site transfer (#5418)
* Expose rescue zone/site transfer in CS

* Add notes

* Clean up
2025-05-22 07:47:22 +00:00
hq1 6f8156a482
CS: Enable searching for teams with subscriptions (#5415)
* CS: Enable searching for teams with subscriptions

* Fixup typespecs
2025-05-21 13:28:39 +00:00
Adrian Gruntkowski 9de15326dc
Introduce migration and schemas for SSO (#5411)
* Add polymorphic_embed library

* Add formatter rules for polymorphic_embed

* Add new and extend existing schemas for SSO
2025-05-21 09:53:12 +00:00
Marko Saric fcb704fa24
Adjust note about no invoices (#5412)
* Note about no invoices

* Adjust tests

---------

Co-authored-by: Adrian Gruntkowski <adrian.gruntkowski@gmail.com>
2025-05-21 09:20:09 +00:00
hq1 5495947c8d
CS: update tests + display user ID (#5405)
* Ensure 404 is handled

* Update /cs/users/user/:id test

* Unrelated: fix live sites test assertions
2025-05-21 07:13:16 +00:00
hq1 990a760f5d
Minimal stub for CS tests (#5402)
* Init customer support tests

* Rename copy pasta

* !fixup
2025-05-20 13:23:20 +00:00
RobertJoonas 2dd144bf85
Starter tier: Upgrade page remodelling (#5394)
* add a new (feature flagged) upgrade page offering v5 plans

* include starter tier plans in available_plans_for + use dev prices in test

* upgrade page remodelling with starter tier

* mobile optimizations

* optimize for darkmode

* add embedded dashboards as a growth benefit

* do not hide header on LegacyChoosePlan

* consistent v5 plan feature order

* slight grandfathering notice adjustment

* display monthly price too on yearly plans

* default to v5 plans unlesss legacy? is true

* refactor: suggest volume not plan for emails

* align back link with page title

* render grandfathering notice for growth v4 too
2025-05-20 13:22:12 +00:00
ruslandoga 97449613e1
Support `sslmode` in `DATABASE_URL` in CE (#5280)
* sslmode

* Update config/runtime.exs

---------

Co-authored-by: Cenk Kücük <cenk@plausible.io>
2025-05-20 13:21:48 +00:00
Karl-Aksel Puulmann 844c118135
ScriptV2: `plausible.init`, `customProperties`, snippet compilation, double initialization protection, `swc` (#5391)
* WIP: init() for plausible.js

* Reformat whitespace

* Handle double-initialization gracefully

* Script customProperties option

* Remove pageview-props from tracker script interpolation - its now an advanced config

* Add compile option for compiling the web snippet. This can then be copied to e.g. onboarding

* Switch minification from uglify-js to swc

* Use 4 passes for optimal output

* Remove use strict to remove it from output. Uglifyjs already removed this

* Minor optimization: Remove nulls from output via runningEngagementStart

* Minor optimization: Reduce onIgnoredEvent

* config_json -> config_js

* Dead attribute

* Remove guard for engagements

* More protective customProperties

* Object.assign

* chore: Bump tracker_script_version to 10

* No need for default in Object.assign

* Remove dead guard
2025-05-20 06:57:35 +00:00
Karl-Aksel Puulmann f8658320d5
ScriptV2: plausible-main application code (#5389)
* PlausibleWeb.Tracker -> PlausibleWeb.TrackerPlug

* Support getting plausible-main.js via app from `/js/s-${tag}`

tag currently is site.installation_meta["id"] but im planning (separately) to
introduce a different, shorter id version (using something like NanoId/HashId).

This will be introduced in a separate PR though

* Mark some variables as legacy

* Remove compile-time dependency on plausible-main.js

* Fix build

* moduledoc

* Bump CACHE_VERSION to ensure plausible-main is compiled

* 404 consistently

* Revert "Remove compile-time dependency on plausible-main.js"

This reverts commit 4b533ef0f6.

* Ensure file exists at compile-time

* flat_map over reject

* assert -> refute

* JSON.encode!
2025-05-19 06:02:26 +00:00
RobertJoonas 18907aef63
Starter Tier: Add plans and Mix tasks (#5392)
* fix sandbox plans v4 to be in sync with prod ones

* sync sandbox plans + unify formatting

* create v5 plans in paddle prod + sandbox + Mix.tasks

* add teams and shared links features

* remove unused line of code

* paddle credentials as module attrs

* remove teams and shared links as growth benefits for time being
2025-05-15 10:02:43 +00:00
hq1 e017ec3268
Add extra checks to k6 load test script (#5384) 2025-05-15 08:24:05 +00:00
hq1 c009b92fca
Customer support (#5390)
* Add profile_url helper clause

* Add notes

* Sort features alphabetically

* Fix checkbox/textarea components

* Unrlelated: update combobox docs

* Initial customer support UI

* Unrelated: don't expand member dropdown if disabled

* Cross link both CRMs

* Remove unused things

* Stop polluting history with tab navigation

* Truncate search results

* Format

* Use routes in favour of phx-click events

* Fix / keypress to search focus

* Rename phx event

* Rename remaining save events

* Fix up x-data

* Fix alpine placeholder event

* Enable progress animation with topbar

* Team: separate assign clauses per tab

* Site: separate assign clauses per tab

* lint

* Replace URI patch on filter text update

* Unifyu filter_bar component usage

* !fixup

* Fix up filter form event name

* Fix number formatting as you type

* Fix enterprise plan number inputs

* Link CS from HelpScout

* Remove target=_blank from kaffy URLs

* Pre-fill custom plans

* Rework the billing tab

* Make checkbox labels clickable

* Put Stats API first

* Format

* Credo

* !fixup

* Don't show empty labels
2025-05-15 08:05:32 +00:00
Karl-Aksel Puulmann 7265d04a8c
ScriptV2: Improved tracker compile.js (#5363)
* Add CLI arguments to compile.js and logging

* Rename folder

* Extract compile code, es modules

* Add a progress bar

* Remove handlebars

* Update report-sizes

* Remove debug code

* inline

* More generous split

* Allow positional arguments for compiling

* Add watch option to compile

* Add compileFile logic

* Most tests run under playwright

* All tests runnable

* Update playwright, remove hack

Note that upgrading to latest failed due to a new test failure. This
might be due to a chrome update.

* Compile script on the fly for tests

* Minor refactor for compileAll

* es module for generate-variants.js

* Allow passing suffix to compilation script - this can be used to generate separate files for comparison

* Fix positionals

* Switch from 2 passes to 1 pass

Did some data analysis on this data:
- Compared to master, 1 pass increased brotli size by 0.7%, 2 passes 0.4%.

Given the change is insignificant enough, we can ignore it for now

The increase is likely due to order of operations in compilation and
some inlined functions getting lost.

* Move customEvents.js to plausible.js

* Clean up API

* Suffix default

* Rework variants.json, globals stored there

* Add more variants under test

* Distribute work across multiple worker threads

Compile time went on my machine from 60s -> 30s

* Fixup server

* Update canSkipCompile

* chore: Bump tracker_script_version to 7

* Update scripts

* Update node-version

* Experiment with adding a small delay to page

* Casing

* rename variable

* Update help text

* features -> compileIds, backport functionality from other branch
2025-05-08 07:05:09 +00:00
Artur Pata 429b055920
Update headlessui to v1.7.19, refactor site switcher (#5255)
* Migrate some

* Making progress

* All fixed

* Convert interval picker to tsx

* Fix format

* Fix tests

* Make sure focus outline looks right on DropdownTabButton

* Refactor Site Switcher to Popover

* Fix site switcher test

* Better jsdom mocks in assets tests

* Try svg placeholder favicon

* Update favicon test

* Try giving transition config directly

* Remove empty props

* Remove unnecessary closeDropdown to prevent Firefox transition issue

* Register open dropmenus globally

This is needed to prevent invalid state when navigating with site hotkeys with Firefox while a dropdown is open and coming back using browser

* Colocate popover-specific component

* Clarify behaviour on hitting hotkey for current site

* Try fix Firefox issue

* Try 1.7.19

* Commit to @headlessui/react v1.7.x

* Fix last two transition origins

* Align active tab on baseline

* Remove unneeded global dropmenu state

* Add changelog

* Funnels menu is searchable and scrollable

* Fix transform origin

* Stop funnels menu from holding onto search state

* Mandate ref be passed to SearchInput from the outside
2025-05-07 05:22:53 +00:00
hq1 8f4b63083e
Loadtest p2 (#5380)
* Bring back previous dev config

* Dedicated MIX_ENV for load testing + change k6 script

* Remove unused env var

* Remove test flag

* Add .env.load

* Fixup
2025-05-06 10:58:06 +00:00
hq1 aa4a8339cb
Ingest throughput fixes (#5378)
* Update

* Update

* Naive safety valve in front of RL

* Revert "Naive safety valve in front of RL"

This reverts commit 3bb553ec2e.

* rate limit with atomics

* update test

* Reapply "Add +Mdai max emulator flag (#5373)" (#5374)

This reverts commit b28ca2ffee.

* Update load script

* Update LOADTEST mode

* Revert "Stop aggregating buffered ingest counters (#5372)"

This reverts commit 2c41dcd4c1.

* update

* Fix cache hit/miss metric tags

---------

Co-authored-by: ruslandoga <ruslandoga+gh@icloud.com>
2025-05-05 14:00:37 +00:00
RobertJoonas 1de37a125c
Staging subscriptions (#5349)
* sandbox_plans.json -> sandbox_plans_v4.json

* add mix task and generate sandbox plans

* manually add sandbox_legacy_plans.json

* make all staging plans consistent with prod

* slight code style improvement

* add kb link
2025-05-05 09:23:19 +00:00
Adrian Gruntkowski b942081f30
Add ability to create Sites API keys from Account Settings (#5361)
* Extend API key creation with support for Sites API keys

* Remove unnecessary disabled state and improve radio component styling

* Add more tests

* Don't expose Sites API keys in CE

* Only show the notice if Sites API feature is actually disabled

* Adjust API keys subtitle

* Fix condition in one of actions
2025-05-05 09:01:14 +00:00
Karl-Aksel Puulmann 70ed352bcc
Remove accidental console.log (#5371)
https://github.com/plausible/analytics/pull/5328 accidentally added a
console.log to a test template. This minor change removes that.
2025-04-30 10:43:57 +00:00
hq1 2c41dcd4c1
Stop aggregating buffered ingest counters (#5372)
Redundant given events_v2 writes
2025-04-30 10:21:47 +00:00
hq1 ffae16f7b9
Stop Cache.Stats + Revert "Temporarily disable ingest metrics (#5369)" (#5370)
* Revert "Temporarily disable ingest metrics (#5369)"

This reverts commit b96e96a7f6.

* Add :tools to MIX_ENV=dev

* Stop tracking caches hit ratio in favour of raw counters
2025-04-30 08:11:51 +00:00
hq1 b96e96a7f6
Temporarily disable ingest metrics (#5369)
* Temporarily disable ingest metrics

* Skip more
2025-04-29 16:30:20 +00:00
Adrian Gruntkowski 6afd12cdab
Add SitesAPI plan feature (#5366)
* Add SitesAPI plan feature

* Add test for usage of SitesAPI feature
2025-04-29 13:43:00 +00:00
Adrian Gruntkowski 88a1205503
Accept after register via team invite (#5358)
* Pass team identifier for team invites from register form

* Accept team invitation after registering and switch
2025-04-29 07:59:30 +00:00
Adrian Gruntkowski dda551e7f5
Tidy Teams logic around and improve service functions names (#5352) 2025-04-28 08:22:04 +00:00
Adrian Gruntkowski 4ec2e8e151
Switch to the team on accepting team invitation (#5357) 2025-04-28 08:00:37 +00:00