Skip to content

Commit ee3be78

Browse files
committed
Fix items default value issue in track_ecommerce_transaction (closes #252)
1 parent cf58a4f commit ee3be78

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

snowplow_tracker/test/unit/test_tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ def test_track_ecommerce_transaction_no_items(self, mok_complete_payload):
745745
t = Tracker(e)
746746
ctx = SelfDescribingJson("test.context.schema", {"user": "tester"})
747747
evTstamp = 1399021242030
748-
t.track_ecommerce_transaction("1234", 10, "transAffiliation", 2.5, 1.5, "transCity", "transState", "transCountry", "transCurrency", items=[], context=[ctx], tstamp=evTstamp)
748+
t.track_ecommerce_transaction("1234", 10, "transAffiliation", 2.5, 1.5, "transCity", "transState", "transCountry", "transCurrency", context=[ctx], tstamp=evTstamp)
749749
self.assertEqual(mok_complete_payload.call_count, 1)
750750
completeArgsList = mok_complete_payload.call_args_list[0][0]
751751
self.assertEqual(len(completeArgsList), 4)

snowplow_tracker/tracker.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def track_ecommerce_transaction(self, order_id, total_value, affiliation=None,
540540
:param currency: The currency the price is expressed in
541541
:type currency: string_or_none
542542
:param items: The items in the transaction
543-
:type items: list(dict(str:*))
543+
:type items: list(dict(str:*)) | None
544544
:param context: Custom context for the event
545545
:type context: context_array | None
546546
:param tstamp: Optional event timestamp in milliseconds
@@ -565,6 +565,8 @@ def track_ecommerce_transaction(self, order_id, total_value, affiliation=None,
565565

566566
self.complete_payload(pb, context, tstamp, event_subject)
567567

568+
if items is None:
569+
items = []
568570
for item in items:
569571
item["tstamp"] = tstamp
570572
item["event_subject"] = event_subject

0 commit comments

Comments
 (0)