2222import time
2323import random
2424import logging
25- from snowplow_tracker import payload , _version
25+ from snowplow_tracker import payload , _version , subject
2626from contracts import contract , new_contract , disable_all
2727
2828
@@ -56,12 +56,14 @@ class Tracker:
5656 new_contract ("consumer" , lambda s : hasattr (s , "input" ))
5757
5858 @contract
59- def __init__ (self , out_queue , subject = None ,
59+ def __init__ (self , out_queue , _subject = None ,
6060 namespace = None , app_id = None , context_vendor = None , encode_base64 = DEFAULT_ENCODE_BASE64 ,
6161 contracts = True , log = True ):
6262 """
6363 :param out_queue: Consumer to which events will be sent
6464 :type out_queue: consumer
65+ :param _subject: Subject to be tracked
66+ :type _subject: subject | None
6567 :param namespace: Identifier for the Tracker instance
6668 :type namespace: string_or_none
6769 :param app_id: Application ID
@@ -82,7 +84,7 @@ def __init__(self, out_queue, subject=None,
8284 logger .setLevel (logging .CRITICAL )
8385
8486 self .out_queue = out_queue
85- self .subject = subject
87+ self .subject = _subject
8688 self .encode_base64 = encode_base64
8789 self .context_vendor = context_vendor
8890
@@ -166,7 +168,7 @@ def track_page_view(self, page_url, page_title=None, referrer=None, context=None
166168 :param referrer: Referrer of the page
167169 :type referrer: string_or_none
168170 :param context: Custom context for the event
169- :type context: dict(str :*) | None
171+ :type context: dict(string :*) | None
170172 :rtype: tracker | int
171173 """
172174 pb = payload .Payload ()
@@ -208,7 +210,7 @@ def track_ecommerce_transaction_item(self, order_id, sku, price, quantity,
208210 :param currency: The currency the price is expressed in
209211 :type currency: string_or_none
210212 :param context: Custom context for the event
211- :type context: dict(str :*) | None
213+ :type context: dict(string :*) | None
212214 :rtype: tracker | int
213215 """
214216 pb = payload .Payload ()
@@ -255,8 +257,8 @@ def track_ecommerce_transaction(self, order_id, total_value,
255257 :param items: The items in the transaction
256258 :type items: list(dict(str:*))
257259 :param context: Custom context for the event
258- :type context: dict(str :*) | None
259- :rtype: tracker | dict(str :*)
260+ :type context: dict(string :*) | None
261+ :rtype: tracker | dict(string :*)
260262 """
261263 pb = payload .Payload ()
262264 pb .add ("e" , "tr" )
@@ -302,7 +304,7 @@ def track_screen_view(self, name, id_=None, context=None, tstamp=None):
302304 :param id_: Screen view ID
303305 :type id_: string_or_none
304306 :param context: Custom context for the event
305- :type context: dict(str :*) | None
307+ :type context: dict(string :*) | None
306308 :rtype: tracker | int
307309 """
308310 screen_view_properties = {"name" : name }
@@ -328,7 +330,7 @@ def track_struct_event(self, category, action, label=None, property_=None, value
328330 :param value: A value associated with the user action
329331 :type value: int | float | None
330332 :param context: Custom context for the event
331- :type context: dict(str :*) | None
333+ :type context: dict(string :*) | None
332334 :rtype: tracker | int
333335 """
334336 pb = payload .Payload ()
@@ -356,9 +358,9 @@ def track_unstruct_event(self, event_vendor, event_name, dict_, context=None, ts
356358 :param event_name: The name of the event
357359 :type event_name: non_empty_string
358360 :param dict_: The properties of the event
359- :type dict_: dict(str :*)
361+ :type dict_: dict(string :*)
360362 :param context: Custom context for the event
361- :type context: dict(str :*) | None
363+ :type context: dict(string :*) | None
362364 :rtype: tracker | int
363365 """
364366 pb = payload .Payload ()
0 commit comments