From 67f45a42abd07824b8041c7b169cd5436d1fb985 Mon Sep 17 00:00:00 2001 From: Adrian Gruntkowski Date: Thu, 4 Jul 2024 12:01:52 +0200 Subject: [PATCH] Stop listing UA views in Google data import flow --- lib/plausible/google/api.ex | 5 ++- .../google_analytics_controller_test.exs | 33 ++----------------- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/lib/plausible/google/api.ex b/lib/plausible/google/api.ex index 763981aea9171..a20ea7bf95b44 100644 --- a/lib/plausible/google/api.ex +++ b/lib/plausible/google/api.ex @@ -32,9 +32,8 @@ defmodule Plausible.Google.API do end def list_properties_and_views(access_token) do - with {:ok, properties} <- Plausible.Google.GA4.API.list_properties(access_token), - {:ok, views} <- Plausible.Google.UA.API.list_views(access_token) do - {:ok, properties ++ views} + with {:ok, properties} <- Plausible.Google.GA4.API.list_properties(access_token) do + {:ok, properties} end end diff --git a/test/plausible_web/controllers/google_analytics_controller_test.exs b/test/plausible_web/controllers/google_analytics_controller_test.exs index b6a7cc224ad01..904382c07871f 100644 --- a/test/plausible_web/controllers/google_analytics_controller_test.exs +++ b/test/plausible_web/controllers/google_analytics_controller_test.exs @@ -44,7 +44,7 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do describe "GET /:website/import/google-analytics/property-or-view" do setup [:create_user, :log_in, :create_new_site] - test "lists Google Analytics views and properties", %{conn: conn, site: site} do + test "lists Google Analytics properties WITHOUT UA views", %{conn: conn, site: site} do expect( Plausible.HTTPClient.Mock, :get, @@ -54,15 +54,6 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do end ) - expect( - Plausible.HTTPClient.Mock, - :get, - fn _url, _opts -> - body = "fixture/ga_list_views.json" |> File.read!() |> Jason.decode!() - {:ok, %Finch.Response{body: body, status: 200}} - end - ) - response = conn |> get("/#{site.domain}/import/google-analytics/property-or-view", %{ @@ -72,8 +63,8 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do }) |> html_response(200) - assert response =~ "57238190 - one.test" - assert response =~ "54460083 - two.test" + refute response =~ "57238190 - one.test" + refute response =~ "54460083 - two.test" assert response =~ "account.one - GA4 (properties/428685906)" assert response =~ "GA4 - Flood-It! (properties/153293282)" assert response =~ "GA4 - Google Merch Shop (properties/213025502)" @@ -343,15 +334,6 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do end ) - expect( - Plausible.HTTPClient.Mock, - :get, - fn _url, _opts -> - body = "fixture/ga_list_views.json" |> File.read!() |> Jason.decode!() - {:ok, %Finch.Response{body: body, status: 200}} - end - ) - response = conn |> post("/#{site.domain}/import/google-analytics/property-or-view", %{ @@ -392,15 +374,6 @@ defmodule PlausibleWeb.GoogleAnalyticsControllerTest do end ) - expect( - Plausible.HTTPClient.Mock, - :get, - fn _url, _opts -> - body = "fixture/ga_list_views.json" |> File.read!() |> Jason.decode!() - {:ok, %Finch.Response{body: body, status: 200}} - end - ) - response = conn |> post("/#{site.domain}/import/google-analytics/property-or-view", %{