Skip to content

Commit

Permalink
fix pinterest ecommerce
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-astra-via committed Jan 29, 2024
1 parent edc7843 commit fbd0e8e
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ function mapEcommerceData(
ecommerce: EcommerceType
): Record<string, string | number> | null {
const transformedProductData: Record<string, string | number> = {}
if (!ecommerce || !ecommerce.products) {
if (!ecommerce) {
return null
} else {
ecommerce.products.forEach((product, index) =>
ecommerce.products?.forEach((product, index) =>
[
'product_id',
'sku',
Expand Down Expand Up @@ -121,7 +121,6 @@ export const getRequestBody = (
}

const { pdem, tid, ecommerce, ...cleanPayload } = payload

// pd - partner data
if (pdem) {
requestBody['pd[em]'] = pdem
Expand Down Expand Up @@ -186,7 +185,6 @@ export default async function (manager: Manager, settings: ComponentSettings) {
handler(event, settings, ev)
})
})

manager.addEventListener('ecommerce', event => {
if (typeof event.name === 'string') {
const ev = mapEcommerceEvent(event.name)
Expand Down

0 comments on commit fbd0e8e

Please sign in to comment.