mirror of
https://github.com/jazzband/django-analytical.git
synced 2026-05-09 16:04:51 +00:00
Update utils.py
Updated to use the tested and better documented version (Is not tested with Matomo or Django. Only with python)
This commit is contained in:
parent
85c651f6f6
commit
3a514444f3
1 changed files with 4 additions and 7 deletions
|
|
@ -176,9 +176,10 @@ def build_paq_cmd(cmd, args=[]):
|
|||
"""
|
||||
def __to_js_arg(arg):
|
||||
"""
|
||||
Turn the argument into a js variable.
|
||||
True -> true
|
||||
False -> false
|
||||
:Args:
|
||||
- arg: The variable (Matomo argument) to be converted to JS.
|
||||
:Return:
|
||||
Javascript version of the passed arg parameter
|
||||
"""
|
||||
# Recursively handle dictionaries
|
||||
if isinstance(arg, dict):
|
||||
|
|
@ -187,18 +188,14 @@ def build_paq_cmd(cmd, args=[]):
|
|||
arg.pop(k)
|
||||
arg[__to_js_arg(k)] = __to_js_arg(v)
|
||||
return arg
|
||||
# Handle bools
|
||||
|
||||
elif isinstance(arg, bool):
|
||||
if arg:
|
||||
arg = "true"
|
||||
else:
|
||||
arg = "false"
|
||||
# Handle lists
|
||||
elif isinstance(arg, list):
|
||||
for elem_idx in range(len(arg)):
|
||||
arg[elem_idx] = __to_js_arg(arg[elem_idx])
|
||||
|
||||
return arg
|
||||
|
||||
paq = "_paq.push(['%s', " % (cmd)
|
||||
|
|
|
|||
Loading…
Reference in a new issue