Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Run GA import in monthly batches

Uku Taht06b165eb6d1f
diff --git a/Makefile b/Makefile
index 6f60a3c285..a8c9810a5b 100644
--- a/Makefile
+++ b/Makefile
@@ -24,5 +24,5 @@ dummy_event:
-H 'X-Forwarded-For: 127.0.0.1' \
-H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36 OPR/71.0.3770.284' \
-H 'Content-Type: text/plain' \
- --data-binary '{"n":"pageview","u":"http://dummy.site/very-long-link-this-is-going-to-take-a-while-to-read-very-long-indeed-yes","d":"new-site.com","r":null,"w":1666}' \
+ --data-binary '{"n":"pageview","u":"http://dummy.site/some-page","d":"dummy.site","r":null,"w":1666}' \
--compressed
diff --git a/config/runtime.exs b/config/runtime.exs
index 53ec73e213..9121dbea59 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -325,7 +325,6 @@ if config_env() == :prod && !disable_cron do
]
extra_queues = [
- provision_ssl_certificates: 1,
trial_notification_emails: 1,
check_usage: 1,
notify_annual_renewal: 1,
diff --git a/lib/plausible/google/api.ex b/lib/plausible/google/api.ex
index 5539e94900..d1d74ba8cb 100644
--- a/lib/plausible/google/api.ex
+++ b/lib/plausible/google/api.ex
@@ -278,119 +278,105 @@ defmodule Plausible.Google.Api do
Dimensions reference: https://ga-dev-tools.web.app/dimensions-metrics-explorer
"""
- def import_analytics(site, view_id, start_date, end_date, access_token) do
- request = %{
- access_token: access_token,
- view_id: view_id,
- start_date: start_date,
- end_date: end_date
- }
-
- responses =
- Enum.map(
- @request_data,
- fn {dataset, dimensions, metrics} ->
- fetch_analytic_reports(dataset, dimensions, metrics, request)
+ def import_analytics(site, date_range, view_id, access_token) do
+ for month_batch <- prepare_batches(date_range, view_id, access_token) do
+ tasks =
+ for batch_request <- month_batch do
+ Task.async(fn -> fetch_and_persist(site, batch_request) end)
end
- )
- case Keyword.get(responses, :error) do
- nil ->
- results =
- responses
- |> Enum.map(fn {:ok, resp} -> resp end)
- |> Enum.concat()
-
- if Enum.any?(results, fn {_, val} -> val end) do
- maybe_error =
- results
- |> Enum.map(fn {dataset, data} ->
- Imported.from_google_analytics(data, site.id, dataset)
- end)
- |> Keyword.get(:error)
-
- case maybe_error do
- nil ->
- {:ok, nil}
-
- {:error, error} ->
- Sentry.capture_message("Error saving Google analytics data", extra: error)
- {:error, error["error"]["message"]}
- end
- else
- {:error, "No Google Analytics data found."}
- end
-
- error ->
- Sentry.capture_message("Error fetching Google analytics data", extra: error)
- {:error, error}
+ # 1 hour max to get 1 month's worth of data
+ Task.await_many(tasks, 3_600_000)
end
+
+ :ok
end
- defp fetch_analytic_reports(dataset, dimensions, metrics, request, page_token \\ "") do
- report = %{
- viewId: request.view_id,
- dateRanges: [
- %{
- # The earliest valid date
- startDate: request.start_date,
- endDate: request.end_date
- }
- ],
- dimensions: Enum.map(dimensions, &%{name: &1, histogramBuckets: []}),
- metrics: Enum.map(metrics, &%{expression: &1}),
- hideTotals: true,
- hideValueRanges: true,
- orderBys: [
+ defp prepare_batches(import_date_range, view_id, access_token) do
+ total_months = Timex.diff(import_date_range.last, import_date_range.first, :months)
+
+ monthly_batches =
+ for month <- 0..total_months do
+ batch_start_date = Timex.shift(import_date_range.first, months: month)
+ batch_end_date = Timex.shift(batch_start_date, months: 1, days: -1)
+
+ batch_end_date =
+ if Timex.before?(import_date_range.last, batch_end_date),
+ do: import_date_range.last,
+ else: batch_end_date
+
+ Date.range(batch_start_date, batch_end_date)
+ end
+
+ for date_range <- monthly_batches do
+ for {dataset, dimensions, metrics} <- @request_data do
%{
- fieldName: "ga:date",
- sortOrder: "DESCENDING"
+ dataset: dataset,
+ dimensions: dimensions,
+ metrics: metrics,
+ date_range: date_range,
+ view_id: view_id,
+ access_token: access_token,
+ page_token: nil
}
- ],
- pageSize: 5_000,
- pageToken: page_token
- }
+ end
+ end
+ end
- Logger.debug(Jason.encode!(%{reportRequests: [report]}))
+ defp fetch_and_persist(site, request) do
+ report_request = build_import_report_request(request)
- res =
- HTTPoison.post!(
+ {:ok, res} =
+ HTTPoison.post(
"https://analyticsreporting.googleapis.com/v4/reports:batchGet",
- Jason.encode!(%{reportRequests: [report]}),
+ Jason.encode!(%{reportRequests: [report_request]}),
[Authorization: "Bearer #{request.access_token}"],
timeout: 30_000,
recv_timeout: 30_000
)
- |> HTTPoison.Retry.autoretry(max_attempts: 3, wait: 5_000)
+ |> HTTPoison.Retry.autoretry(max_attempts: 5, wait: 5_000)
if res.status_code == 200 do
report = List.first(Jason.decode!(res.body)["reports"])
- data = report["data"]["rows"]
- next_page_token = report["nextPageToken"]
-
- if next_page_token do
- # Recursively make more requests until we run out of next page tokens
- case fetch_analytic_reports(
- dataset,
- dimensions,
- metrics,
- request,
- next_page_token
- ) do
- {:ok, %{^dataset => remainder}} ->
- {:ok, %{dataset => data ++ remainder}}
-
- error ->
- error
- end
- else
- {:ok, %{dataset => data}}
+ data = get_in(report, ["data", "rows"])
+ Imported.from_google_analytics(data, site.id, request.dataset)
+
+ case report["nextPageToken"] do
+ nil ->
+ :ok
+
+ token ->
+ fetch_and_persist(site, %{request | page_token: token})
end
else
{:error, Jason.decode!(res.body)["error"]["message"]}
end
end
+ defp build_import_report_request(request) do
+ %{
+ viewId: request.view_id,
+ dateRanges: [
+ %{
+ startDate: request.date_range.first,
+ endDate: request.date_range.last
+ }
+ ],
+ dimensions: Enum.map(request.dimensions, &%{name: &1, histogramBuckets: []}),
+ metrics: Enum.map(request.metrics, &%{expression: &1}),
+ hideTotals: true,
+ hideValueRanges: true,
+ orderBys: [
+ %{
+ fieldName: "ga:date",
+ sortOrder: "DESCENDING"
+ }
+ ],
+ pageSize: 10_000,
+ pageToken: request.page_token
+ }
+ end
+
defp refresh_if_needed(auth) do
if Timex.before?(auth.expires, Timex.now() |> Timex.shift(seconds: 30)) do
refresh_token(auth)
diff --git a/lib/plausible/imported/site.ex b/lib/plausible/imported/site.ex
index d9eb210870..12f3eebb34 100644
--- a/lib/plausible/imported/site.ex
+++ b/lib/plausible/imported/site.ex
@@ -10,8 +10,6 @@ defmodule Plausible.Imported do
def from_google_analytics(nil, _site_id, _metric), do: {:ok, nil}
def from_google_analytics(data, site_id, table) do
- Logger.debug("Processing imported data (table=#{table}): #{inspect(data)}")
-
data =
Enum.map(data, fn row ->
new_from_google_analytics(site_id, table, row)
@@ -234,8 +232,14 @@ defmodule Plausible.Imported do
end
defp format_date(date) do
- Timex.parse!("#{date}", "%Y%m%d", :strftime)
- |> NaiveDateTime.to_date()
+ case Timex.parse("#{date}", "%Y%m%d", :strftime) do
+ {:ok, datetime} ->
+ NaiveDateTime.to_date(datetime)
+
+ {:error, e} ->
+ Logger.error(e)
+ raise e
+ end
end
@missing_values ["(none)", "(not set)", "(not provided)"]
diff --git a/lib/workers/import_google_analytics.ex b/lib/workers/import_google_analytics.ex
index d5fd30fc74..3595605e5c 100644
--- a/lib/workers/import_google_analytics.ex
+++ b/lib/workers/import_google_analytics.ex
@@ -20,9 +20,12 @@ defmodule Plausible.Workers.ImportGoogleAnalytics do
google_api \\ Plausible.Google.Api
) do
site = Repo.get(Plausible.Site, site_id) |> Repo.preload([[memberships: :user]])
+ start_date = Date.from_iso8601!(start_date)
+ end_date = Date.from_iso8601!(end_date)
+ date_range = Date.range(start_date, end_date)
- case google_api.import_analytics(site, view_id, start_date, end_date, access_token) do
- {:ok, _} ->
+ case google_api.import_analytics(site, date_range, view_id, access_token) do
+ :ok ->
Plausible.Site.import_success(site)
|> Repo.update!()
diff --git a/mix.exs b/mix.exs
index b2314cda84..6695718cca 100644
--- a/mix.exs
+++ b/mix.exs
@@ -56,7 +56,7 @@ defmodule Plausible.MixProject do
{:ecto_sql, "~> 3.0"},
{:elixir_uuid, "~> 1.2", only: :test},
{:jason, "~> 1.2"},
- {:phoenix, "~> 1.5.0"},
+ {:phoenix, "~> 1.6.0"},
{:phoenix_ecto, "~> 4.0"},
{:phoenix_html, "~> 2.12"},
{:phoenix_live_reload, "~> 1.2", only: :dev},
diff --git a/mix.lock b/mix.lock
index 4a6ee92397..e3bb16cc86 100644
--- a/mix.lock
+++ b/mix.lock
@@ -27,17 +27,19 @@
"decorator": {:hex, :decorator, "1.4.0", "a57ac32c823ea7e4e67f5af56412d12b33274661bb7640ec7fc882f8d23ac419", [:mix], [], "hexpm", "0a07cedd9083da875c7418dea95b78361197cf2bf3211d743f6f7ce39656597f"},
"dialyxir": {:hex, :dialyxir, "1.1.0", "c5aab0d6e71e5522e77beff7ba9e08f8e02bad90dfbeffae60eaf0cb47e29488", [:mix], [{:erlex, ">= 0.2.6", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "07ea8e49c45f15264ebe6d5b93799d4dd56a44036cf42d0ad9c960bc266c0b9a"},
"double": {:hex, :double, "0.8.1", "d08a3fe82b1b2efb3bcabbf0e81beee4ed2c8572b50fed7696a53ebe6bb74567", [:mix], [], "hexpm", "956b727ebc4f85ed5a4deca2e263b9d532cdf49f8090700193fea8af131e1d4d"},
- "ecto": {:hex, :ecto, "3.7.1", "a20598862351b29f80f285b21ec5297da1181c0442687f9b8329f0445d228892", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d36e5b39fc479e654cffd4dbe1865d9716e4a9b6311faff799b6f90ab81b8638"},
- "ecto_sql": {:hex, :ecto_sql, "3.7.1", "8de624ef50b2a8540252d8c60506379fbbc2707be1606853df371cf53df5d053", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "2b42a32e2ce92f64aba5c88617891ab3b0ba34f3f3a503fa20009eae1a401c81"},
+ "ecto": {:hex, :ecto, "3.7.2", "44c034f88e1980754983cc4400585970b4206841f6f3780967a65a9150ef09a8", [:mix], [{:decimal, "~> 1.6 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "a600da5772d1c31abbf06f3e4a1ffb150e74ed3e2aa92ff3cee95901657a874e"},
+ "ecto_sql": {:hex, :ecto_sql, "3.7.2", "55c60aa3a06168912abf145c6df38b0295c34118c3624cf7a6977cd6ce043081", [:mix], [{:db_connection, "~> 2.2", [hex: :db_connection, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:myxql, "~> 0.4.0 or ~> 0.5.0 or ~> 0.6.0", [hex: :myxql, repo: "hexpm", optional: true]}, {:postgrex, "~> 0.15.0 or ~> 0.16.0 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}, {:tds, "~> 2.1.1 or ~> 2.2", [hex: :tds, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.0 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3c218ea62f305dcaef0b915fb56583195e7b91c91dcfb006ba1f669bfacbff2a"},
"elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"},
"elixir_uuid": {:hex, :elixir_uuid, "1.2.1", "dce506597acb7e6b0daeaff52ff6a9043f5919a4c3315abb4143f0b00378c097", [:mix], [], "hexpm", "f7eba2ea6c3555cea09706492716b0d87397b88946e6380898c2889d68585752"},
"envy": {:hex, :envy, "1.1.1", "0bc9bd654dec24fcdf203f7c5aa1b8f30620f12cfb28c589d5e9c38fe1b07475", [:mix], [], "hexpm", "7061eb1a47415fd757145d8dec10dc0b1e48344960265cb108f194c4252c3a89"},
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
"eternal": {:hex, :eternal, "1.2.2", "d1641c86368de99375b98d183042dd6c2b234262b8d08dfd72b9eeaafc2a1abd", [:mix], [], "hexpm", "2c9fe32b9c3726703ba5e1d43a1d255a4f3f2d8f8f9bc19f094c7cb1a7a9e782"},
"ex_machina": {:hex, :ex_machina, "2.7.0", "b792cc3127fd0680fecdb6299235b4727a4944a09ff0fa904cc639272cd92dc7", [:mix], [{:ecto, "~> 2.2 or ~> 3.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: true]}], "hexpm", "419aa7a39bde11894c87a615c4ecaa52d8f107bbdd81d810465186f783245bf8"},
+ "exconstructor": {:hex, :exconstructor, "1.2.6", "246473024fad510329ea569d02eead44ca35c413f582a94752e503929b97afe7", [:mix], [], "hexpm", "52142eaf77d3783f4b88003e33d41eed83605d4b32116bfb6e8198e981d10c8c"},
"excoveralls": {:hex, :excoveralls, "0.14.4", "295498f1ae47bdc6dce59af9a585c381e1aefc63298d48172efaaa90c3d251db", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e3ab02f2df4c1c7a519728a6f0a747e71d7d6e846020aae338173619217931c1"},
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"floki": {:hex, :floki, "0.32.0", "f915dc15258bc997d49be1f5ef7d3992f8834d6f5695270acad17b41f5bcc8e2", [:mix], [{:html_entities, "~> 0.5.0", [hex: :html_entities, repo: "hexpm", optional: false]}], "hexpm", "1c5a91cae1fd8931c26a4826b5e2372c284813904c8bacb468b5de39c7ececbd"},
+ "gen_retry": {:hex, :gen_retry, "1.4.0", "682fadcb7ebf629f8dc4d84b4e62e03dce1baa526141133a19a8e7cee5ef7e1b", [:mix], [{:exconstructor, "~> 1.0", [hex: :exconstructor, repo: "hexpm", optional: false]}], "hexpm", "c15311afe0770f5fc58f4391b2ff3362fd25f1e107d02ff63592d36f30eaaae4"},
"gen_smtp": {:hex, :gen_smtp, "1.1.1", "bf9303c31735100631b1d708d629e4c65944319d1143b5c9952054f4a1311d85", [:rebar3], [{:hut, "1.3.0", [hex: :hut, repo: "hexpm", optional: false]}, {:ranch, ">= 1.7.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "51bc50cc017efd4a4248cbc39ea30fb60efa7d4a49688986fafad84434ff9ab7"},
"geolix": {:hex, :geolix, "1.1.0", "8b0fe847fef486d9e8b7c21eae6cbc2d998fb249e61d3f4f136f8016b9c1c833", [:mix], [{:poolboy, "~> 1.0", [hex: :poolboy, repo: "hexpm", optional: false]}], "hexpm", "980854f2aef30c288dc79e86c5267806d704c4525fde1b75de9a92f67fb16300"},
"geolix_adapter_mmdb2": {:hex, :geolix_adapter_mmdb2, "0.5.0", "5912723d9538ecddc6b29b1d8041b917b735a78fd3c122bfea8c44aa782e3369", [:mix], [{:geolix, "~> 1.1", [hex: :geolix, repo: "hexpm", optional: false]}, {:mmdb2_decoder, "~> 3.0", [hex: :mmdb2_decoder, repo: "hexpm", optional: false]}], "hexpm", "cb1485b6a0a2d3e541949207428a245718dbf1258453a0df0e5fdd925bcecd3e"},
@@ -62,22 +64,23 @@
"mmdb2_decoder": {:hex, :mmdb2_decoder, "3.0.0", "54828676a36e75e9a25bc9a0bb0598d4c7fcc767bf0b40674850b22e05b7b6cc", [:mix], [], "hexpm", "359dc9242915538d1dceb9f6d96c72201dca76ce62e49d22e2ed1e86f20bea8e"},
"nanoid": {:hex, :nanoid, "2.0.5", "1d2948d8967ef2d948a58c3fef02385040bd9823fc6394bd604b8d98e5516b22", [:mix], [], "hexpm", "956e8876321104da72aa48770539ff26b36b744cd26753ec8e7a8a37e53d5f58"},
"oauther": {:hex, :oauther, "1.3.0", "82b399607f0ca9d01c640438b34d74ebd9e4acd716508f868e864537ecdb1f76", [:mix], [], "hexpm", "78eb888ea875c72ca27b0864a6f550bc6ee84f2eeca37b093d3d833fbcaec04e"},
- "oban": {:hex, :oban, "2.9.2", "5504c1c28d0b04e326c1075bd5f0f9c0fbe93850f581d9b201e2e2ad86ef8cc8", [:mix], [{:ecto_sql, ">= 3.4.3", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f05a042c6611c013a21717dd78cc1e64690b6b66885e6e237c3a2af1b9e9cff8"},
+ "oban": {:hex, :oban, "2.10.1", "202a90f2aed0130b7d750bdbfea8090c8321bce255bade10fd3699733565add0", [:mix], [{:ecto_sql, "~> 3.6", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.14", [hex: :postgrex, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "161cdd01194147cd6a3efdb1d6c3d9689309991412f799c1e242c18912e307c3"},
"parallel_stream": {:hex, :parallel_stream, "1.0.6", "b967be2b23f0f6787fab7ed681b4c45a215a81481fb62b01a5b750fa8f30f76c", [:mix], [], "hexpm", "639b2e8749e11b87b9eb42f2ad325d161c170b39b288ac8d04c4f31f8f0823eb"},
"parse_trans": {:hex, :parse_trans, "3.3.1", "16328ab840cc09919bd10dab29e431da3af9e9e7e7e6f0089dd5a2d2820011d8", [:rebar3], [], "hexpm", "07cd9577885f56362d414e8c4c4e6bdf10d43a8767abb92d24cbe8b24c54888b"},
- "phoenix": {:hex, :phoenix, "1.5.13", "d4e0805ec0973bed80d67302631130fb47d75b1a0b7335a0b23c4432b6ce55ee", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "1a7c4f1900e6e60bb60ae6680e48418e3f7c360d58bcb9f812487b6d0d281a0f"},
+ "phoenix": {:hex, :phoenix, "1.6.6", "281c8ce8dccc9f60607346b72cdfc597c3dde134dd9df28dff08282f0b751754", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 1.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "807bd646e64cd9dc83db016199715faba72758e6db1de0707eef0a2da4924364"},
"phoenix_ecto": {:hex, :phoenix_ecto, "4.4.0", "0672ed4e4808b3fbed494dded89958e22fb882de47a97634c0b13e7b0b5f7720", [:mix], [{:ecto, "~> 3.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "09864e558ed31ee00bd48fcc1d4fc58ae9678c9e81649075431e69dbabb43cc1"},
"phoenix_html": {:hex, :phoenix_html, "2.14.3", "51f720d0d543e4e157ff06b65de38e13303d5778a7919bcc696599e5934271b8", [:mix], [{:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "efd697a7fff35a13eeeb6b43db884705cba353a1a41d127d118fda5f90c8e80f"},
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.3.3", "3a53772a6118d5679bf50fc1670505a290e32a1d195df9e069d8c53ab040c054", [:mix], [{:file_system, "~> 0.2.1 or ~> 0.3", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "766796676e5f558dbae5d1bdb066849673e956005e3730dfd5affd7a6da4abac"},
"phoenix_pagination": {:hex, :phoenix_pagination, "0.7.0", "e8503270da3c41f4ac4fea5ae90503f51287e9cd72b3a6abb0c547fe84d9639b", [:mix], [{:ecto_sql, "~> 3.0", [hex: :ecto_sql, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.12", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.11.1", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "27055338e9824bb302bb0d72e14972a9a2fb916bf435545f04f361671d6d827f"},
- "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"},
+ "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.1.1", "ba04e489ef03763bf28a17eb2eaddc2c20c6d217e2150a61e3298b0f4c2012b5", [:mix], [], "hexpm", "81367c6d1eea5878ad726be80808eb5a787a23dee699f96e72b1109c57cdd8d9"},
+ "phoenix_view": {:hex, :phoenix_view, "1.1.2", "1b82764a065fb41051637872c7bd07ed2fdb6f5c3bd89684d4dca6e10115c95a", [:mix], [{:phoenix_html, "~> 2.14.2 or ~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: true]}], "hexpm", "7ae90ad27b09091266f6adbb61e1d2516a7c3d7062c6789d46a7554ec40f3a56"},
"php_serializer": {:hex, :php_serializer, "2.0.0", "b43f31aca22ed7321f32da2b94fe2ddf9b6739a965cb51541969119e572e821d", [:mix], [], "hexpm", "61e402e99d9062c0225a3f4fcf7e43b4cba1b8654944c0e7c139c3ca9de481da"},
"plug": {:hex, :plug, "1.11.1", "f2992bac66fdae679453c9e86134a4201f6f43a687d8ff1cd1b2862d53c80259", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "23524e4fefbb587c11f0833b3910bfb414bf2e2534d61928e920f54e3a1b881f"},
"plug_cowboy": {:hex, :plug_cowboy, "2.5.2", "62894ccd601cf9597e2c23911ff12798a8a18d237e9739f58a6b04e4988899fe", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ea6e87f774c8608d60c8d34022a7d073bd7680a0a013f049fc62bf35efea1044"},
"plug_crypto": {:hex, :plug_crypto, "1.2.2", "05654514ac717ff3a1843204b424477d9e60c143406aa94daf2274fdd280794d", [:mix], [], "hexpm", "87631c7ad914a5a445f0a3809f99b079113ae4ed4b867348dd9eec288cecb6db"},
"poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], [], "hexpm", "fec8660eb7733ee4117b85f55799fd3833eb769a6df71ccf8903e8dc5447cfce"},
"poolboy": {:hex, :poolboy, "1.5.2", "392b007a1693a64540cead79830443abf5762f5d30cf50bc95cb2c1aaafa006b", [:rebar3], [], "hexpm", "dad79704ce5440f3d5a3681c8590b9dc25d1a561e8f5a9c995281012860901e3"},
- "postgrex": {:hex, :postgrex, "0.15.12", "9ee623448310a6ea8543c1207379aea072d699b738b89549f05248b5807302d1", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "1234a9cda8803ca5026dd1512d9fa171c78dd9a27ed3ffd2ca2c5d5753af8922"},
+ "postgrex": {:hex, :postgrex, "0.15.13", "7794e697481799aee8982688c261901de493eb64451feee6ea58207d7266d54a", [:mix], [{:connection, "~> 1.0", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "3ffb76e1a97cfefe5c6a95632a27ffb67f28871c9741fb585f9d1c3cd2af70f1"},
"public_suffix": {:git, "https://github.com/axelson/publicsuffix-elixir", "89372422ab8b433de508519ef474e39699fd11ca", []},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"ref_inspector": {:hex, :ref_inspector, "1.3.1", "bb0489a4c4299dcd633f2b7a60c41a01f5590789d0b28225a60be484e1fbe777", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:yamerl, "~> 0.7", [hex: :yamerl, repo: "hexpm", optional: false]}], "hexpm", "3172eb1b08e5c69966f796e3fe0e691257546fa143a5eb0ecc18a6e39b233854"},
diff --git a/test/workers/import_google_analytics_test.exs b/test/workers/import_google_analytics_test.exs
index 1852945a47..71857fd45e 100644
--- a/test/workers/import_google_analytics_test.exs
+++ b/test/workers/import_google_analytics_test.exs
@@ -18,11 +18,10 @@ defmodule Plausible.Workers.ImportGoogleAnalyticsTest do
api_stub =
stub(Plausible.Google.Api, :import_analytics, fn _site,
+ _date_range,
_view_id,
- _start_date,
- _end_date,
_access_token ->
- {:ok, nil}
+ :ok
end)
ImportGoogleAnalytics.perform(
@@ -47,11 +46,10 @@ defmodule Plausible.Workers.ImportGoogleAnalyticsTest do
api_stub =
stub(Plausible.Google.Api, :import_analytics, fn _site,
+ _date_range,
_view_id,
- _start_date,
- _end_date,
_access_token ->
- {:ok, nil}
+ :ok
end)
ImportGoogleAnalytics.perform(
@@ -76,11 +74,10 @@ defmodule Plausible.Workers.ImportGoogleAnalyticsTest do
api_stub =
stub(Plausible.Google.Api, :import_analytics, fn _site,
+ _date_range,
_view_id,
- _start_date,
- _end_date,
_access_token ->
- {:ok, nil}
+ :ok
end)
ImportGoogleAnalytics.perform(
@@ -108,9 +105,8 @@ defmodule Plausible.Workers.ImportGoogleAnalyticsTest do
api_stub =
stub(Plausible.Google.Api, :import_analytics, fn _site,
+ _date_range,
_view_id,
- _start_date,
- _end_date,
_access_token ->
{:error, "Something went wrong"}
end)
@@ -141,9 +137,8 @@ defmodule Plausible.Workers.ImportGoogleAnalyticsTest do
api_stub =
stub(Plausible.Google.Api, :import_analytics, fn _site,
+ _date_range,
_view_id,
- _start_date,
- _end_date,
_access_token ->
{:error, "Something went wrong"}
end)
@@ -170,9 +165,8 @@ defmodule Plausible.Workers.ImportGoogleAnalyticsTest do
api_stub =
stub(Plausible.Google.Api, :import_analytics, fn _site,
+ _date_range,
_view_id,
- _start_date,
- _end_date,
_access_token ->
{:error, "Something went wrong"}
end)