hotfix(segment): better order tracking

This commit is contained in:
Sebastian Rindom
2021-01-08 16:59:25 +01:00
parent d84c40e207
commit 8dad0b3ac7
@@ -101,7 +101,6 @@ class SegmentService extends BaseService {
products: await Promise.all( products: await Promise.all(
order.items.map(async (item) => { order.items.map(async (item) => {
let name = item.title let name = item.title
let variant = item.description
const unit_price = item.content.unit_price const unit_price = item.content.unit_price
const line_total = unit_price * item.content.quantity * item.quantity const line_total = unit_price * item.content.quantity * item.quantity
@@ -109,13 +108,17 @@ class SegmentService extends BaseService {
order.currency_code, order.currency_code,
line_total line_total
) )
const skuParts = item.content.variant.sku.split("-")
skuParts.pop()
return { return {
name, name,
variant, variant: item.content.variant.sku,
price: unit_price, price: unit_price,
reporting_revenue: revenue, reporting_revenue: revenue,
product_id: `${item.content.product._id}`, product_id: `${item.content.product._id}`,
sku: item.content.variant.sku, sku: skuParts.join("-"),
quantity: item.quantity, quantity: item.quantity,
} }
}) })