RefInspector (RefInspector v2.1.0)
View SourceReferer parser library.
Preparation
- Verify your supervision setup according to
RefInspector.Supervisor - Revise the default configuration values of
RefInspector.Configand adjust to your project/environment where necessary - Download a copy of the parser database file(s) as outlined in
RefInspector.Downloader
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):
:refererwill contain the unmodified referer passed to the parser.:mediumwill be:internal(if configured),:unknownif no matching database entry could be found, or a string matching the entry in the database. Detecting a referer as:internalrequires additional configuration (seeRefInspector.Config).:sourcewill be:unknownif no known source could be detected. Otherwise it will contain a string with the provider's name.:termwill be:noneif 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.
Summary
Functions
Parses a referer.
Checks if RefInspector is ready to perform lookups.
Reloads all databases.
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.