Skip to content

Commit

Permalink
fix: only new users to have default createDate
Browse files Browse the repository at this point in the history
  • Loading branch information
shrouti1507 committed Dec 26, 2023
1 parent 9da315c commit 87e76a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,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
6 changes: 6 additions & 0 deletions src/v0/destinations/gainsight_px/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ const identifyResponseBuilder = async (message, { Config }) => {
if (!isPresent && !payload.signUpDate) {
payload.signUpDate = formatTimeStamp(message.timestamp || message.originalTimestamp);
}

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

let customAttributes = {};
customAttributes = extractCustomFields(
message,
Expand Down
9 changes: 3 additions & 6 deletions test/integrations/destinations/gainsight_px/processor/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,6 @@ export const data = [
firstName: 'Sample',
lastName: 'User',
signUpDate: 1624431528295,
createDate: 1571043797562,
title: 'engineer',
propertyKeys: ['AP-XABC-123'],
location: {
Expand Down Expand Up @@ -1716,7 +1715,7 @@ export const data = [
},
{
name: 'gainsight_px',
description: 'Test 14',
description: 'Test 14 : existing user with no createdAt field in traits but signUpDate exists',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -1815,7 +1814,6 @@ export const data = [
firstName: 'Sample',
lastName: 'User',
signUpDate: 1624431528295,
createDate: 1571043797562,
title: 'engineer',
propertyKeys: ['AP-XABC-123'],
location: {
Expand Down Expand Up @@ -1848,7 +1846,7 @@ export const data = [
},
{
name: 'gainsight_px',
description: 'Test 15 : new user with no signUpDate in traits',
description: 'Test 15 : new user with no signUpDate and createDate in traits',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -1978,7 +1976,7 @@ export const data = [
},
{
name: 'gainsight_px',
description: 'Test 16 : existing user with no signUpDate in traits',
description: 'Test 16 : existing user with no signUpDate and createDate in traits',
feature: 'processor',
module: 'destination',
version: 'v0',
Expand Down Expand Up @@ -2140,7 +2138,6 @@ export const data = [
gender: 'MALE',
title: 'Director/Film Maker',
score: 100,
createDate: 1624611592911,
location: {
countryName: 'USA',
countryCode: 'US',
Expand Down
1 change: 0 additions & 1 deletion test/integrations/destinations/gainsight_px/router/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ export const data = [
gender: 'MALE',
title: 'Director/Film Maker',
score: 100,
createDate: 1624611592911,
location: {
countryName: 'USA',
countryCode: 'US',
Expand Down

0 comments on commit 87e76a1

Please sign in to comment.