Skip to content

Commit d2eedde

Browse files
committed
Made the "name" argument of track_screen_view optional
- fixes snowplow#103
1 parent 23a24ce commit d2eedde

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Stopped setting and sending tid (#94)
77
Started setting and sending eid (#93)
88
Allowed a single Tracker instance to send events to multiple Emitters (#91)
99
Started passing a list of dictionaries to the on_failure callback for POST requests (#104)
10+
Made the "name" argument of track_screen_view optional (#103)
1011

1112
Version 0.4.0 (2014-06-10)
1213
--------------------------

snowplow_tracker/test/integration/test_integration.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,23 @@ def test_integration_ecommerce_transaction(self):
110110
self.assertEquals(from_querystring("dtm", querystrings[-3]), from_querystring("dtm", querystrings[-2]))
111111

112112
def test_integration_screen_view(self):
113-
t = tracker.Tracker([default_emitter], default_subject)
113+
t = tracker.Tracker([default_emitter], default_subject, encode_base64=False)
114114
with HTTMock(pass_response_content):
115-
t.track_screen_view("Game HUD 2", "Hello!")
115+
t.track_screen_view("Game HUD 2", id_="534")
116116
expected_fields = {"e": "ue"}
117117
for key in expected_fields:
118118
self.assertEquals(from_querystring(key, querystrings[-1]), expected_fields[key])
119+
envelope_string = from_querystring("ue_pr", querystrings[-1])
120+
envelope = json.loads(unquote_plus(envelope_string))
121+
self.assertEquals(envelope, {
122+
"schema": "iglu:com.snowplowanalytics.snowplow/unstruct_event/jsonschema/1-0-0",
123+
"data": {"schema": "iglu:com.snowplowanalytics.snowplow/screen_view/jsonschema/1-0-0",
124+
"data": {
125+
"name": "Game HUD 2",
126+
"id": "534"
127+
}
128+
}
129+
})
119130

120131
def test_integration_struct_event(self):
121132
t = tracker.Tracker([default_emitter], default_subject)

snowplow_tracker/test/unit/test_payload.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222

2323
import unittest
24-
import time
2524
from snowplow_tracker import payload
2625

2726

snowplow_tracker/tracker.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,19 @@ def track_ecommerce_transaction(self, order_id, total_value,
279279
return self
280280

281281
@contract
282-
def track_screen_view(self, name, id_=None, context=None, tstamp=None):
282+
def track_screen_view(self, name=None, id_=None, context=None, tstamp=None):
283283
"""
284284
:param name: The name of the screen view event
285-
:type name: non_empty_string
285+
:type name: string_or_none
286286
:param id_: Screen view ID
287287
:type id_: string_or_none
288288
:param context: Custom context for the event
289289
:type context: list(dict(string:*)) | None
290290
:rtype: tracker | list(int)
291291
"""
292-
screen_view_properties = {"name": name}
292+
screen_view_properties = {}
293+
if name is not None:
294+
screen_view_properties["name"] = name
293295
if id_ is not None:
294296
screen_view_properties["id"] = id_
295297

0 commit comments

Comments
 (0)