Skip to content

Commit 86d5e5f

Browse files
committed
User-set timestamps now assumed to be in milliseconds
1 parent 98a5244 commit 86d5e5f

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

snowplow_tracker/payload.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ def set_timestamp(self, tstamp=None):
6262
:param tstamp: Timestamp value
6363
"""
6464
if tstamp is None:
65-
tstamp = time.time()
66-
if tstamp and isinstance(tstamp, (int, float)):
67-
value = int(tstamp * 1000)
65+
value = int(time.time() * 1000)
66+
elif tstamp and isinstance(tstamp, (int, float)):
67+
value = int(tstamp)
6868
else:
6969
value = tstamp
7070
self.context["dtm"] = value

snowplow_tracker/test/integration/test_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_integration_ecommerce_transaction_item(self):
6868
def test_integration_ecommerce_transaction(self):
6969
t = tracker.Tracker("localhost")
7070
with HTTMock(pass_response_content):
71-
t.track_ecommerce_transaction("6a8078be", 45, city="London", currency="GBP", items=
71+
t.track_ecommerce_transaction("6a8078be", 35, city="London", currency="GBP", items=
7272
[{
7373
"sku": "pbz0026",
7474
"price": 20,
@@ -80,7 +80,7 @@ def test_integration_ecommerce_transaction(self):
8080
"quantity": 1
8181
}])
8282

83-
expected_fields = {"e": "tr", "tr_id": "6a8078be", "tr_tt": "45", "tr_ci": "London", "tr_cu": "GBP"}
83+
expected_fields = {"e": "tr", "tr_id": "6a8078be", "tr_tt": "35", "tr_ci": "London", "tr_cu": "GBP"}
8484
for key in expected_fields:
8585
self.assertEquals(from_querystring(key, querystrings[-3]), expected_fields[key])
8686

snowplow_tracker/test/unit/test_payload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_set_timestamp_2(self):
8686

8787
def test_set_timestamp(self):
8888
p = payload.Payload()
89-
p.set_timestamp(12345654321)
89+
p.set_timestamp(12345654321000)
9090
self.assertEquals(p.context["dtm"], 12345654321000)
9191

9292
def test_add_unstruct_1(self):

snowplow_tracker/tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def http_get(self, payload):
100100
r = requests.get(self.collector_uri, params=payload.context)
101101
code = r.status_code
102102
if code in HTTP_ERRORS:
103-
return (False, "Host [" + r.url + "] not found (possible connectivity error")
103+
return (False, "Host [" + r.url + "] not found (possible connectivity error)")
104104
elif code < 0 or code > 600:
105105
return (False, code)
106106
elif code >= 400 and code < 500:

0 commit comments

Comments
 (0)