Commit Graph

2020 Commits

Author SHA1 Message Date
ruslandoga
fd15853965
disable registration by default in self-hosted setups (#3014)
* disable registration by default in self-hosted setups

* add changelog entry

* add error flash
2023-06-14 12:08:52 +03:00
Vini Brasil
2c4cea6dce
Add revenue metrics in StatsController instead of Stats.Breakdown (#3028)
This commit makes total_revenue and average_revenue first-class metrics
instead of adding them magically in `Plausible.Stats.Breakdown`. To
keep the same behavior, revenue metrics are added in StatsController.

Related: https://github.com/plausible/analytics/pull/2957#pullrequestreview-1475017620
2023-06-14 09:32:08 +01:00
hq1
a356009af8
Implement backend core for funnels (#3023)
* Implement Funnel schema

* Implement Funnels context module

lib/plausible/funnels.ex - restored from:

dca93621 Mark Vini's suggestion applied
7d1eec75 Update lib/plausible/funnels.ex
028036ad Review comments
b694ccd5 Express the guard nicely
acd9c4f2 Prepare ephemeral funnel definitions so that users can test funnels
aea4ebc4 Access Funnel min/max steps via the __using__/1 macro
51f0397d Implement deleting funnels
cf228630 wip
1f6fe25d Add number of steps to funnels list
89f10ecb wip
950a18d9 Dirty funnel save
e62bfce5 Refactor funnel result evaluation
88e38a33 Update funnel tests
bf47f654 Calculate conversion rate/dropoff in the backend
9e62ffb1 Make existing tests pass
7a88fe44 Outline basic error handling
c8ae3eaf Move Funnels to StatsController and use base query
2929bfd4 Minor rework
b490403b !ifxup
ae44db77 Add Funnels.list/1 function
4f3216b3 Unique steps
6e0c3efc Ensure step ordering works
cea93ba1 It works I think
c50ac0c2 WIP
a466ec4c Dirty wip
fbd14e23 Absolute dirty wip
3ddd15ad wip
34ceb3f5 dirty wip

test/plausible_web/controllers/api/stats_controller/funnels_test.exs - restored from:

9b532273 Test funnel stats controller

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

* Update Goals implementation

lib/plausible/goal/schema.ex - restored from:

028036ad Review comments
acd9c4f2 Prepare ephemeral funnel definitions so that users can test funnels
4a4ddbdc Optionally preload funnels for goals and stub funnel-goal deletion
fbd14e23 Absolute dirty wip

lib/plausible/goals.ex - restored from:

aea4ebc4 Access Funnel min/max steps via the __using__/1 macro
a418c039 Implement funnel reduction logic on goal deletion
4a4ddbdc Optionally preload funnels for goals and stub funnel-goal deletion
ebdc4333 Extend the prompt in case of funnel-goal deletion
950a18d9 Dirty funnel save
f06c3fcf wip

test/plausible/goals_test.exs - restored from:

a418c039 Implement funnel reduction logic on goal deletion
4a4ddbdc Optionally preload funnels for goals and stub funnel-goal deletion
dee5bc9e Fixup tests

* Update seeds

* Split funnel schema modules

* Add moduledoc to Funnel schema

* Update Funnel.Step moduledoc

* Add typespecs to Plausible.Funnels

* Implement Phoenix.HTML.Safe for Funnel schema

* Fixup a test after ordering goals by desc:id

test/plausible_web/controllers/api/stats_controller/conversions_test.exs - restored from:

26a493cb Fixup a test after ordering goals by desc:id

* Annotate Goal schema with type t()

* Reword schema module docs

* Fix up typespecs

* Stop tagging Funnels.get/2 result

* Nuke Goals.by_id!/2

* Test Funnels module

test/plausible/funnels_test.exs - restored from:

b7a6d3ad ya, rly
028036ad Review comments
acd9c4f2 Prepare ephemeral funnel definitions so that users can test funnels
51f0397d Implement deleting funnels
1f6fe25d Add number of steps to funnels list
dee5bc9e Fixup tests
950a18d9 Dirty funnel save
88e38a33 Update funnel tests
bf47f654 Calculate conversion rate/dropoff in the backend
9e62ffb1 Make existing tests pass
2929bfd4 Minor rework
b490403b !ifxup
ae44db77 Add Funnels.list/1 function
4f3216b3 Unique steps
6e0c3efc Ensure step ordering works
cea93ba1 It works I think
c50ac0c2 WIP
a466ec4c Dirty wip
34ceb3f5 dirty wip

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

* Apply changes related to 242081e5

* Evaluate funnels through `Stats.funnel/3` entry point

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
2023-06-13 14:01:39 +02:00
hq1
c7b8a8ef27
Bugfix for #3005 (#3025)
* Revert "Revert "UI groundwork: Conversions to Behaviors (#3005)" (#3024)"

This reverts commit dc0853bac7.

* Move ref back to LazyLoader container
2023-06-13 12:26:33 +02:00
hq1
dc0853bac7
Revert "UI groundwork: Conversions to Behaviors (#3005)" (#3024)
This reverts commit ba19f9530e.
2023-06-13 12:05:13 +02:00
hq1
3dce3142bf
Migration: add funnel related tables (#3022)
priv/repo/migrations/20230417095029_init_funnels.exs - restored from:

aa59adeb wip
4d039ba2 Make funnel names unique
4f3216b3 Unique steps
e55edf8e Rename funnel_goals->funnel_steps
34ceb3f5 dirty wip
2023-06-13 09:27:18 +02:00
RobertJoonas
ba19f9530e
UI groundwork: Conversions to Behaviors (#3005)
* copy relevant files from b2ace16540

* make it work and set site.funnels to empty list

* make Behaviours a functional component

* add UI for a setup hint and always display conversions by default

* cherry-pick migration commit

* update site schema with new fields

* backend: implement disable-feature action

* switch between tabs in the behaviors section

Introduces template components to build props and funnels on. Both
only show a setup notice atm, and both are behind feature flags.

* extend API for disabling props and funnels

* render feature setup note directly from the Behaviours component

* fix UI behavior when features are hidden

* update setup notices

* add conversions feature switch to Site Settings > Goals

* mix format

* remove IO.inspect

* change setup notice - use buttons + popup confirmation

* optimize for light mode

* restrict access to setup notices

* some styling improvements

* allow super-admins to enable/disable features

* only show conversions (last 30min) in realtime mode

* use shorter display names for tabs

* optimize for mobile screens

* note about sending custom events

* changelog update + fix CI

* change HTTP verb for the disable-feature action

* change UI label for show/hide goals
2023-06-13 08:16:38 +02:00
Vini Brasil
e4d4f7d954
Revenue tracking: Ingestion and breakdown queries (#2957)
* Add revenue fields to ClickHouse events

This commit adds 4 fields to the ClickHouse events_v2 table:

* `revenue_source_amount` and `revenue_source_currency` store revenue in
  the original currency sent during ingestion

* `revenue_reporting_amount` and `revenue_reporting_currency` store
  revenue in a common currency to perform calculations, and this
  currency is defined by the user when setting up the goal

The type of amount fields is `Nullable(Decimal64(3))`. That covers all
fiat currencies and allows us to store huge amounts. Even though
ClickHouse does not suggest using `Nullable`, this is a good use case,
because otherwise additional work would have to be done to
differentiate missing values from real zeroes.

I ran a benchmark with the data pattern we expect in production, where
we have more missing values than real decimals. I created 100 million
records where 90% of decimals are missing. The difference between the
tables in storage is just 0.4Mb.

* Add revenue parameter to Events API

This commit adds support for sending revenue data in ingestion using the
`revenue` parameter - aliased to `$`.

* Add revenue parameter to mix send_pageview

* Add average and total revenue to breakdown queries
2023-06-12 18:29:17 +01:00
Vini Brasil
d98242895b
Add revenue fields to events_v2 (#3018) 2023-06-12 18:12:41 +01:00
RobertJoonas
5162da473c
add migration (#2988) 2023-06-12 10:17:46 +03:00
ruslandoga
b0c0214b6b fix twitter link 2023-06-08 17:47:55 +08:00
Vini Brasil
c559370201
Trim prop list to 30 items during ingestion (#3009)
This commit adds an upper bound limit to custom props. It fails silently
and trims the list instead of dropping the event.
2023-06-07 09:24:43 +01:00
ruslandoga
131c99c69e
remove custom_dimension_filter feature and views_per_visit_metric flags (#2996)
* remove custom_dimension_filter feature flag

* add changelog entry

* fix shouldLinkToFilterModal removal

* remove views_per_visit_metric flag
2023-06-07 11:02:36 +03:00
Uku Taht
995556e86f
Enable sampling in the Stats API (#2985) 2023-06-01 15:35:08 +02:00
hq1
49ca6b859a
Prepare base for the funnel PRs merge (#2993)
* Update dependencies as per the funnels branch

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

* Mute sigil_E deprecation errors

* Use Phoenix.Component in PlausbileWeb

* Add tooltip to react/no-unknown-property whitelist

---------

Co-authored-by: Uku Taht <uku.taht@gmail.com>
Co-authored-by: Vinicius Brasil <vini@hey.com>
2023-06-01 15:26:23 +02:00
ruslandoga
54f5718ac8
remove fetch.min.js shim from waiting_first_pageview page (#2999) 2023-06-01 14:38:04 +03:00
Uku Taht
fc918081b5
Fix event name validation (#2975)
* Fix event name validation

* Add @moduledoc

* Move tests to Ingestion.RequestTest

* Remove comment
2023-06-01 14:37:46 +03:00
ruslandoga
25f95ae84e
add landing page (#2989)
* add landing page

* cont.

* add redirect to /sites test

* add changelog entry

* adapt for mobile
2023-06-01 14:34:48 +03:00
RobertJoonas
6c907cbf42
Fix favicon request URLS (#2976)
Also use the favicon.ex proxy in referrer drilldown
2023-05-29 10:30:03 +03:00
ruslandoga
40e95ffd3d
add LOG_FAILED_LOGIN_ATTEMPTS (#2936)
* add failed login logs

* put failed login attempt logs behind a config option

* add changelog entry

* add config test

* add auth_controller tests

* move tests to separate non-async test module

---------

Co-authored-by: Uku Taht <Uku.taht@gmail.com>
2023-05-25 10:37:10 +03:00
ruslandoga
ce7401dd83
add MAILER_NAME (#2937)
* add MAILER_NAME

* add mailer test

---------

Co-authored-by: Uku Taht <Uku.taht@gmail.com>
2023-05-25 10:34:39 +03:00
Uku Taht
e4b1aa64d1
Fix tailwind safelist (#2966) 2023-05-25 10:34:10 +03:00
ruslandoga
7b22aff11c
add MAILGUN_BASE_URI (#2935)
* add MAILGUN_BASE_URI support

* add changelog entry
2023-05-25 10:32:50 +03:00
ruslandoga
f489d96251
skip v1 table drop in self-host (#2945) 2023-05-25 10:32:33 +03:00
ruslandoga
447ed12155
use ecto_ch (#2890)
* use ecto_ch

* use Ch type in BoolUInt8

* update ecto_ch and ch to latest versions
2023-05-25 09:26:50 +02:00
RobertJoonas
dafb60164a
Allow setting sample_threshold in dashboard API queries (#2958)
* refactor Query.from/2

* allow specifying sample_threshold number in query
2023-05-24 14:25:05 +03:00
Uku Taht
6be67bc6c2
Carry _sample_factor from right side to left in join (#2962) 2023-05-24 14:23:35 +03:00
Uku Taht
1a94456586
Wrap user deletion in DB transaction (#2964) 2023-05-24 14:23:23 +03:00
Uku Taht
3b1e0101d8
Limit width of embedded dashboards by default (#2965) 2023-05-24 14:23:12 +03:00
Vini Brasil
10d9e3b083
Revenue tracking: Add currency field to goal creation (#2948)
* Add revenue goal option to goal creation

This commit adds a currency field to the goals form. Goals that have a
currency set are now revenue goals, and are cached with sites to later
be used during ingestion.

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>

* Enable feature flag in tests

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2023-05-23 12:08:09 +02:00
Vini Brasil
3a07487c05
Add currency field to goals table (#2955) 2023-05-23 11:55:46 +03:00
Uku Taht
ca3e2e5121
Add unique constraint to api keys (#2931)
* Add unique constraint to api keys

* Fix test

* Remove `user_id` from api key index
2023-05-23 11:37:58 +03:00
Marko Saric
3482337348
link to the WP plugin and the integration guides (#2927) 2023-05-23 11:37:35 +03:00
Marko Saric
1723d3ca68
Keep the in-app footer consistent with the main site (#2944) 2023-05-23 11:37:22 +03:00
Uku Taht
2259651b21
Ignore missing subscription on update (#2930) 2023-05-23 11:35:18 +03:00
RobertJoonas
e27e29250b
Fix tracker bug - call callback function when ignoring event (#2947)
* call callback function when ignoring event

* update changelog
2023-05-19 13:27:11 +02:00
Harry Vangberg
34a6b984c7
Escape domain when creating URL for favicon (#2942)
* Escape domain when constructing favicon URL

A domain may include a slash, and in that case the domain must be
escaped, before it is used as an attribute for the image tag.

* match with 'conn.request_path' instead + test

---------

Co-authored-by: Robert Joonas <robertjoonas16@gmail.com>
2023-05-19 13:26:13 +02:00
RobertJoonas
fa54efbc6d
Support with_imported=true in Stats API aggregate (#2919)
* default to source_query.include_imported before true

This fixes a bug where a Stats API aggregate query was trying
to query current period *without imported data* but previous
period *with imported data*.

* remove __internal_visits at a better time

As soon as we have made the db query, we don't need it anymore

* disallow events metric with imported data

* update changelog

* keep default in a better place

* remove unused option

* update test description

Co-authored-by: Vini Brasil <vini@hey.com>

---------

Co-authored-by: Vini Brasil <vini@hey.com>
2023-05-18 12:05:24 +02:00
Vini Brasil
f29d07a49e
Add tracking back to upgrade-success page (#2938) 2023-05-17 15:13:41 +02:00
Vini Brasil
4ca2e26b9c
Limit ingestion payload size (#2904)
This pull request adds constraints on user input values during ingestion. The purpose of this PR is to filter out unrealistic or invalid inputs. More comments about each limit inline.
2023-05-17 15:13:28 +02:00
RobertJoonas
00d05b2edd
Fix a bug with query bindings (#2932) 2023-05-17 14:26:39 +02:00
Marko Saric
42f88be12a
Tweaks to the email copy (#2933)
* Removing the spike line

* Update dashboard_locked.html.eex
2023-05-16 17:49:28 +02:00
Uku Taht
e954f946e1
Adds nofollow to X-Robots-Tag header in stats page (#2929) 2023-05-16 13:19:55 +02:00
RobertJoonas
db359c2a6f
Filter out garbage props by site.allowed_event_props (#2907)
* add migration

* add not null constraint

* remove not null constraint and default value

* add site schema change

* filter garbage props for prop_key suggestions

* filter garbage props returned by StatsController.conversions/2

* add crm action to set prop allowlist

* use nullable allowed_event_props field instead

* filter garbage props in db query instead

* implement suggestion dealing with string input

* refactor the allowlist condition in db query

* improve test
2023-05-16 11:59:56 +02:00
Uku Taht
eec842c46b
Remove visits_metric feature flag (#2898)
* Remove `visits_metric` feature flag

* Fix credo warning
2023-05-16 11:58:40 +02:00
Vini Brasil
257fa16cdc
Simplify Phoenix error template (#2913)
* Simplify Phoenix error template

* Test tracking script is not included in error pages

* Test tracking script is not rendered in error templates

* Rename error layout and remove unnecessary HTML boilerplate

* Add layout setting to errors rendered without exceptions

* Add skip_plausible_tracking option to more pages
2023-05-16 10:52:17 +02:00
dependabot[bot]
16c4b9e3eb
Bump docker/build-push-action from 2 to 4 (#2918)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2 to 4.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v2...v4)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-11 14:55:57 +02:00
dependabot[bot]
007ff2c729
Bump docker/setup-buildx-action from 1 to 2 (#2916)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 1 to 2.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v1...v2)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-11 14:30:12 +02:00
dependabot[bot]
6ab1cfc319
Bump actions/setup-node from 2 to 3 (#2917)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 2 to 3.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-11 14:10:14 +02:00
dependabot[bot]
42022fcb29
Bump actions/cache from 2 to 3 (#2915)
Bumps [actions/cache](https://github.com/actions/cache) from 2 to 3.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-11 14:08:39 +02:00