From 369f63bc58133c4c8f83118ffa26a9c2198cd105 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Fri, 23 Jul 2021 15:17:32 +0300 Subject: [PATCH 1/4] Adds an option to rename the script file --- CHANGELOG.md | 1 + config/runtime.exs | 7 ++++++- lib/plausible_web/plugs/tracker.ex | 8 +++++--- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eb5dd0f91..8a9cc0160f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file. - Menu (with auto-complete) to add new and edit existing filters directly plausible/analytics#1089 - Added `CLICKHOUSE_FLUSH_INTERVAL_MS` and `CLICKHOUSE_MAX_BUFFER_SIZE` configuration parameters plausible/analytics#1073 - Ability to invite users to sites with different roles plausible/analytics#1122 +- Option to configure a custom name for the script file ### Fixed - Fix weekly report time range plausible/analytics#951 diff --git a/config/runtime.exs b/config/runtime.exs index 48c08b58ec..fca0206ac8 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -136,6 +136,10 @@ is_selfhost = |> 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") + {site_limit, ""} = config_dir |> get_var_from_path_or_env("SITE_LIMIT", "50") @@ -171,7 +175,8 @@ config :plausible, admin_user_ids: admin_user_ids, site_limit: site_limit, site_limit_exempt: site_limit_exempt, - is_selfhost: is_selfhost + is_selfhost: is_selfhost, + custom_script_name: custom_script_name config :plausible, :selfhost, disable_authentication: disable_auth, diff --git a/lib/plausible_web/plugs/tracker.ex b/lib/plausible_web/plugs/tracker.ex index 8252f04c41..54f0f54712 100644 --- a/lib/plausible_web/plugs/tracker.ex +++ b/lib/plausible_web/plugs/tracker.ex @@ -2,7 +2,9 @@ defmodule PlausibleWeb.Tracker do import Plug.Conn use Agent + custom_script_name = Application.get_env(:plausible, :custom_script_name) base_variants = ["hash", "outbound-links", "exclusions", "compat"] + base_filenames = ["plausible", custom_script_name] # Generates Power Set of all variants variants = @@ -24,8 +26,8 @@ defmodule PlausibleWeb.Tracker do String.split(x, ".") |> Combination.permutate() |> Enum.map(fn p -> Enum.join(p, ".") end) - |> Enum.filter(fn permutation -> permutation != x end) - |> Enum.map(fn v -> "plausible.#{v}.js" end) + |> Enum.map(fn v -> Enum.map(base_filenames, fn filename -> "#{filename}.#{v}.js" end) end) + |> List.flatten() if Enum.count(variants) > 0 do {"plausible.#{x}.js", variants} @@ -33,7 +35,7 @@ defmodule PlausibleWeb.Tracker do end) |> Enum.reject(fn x -> x == nil end) |> Enum.into(%{}) - |> Map.put("plausible.js", ["analytics.js"]) + |> Map.put("plausible.js", ["analytics.js", "#{custom_script_name}.js"]) @templates files_available @aliases aliases_available From 13d0dce901ab011469fa208dec95a9cef3a84c15 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Mon, 26 Jul 2021 12:08:35 +0300 Subject: [PATCH 2/4] Make invitations email case insensitive --- ...11_make_invitation_email_case_insensitive.exs | 9 +++++++++ .../controllers/site_controller_test.exs | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 priv/repo/migrations/20210726090211_make_invitation_email_case_insensitive.exs diff --git a/priv/repo/migrations/20210726090211_make_invitation_email_case_insensitive.exs b/priv/repo/migrations/20210726090211_make_invitation_email_case_insensitive.exs new file mode 100644 index 0000000000..024ac42f80 --- /dev/null +++ b/priv/repo/migrations/20210726090211_make_invitation_email_case_insensitive.exs @@ -0,0 +1,9 @@ +defmodule Plausible.Repo.Migrations.MakeInvitationEmailCaseInsensitive do + use Ecto.Migration + + def change do + alter table(:invitations) do + modify :email, :citext, null: false + end + end +end diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs index 52b139c0a7..ac950c48b3 100644 --- a/test/plausible_web/controllers/site_controller_test.exs +++ b/test/plausible_web/controllers/site_controller_test.exs @@ -44,6 +44,22 @@ defmodule PlausibleWeb.SiteControllerTest do assert html_response(conn, 200) =~ "3 visitors in last 24h" end + test "shows invitations for user by email address", %{conn: conn, user: user} do + site = insert(:site) + insert(:invitation, email: user.email, site_id: site.id, inviter: build(:user)) + conn = get(conn, "/sites") + + assert html_response(conn, 200) =~ site.domain + end + + test "invitations are case insensitive", %{conn: conn, user: user} do + site = insert(:site) + insert(:invitation, email: String.upcase(user.email), site_id: site.id, inviter: build(:user)) + conn = get(conn, "/sites") + + assert html_response(conn, 200) =~ site.domain + end + test "paginates sites", %{conn: conn, user: user} do insert(:site, members: [user], domain: "test-site1.com") insert(:site, members: [user], domain: "test-site2.com") From a5c7e4f7ef8f764c56428b4d06c9c9630017b183 Mon Sep 17 00:00:00 2001 From: Uku Taht Date: Tue, 27 Jul 2021 11:41:04 +0300 Subject: [PATCH 3/4] mix format --- test/plausible_web/controllers/site_controller_test.exs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/plausible_web/controllers/site_controller_test.exs b/test/plausible_web/controllers/site_controller_test.exs index ac950c48b3..3a6dc0bd5b 100644 --- a/test/plausible_web/controllers/site_controller_test.exs +++ b/test/plausible_web/controllers/site_controller_test.exs @@ -54,7 +54,13 @@ defmodule PlausibleWeb.SiteControllerTest do test "invitations are case insensitive", %{conn: conn, user: user} do site = insert(:site) - insert(:invitation, email: String.upcase(user.email), site_id: site.id, inviter: build(:user)) + + insert(:invitation, + email: String.upcase(user.email), + site_id: site.id, + inviter: build(:user) + ) + conn = get(conn, "/sites") assert html_response(conn, 200) =~ site.domain From f179b253b43dc199871609b4eaebe7bbacf3237a Mon Sep 17 00:00:00 2001 From: Ru Singh Date: Thu, 29 Jul 2021 12:24:52 +0530 Subject: [PATCH 4/4] Hotfix/bar overflow (#1202) * chore(docker): improve repeat contributions workflow * This change adds two new commands to gracefully stop and remove the Postgres and Clickhouse docker containers. To do so, it also gives them a recognizable name. * Additionally, the Postgres container is updated to use a named volume for its data. This lower friction for repeat contributions where one would otherwise sign up and activate their accounts again and again each time. * Break words early to maintain spacing; truncate on larger screens * Update changelog entry on UI bars * Truncate bar text from md breakpoint --- CHANGELOG.md | 2 +- assets/js/dashboard/stats/conversions/index.js | 6 +++--- assets/js/dashboard/stats/conversions/prop-breakdown.js | 4 ++-- assets/js/dashboard/stats/devices/browsers.js | 4 ++-- assets/js/dashboard/stats/devices/index.js | 2 +- assets/js/dashboard/stats/devices/operating-systems.js | 4 ++-- assets/js/dashboard/stats/pages/entry-pages.js | 4 ++-- assets/js/dashboard/stats/pages/exit-pages.js | 4 ++-- assets/js/dashboard/stats/pages/pages.js | 4 ++-- assets/js/dashboard/stats/sources/referrer-list.js | 4 ++-- assets/js/dashboard/stats/sources/search-terms.js | 4 ++-- assets/js/dashboard/stats/sources/source-list.js | 8 ++++---- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a9cc0160f..5efb58019c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ All notable changes to this project will be documented in this file. - Crash when changing theme on a loaded dashboard plausible/analytics#1123 - UI fix for details button overlapping content on mobile plausible/analytics#1114 - UI fix for the main graph on mobile overlapping its tick items on both axis -- UI fixes for text not showing properly in bars across multiple lines. This hides the totals on <768px and only shows the uniques and % to accommodate the goals text too. +- UI fixes for text not showing properly in bars across multiple lines. This hides the totals on <768px and only shows the uniques and % to accommodate the goals text too. Larger screens still truncate as usual. - Turn off autocomplete for name and password inputs in the _New shared link_ form. ### Removed diff --git a/assets/js/dashboard/stats/conversions/index.js b/assets/js/dashboard/stats/conversions/index.js index 82a3909ef9..d0d252d115 100644 --- a/assets/js/dashboard/stats/conversions/index.js +++ b/assets/js/dashboard/stats/conversions/index.js @@ -59,14 +59,14 @@ export default class Conversions extends React.Component { renderGoalText(goalName) { if (this.props.query.period === 'realtime') { - return {goalName} + return {goalName} } else { const query = new URLSearchParams(window.location.search) query.set('goal', goalName) return ( - - { goalName } + + {goalName} ) } diff --git a/assets/js/dashboard/stats/conversions/prop-breakdown.js b/assets/js/dashboard/stats/conversions/prop-breakdown.js index 1d8b89ea21..f7c35b1b63 100644 --- a/assets/js/dashboard/stats/conversions/prop-breakdown.js +++ b/assets/js/dashboard/stats/conversions/prop-breakdown.js @@ -71,10 +71,10 @@ export default class PropertyBreakdown extends React.Component { renderPropContent(value, query) { return ( - + { value.name } diff --git a/assets/js/dashboard/stats/devices/browsers.js b/assets/js/dashboard/stats/devices/browsers.js index 24a2d210d2..7cf964469a 100644 --- a/assets/js/dashboard/stats/devices/browsers.js +++ b/assets/js/dashboard/stats/devices/browsers.js @@ -43,8 +43,8 @@ export default class Browsers extends React.Component { renderBrowserContent(browser, query) { return ( - - + + {browser.name} diff --git a/assets/js/dashboard/stats/devices/index.js b/assets/js/dashboard/stats/devices/index.js index 205e0fa3af..f8f454c523 100644 --- a/assets/js/dashboard/stats/devices/index.js +++ b/assets/js/dashboard/stats/devices/index.js @@ -86,7 +86,7 @@ class ScreenSizes extends React.Component { tooltip={EXPLANATION[size.name]} className="flex px-2 py-1.5 dark:text-gray-300" > - + {iconFor(size.name)} {size.name} diff --git a/assets/js/dashboard/stats/devices/operating-systems.js b/assets/js/dashboard/stats/devices/operating-systems.js index 4f80d5762c..ff6df4f56a 100644 --- a/assets/js/dashboard/stats/devices/operating-systems.js +++ b/assets/js/dashboard/stats/devices/operating-systems.js @@ -55,8 +55,8 @@ export default class OperatingSystems extends React.Component { bg="bg-green-50 dark:gray-500 dark:bg-opacity-15" maxWidthDeduction="6rem" > - - + + {os.name} diff --git a/assets/js/dashboard/stats/pages/entry-pages.js b/assets/js/dashboard/stats/pages/entry-pages.js index ab5f3ef445..c9787e043c 100644 --- a/assets/js/dashboard/stats/pages/entry-pages.js +++ b/assets/js/dashboard/stats/pages/entry-pages.js @@ -46,10 +46,10 @@ export default class EntryPages extends React.Component { bg="bg-orange-50 dark:bg-gray-500 dark:bg-opacity-15" maxWidthDeduction="4rem" > - + {page.name} diff --git a/assets/js/dashboard/stats/pages/exit-pages.js b/assets/js/dashboard/stats/pages/exit-pages.js index 9295fef391..d156627f2f 100644 --- a/assets/js/dashboard/stats/pages/exit-pages.js +++ b/assets/js/dashboard/stats/pages/exit-pages.js @@ -46,10 +46,10 @@ export default class ExitPages extends React.Component { bg="bg-orange-50 dark:bg-gray-500 dark:bg-opacity-15" maxWidthDeduction="4rem" > - + {page.name} diff --git a/assets/js/dashboard/stats/pages/pages.js b/assets/js/dashboard/stats/pages/pages.js index dc0276f031..92dd87cf73 100644 --- a/assets/js/dashboard/stats/pages/pages.js +++ b/assets/js/dashboard/stats/pages/pages.js @@ -52,11 +52,11 @@ export default class Visits extends React.Component { maxWidthDeduction="4rem" > {page.name} diff --git a/assets/js/dashboard/stats/sources/referrer-list.js b/assets/js/dashboard/stats/sources/referrer-list.js index c4bb7795f3..93b8d98c66 100644 --- a/assets/js/dashboard/stats/sources/referrer-list.js +++ b/assets/js/dashboard/stats/sources/referrer-list.js @@ -78,9 +78,9 @@ export default class Referrers extends React.Component { bg="bg-blue-50 dark:bg-gray-500 dark:bg-opacity-15" maxWidthDeduction="4rem" > - + diff --git a/assets/js/dashboard/stats/sources/search-terms.js b/assets/js/dashboard/stats/sources/search-terms.js index 6fc5607346..9ee3e7d40e 100644 --- a/assets/js/dashboard/stats/sources/search-terms.js +++ b/assets/js/dashboard/stats/sources/search-terms.js @@ -42,8 +42,8 @@ export default class SearchTerms extends React.Component { bg="bg-blue-50 dark:bg-gray-500 dark:bg-opacity-15" maxWidthDeduction="4rem" > - - + + { term.name } diff --git a/assets/js/dashboard/stats/sources/source-list.js b/assets/js/dashboard/stats/sources/source-list.js index b1442b1cec..5d916ed97a 100644 --- a/assets/js/dashboard/stats/sources/source-list.js +++ b/assets/js/dashboard/stats/sources/source-list.js @@ -53,9 +53,9 @@ class AllSources extends React.Component { bg="bg-blue-50 dark:bg-gray-500 dark:bg-opacity-15" maxWidthDeduction="4rem" > - + - + { referrer.name }