Skip to content

Commit

Permalink
ecommerceProductDetailView
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Feb 20, 2025
1 parent 706ca42 commit f402c6b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
17 changes: 17 additions & 0 deletions packages/destinations/web/piwikpro/examples/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ export function ecommerceAddToCart(custom: WalkerOS.AnyObject = {}) {
];
}

export function ecommerceProductDetailView(custom: WalkerOS.AnyObject = {}) {
const event = getEvent('product view');

return [
[
'ecommerceProductDetailView',
[
{
...getProduct(event),
...custom,
},
],
{ currencyCode: 'EUR' },
],
];
}

export function InitiateCheckout(custom: WalkerOS.AnyObject = {}) {
const event = getEvent('cart view');

Expand Down
22 changes: 21 additions & 1 deletion packages/destinations/web/piwikpro/examples/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,33 @@ export const ecommerceAddToCart: DestinationPiwikPro.EventConfig = {
},
};

export const ecommerceProductDetailView: DestinationPiwikPro.EventConfig = {
name: 'ecommerceProductDetailView',
data: {
set: [
{
set: [
{
map: productMap,
},
],
},
{
map: {
currencyCode: { value: 'EUR' },
},
},
],
},
};

export const InitiateCheckout: DestinationPiwikPro.EventConfig = {
name: 'InitiateCheckout',
data: {},
};

export const config = {
order: { complete: ecommerceOrder },
product: { add: ecommerceAddToCart },
product: { add: ecommerceAddToCart, view: ecommerceProductDetailView },
cart: { view: InitiateCheckout },
} satisfies Mapping.Config;
10 changes: 10 additions & 0 deletions packages/destinations/web/piwikpro/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,14 @@ describe('Destination PiwikPro', () => {
elb(event);
expect(mockFn).toHaveBeenCalledWith(...events.ecommerceAddToCart());
});

test('event ecommerceProductDetailView', () => {
const event = getEvent('product view');
elb('walker destination', destination, {
custom,
mapping: mapping.config,
});
elb(event);
expect(mockFn).toHaveBeenCalledWith(...events.ecommerceProductDetailView());
});
});

0 comments on commit f402c6b

Please sign in to comment.