diff --git a/src/index.ts b/src/index.ts index aa7f3df..0d31491 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,7 +27,9 @@ const getECParams = (event: MCEvent) => { payload.name || payload.product_id || payload.sku || - payload.products?.map((p: any) => p.name).join() + Array.isArray(payload.products) + ? payload.products.map((p: any) => p.name).join() + : '' data.ev = payload.price || payload.total || payload.value data.gv = payload.price || data.gv break @@ -48,7 +50,9 @@ const getECParams = (event: MCEvent) => { payload.checkout_id || payload.product_id || payload.name || - payload.products?.map((p: any) => p.name).join() + Array.isArray(payload.products) + ? payload.products.map((p: any) => p.name).join() + : '' data.ev = payload.revenue || payload.total || payload.value || payload.price }