Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Drop events when classified as datacenter IP (#3647)
Cenk Kücük147597cd98a1
diff --git a/lib/plausible/ingestion/event.ex b/lib/plausible/ingestion/event.exindex 950579acf3..881353b436 100644--- a/lib/plausible/ingestion/event.ex+++ b/lib/plausible/ingestion/event.ex@@ -144,8 +144,7 @@ defmodule Plausible.Ingestion.Event dodefp put_ip_classification(%__MODULE__{} = event) docase event.request.ip_classification do"dc_ip" ->- emit_telemetry_dropped(event, :dc_ip)- event+ drop(event, :dc_ip)_any ->eventdiff --git a/test/plausible/ingestion/event_test.exs b/test/plausible/ingestion/event_test.exsindex e4a6854b3d..3db601961c 100644--- a/test/plausible/ingestion/event_test.exs+++ b/test/plausible/ingestion/event_test.exs@@ -100,6 +100,23 @@ defmodule Plausible.Ingestion.EventTest doassert dropped.drop_reason == :throttleend+ test "event pipeline drops a request when header x-plausible-ip-type is dc_ip" do+ site = insert(:site)++ payload = %{+ name: "pageview",+ url: "http://dummy.site",+ domain: site.domain+ }++ conn = build_conn(:post, "/api/events", payload)+ conn = Plug.Conn.put_req_header(conn, "x-plausible-ip-type", "dc_ip")+ assert {:ok, request} = Request.build(conn)++ assert {:ok, %{buffered: [], dropped: [dropped]}} = Event.build_and_buffer(request)+ assert dropped.drop_reason == :dc_ip+ end+test "event pipeline drops events for site with accept_trafic_until in the past" doyesterday = NaiveDateTime.add(NaiveDateTime.utc_now(), -1, :day)site = insert(:site, ingest_rate_limit_threshold: 1, accept_traffic_until: yesterday)