snowplow / snowplow-python-tracker

Snowplow event tracker for Python. Add analytics to your Python and Django apps, webapps and games
Apache License 2.0
43 stars 67 forks source link

Add missing tracker events #165

Closed adamlwgriffiths closed 8 years ago

adamlwgriffiths commented 8 years ago

The python tracker is missing functionality that is present in the JS tracker. Ie. click event, link click event, performance tracking, search tracking, add to cart, remove from cart. Some of these events are pretty important to us. Are there plans to add support for these to the Python tracker?

alexanderdean commented 8 years ago

Hey @adamlwgriffiths - no immediate plans to add, but PRs welcome!

adamlwgriffiths commented 8 years ago

If I were to use the custom context to send the same events, will the final data be the equivalent?

alexanderdean commented 8 years ago

If you were to use t.track_unstruct_event(SelfDescribingJson)` it would be equivalent; if you used contexts it would be slightly different (because these would become contexts on another event type).

alexanderdean commented 8 years ago

See #166

yalisassoon commented 8 years ago

Hey @chuwy - I'm having an issue with the track_form_change event:

>>> t.track_form_change("form id 123", "element id abc", "input element", "input value", "text", None, None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<decorator-gen-38>", line 2, in track_form_change
  File "/vagrant/pytracket-test2/local/lib/python2.7/site-packages/contracts/main.py", line 278, in contracts_checker
    raise e
contracts.interface.ContractNotRespected: Breach for argument 'node_name' to instance:track_form_change().
Value does not pass criteria of <lambda>()() (module: snowplow_tracker.tracker).
checking: callable()                        for value: Instance of str: 'input element'
checking: form_node_name                    for value: Instance of str: 'input element'
checking: non_empty_string,form_node_name   for value: Instance of str: 'input element'
Variables bound in inner context:
- args: Instance of tuple: ()
- kwargs: Instance of dict: {}
- self: Instance of Tracker: <snowplow_tracker.tracker.Tracker insta... [clip]

Looks like there's an issue parsing "input element" for the node_name argument. It looks from the documentation that this only needs to be a non-empty string?

yalisassoon commented 8 years ago

Also an issue with the form submission event. According to the documentation only the first argument is required but:

>>> t.track_form_submit("form id 123", None, None, None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<decorator-gen-39>", line 2, in track_form_submit
  File "/vagrant/pytracket-test2/local/lib/python2.7/site-packages/contracts/main.py", line 278, in contracts_checker
    raise e
contracts.interface.ContractNotRespected: Breach for argument 'elements' to instance:track_form_submit().
Could not satisfy any of the 3 clauses in list(dict[N](str:*))|tuple(dict[N](str:*),*)|None,N>=3,N<=4.
 ---- Clause #1:   list(dict[N](str:*))
 | Expected a sequence, got 'NoneType'.
 | checking: list(dict[N](str:*))   for value: Instance of NoneType: None
 | Variables bound in inner context:
 | - args: Instance of tuple: ()
 | - kwargs: Instance of dict: {}
 | - self: Instance of Tracker: <snowplow_tracker.tracker.Tracker insta... [clip]
 ---- Clause #2:   tuple(dict[N](str:*),*)
 | Expected a tuple, got 'NoneType'.
 | checking: tuple(dict[N](str:*),*)   for value: Instance of NoneType: None
 | Variables bound in inner context:
 | - args: Instance of tuple: ()
 | - kwargs: Instance of dict: {}
 | - self: Instance of Tracker: <snowplow_tracker.tracker.Tracker insta... [clip]
 ---- Clause #3:   None,N>=3,N<=4
 | Error while evaluating RValue VariableRef('N'): Unknown variable 'N'.
 | checking: N>=3             for value: Instance of NoneType: None
 | checking: None,N>=3,N<=4   for value: Instance of NoneType: None
 | Variables bound in inner context:
 | - args: Instance of tuple: ()
 | - kwargs: Instance of dict: {}
 | - self: Instance of Tracker: <snowplow_tracker.tracker.Tracker insta... [clip]
 ------- (end clauses) -------
checking: list(dict[N](str:*))|tuple(dict[N](str:*),*)|None,N>=3,N<=4   for value: Instance of NoneType: None
Variables bound in inner context:
- args: Instance of tuple: ()
- kwargs: Instance of dict: {}
- self: Instance of Tracker: <snowplow_tracker.tracker.Tracker insta... [clip]
yalisassoon commented 8 years ago

I'm waiting to test the track_site_search on the documentation being updated with an example. The other new methods all seem to be working great!

chuwy commented 8 years ago

This was fixed.