Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/services/destination/preTransformation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Context } from 'koa';
import { ProcessorTransformationRequest, RouterTransformationRequestData } from '../../types/index';
import { DynamicConfigParser } from '../../util/dynamicConfigParser';

Check failure on line 3 in src/services/destination/preTransformation.ts

View workflow job for this annotation

GitHub Actions / Check for formatting & lint errors

'DynamicConfigParser' is defined but never used

Check failure on line 3 in src/services/destination/preTransformation.ts

View workflow job for this annotation

GitHub Actions / Code Coverage

'DynamicConfigParser' is defined but never used
import { oncehubTransformer } from '../../util/oncehub-custom-transformer';

export class DestinationPreTransformationService {
Expand All @@ -21,10 +21,7 @@
return parsedEvent;
},
);
// Filter out any undefined or null events after processing
// This is important to ensure that we only return valid events to the next step in the pipeline
const filteredEvents = eventsProcessed.filter((event: any) => !!event);

return filteredEvents;
return eventsProcessed;
}
}
12 changes: 0 additions & 12 deletions src/util/oncehub-custom-transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
};

const doesEventContainContextTraits = (event) => {
return event && event.message && event.message.context && event.message.context.traits;

Check failure on line 12 in src/util/oncehub-custom-transformer.js

View workflow job for this annotation

GitHub Actions / Check for formatting & lint errors

Assignment to property of function parameter 'traits'

Check failure on line 12 in src/util/oncehub-custom-transformer.js

View workflow job for this annotation

GitHub Actions / Code Coverage

Assignment to property of function parameter 'traits'
};

const getPageEventBlockedDestinationsList = () => {
return (process.env.BLOCKED_PAGE_DESTINATIONS || '').trim().split(',');
};

const handleFirstLoginGA4Property = (destination, event, traits) => {
// delete firstLoginGA4 property from traits when destination is not GA4
if (destination !== 'ga4') {
delete traits.firstLoginGA4;

Check failure on line 18 in src/util/oncehub-custom-transformer.js

View workflow job for this annotation

GitHub Actions / Check for formatting & lint errors

Assignment to property of function parameter 'traits'

Check failure on line 18 in src/util/oncehub-custom-transformer.js

View workflow job for this annotation

GitHub Actions / Code Coverage

Assignment to property of function parameter 'traits'
return;

Check failure on line 19 in src/util/oncehub-custom-transformer.js

View workflow job for this annotation

GitHub Actions / Check for formatting & lint errors

Assignment to property of function parameter 'traits'

Check failure on line 19 in src/util/oncehub-custom-transformer.js

View workflow job for this annotation

GitHub Actions / Code Coverage

Assignment to property of function parameter 'traits'
}

// add firstLoginGA4 property in traits when Identify call is for GA4 destination
Expand All @@ -47,7 +43,7 @@
// eslint-disable-next-line no-param-reassign
event.message.traits.accountCreatedDate = Math.floor(
Date.parse(event.message.traits.accountCreatedDate) / 1000,
);

Check failure on line 46 in src/util/oncehub-custom-transformer.js

View workflow job for this annotation

GitHub Actions / Check for formatting & lint errors

Assignment to function parameter 'destination'

Check failure on line 46 in src/util/oncehub-custom-transformer.js

View workflow job for this annotation

GitHub Actions / Code Coverage

Assignment to function parameter 'destination'
}
}
};
Expand All @@ -57,13 +53,6 @@
const contextTraitsPresent = doesEventContainContextTraits(event);
const eventTraitsPresent = doesEventContainsTraits(event);
const checkDestinationList = getPIIDestinationList().includes(destination);
const checkPageEventBlockedDestination =
getPageEventBlockedDestinationsList().includes(destination);
if (event.message.type === EventType.PAGE && checkPageEventBlockedDestination) {
// eslint-disable-next-line no-param-reassign
return null;
}

changeDateFormatForCustomerio(
contextTraitsPresent,
eventTraitsPresent,
Expand Down Expand Up @@ -100,7 +89,6 @@

// eslint-disable-next-line no-console
// if(doesEventContainsTraits(event)) console.log("event log=>destination : ", JSON.stringify(destination), " , ==> event traits : ", JSON.stringify(event.message.traits), " , ==> event here : ",JSON.stringify(event));

return event;
};

Expand Down
Loading