Ignore nil custom prop as well

pull/1877/head
Uku Taht 5 years ago
parent c92c548ca8
commit 02abbda06d

@ -204,6 +204,7 @@ defmodule PlausibleWeb.Api.ExternalController do
{:ok, parsed_json} ->
Enum.filter(parsed_json, fn
{_, ""} -> false
{_, nil} -> false
{_, val} when is_list(val) -> false
{_, val} when is_map(val) -> false
_ -> true

@ -558,6 +558,24 @@ defmodule PlausibleWeb.Api.ExternalControllerTest do
assert Map.get(event, :"meta.value") == ["true"]
end
test "ignores custom prop with nil value", %{conn: conn} do
params = %{
name: "Signup",
url: "http://gigride.live/",
domain: "custom-prop-test-nil.com",
props: Jason.encode!(%{foo: nil, other_key: true})
}
conn = post(conn, "/api/event", params)
assert conn.status == 202
event = get_event("custom-prop-test-nil.com")
assert Map.get(event, :"meta.key") == ["other_key"]
assert Map.get(event, :"meta.value") == ["true"]
end
test "ignores a malformed referrer URL", %{conn: conn} do
params = %{
name: "pageview",

Loading…
Cancel
Save