Skip to content

Commit 5bda2be

Browse files
committed
ONCEHUB-94733: Block PAGE calls for mixpanel destination
1 parent 25c66c5 commit 5bda2be

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/services/destination/preTransformation.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@ export class DestinationPreTransformationService {
1515
// "traits": ["traits", "context.traits"]
1616
const destination = event?.destination?.DestinationDefinition?.Name;
1717
let parsedEvent = oncehubTransformer(destination, event);
18-
parsedEvent.request = { query: reqParams };
18+
if (parsedEvent) {
19+
parsedEvent.request = { query: reqParams };
20+
}
1921
return parsedEvent;
2022
},
2123
);
22-
return eventsProcessed;
24+
// Filter out any undefined or null events after processing
25+
// This is important to ensure that we only return valid events to the next step in the pipeline
26+
const filteredEvents = eventsProcessed.filter((event: any) => !!event );
27+
28+
return filteredEvents;
2329
}
2430
}

src/util/oncehub-custom-transformer.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ const getPIIDestinationList = () => {
1414
return event && event.message && event.message.context && event.message.context.traits;
1515
};
1616

17+
const getPageEventBlockedDestinationsList = () => {
18+
return (process.env.BLOCKED_PAGE_DESTINATIONS || "mp")
19+
.trim()
20+
.split(",");
21+
};
22+
1723
const handleFirstLoginGA4Property = (destination, event, traits) => {
1824
// delete firstLoginGA4 property from traits when destination is not GA4
1925
if (destination !== 'ga4') {
@@ -27,7 +33,7 @@ const handleFirstLoginGA4Property = (destination, event, traits) => {
2733
traits.value = 0;
2834
}
2935

30-
};
36+
};
3137

3238
const changeDateFormatForCustomerio = (contextTraitsPresent, eventTraitsPresent,checkDestinationList, event) => {
3339
if (checkDestinationList) {
@@ -51,6 +57,13 @@ const handleFirstLoginGA4Property = (destination, event, traits) => {
5157
const contextTraitsPresent = doesEventContainContextTraits(event);
5258
const eventTraitsPresent = doesEventContainsTraits(event);
5359
const checkDestinationList=getPIIDestinationList().includes(destination);
60+
const checkPageEventBlockedDestination=getPageEventBlockedDestinationsList().includes(destination);
61+
if (event.message.type === EventType.PAGE && checkPageEventBlockedDestination) {
62+
// eslint-disable-next-line no-param-reassign
63+
return null;
64+
}
65+
66+
5467
changeDateFormatForCustomerio(contextTraitsPresent, eventTraitsPresent,checkDestinationList,event);
5568

5669
if (!checkDestinationList && eventTraitsPresent) {
@@ -82,6 +95,7 @@ const handleFirstLoginGA4Property = (destination, event, traits) => {
8295

8396
// eslint-disable-next-line no-console
8497
// if(doesEventContainsTraits(event)) console.log("event log=>destination : ", JSON.stringify(destination), " , ==> event traits : ", JSON.stringify(event.message.traits), " , ==> event here : ",JSON.stringify(event));
98+
8599
return event;
86100
};
87101

0 commit comments

Comments
 (0)