File tree Expand file tree Collapse file tree 3 files changed +42
-6
lines changed
packages/destinations/web/piwikpro Expand file tree Collapse file tree 3 files changed +42
-6
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
94113export const config = {
95114 order : { complete : ecommerceOrder } ,
96115 product : { add : ecommerceAddToCart , view : ecommerceProductDetailView } ,
97- cart : { view : InitiateCheckout } ,
116+ cart : { view : ecommerceCartUpdate } ,
98117} satisfies Mapping . Config ;
Original file line number Diff line number Diff 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} ) ;
You can’t perform that action at this time.
0 commit comments