Meter v0.2.0 Meter.Utils
A module with utility functions to generate parameters to send to Google Analytycs.
The function param_generator/6 is the default function in Meter.track/2 and Meter.track_error/3
Summary
Functions
Generate a list of 2-element tuple, the first element is the name of the parameter (cd1, cd2, cd …) and the second is the value
Default param_generator function. Generate all parameters necessary to send a tracking request to google analytics
Default param_generator function. Generate all parameters necessary to send a tracking request to google analytics
Functions
Generate a list of 2-element tuple, the first element is the name of the parameter (cd1, cd2, cd …) and the second is the value.
This function is used in to the default param_generator function providing the values from the application configuration. It could be used in a custom param_generator. It maintain the order as defined in the configuration.
iex> Meter.Utils.custom_dimensions([], [key: "value"])
[]
iex> Meter.Utils.custom_dimensions([:key], [])
[]
iex> Meter.Utils.custom_dimensions([:key], [key: "value"])
[{"cd1", "value"}]
iex> Meter.Utils.custom_dimensions([:key, :key2], [key: "value"])
[{"cd1", "value"}, {"cd2", nil}]
iex> Meter.Utils.custom_dimensions([:key, :key2], [key: "value", key3: 12])
[{"cd1", "value"}, {"cd2", nil}]
Specs
error_params(map) :: Keyword.t
Default param_generator function. Generate all parameters necessary to send a tracking request to google analytics
iex>Meter.Utils.error_params(%RuntimeError{message: "an error"})
[exf: 1, exd: "%RuntimeError{message: \"an error\"}"]
iex>Meter.Utils.error_params(nil)
[]
Default param_generator function. Generate all parameters necessary to send a tracking request to google analytics
iex>Meter.Utils.param_generator(:fn, [arg1: 3, arg2: 5], "UA-123", [cid: :arg2], [:arg2, :arg1])
[v: 1,
tid: "UA-123",
cid: 5,
ds: "server",
t: "pageview",
dt: "fn",
dp: "/fn"] ++
[{"cd1", 5},{"cd2", 3}]
iex>Meter.Utils.param_generator(:fn, [arg1: 3, arg2: 5], "UA-123", [cid: :arg2], [:arg2, :arg1], %RuntimeError{message: "an error"})
[v: 1,
tid: "UA-123",
cid: 5,
ds: "server",
t: "pageview",
dt: "fn",
dp: "/fn"] ++
[{"cd1", 5},{"cd2", 3}] ++ [exf: 1, exd: "%RuntimeError{message: \"an error\"}"]