Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove unimportant information from keyword modal
  • Loading branch information
ukutaht committed May 9, 2024
commit ec9090fd46d65ce53d17ce535e7d152c536702f7
23 changes: 1 addition & 22 deletions assets/js/dashboard/stats/modals/google-keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class GoogleKeywordsModal extends React.Component {
.then((res) => this.setState({
loading: false,
searchTerms: res.search_terms,
totalVisitors: res.total_visitors,
notConfigured: res.not_configured,
isOwner: res.is_owner
}))
Expand All @@ -40,15 +39,7 @@ class GoogleKeywordsModal extends React.Component {
}

renderKeywords() {
if (this.state.query.filters.goal) {
return (
<div className="text-center text-gray-700 dark:text-gray-300 mt-6">
<RocketIcon />
<div className="text-lg">Sorry, we cannot show which keywords converted best for goal <b>{this.state.query.filters.goal}</b></div>
<div className="text-lg">Google does not share this information</div>
</div>
)
} else if (this.state.notConfigured) {
if (this.state.notConfigured) {
if (this.state.isOwner) {
return (
<div className="text-center text-gray-700 dark:text-gray-300 mt-6">
Expand Down Expand Up @@ -91,14 +82,6 @@ class GoogleKeywordsModal extends React.Component {
}
}

renderGoalText() {
if (this.state.query.filters.goal) {
return (
<h1 className="text-xl font-semibold text-gray-500 dark:text-gray-200 leading-none">completed {this.state.query.filters.goal}</h1>
)
}
}

renderBody() {
if (this.state.loading) {
return (
Expand All @@ -111,10 +94,6 @@ class GoogleKeywordsModal extends React.Component {

<div className="my-4 border-b border-gray-300 dark:border-gray-500"></div>
<main className="modal__content">
<h1 className="text-xl font-semibold mb-0 leading-none dark:text-gray-200">
{this.state.totalVisitors} visitors from Google<br />
</h1>
{this.renderGoalText()}
{ this.renderKeywords() }
</main>
</React.Fragment>
Expand Down
2 changes: 0 additions & 2 deletions lib/plausible/google/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ defmodule Plausible.Google.API do
end

defp get_search_console_filters(property, plausible_filters) do
plausible_filters = Map.drop(plausible_filters, ["visit:source"])

search_console_filters =
Enum.reduce_while(plausible_filters, [], fn plausible_filter, search_console_filters ->
case transform_filter(property, plausible_filter) do
Expand Down
15 changes: 5 additions & 10 deletions lib/plausible_web/controllers/api/stats_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -682,34 +682,29 @@ defmodule PlausibleWeb.Api.StatsController do
def referrer_drilldown(conn, %{"referrer" => "Google"} = params) do
site = conn.assigns[:site] |> Repo.preload(:google_auth)

query =
Query.from(site, params)
|> Query.put_filter("visit:source", "Google")
query = Query.from(site, params)

search_terms =
if site.google_auth && site.google_auth.property && !query.filters["goal"] do
if site.google_auth && site.google_auth.property do
google_api().fetch_stats(site, query, params["limit"] || 9)
end

%{:visitors => %{value: total_visitors}} = Stats.aggregate(site, query, [:visitors])

user_id = get_session(conn, :current_user_id)
is_admin = user_id && Plausible.Sites.has_admin_access?(user_id, site)

case search_terms do
nil ->
json(conn, %{not_configured: true, is_admin: is_admin, total_visitors: total_visitors})
json(conn, %{not_configured: true, is_admin: is_admin})

{:ok, terms} ->
json(conn, %{search_terms: terms, total_visitors: total_visitors})
json(conn, %{search_terms: terms})

{:error, _} ->
conn
|> put_status(502)
|> json(%{
not_configured: true,
is_admin: is_admin,
total_visitors: total_visitors
is_admin: is_admin
})
end
end
Expand Down