From 8a8df685a7c3fcc00e52f5569781ca4e460abcfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20K=C3=BCc=C3=BCk?= Date: Tue, 27 Feb 2024 09:42:41 +0000 Subject: [PATCH] Update country code for anonymising VPN services (#3766) * Update country code for anonymising VPN services * Update to latest --- lib/plausible/ingestion/event.ex | 10 ++++++++-- mix.lock | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/plausible/ingestion/event.ex b/lib/plausible/ingestion/event.ex index d31aebeba..721411bba 100644 --- a/lib/plausible/ingestion/event.ex +++ b/lib/plausible/ingestion/event.ex @@ -221,9 +221,15 @@ defmodule Plausible.Ingestion.Event do end defp put_geolocation(%__MODULE__{} = event) do - result = Plausible.Ingestion.Geolocation.lookup(event.request.remote_ip) || %{} + case event.request.ip_classification do + "anonymous_vpn_ip" -> + result = %{country_code: "A1"} + update_attrs(event, result) - update_attrs(event, result) + _any -> + result = Plausible.Ingestion.Geolocation.lookup(event.request.remote_ip) || %{} + update_attrs(event, result) + end end defp put_props(%__MODULE__{request: %{props: %{} = props}} = event) do diff --git a/mix.lock b/mix.lock index 8a108e96e..e9520717c 100644 --- a/mix.lock +++ b/mix.lock @@ -71,7 +71,7 @@ "jose": {:hex, :jose, "1.11.6", "613fda82552128aa6fb804682e3a616f4bc15565a048dabd05b1ebd5827ed965", [:mix, :rebar3], [], "hexpm", "6275cb75504f9c1e60eeacb771adfeee4905a9e182103aa59b53fed651ff9738"}, "jumper": {:hex, :jumper, "1.0.2", "68cdcd84472a00ac596b4e6459a41b3062d4427cbd4f1e8c8793c5b54f1406a7", [:mix], [], "hexpm", "9b7782409021e01ab3c08270e26f36eb62976a38c1aa64b2eaf6348422f165e1"}, "kaffy": {:hex, :kaffy, "0.10.2", "72e807c525323bd0cbc3ac0c127b7bde61caffdc576fb6554964d3fe6a2a6100", [:mix], [{:ecto, "~> 3.0", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.6", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0.2", [hex: :phoenix_view, repo: "hexpm", optional: false]}], "hexpm", "651cad5f3bcc91510a671c13c7a273b8b8195fdf2d809208708baecbb77300bf"}, - "location": {:git, "https://github.com/plausible/location.git", "31f91c4df430cfc16219000ac667cc665826b77c", []}, + "location": {:git, "https://github.com/plausible/location.git", "3f360af0c9deac1d2ca0bd1c4fcb8769b673d948", []}, "locus": {:hex, :locus, "2.3.6", "c9f53fd5df872fca66a54dc0aa2f8b2d3640388e56a0c39a741be0df6d8854bf", [:rebar3], [{:tls_certificate_check, "~> 1.9", [hex: :tls_certificate_check, repo: "hexpm", optional: false]}], "hexpm", "6087aa9a69673e7011837fb4b3d7f756560adde76892c32f5f93904ee30064e2"}, "makeup": {:hex, :makeup, "1.1.1", "fa0bc768698053b2b3869fa8a62616501ff9d11a562f3ce39580d60860c3a55e", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "5dc62fbdd0de44de194898b6710692490be74baa02d9d108bc29f007783b0b48"}, "makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},