From 942724588d18d88651a53b59f889c1631bcb6223 Mon Sep 17 00:00:00 2001 From: Yair Dovrat Date: Tue, 18 Jun 2024 11:43:59 +0200 Subject: [PATCH] make sure products is an array before .map() --- src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index a6da069..3ca96f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,9 +27,10 @@ const getECParams = (event: MCEvent) => { payload.name || payload.product_id || payload.sku || - Array.isArray(payload.products) + (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