mirror of
https://github.com/plausible/analytics.git
synced 2024-10-26 18:32:25 +03:00
Drop events when classified as datacenter IP (#3647)
This commit is contained in:
parent
9d97dc1912
commit
147597cd98
@ -144,8 +144,7 @@ defmodule Plausible.Ingestion.Event do
|
||||
defp put_ip_classification(%__MODULE__{} = event) do
|
||||
case event.request.ip_classification do
|
||||
"dc_ip" ->
|
||||
emit_telemetry_dropped(event, :dc_ip)
|
||||
event
|
||||
drop(event, :dc_ip)
|
||||
|
||||
_any ->
|
||||
event
|
||||
|
@ -100,6 +100,23 @@ defmodule Plausible.Ingestion.EventTest do
|
||||
assert dropped.drop_reason == :throttle
|
||||
end
|
||||
|
||||
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" do
|
||||
yesterday = NaiveDateTime.add(NaiveDateTime.utc_now(), -1, :day)
|
||||
site = insert(:site, ingest_rate_limit_threshold: 1, accept_traffic_until: yesterday)
|
||||
|
Loading…
Reference in New Issue
Block a user