Skip to content

Commit

Permalink
Merge branch 'develop' into chore.cleanup-metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayachand authored Jun 25, 2024
2 parents f925262 + a0f5c2f commit 5560821
Show file tree
Hide file tree
Showing 7 changed files with 484 additions and 17 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"@ndhoule/extend": "^2.0.0",
"@pyroscope/nodejs": "^0.2.9",
"@rudderstack/integrations-lib": "^0.2.10",
"@rudderstack/json-template-engine": "^0.14.1",
"@rudderstack/workflow-engine": "^0.8.8",
"@rudderstack/json-template-engine": "^0.15.0",
"@rudderstack/workflow-engine": "^0.8.9",
"@shopify/jest-koa-mocks": "^5.1.1",
"ajv": "^8.12.0",
"ajv-draft-04": "^1.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,23 @@
{
"destKey": "aifa",
"sourceKeys": "context.device.advertisingId",
"required": true
"required": false,
"metadata": {
"defaultValue": ""
}
},
{
"destKey": "andi",
"sourceKeys": "context.device.id",
"required": true
"required": false,
"metadata": {
"defaultValue": ""
}
},
{
"destKey": "asid",
"sourceKeys": "properties.asid",
"required": true,
"required": false,
"metadata": {
"defaultValue": ""
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
{
"destKey": "asid",
"sourceKeys": "properties.asid",
"required": true,
"required": false,
"metadata": {
"defaultValue": ""
}
Expand Down Expand Up @@ -91,12 +91,18 @@
{
"destKey": "aifa",
"sourceKeys": "context.device.advertisingId",
"required": true
"required": false,
"metadata": {
"defaultValue": ""
}
},
{
"destKey": "andi",
"sourceKeys": "context.device.id",
"required": true
"required": false,
"metadata": {
"defaultValue": ""
}
},
{
"destKey": "utime",
Expand Down
3 changes: 3 additions & 0 deletions src/v1/sources/close_crm/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const excludedFieldList = ['changed_fields', 'previous_data'];

module.exports = { excludedFieldList };
57 changes: 57 additions & 0 deletions src/v1/sources/close_crm/transform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const moment = require('moment');
const {
removeUndefinedAndNullValues,
removeUndefinedAndNullRecurse,
generateUUID,
formatTimeStamp,
} = require('../../../v0/util');
const { excludedFieldList } = require('./config');
const Message = require('../../../v0/sources/message');

function processEvent(inputEvent) {
// eslint-disable-next-line @typescript-eslint/naming-convention
const { event, subscription_id } = inputEvent;

const message = new Message('CloseCRM');

// Set event type track
message.setEventType('track');

// Set event name
const eventName = `${event.object_type} ${event.action}`;
message.setEventName(eventName);

// Set userId
if (event.lead_id) {
message.setProperty('userId', event.lead_id);
} else {
message.setProperty('anonymousId', generateUUID());
}

// Set messageId
message.setProperty('messageId', event.id);

// Set Timestamp
const timestamp = moment.utc(event.date_updated);
message.setProperty('originalTimestamp', formatTimeStamp(timestamp, 'yyyy-MM-ddTHH:mm:ss.SSSZ'));

// Set properties
removeUndefinedAndNullRecurse(event);
message.setProperty('properties', event);
message.setProperty('properties.subscription_id', subscription_id);

// Remove excluding fields
excludedFieldList.forEach((field) => {
delete message.properties[field];
});

return message;
}

function process(inputEvent) {
const { event } = inputEvent;
const response = processEvent(event);
return removeUndefinedAndNullValues(response);
}

exports.process = process;
Loading

0 comments on commit 5560821

Please sign in to comment.