Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Hyperengage] Resolved issue with Timezone Offset and Added Missing user_id field in group call #1733

Merged
merged 18 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 16 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
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: 'shortOffset' })
.split(' ')[3]
.slice(3)
properties.local_tz_offset = parseInt(offset) * 60
delete properties.timezone
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Generated file. DO NOT MODIFY IT BY HAND.

Copy link
Contributor

@joe-ayoub-segment joe-ayoub-segment Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zhadier39 and @saadhypng the PR looks good. Can you just remove the change to this file from the PR please?

It was likely automatically added when you ran the ./bin/run generate:types command.

Next steps are:

  • We're planning a deploy next Wednesday. The deploy rolls out across 2 days, so the code will be live for all customers by the end of Thursday.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zhadier39 Will get this updated.

Also @joe-ayoub-segment On the deployment we will convert to our customers to install on next Thursday.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @zhadier39 and @saadhypng .

Just to clarify: We don't have a deploy happening this week. If we did we would push this change out.
The next deploy is next Wednesday/Thursday.

Best regards,
Joe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes got it, next Thursday it will be live. 30th November.

export interface Payload {
/**
* User credentials for establishing an SFTP connection with LiveRamp.
*/
sftp_username?: string
/**
* User credentials for establishing an SFTP connection with LiveRamp.
*/
sftp_password?: string
/**
* Path within the LiveRamp SFTP server to upload the files to. This path must exist and all subfolders must be pre-created.
*/
sftp_folder_path?: string
/**
* Unique ID that identifies members of an audience. A typical audience key might be client customer IDs, email addresses, or phone numbers.
*/
audience_key: string
/**
* Additional data pertaining to the user to be written to the file.
*/
identifier_data?: {
[k: string]: unknown
}
/**
* Additional data pertaining to the user to be hashed before written to the file. Use field name **phone_number** or **email** to apply LiveRamp's specific hashing rules.
*/
unhashed_identifier_data?: {
[k: string]: unknown
}
/**
* Character used to separate tokens in the resulting file.
*/
delimiter: string
/**
* Name of the CSV file to upload for LiveRamp ingestion.
*/
filename: string
/**
* Receive events in a batch payload. This is required for LiveRamp audiences ingestion.
*/
enable_batching: boolean
/**
* Maximum number of events to include in each batch. Actual batch sizes may be lower.
*/
batch_size?: number
}