Compare commits

...

8 Commits

Author SHA1 Message Date
ruslandoga 0621fc0a77 release v2.0.0 3 years ago
Kris Buist 2712a58f94 Fix the country filter label when clicking on a country on the map (#3109) 3 years ago
risson e245d9c5b5 Allow optional IPv6 for clickhouse repo (#2970)
* Allow optional IPv6 for clickhouse repo

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>

* remove trailing comma

---------

Signed-off-by: Marc 'risson' Schmitt <marc.schmitt@risson.space>
Co-authored-by: ruslandoga <rusl@n-do.ga>
3 years ago
Roj 5666ab0d38 Add missed space (#3116) 3 years ago
hq1 f2e8da55a3 Pin alpine versions to 3.18.0 (#3057)
* Revert "Bump alpine from 3.18.0 to 3.18.2 (#3044)"

This reverts commit c19a51efb0.

* Pin both images to alpine 3.18.0
3 years ago
Vini Brasil 2ab8453a57 Set with_imported=false in realtime mode (#3053)
This commit fixes a bug where timeseries queries - such as the main
graph - would fail with imported data in realtime mode. Realtime mode
`date` field is not actually a date, but minutes from now. This would
cause the imported tables join to fail with this error:

```
(Ch.Error Code: 53. DB::Exception: Can't infer common type for joined
columns: date: Int64 at left, s1.date: Date at right. There is no
supertype for types Int64, Date because some of them are
Date/Date32/DateTime/DateTime64 and some of them are not.
(TYPE_MISMATCH)
```

This commit removes imported data from realtime queries, as it doesn't
make sense to include it. Imported data does not have time precision,
and would only appear in the first day the data was imported anyways.
3 years ago
Uku Taht dec7e7e824 Fix queries with wildcard goals (#3015)
* Fix queries with wildcard goals

* Changelog
3 years ago
ruslandoga 5261c90d3a disable registration by default in self-hosted setups (#3014)
* disable registration by default in self-hosted setups

* add changelog entry

* add error flash
3 years ago

@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
## Unreleased
## v2.0.0 - 2023-07-12
### Added
- Add support for `with_imported=true` in Stats API aggregate endpoint
- Ability to use '--' instead of '=' sign in the `tagged-events` classnames
@ -13,6 +15,7 @@ All notable changes to this project will be documented in this file.
- Add `MAILER_NAME` environment variable support plausible/analytics#2937
- Add `MAILGUN_BASE_URI` support for `Bamboo.MailgunAdapter` plausible/analytics#2935
- Add a landing page for self-hosters plausible/analytics#2989
- Allow optional IPv6 for clickhouse repo plausible/analytics#2970
### Fixed
- Fix tracker bug - call callback function even when event is ignored
@ -30,6 +33,9 @@ All notable changes to this project will be documented in this file.
- Fix bug with [showing property breakdown with a prop filter](https://github.com/plausible/analytics/issues/1789)
- Fix bug when combining goal and prop filters plausible/analytics#2654
- Fix broken favicons when domain includes a slash
- Fix bug when using multiple [wildcard goal filters](https://github.com/plausible/analytics/pull/3015)
- Fix a bug where realtime would fail with imported data
- Fix a bug where the country name was not shown when [filtering through the map](https://github.com/plausible/analytics/issues/3086)
### Changed
- Treat page filter as entry page filter for `bounce_rate`
@ -39,6 +45,7 @@ All notable changes to this project will be documented in this file.
- Device type is now determined from the User-Agent instead of window.innerWidth plausible/analytics#2711
- Add padding by default to embedded dashboards so that shadows are not cut off plausible/analytics#2744
- Update the User Agents database (https://github.com/matomo-org/device-detector/releases/tag/6.1.1)
- Disable registration in self-hosted setups by default plausible/analytics#3014
### Removed
- Remove Firewall plug and `IP_BLOCKLIST` environment variable

@ -2,7 +2,7 @@
# platform specific, it makes sense to build it in the docker
#### Builder
FROM hexpm/elixir:1.14.3-erlang-25.2.3-alpine-3.17.0 as buildcontainer
FROM hexpm/elixir:1.14.3-erlang-25.2.3-alpine-3.18.0 as buildcontainer
# preparation
ENV MIX_ENV=prod

@ -121,7 +121,7 @@ class Countries extends React.Component {
this.props.query,
{
country: country.code,
country_name: country.name
country_labels: country.name
}
)
}

@ -175,9 +175,17 @@ enable_email_verification =
|> get_var_from_path_or_env("ENABLE_EMAIL_VERIFICATION", "false")
|> String.to_existing_atom()
is_selfhost =
config_dir
|> get_var_from_path_or_env("SELFHOST", "true")
|> String.to_existing_atom()
# by default, registration is disabled in self-hosted setups
disable_registration_default = to_string(is_selfhost)
disable_registration =
config_dir
|> get_var_from_path_or_env("DISABLE_REGISTRATION", "false")
|> get_var_from_path_or_env("DISABLE_REGISTRATION", disable_registration_default)
|> String.to_existing_atom()
if disable_registration not in [true, false, :invite_only] do
@ -192,11 +200,6 @@ log_level =
|> get_var_from_path_or_env("LOG_LEVEL", "warn")
|> String.to_existing_atom()
is_selfhost =
config_dir
|> get_var_from_path_or_env("SELFHOST", "true")
|> String.to_existing_atom()
custom_script_name =
config_dir
|> get_var_from_path_or_env("CUSTOM_SCRIPT_NAME", "script")
@ -289,9 +292,14 @@ config :plausible, :google,
reporting_api_url: "https://analyticsreporting.googleapis.com",
max_buffer_size: get_int_from_path_or_env(config_dir, "GOOGLE_MAX_BUFFER_SIZE", 10_000)
maybe_ch_ipv6 =
get_var_from_path_or_env(config_dir, "ECTO_CH_IPV6", "false")
|> String.to_existing_atom()
ch_transport_opts = [
keepalive: true,
show_econnreset: true
show_econnreset: true,
inet6: maybe_ch_ipv6
]
config :plausible, Plausible.ClickhouseRepo,

@ -75,20 +75,44 @@ defmodule Plausible.Stats.Base do
{:matches_member, clauses} ->
{events, pages} = split_goals(clauses, &page_regex/1)
from(e in q,
where:
fragment("multiMatchAny(?, ?)", e.pathname, ^pages) or
fragment("multiMatchAny(?, ?)", e.name, ^events)
)
event_clause =
if Enum.any?(events) do
dynamic([x], fragment("multiMatchAny(?, ?)", x.name, ^events))
else
dynamic([x], false)
end
page_clause =
if Enum.any?(pages) do
dynamic([x], fragment("multiMatchAny(?, ?)", x.pathname, ^pages))
else
dynamic([x], false)
end
where_clause = dynamic([], ^event_clause or ^page_clause)
from(e in q, where: ^where_clause)
{:not_matches_member, clauses} ->
{events, pages} = split_goals(clauses, &page_regex/1)
from(e in q,
where:
fragment("not(multiMatchAny(?, ?))", e.pathname, ^pages) and
fragment("not(multiMatchAny(?, ?))", e.name, ^events)
)
event_clause =
if Enum.any?(events) do
dynamic([x], fragment("multiMatchAny(?, ?)", x.name, ^events))
else
dynamic([x], false)
end
page_clause =
if Enum.any?(pages) do
dynamic([x], fragment("multiMatchAny(?, ?)", x.pathname, ^pages))
else
dynamic([x], false)
end
where_clause = dynamic([], not (^event_clause or ^page_clause))
from(e in q, where: ^where_clause)
{:not_member, clauses} ->
{events, pages} = split_goals(clauses)

@ -235,6 +235,7 @@ defmodule Plausible.Stats.Query do
site.imported_data.status != "ok" -> false
Timex.after?(query.date_range.first, site.imported_data.end_date) -> false
Enum.any?(query.filters) -> false
query.period == "realtime" -> false
true -> requested?
end
end

@ -37,7 +37,10 @@ defmodule PlausibleWeb.AuthController do
conn
disable_registration in [:invite_only, true] ->
conn |> redirect(to: Routes.auth_path(conn, :login_form)) |> halt()
conn
|> put_flash(:error, "Registration is disabled on this instance")
|> redirect(to: Routes.auth_path(conn, :login_form))
|> halt()
true ->
conn

@ -26,7 +26,7 @@
<p class="text-center text-gray-500 text-xs py-8">
©<%= DateTime.utc_now().year() %> Plausible Analytics. All rights reserved.
© <%= DateTime.utc_now().year() %> Plausible Analytics. All rights reserved.
</p>
<script type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>

@ -514,6 +514,42 @@ defmodule PlausibleWeb.Api.StatsController.ConversionsTest do
]
end
test "can combine wildcard and no wildcard in matches_member", %{conn: conn, site: site} do
populate_stats(site, [
build(:pageview, pathname: "/blog/post-1"),
build(:pageview, pathname: "/blog/post-2"),
build(:pageview, pathname: "/billing/upgrade")
])
insert(:goal, %{site: site, page_path: "/blog/**"})
insert(:goal, %{site: site, page_path: "/billing/upgrade"})
filters = Jason.encode!(%{goal: "Visit /blog/**|Visit /billing/upgrade"})
conn =
get(
conn,
"/api/stats/#{site.domain}/conversions?period=day&filters=#{filters}"
)
assert json_response(conn, 200) == [
%{
"name" => "Visit /blog/**",
"unique_conversions" => 2,
"total_conversions" => 2,
"prop_names" => [],
"conversion_rate" => 66.7
},
%{
"name" => "Visit /billing/upgrade",
"unique_conversions" => 1,
"total_conversions" => 1,
"prop_names" => [],
"conversion_rate" => 33.3
}
]
end
test "can filter by matches_member filter type on goals", %{conn: conn, site: site} do
populate_stats(site, [
build(:pageview, pathname: "/"),
@ -594,6 +630,37 @@ defmodule PlausibleWeb.Api.StatsController.ConversionsTest do
}
]
end
test "can combine wildcard and no wildcard in not_matches_member", %{conn: conn, site: site} do
populate_stats(site, [
build(:pageview, pathname: "/blog/post-1"),
build(:pageview, pathname: "/blog/post-2"),
build(:pageview, pathname: "/billing/upgrade"),
build(:pageview, pathname: "/register")
])
insert(:goal, %{site: site, page_path: "/blog/**"})
insert(:goal, %{site: site, page_path: "/billing/upgrade"})
insert(:goal, %{site: site, page_path: "/register"})
filters = Jason.encode!(%{goal: "!Visit /blog/**|Visit /billing/upgrade"})
conn =
get(
conn,
"/api/stats/#{site.domain}/conversions?period=day&filters=#{filters}"
)
assert json_response(conn, 200) == [
%{
"name" => "Visit /register",
"unique_conversions" => 1,
"total_conversions" => 1,
"prop_names" => [],
"conversion_rate" => 25
}
]
end
end
describe "GET /api/stats/:domain/conversions - with goal and prop=(none) filter" do

@ -33,12 +33,29 @@ defmodule PlausibleWeb.Api.StatsController.MainGraphTest do
assert %{"plot" => plot} = json_response(conn, 200)
zeroes = Stream.repeatedly(fn -> 0 end) |> Stream.take(22) |> Enum.into([])
zeroes = List.duplicate(0, 22)
assert Enum.count(plot) == 24
assert plot == [1] ++ zeroes ++ [1]
end
test "returns empty plot with no native data and recently imported from ga in realtime graph",
%{conn: conn, site: site} do
populate_stats(site, [
build(:imported_visitors, date: Date.utc_today()),
build(:imported_visitors, date: Date.utc_today())
])
conn =
get(
conn,
"/api/stats/#{site.domain}/main-graph?period=realtime&with_imported=true"
)
zeroes = List.duplicate(0, 30)
assert %{"plot" => ^zeroes, "with_imported" => false} = json_response(conn, 200)
end
test "displays visitors for a day with imported data", %{conn: conn, site: site} do
populate_stats(site, [
build(:pageview, timestamp: ~N[2021-01-01 00:00:00]),

Loading…
Cancel
Save