Skip to content

Commit

Permalink
data parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Dec 4, 2024
1 parent 36caa95 commit 1f4cdd5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
16 changes: 15 additions & 1 deletion packages/destinations/web/piwikpro/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,19 @@ describe('Destination PiwikPro', () => {
order: {
complete: {
name: 'trackEcommerceOrder',
data: 'data.id',
data: [
'data.id',
'data.total',
{
fn: (event) => {
const total = Number(event.data?.total ?? 0);
const taxes = Number(event.data?.taxes ?? 0);
const shipping = Number(event.data?.shipping ?? 0);

return total - taxes - shipping;
},
},
],
},
},
},
Expand All @@ -76,6 +88,8 @@ describe('Destination PiwikPro', () => {
expect(mockFn).toHaveBeenCalledWith([
'trackEcommerceOrder',
order_complete.data.id,
order_complete.data.total,
expect.any(Number),
]);
});
});
8 changes: 3 additions & 5 deletions packages/destinations/web/piwikpro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@ export const destinationPiwikPro: Destination = {

const customMapping: CustomEvent = mapping.custom || {};

func([
event.event,
data || event.entity,
// @TODO parameters
]);
const parameters = Array.isArray(data) ? data : [data];

func([event.event, ...parameters]);

if (customMapping.goalId) {
const goalValue = customMapping.goalValue
Expand Down
1 change: 0 additions & 1 deletion packages/destinations/web/plausible/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const destinationPlausible: Destination = {
},

push(event, config, mapping, options = {}) {
console.log('🚀 ~ push ~ options:', options);
const { fn } = config;
const props = isObject(options.data) ? options.data : event.data;

Expand Down
1 change: 0 additions & 1 deletion packages/sources/node/src/__tests__/destination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe('Destination', () => {
const eventCall = jest.fn();
const mockPush = jest.fn().mockImplementation((event) => {
eventCall(event);
// console.log(event);
});
const mockInit = jest.fn();

Expand Down
3 changes: 0 additions & 3 deletions packages/utils/src/__tests__/eventGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,5 @@ describe('createEvent', () => {
trigger: 'visible',
}),
);

// All the other events are tested in the same way
// console.log(getEvent('order complete'));
});
});

0 comments on commit 1f4cdd5

Please sign in to comment.