View Source Plausible.Stats.Filters (Plausible v0.0.1)
A module for parsing filters used in stat queries.
Summary
Functions
Parses different filter formats.
Functions
Parses different filter formats.
Depending on the format and type of the filters
argument, returns:
- a decoded map, when
filters
is encoded JSON - a parsed filter map, when
filters
is a filter expression string - the same map, when
filters
is a map
Returns an empty map when argument type is unexpected (e.g. nil
).
Examples:
iex> Filters.parse("{\"page\":\"/blog/**\"}")
%{"event:page" => {:matches, "/blog/**"}}
iex> Filters.parse("visit:browser!=Chrome")
%{"visit:browser" => {:is_not, "Chrome"}}
iex> Filters.parse(nil)
%{}