mirror of
https://github.com/plausible/analytics.git
synced 2024-12-29 04:22:34 +03:00
ff32218bd0
* Initial Pass * Adds support for page visits counting by referrer * Includes goal selection in entry and exit computation * Adds goal-based entry and exit page stats, formatting, code cleanup * Changelog * Format * Exit rate, visit duration, updated tests * I keep forgetting to format :/ * Tests, last time * Fixes double counting, exit rate >100%, relevant tests * Fixes exit pages on filter and goal states * Adds entry and exit filters, fixes various bugs * Fixes discussed issues * Format * Fixes impossible case in tests Originally, there were only 2 pageviews for `test-site.com`,`/` on `2019-01-01`, but that doesn't make sense when there were 3 sessions that exited on the same site/date. * Format * Removes boolean function parameter in favor of separate function * Adds support for queries that use `page` filter as `entry-page` * Format * Makes loader/title interaction in sources report consistent
34 lines
1.0 KiB
Elixir
34 lines
1.0 KiB
Elixir
defmodule PlausibleWeb.Api.StatsController.CountriesTest do
|
|
use PlausibleWeb.ConnCase
|
|
import Plausible.TestUtils
|
|
|
|
describe "GET /api/stats/:domain/countries" do
|
|
setup [:create_user, :log_in, :create_site]
|
|
|
|
test "returns top countries by new visitors", %{conn: conn, site: site} do
|
|
conn = get(conn, "/api/stats/#{site.domain}/countries?period=day&date=2019-01-01")
|
|
|
|
assert json_response(conn, 200) == [
|
|
%{
|
|
"name" => "EST",
|
|
"full_country_name" => "Estonia",
|
|
"count" => 2,
|
|
"percentage" => 50
|
|
},
|
|
%{
|
|
"name" => "GBR",
|
|
"full_country_name" => "United Kingdom",
|
|
"count" => 1,
|
|
"percentage" => 25
|
|
},
|
|
%{
|
|
"name" => "USA",
|
|
"full_country_name" => "United States",
|
|
"count" => 1,
|
|
"percentage" => 25
|
|
}
|
|
]
|
|
end
|
|
end
|
|
end
|