Skip to content

Commit 5fd846f

Browse files
ecommerceCartUpdate
1 parent f402c6b commit 5fd846f

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

packages/destinations/web/piwikpro/examples/events.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,15 @@ export function ecommerceProductDetailView(custom: WalkerOS.AnyObject = {}) {
6767
];
6868
}
6969

70-
export function InitiateCheckout(custom: WalkerOS.AnyObject = {}) {
70+
export function ecommerceCartUpdate(custom: WalkerOS.AnyObject = {}) {
7171
const event = getEvent('cart view');
7272

73-
return [];
73+
return [
74+
[
75+
'ecommerceCartUpdate',
76+
event.nested.filter((item) => item.type === 'product').map(getProduct),
77+
event.data.total,
78+
{ currencyCode: 'EUR' },
79+
],
80+
];
7481
}

packages/destinations/web/piwikpro/examples/mapping.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,32 @@ export const ecommerceProductDetailView: DestinationPiwikPro.EventConfig = {
8686
},
8787
};
8888

89-
export const InitiateCheckout: DestinationPiwikPro.EventConfig = {
90-
name: 'InitiateCheckout',
91-
data: {},
89+
export const ecommerceCartUpdate: DestinationPiwikPro.EventConfig = {
90+
name: 'ecommerceCartUpdate',
91+
data: {
92+
set: [
93+
{
94+
loop: [
95+
'nested',
96+
{
97+
condition: (entity) =>
98+
isObject(entity) && entity.type === 'product',
99+
map: productMap,
100+
},
101+
],
102+
},
103+
'data.total',
104+
{
105+
map: {
106+
currencyCode: { value: 'EUR' },
107+
},
108+
},
109+
],
110+
},
92111
};
93112

94113
export const config = {
95114
order: { complete: ecommerceOrder },
96115
product: { add: ecommerceAddToCart, view: ecommerceProductDetailView },
97-
cart: { view: InitiateCheckout },
116+
cart: { view: ecommerceCartUpdate },
98117
} satisfies Mapping.Config;

packages/destinations/web/piwikpro/src/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,14 @@ describe('Destination PiwikPro', () => {
8888
elb(event);
8989
expect(mockFn).toHaveBeenCalledWith(...events.ecommerceProductDetailView());
9090
});
91+
92+
test('event ecommerceCartUpdate', () => {
93+
const event = getEvent('cart view');
94+
elb('walker destination', destination, {
95+
custom,
96+
mapping: mapping.config,
97+
});
98+
elb(event);
99+
expect(mockFn).toHaveBeenCalledWith(...events.ecommerceCartUpdate());
100+
});
91101
});

0 commit comments

Comments
 (0)