View Source Plausible.Stats.Filters (Plausible v0.0.1)

A module for parsing filters used in stat queries.

Summary

Functions

Link to this function

dimensions_used_in_filters(filters, opts \\ [])

View Source
Link to this function

event_table_visit_props()

View Source
Link to this function

filtering_on_dimension?(query, dimension)

View Source
Link to this function

get_toplevel_filter(query, prefix)

View Source

Gets the first top level filter with matching dimension (or nil).

Only use in cases where it's known that filters are only set on the top level as it does not handle AND/OR/NOT!

Parses different filter formats.

Depending on the format and type of the filters argument, returns:

  • a decoded list, when filters is encoded JSON
  • a parsed filter list, when filters is a filter expression string
  • the same list, when filters is a map

Returns an empty list when argument type is unexpected (e.g. nil).

Examples:

iex> Filters.parse("{\"page\":\"/blog/**\"}")
[[:matches_wildcard, "event:page", ["/blog/**"]]]

iex> Filters.parse("visit:browser!=Chrome")
[[:is_not, "visit:browser", ["Chrome"]]]

iex> Filters.parse(nil)
[]
Link to this function

rename_dimensions_used_in_filter(filters, renames)

View Source
Link to this function

transform_filters(filters, transformer)

View Source

Updates filters via transformer.

Transformer will receive each node (filter, and/or/not subtree) of query and must return a list of nodes to replace it with or nil to ignore and look deeper.

Link to this function

without_prefix(dimension)

View Source