5
5
Subject ,
6
6
TrackerConfiguration ,
7
7
SelfDescribingJson ,
8
+ PagePing ,
9
+ PageView ,
10
+ ScreenView ,
11
+ SelfDescribing ,
12
+ StructuredEvent ,
8
13
)
9
14
10
15
@@ -15,11 +20,12 @@ def get_url_from_args():
15
20
16
21
17
22
def main ():
18
-
19
23
collector_url = get_url_from_args ()
20
24
# Configure Emitter
21
25
custom_retry_codes = {500 : False , 401 : True }
22
- emitter_config = EmitterConfiguration (batch_size = 5 , custom_retry_codes = custom_retry_codes )
26
+ emitter_config = EmitterConfiguration (
27
+ batch_size = 5 , custom_retry_codes = custom_retry_codes
28
+ )
23
29
24
30
# Configure Tracker
25
31
tracker_config = TrackerConfiguration (encode_base64 = True )
@@ -39,19 +45,28 @@ def main():
39
45
40
46
tracker = Snowplow .get_tracker ("ns" )
41
47
42
- tracker .track_page_view ("https://www.snowplow.io" , "Homepage" )
43
- tracker .track_page_ping ("https://www.snowplow.io" , "Homepage" )
44
- tracker .track_link_click ("https://www.snowplow.io/about" )
45
- tracker .track_page_view ("https://www.snowplow.io/about" , "About" )
48
+ page_view = PageView (page_url = "https://www.snowplow.io" , page_title = "Homepage" )
49
+ tracker .track (page_view )
50
+
51
+ page_ping = PagePing (page_url = "https://www.snowplow.io" , page_title = "Homepage" )
52
+ tracker .track (page_ping )
46
53
47
- tracker . track_self_describing_event (
54
+ link_click = SelfDescribing (
48
55
SelfDescribingJson (
49
56
"iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1" ,
50
- {"targetUrl" : "example.com " },
57
+ {"targetUrl" : "https://www.snowplow.io " },
51
58
)
52
59
)
53
- tracker .track_struct_event ( "shop" , "add-to-basket" , None , "pcs" , 2 )
60
+ tracker .track ( link_click )
54
61
62
+ id = tracker .get_uuid ()
63
+ screen_view = ScreenView (id_ = id , name = "name" )
64
+ tracker .track (screen_view )
65
+
66
+ struct_event = StructuredEvent (
67
+ category = "shop" , action = "add-to-basket" , property_ = "pcs" , value = 2
68
+ )
69
+ tracker .track (struct_event )
55
70
tracker .flush ()
56
71
57
72
0 commit comments