Skip to content

Commit

Permalink
Enhancements (#1992)
Browse files Browse the repository at this point in the history
* Enhancements

* cherry-pick 234c909

* increase size to 160 KB to bypass Size Limit error in browser-destinations

* Empty Commit

* Extra line break

* Hide retry dropdown

* Change order of tests

---------

Co-authored-by: Marín Alcaraz <[email protected]>
  • Loading branch information
mayur-pitale and marinhero authored Apr 25, 2024
1 parent 3ef6c21 commit 528eb6c
Show file tree
Hide file tree
Showing 8 changed files with 92 additions and 46 deletions.

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 @@ -76,7 +76,9 @@ const destination: DestinationDefinition<Settings> = {
matchColumnName1: {
label: 'First Column Match',
description: `First match column for determining whether an insert or update should occur.
An underscore (_) is implicitly appended to the match column name for the upsertListMember action.`,
A trailing underscore (_) is added to the match column name at the time of request
to Responsys.
This aligns with Responsys’ naming conventions for match columns.`,
type: 'string',
choices: [
{ label: 'RIID', value: 'RIID' },
Expand All @@ -92,7 +94,9 @@ const destination: DestinationDefinition<Settings> = {
matchColumnName2: {
label: 'Second Column Match',
description: `Second match column for determining whether an insert or update should occur.
An underscore (_) is implicitly appended to the match column name for the upsertListMember action.`,
A trailing underscore (_) is added to the match column name at the time of request
to Responsys.
This aligns with Responsys’ naming conventions for match columns.`,
type: 'string',
choices: [
{ label: 'RIID', value: 'RIID' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,40 @@ describe('Responsys.sendAudience', () => {
})

describe('Failure cases', () => {
it('should throw an error if audience event missing mandatory "computation_class" field', async () => {
it('should throw an error if event does not include email / riid / customer_id', async () => {
const errorMessage = 'At least one of the following fields is required: Email Address, RIID, or Customer ID'
nock('https://njp1q7u-api.responsys.ocs.oraclecloud.com')
.post(
`/rest/asyncApi/v1.3/lists/${testSettings.profileListName}/listExtensions/${testSettings.profileExtensionTable}/members`
)
.reply(400)
.replyWithError({
message: errorMessage,
statusCode: 400
})
const bad_event = createTestEvent({
context: {
personas: {
computation_id: AUDIENCE_ID,
computation_key: AUDIENCE_KEY
computation_key: AUDIENCE_KEY,
computation_class: 'audience'
}
},
timestamp: '2024-02-09T20:01:47.853Z',
traits: {
test_key: false,
email: '[email protected]'
test_key: false
},
type: 'identify',
userId: '6789013'
type: 'identify'
})
await expect(
testDestination.testAction('sendAudience', {
event: bad_event,
useDefaultMappings: true
useDefaultMappings: true,
settings: testSettings
})
).rejects.toThrowError("The root value is missing the required field 'computation_class'")
).rejects.toThrow(errorMessage)
})

it('should throw an error if audience key does not match traits object', async () => {
it('should throw an error if audience event missing mandatory "computation_class" field', async () => {
nock('https://njp1q7u-api.responsys.ocs.oraclecloud.com')
.post(
`/rest/asyncApi/v1.3/lists/${testSettings.profileListName}/listExtensions/${testSettings.profileExtensionTable}/members`
Expand All @@ -112,8 +116,7 @@ describe('Responsys.sendAudience', () => {
context: {
personas: {
computation_id: AUDIENCE_ID,
computation_key: AUDIENCE_KEY,
computation_class: 'audience'
computation_key: AUDIENCE_KEY
}
},
timestamp: '2024-02-09T20:01:47.853Z',
Expand All @@ -129,19 +132,15 @@ describe('Responsys.sendAudience', () => {
event: bad_event,
useDefaultMappings: true
})
).rejects.toThrow()
).rejects.toThrowError("The root value is missing the required field 'computation_class'")
})

it('should throw an error if event does not include email / riid / customer_id', async () => {
const errorMessage = 'At least one of the following fields is required: Email Address, RIID, or Customer ID'
it('should throw an error if audience key does not match traits object', async () => {
nock('https://njp1q7u-api.responsys.ocs.oraclecloud.com')
.post(
`/rest/asyncApi/v1.3/lists/${testSettings.profileListName}/listExtensions/${testSettings.profileExtensionTable}/members`
)
.replyWithError({
message: errorMessage,
statusCode: 400
})
.reply(400)
const bad_event = createTestEvent({
context: {
personas: {
Expand All @@ -152,17 +151,18 @@ describe('Responsys.sendAudience', () => {
},
timestamp: '2024-02-09T20:01:47.853Z',
traits: {
test_key: false
test_key: false,
email: '[email protected]'
},
type: 'identify'
type: 'identify',
userId: '6789013'
})
await expect(
testDestination.testAction('sendAudience', {
event: bad_event,
useDefaultMappings: true,
settings: testSettings
useDefaultMappings: true
})
).rejects.toThrow(errorMessage)
).rejects.toThrow()
})
})
})

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 @@ -95,11 +95,21 @@ const action: ActionDefinition<Settings, Payload> = {
}
},
retry: {
label: 'Retry',
description: 'If true, a delay of 30 seconds will be added before retrying a failed request.',
type: 'boolean',
label: 'Delay (seconds)',
description: `A delay of the selected seconds will be added before retrying a failed request.
Max delay allowed is 600 secs (10 mins). The default is 0 seconds.`,
type: 'number',
choices: [
{ label: '0 secs', value: 0 },
{ label: '30 secs', value: 30 },
{ label: '120 secs', value: 120 },
{ label: '300 secs', value: 300 },
{ label: '480 secs', value: 480 },
{ label: '600 secs', value: 600 }
],
required: false,
default: false
unsafe_hidden: true,
default: 0
}
},

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 @@ -57,11 +57,21 @@ const action: ActionDefinition<Settings, Payload> = {
}
},
retry: {
label: 'Retry',
description: 'If true, a delay of 30 seconds will be added before retrying a failed request.',
type: 'boolean',
label: 'Delay (seconds)',
description: `A delay of the selected seconds will be added before retrying a failed request.
Max delay allowed is 600 secs (10 mins). The default is 0 seconds.`,
type: 'number',
choices: [
{ label: '0 secs', value: 0 },
{ label: '30 secs', value: 30 },
{ label: '120 secs', value: 120 },
{ label: '300 secs', value: 300 },
{ label: '480 secs', value: 480 },
{ label: '600 secs', value: 600 }
],
required: false,
default: false
unsafe_hidden: true,
default: 0
}
},

Expand Down
28 changes: 22 additions & 6 deletions packages/destination-actions/src/destinations/responsys/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export const validateCustomTraits = ({
profileExtensionTable?: string
timestamp: string | number
statsContext: StatsContext | undefined
retry?: boolean
retry?: number
}): void => {
const statsClient = statsContext?.statsClient
const statsTag = statsContext?.tags
if (retry && shouldRetry(timestamp)) {
if (retry !== undefined && retry > 0 && shouldRetry(timestamp, retry)) {
if (statsClient && statsTag) {
statsClient?.incr('responsysShouldRetryTRUE', 1, statsTag)
}
Expand All @@ -49,8 +49,8 @@ export const validateCustomTraits = ({
}
}

export const shouldRetry = (timestamp: string | number): boolean => {
return (new Date().getTime() - new Date(timestamp).getTime()) / 1000 < 30
export const shouldRetry = (timestamp: string | number, retry: number): boolean => {
return (new Date().getTime() - new Date(timestamp).getTime()) / 1000 < retry
}

export const validateListMemberPayload = ({
Expand Down Expand Up @@ -154,7 +154,13 @@ export const sendCustomTraits = async (
body: JSON.stringify({
type: 'track',
event: 'Responsys Response Message Received',
properties: { body, responsysRequest: requestBody },
properties: {
body,
responsysRequest: {
...requestBody,
recordCount: requestBody.recordData.records.length
}
},
anonymousId: '__responsys__API__response__'
})
}
Expand Down Expand Up @@ -232,7 +238,17 @@ export const upsertListMembers = async (
body: JSON.stringify({
type: 'track',
event: 'Responsys Response Message Received',
properties: { body, responsysRequest: requestBody },
requestBody: {
...requestBody,
recordCount: requestBody.recordData.records.length
},
properties: {
body,
responsysRequest: {
...requestBody,
recordCount: requestBody.recordData.records.length
}
},
anonymousId: '__responsys__API__response__'
})
}
Expand Down

0 comments on commit 528eb6c

Please sign in to comment.