Skip to content

Commit 98a5244

Browse files
committed
Removed -ti and -tr prefixes from ecommerce tracking arguments (snowplow#25)
1 parent 8537831 commit 98a5244

2 files changed

Lines changed: 60 additions & 60 deletions

File tree

snowplow_tracker/test/integration/test_integration.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,24 @@ def test_integration_page_view(self):
6060
def test_integration_ecommerce_transaction_item(self):
6161
t = tracker.Tracker("localhost")
6262
with HTTMock(pass_response_content):
63-
t.track_ecommerce_transaction_item("12345", "pbz0025", 7.99, 2, "black-tarot", "tarot", ti_currency="GBP")
63+
t.track_ecommerce_transaction_item("12345", "pbz0025", 7.99, 2, "black-tarot", "tarot", currency="GBP")
6464
expected_fields = {"ti_ca": "tarot", "ti_id": "12345", "ti_qu": "2", "ti_sk": "pbz0025", "e": "ti", "ti_nm": "black-tarot", "ti_pr": "7.99", "ti_cu": "GBP"}
6565
for key in expected_fields:
6666
self.assertEquals(from_querystring(key, querystrings[-1]), expected_fields[key])
6767

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, tr_city="London", tr_currency="GBP", items=
71+
t.track_ecommerce_transaction("6a8078be", 45, city="London", currency="GBP", items=
7272
[{
73-
"ti_sku": "pbz0026",
74-
"ti_price": 20,
75-
"ti_quantity": 1
73+
"sku": "pbz0026",
74+
"price": 20,
75+
"quantity": 1
7676
},
7777
{
78-
"ti_sku": "pbz0038",
79-
"ti_price": 15,
80-
"ti_quantity": 1
78+
"sku": "pbz0038",
79+
"price": 15,
80+
"quantity": 1
8181
}])
8282

8383
expected_fields = {"e": "tr", "tr_id": "6a8078be", "tr_tt": "45", "tr_ci": "London", "tr_cu": "GBP"}

snowplow_tracker/tracker.py

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -220,71 +220,71 @@ def track_page_view(self, page_url, page_title=None, referrer=None, context=None
220220
return self.track(pb)
221221

222222
@contract
223-
def track_ecommerce_transaction_item(self, ti_id, ti_sku, ti_price, ti_quantity,
224-
ti_name=None, ti_category=None, ti_currency=None,
223+
def track_ecommerce_transaction_item(self, order_id, sku, price, quantity,
224+
name=None, category=None, currency=None,
225225
context=None,
226226
tstamp=None, tid=None):
227227
"""
228228
This is an internal method called by track_ecommerce_transaction.
229229
It is not for public use.
230230
231-
:param ti_id: Order ID
232-
:type ti_id: non_empty_string
233-
:param ti_sku: Item SKU
234-
:type ti_sku: non_empty_string
235-
:param ti_price: Item price
236-
:type ti_price: int | float
237-
:param ti_quantity: Item quantity
238-
:type ti_quantity: int
239-
:param ti_name: Item name
240-
:type ti_name: string_or_none
241-
:param ti_category: Item category
242-
:type ti_category: string_or_none
243-
:param ti_currency: The currency the price is expressed in
244-
:type ti_currency: string_or_none
231+
:param order_id: Order ID
232+
:type order_id: non_empty_string
233+
:param sku: Item SKU
234+
:type sku: non_empty_string
235+
:param price: Item price
236+
:type price: int | float
237+
:param quantity: Item quantity
238+
:type quantity: int
239+
:param name: Item name
240+
:type name: string_or_none
241+
:param category: Item category
242+
:type category: string_or_none
243+
:param currency: The currency the price is expressed in
244+
:type currency: string_or_none
245245
:param context: Custom context for the event
246246
:type context: dict(str:*) | None
247247
:rtype: tuple(bool, int | str)
248248
"""
249249
pb = payload.Payload(tstamp)
250250
pb.add("e", "ti")
251-
pb.add("ti_id", ti_id)
252-
pb.add("ti_sk", ti_sku)
253-
pb.add("ti_nm", ti_name)
254-
pb.add("ti_ca", ti_category)
255-
pb.add("ti_pr", ti_price)
256-
pb.add("ti_qu", ti_quantity)
257-
pb.add("ti_cu", ti_currency)
251+
pb.add("ti_id", order_id)
252+
pb.add("ti_sk", sku)
253+
pb.add("ti_nm", name)
254+
pb.add("ti_ca", category)
255+
pb.add("ti_pr", price)
256+
pb.add("ti_qu", quantity)
257+
pb.add("ti_cu", currency)
258258
pb.add("evn", DEFAULT_VENDOR)
259259
pb.add("tid", tid)
260260
pb.add_json(context, self.config["encode_base64"], "cx", "co")
261261
return self.track(pb)
262262

263263
@contract
264-
def track_ecommerce_transaction(self, order_id, tr_total_value,
265-
tr_affiliation=None, tr_tax_value=None, tr_shipping=None,
266-
tr_city=None, tr_state=None, tr_country=None, tr_currency=None,
264+
def track_ecommerce_transaction(self, order_id, total_value,
265+
affiliation=None, tax_value=None, shipping=None,
266+
city=None, state=None, country=None, currency=None,
267267
items=None,
268268
context=None, tstamp=None):
269269
"""
270270
:param order_id: ID of the eCommerce transaction
271271
:type order_id: non_empty_string
272-
:param tr_total_value: Total transaction value
273-
:type tr_total_value: int | float
274-
:param tr_affiliation: Transaction affiliation
275-
:type tr_affiliation: string_or_none
276-
:param tr_tax_value: Transaction tax value
277-
:type tr_tax_value: int | float | None
278-
:param tr_shipping: Delivery cost charged
279-
:type tr_shipping: int | float | None
280-
:param tr_city: Delivery address city
281-
:type tr_city: string_or_none
282-
:param tr_state: Delivery address state
283-
:type tr_state: string_or_none
284-
:param tr_country: Delivery address country
285-
:type tr_country: string_or_none
286-
:param tr_currency: The currency the price is expressed in
287-
:type tr_currency: string_or_none
272+
:param total_value: Total transaction value
273+
:type total_value: int | float
274+
:param affiliation: Transaction affiliation
275+
:type affiliation: string_or_none
276+
:param tax_value: Transaction tax value
277+
:type tax_value: int | float | None
278+
:param shipping: Delivery cost charged
279+
:type shipping: int | float | None
280+
:param city: Delivery address city
281+
:type city: string_or_none
282+
:param state: Delivery address state
283+
:type state: string_or_none
284+
:param country: Delivery address country
285+
:type country: string_or_none
286+
:param currency: The currency the price is expressed in
287+
:type currency: string_or_none
288288
:param items: The items in the transaction
289289
:type items: list(dict(str:*))
290290
:param context: Custom context for the event
@@ -301,14 +301,14 @@ def track_ecommerce_transaction(self, order_id, tr_total_value,
301301
pb = payload.Payload(tstamp)
302302
pb.add("e", "tr")
303303
pb.add("tr_id", order_id)
304-
pb.add("tr_tt", tr_total_value)
305-
pb.add("tr_af", tr_affiliation)
306-
pb.add("tr_tx", tr_tax_value)
307-
pb.add("tr_sh", tr_shipping)
308-
pb.add("tr_ci", tr_city)
309-
pb.add("tr_st", tr_state)
310-
pb.add("tr_co", tr_country)
311-
pb.add("tr_cu", tr_currency)
304+
pb.add("tr_tt", total_value)
305+
pb.add("tr_af", affiliation)
306+
pb.add("tr_tx", tax_value)
307+
pb.add("tr_sh", shipping)
308+
pb.add("tr_ci", city)
309+
pb.add("tr_st", state)
310+
pb.add("tr_co", country)
311+
pb.add("tr_cu", currency)
312312
pb.add("evn", DEFAULT_VENDOR)
313313
pb.add("tid", tid)
314314
pb.add("dtm", tstamp)
@@ -321,8 +321,8 @@ def track_ecommerce_transaction(self, order_id, tr_total_value,
321321
for item in items:
322322
item["tstamp"] = str(tstamp)
323323
item["tid"] = tid
324-
item["ti_id"] = order_id
325-
item["ti_currency"] = tr_currency
324+
item["order_id"] = order_id
325+
item["currency"] = currency
326326
item_results.append(self.track_ecommerce_transaction_item(**item))
327327

328328
return {"transaction_result": transaction_result, "item_results": item_results}

0 commit comments

Comments
 (0)