Skip to content

Commit

Permalink
Enable event processing without matching mapping #391
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Jun 6, 2024
1 parent a6a4030 commit 8092770
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changeset/brown-owls-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@elbwalker/walker.js': major
---

Enable event processing without matching mapping
(#391)[https://github.com/elbwalker/walkerOS/issues/391]
13 changes: 7 additions & 6 deletions packages/clients/walkerjs/src/__tests__/destination.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,15 @@ describe('Destination', () => {
const destinationB: WebDestination.Destination = {
push: mockPushB,
config: {
mapping: { '*': { action: {} } },
mapping: { '*': { action: {}, '*': { ignore: true } } },
},
};

const destinationC: WebDestination.Destination = {
push: mockPushC,
config: { mapping: { entity: { '*': {} } } },
config: {
mapping: { entity: { '*': {} }, '*': { '*': { ignore: true } } },
},
};

elb('walker destination', destinationA);
Expand Down Expand Up @@ -267,7 +269,7 @@ describe('Destination', () => {

jest.clearAllMocks();
elb('random action');
expect(mockPushA).toHaveBeenCalledTimes(0);
expect(mockPushA).toHaveBeenCalledTimes(1);
expect(mockPushB).toHaveBeenCalledTimes(1);
expect(mockPushC).toHaveBeenCalledTimes(0);
expect(mockPushB).toHaveBeenCalledWith(
Expand All @@ -281,7 +283,7 @@ describe('Destination', () => {

jest.clearAllMocks();
elb('entity random');
expect(mockPushA).toHaveBeenCalledTimes(0);
expect(mockPushA).toHaveBeenCalledTimes(1);
expect(mockPushB).toHaveBeenCalledTimes(0);
expect(mockPushC).toHaveBeenCalledTimes(1);
expect(mockPushC).toHaveBeenCalledWith(
Expand All @@ -295,7 +297,7 @@ describe('Destination', () => {

jest.clearAllMocks();
elb('absolutely unacceptable');
expect(mockPushA).toHaveBeenCalledTimes(0);
expect(mockPushA).toHaveBeenCalledTimes(1);
expect(mockPushB).toHaveBeenCalledTimes(0);
expect(mockPushC).toHaveBeenCalledTimes(0);
});
Expand Down Expand Up @@ -665,7 +667,6 @@ describe('Destination', () => {
'*': {
visible: { batch: 2000 },
click: { batch: 2000 },
important: {},
},
},
},
Expand Down
3 changes: 0 additions & 3 deletions packages/clients/walkerjs/src/lib/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ export function pushToDestination(
// Check to use specific event names
if (mappingEvent.name) event.event = mappingEvent.name;
}

// don't push if there's no matching mapping
if (!mappingEvent) return false;
}

const pushed = !!tryCatch(() => {
Expand Down

0 comments on commit 8092770

Please sign in to comment.