Skip to content

Commit

Permalink
Merge branch 'develop' into enhance.gaec
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 authored Jan 4, 2024
2 parents d1240de + 8bf56cc commit d50521b
Show file tree
Hide file tree
Showing 4 changed files with 2,729 additions and 2,418 deletions.
14 changes: 2 additions & 12 deletions src/v0/destinations/gainsight_px/data/GainsightPX_Identify.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,7 @@
},
{
"destKey": "signUpDate",
"sourceKeys": [
"traits.signUpDate",
"context.traits.signUpDate",
"timestamp",
"originalTimestamp"
],
"sourceKeys": ["traits.signUpDate", "context.traits.signUpDate"],
"required": false,
"metadata": {
"type": "timestamp"
Expand Down Expand Up @@ -109,12 +104,7 @@
},
{
"destKey": "createDate",
"sourceKeys": [
"traits.createDate",
"context.traits.createDate",
"timestamp",
"originalTimestamp"
],
"sourceKeys": ["traits.createDate", "context.traits.createDate"],
"required": false,
"metadata": {
"type": "timestamp"
Expand Down
20 changes: 17 additions & 3 deletions src/v0/destinations/gainsight_px/transform.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* eslint-disable no-nested-ternary */
const { InstrumentationError, ConfigurationError } = require('@rudderstack/integrations-lib');
const {
InstrumentationError,
ConfigurationError,
formatTimeStamp,
} = require('@rudderstack/integrations-lib');
const { EventType } = require('../../../constants');
const {
isEmptyObject,
Expand Down Expand Up @@ -47,7 +51,7 @@ const identifyResponseBuilder = async (message, { Config }) => {
'Content-Type': JSON_MIME_TYPE,
};

const { success: isPresent } = await objectExists(userId, Config, 'user');
const { success: isUserPresent } = await objectExists(userId, Config, 'user');

let payload = constructPayload(message, identifyMapping);
const name = getValueFromMessage(message, ['traits.name', 'context.traits.name']);
Expand All @@ -56,6 +60,16 @@ const identifyResponseBuilder = async (message, { Config }) => {
payload.firstName = fName;
payload.lastName = lName;
}
// Only for the case of new user creation, if signUpDate is not provided in traits, timestamp / originalTimestamp is mapped
if (!isUserPresent && !payload.signUpDate) {
payload.signUpDate = formatTimeStamp(message.timestamp || message.originalTimestamp);
}

// Only for the case of new user creation, if createDate is not provided in traits, timestamp / originalTimestamp is mapped
if (!isUserPresent && !payload.createDate) {
payload.createDate = formatTimeStamp(message.timestamp || message.originalTimestamp);
}

let customAttributes = {};
customAttributes = extractCustomFields(
message,
Expand All @@ -75,7 +89,7 @@ const identifyResponseBuilder = async (message, { Config }) => {
type: 'USER',
};

if (isPresent) {
if (isUserPresent) {
// update user
response.method = defaultPutRequestConfig.requestMethod;
response.endpoint = `${ENDPOINTS.USERS_ENDPOINT}/${userId}`;
Expand Down
Loading

0 comments on commit d50521b

Please sign in to comment.