Skip to content

Commit

Permalink
Merge pull request #6 from managed-components/ZRZ-1327
Browse files Browse the repository at this point in the history
ZRZ-1327 make sure products is an array before running map()
  • Loading branch information
ad-astra-via authored Jun 5, 2024
2 parents 16b8fa6 + d758505 commit b777383
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Check warning on line 31 in src/index.ts

View workflow job for this annotation

GitHub Actions / build-test (18.x)

Unexpected any. Specify a different type
: ''
data.ev = payload.price || payload.total || payload.value
data.gv = payload.price || data.gv
break
Expand All @@ -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()

Check warning on line 54 in src/index.ts

View workflow job for this annotation

GitHub Actions / build-test (18.x)

Unexpected any. Specify a different type
: ''
data.ev =
payload.revenue || payload.total || payload.value || payload.price
}
Expand Down

0 comments on commit b777383

Please sign in to comment.