View Source RefInspector (RefInspector v2.0.0)
Referer parser library.
preparation
Preparation
- Verify your supervision setup according to
RefInspector.Supervisor
- Revise the default configuration values of
RefInspector.Config
and adjust to your project/environment where necessary - Download a copy of the parser database file(s) as outlined in
RefInspector.Downloader
usage
Usage
iex> RefInspector.parse("http://www.google.com/search?q=ref_inspector")
%RefInspector.Result{
medium: "search",
referer: "http://www.google.com/search?q=ref_inspector",
source: "Google",
term: "ref_inspector"
}
Passing a referer string will result in a %RefInspector.Result{}
returned
with the following information (if available):
:referer
will contain the unmodified referer passed to the parser.:medium
will be:internal
(if configured),:unknown
if no matching database entry could be found, or a string matching the entry in the database. Detecting a referer as:internal
requires additional configuration (seeRefInspector.Config
).:source
will be:unknown
if no known source could be detected. Otherwise it will contain a string with the provider's name.:term
will be:none
if no query parameters were given or the provider has no configured term parameters in the database (mostly relevant for social or email referers). If a configured term parameter was found it will be an unencoded string (possibly empty).
Note about Result Medium Atoms/Binaries
The medium atoms :unknown
and :internal
are specially treated to reflect
two special cases. One being reserved for completely unknown referers and
one being for configured domains to not be parsed.
Your database can still include "unknown"
and "internal"
sections. These
will be parsed fully and returned using a binary as the medium instead of
the aforementioned atoms.
Link to this section Summary
Functions
Parses a referer.
Checks if RefInspector is ready to perform lookups.
Reloads all databases.
Link to this section Functions
@spec parse(URI.t() | String.t() | nil, Keyword.t()) :: RefInspector.Result.t()
Parses a referer.
Passing an empty referer (""
or nil
) will directly return an empty result
without accessing the database.
Checks if RefInspector is ready to perform lookups.
The true == ready?
definition is made on the assumption that if there is
at least one referer in the database then lookups can be performed.
Checking the state is done using the currently active database. Any potentially concurrent reload requests are not considered.
@spec reload(Keyword.t()) :: :ok
Reloads all databases.
You can pass [async: true|false]
to define if the reload should happen
in the background or block your calling process until completed.