Meter v0.1.0 Meter.Utils

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

Functions

custom_dimensions(dimensions, kwargs)

Specs

custom_dimensions([atom], Keyword.t) :: Keyword.t

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}]
param_generator(function_name, kwargs, tid, mapping, custom_dimensions)

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}]