Skip to content

Commit

Permalink
[Hyperengage] Resolved issue with Timezone Offset and Added Missing u…
Browse files Browse the repository at this point in the history
…ser_id field in group call (#1733)

* Add unit and integration tests

* Updated field descriptions for group, identify and track

* Updated common fields

* Fix identify function error

* Added authentication endpoint

* Revise tests to enable auth

* Update default paths for groupId.

* Implement recommended changes from PR #1621

* Add url field

* Resolve pathing issues and add tests/checks for first and last name fields

* Resolve test issues, payload validation error, and correct context default

* Fix no user_id field in group call and timezone offset bug

* Add tests for new functionality

* Delete packages/destination-actions/src/destinations/liveramp-audiences/audienceEnteredSFTP.types.ts

Remove auto generated types file on liveramp platform

* Fix ts error with timeZoneName

---------

Co-authored-by: saadhypng <[email protected]>
Co-authored-by: Saad Ali <[email protected]>
  • Loading branch information
3 people authored and marinhero committed Nov 30, 2023
1 parent 2e5422e commit 35996c1
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const fakeGroupData = {
required: 'false'
},
timestamp: '2023-09-11T08:06:11.192Z',
timezone: 'Europe/Amsterdam',
user_id: 'test',
account_id: 'testAccount'
}
Expand Down Expand Up @@ -75,10 +76,12 @@ describe('validateInput', () => {
it('should return converted payload', async () => {
const payload = validateInput(settings, fakeGroupData, 'account_identify')
expect(payload.account_id).toEqual(fakeGroupData.account_id)
expect(payload.user_id).toEqual(fakeGroupData.user_id)
expect(payload.traits.plan_name).toEqual(fakeGroupData.plan)
expect(payload.traits.industry).toEqual(fakeGroupData.industry)
expect(payload.traits.website).toEqual(fakeGroupData.website)
expect(payload.traits).toHaveProperty('required')
expect(payload.local_tz_offset).toEqual(60)
})
})

Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ const action: ActionDefinition<Settings, Payload> = {
}
}
},
user_id: {
type: 'string',
description: 'The ID associated with the user',
label: 'User ID',
default: { '@path': '$.userId' }
},
name: {
type: 'string',
required: true,
Expand All @@ -41,7 +47,13 @@ const action: ActionDefinition<Settings, Payload> = {
description:
'The timestamp when the account was created, represented in the ISO-8601 date format. For instance, "2023-09-26T15:30:00Z".',
label: 'Account created at',
default: { '@path': '$.traits.created_at' }
default: {
'@if': {
exists: { '@path': '$.traits.created_at' },
then: { '@path': '$.traits.created_at' },
else: { '@path': '$.traits.createdAt' }
}
}
},
traits: {
type: 'object',
Expand All @@ -55,7 +67,13 @@ const action: ActionDefinition<Settings, Payload> = {
required: false,
description: 'Subscription plan the account is associated with',
label: 'Account subscription plan',
default: { '@path': '$.traits.plan' }
default: {
'@if': {
exists: { '@path': '$.traits.plan' },
then: { '@path': '$.traits.plan' },
else: { '@path': '$.traits.plan_name' }
}
}
},
industry: {
type: 'string',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ const action: ActionDefinition<Settings, Payload> = {
description:
'The timestamp when the user was created, represented in the ISO-8601 date format. For instance, "2023-09-26T15:30:00Z".',
label: 'Created at',
default: { '@path': '$.traits.created_at' }
default: {
'@if': {
exists: { '@path': '$.traits.created_at' },
then: { '@path': '$.traits.created_at' },
else: { '@path': '$.traits.createdAt' }
}
}
},
traits: {
type: 'object',
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,26 @@ const action: ActionDefinition<Settings, Payload> = {
label: 'User id',
default: { '@path': '$.userId' }
},
properties: {
type: 'object',
required: false,
description: 'The properties of the track call',
label: 'Event properties',
default: { '@path': '$.properties' }
},
account_id: {
type: 'string',
required: false,
description: 'The account id, to uniquely identify the account associated with the user',
label: 'Account id',
default: {
'@if': {
exists: { '@path': '$.context.group_id' },
then: { '@path': '$.context.group_id' },
exists: { '@path': '$.context.groupId' },
then: { '@path': '$.context.groupId' },
else: { '@path': '$.groupId' }
}
}
},
properties: {
type: 'object',
required: false,
description: 'The properties of the track call',
label: 'Event properties',
default: { '@path': '$.properties' }
},
...commonFields
},
perform: (request, data) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ export const validateInput = (

// Resolve local_tz_offset property, we can get local_tz_offset from the input context.timezone
if (input?.timezone) {
const offset = new Date().toLocaleString('en-US', { timeZone: input.timezone, timeZoneName: 'short' }).split(' ')[2]
properties.local_tz_offset = offset
const offset = new Date()
.toLocaleString('en-US', { timeZone: input.timezone, timeZoneName: 'short' })
.split(' ')[3]
.slice(3)
properties.local_tz_offset = parseInt(offset) * 60
delete properties.timezone
}

Expand Down

0 comments on commit 35996c1

Please sign in to comment.