Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -57,7 +57,7 @@ const destination: DestinationDefinition<Settings> = {
return {
headers: {
authorization: `Bearer ${auth?.accessToken}`,
'Amazon-Advertising-API-ClientID': process.env.ACTIONS_AMAZON_CONVERSIONS_API_CLIENT_ID || ''
'Amazon-Ads-ClientId': process.env.ACTIONS_AMAZON_CONVERSIONS_API_CLIENT_ID || ''
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('trackConversion fields', () => {
expect(fields.unitsSold?.type).toBe('integer')
expect(fields.clientDedupeId?.type).toBe('string')
expect(fields.dataProcessingOptions?.type).toBe('string')
expect(fields.dataProcessingOptions?.multiple).toBe(true)
expect(fields.consent?.type).toBe('object')
expect(fields.customAttributes?.type).toBe('object')
expect(fields.enable_batching.type).toBe('boolean')
Expand Down Expand Up @@ -74,13 +73,15 @@ describe('trackConversion fields', () => {
expect(fields.currencyCode?.depends_on).toBeDefined()
expect(fields.currencyCode?.depends_on?.conditions).toBeDefined()
expect(fields.currencyCode?.depends_on?.conditions?.[0]).toMatchObject({
fieldKey: 'eventType',
operator: 'is',
value: 'OFF_AMAZON_PURCHASES'
})

expect(fields.unitsSold?.depends_on).toBeDefined()
expect(fields.unitsSold?.depends_on?.conditions).toBeDefined()
expect(fields.unitsSold?.depends_on?.conditions?.[0]).toMatchObject({
fieldKey: 'eventType',
operator: 'is',
value: 'OFF_AMAZON_PURCHASES'
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('trackConversion', () => {
describe('perform', () => {
it('should send event data successfully', async () => {
nock(`${Region.NA}`)
.post('/events/v1')
.post('/adsApi/v1/create/events')
.reply(200, { success: true })

const responses = await testDestination.testAction('trackConversion', {
Expand All @@ -66,7 +66,7 @@ describe('trackConversion', () => {
it('should handle API errors', async () => {
// Mock an API error response
nock(`${Region.NA}`)
.post('/events/v1')
.post('/adsApi/v1/create/events')
.replyWithError('Invalid event data')

await expect(
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('trackConversion', () => {
settings,
mapping: {
name: 'test_conversion',
// Missing eventType
// Missing conversionType
eventActionSource: 'website',
countryCode: 'US',
timestamp: '2023-01-01T12:00:00Z',
Expand Down Expand Up @@ -130,14 +130,10 @@ describe('trackConversion', () => {
it('should process a batch of events successfully', async () => {
// Mock a 207 multi-status response
nock(`${Region.NA}`)
.post('/events/v1')
.post('/adsApi/v1/create/events')
.reply(207, {
success: [
{ index: 1, message: 'Success' }
],
error: [
{ index: 2, httpStatusCode: '400', subErrors: [{ errorMessage: 'Invalid event' }] }
]
success: [{ index: 0, event: null }],
error: [{ index: 1, errors: [{ code: "BAD_REQUEST", message: 'Invalid data' }] }]
})

const responses = await testDestination.testBatchAction('trackConversion', {
Expand Down Expand Up @@ -169,9 +165,9 @@ describe('trackConversion', () => {
it('should handle validation errors for individual payloads', async () => {
// Mock the API request to send a partial success response
nock(`${Region.NA}`)
.post('/events/v1')
.post('/adsApi/v1/create/events')
.reply(207, {
success: [{ index: 1, message: 'Success' },{ index: 2, message: 'Success' }],
success: [{ index: 0, event: null }, { index: 1, event: null }],
error: []
})

Expand Down Expand Up @@ -221,7 +217,7 @@ describe('trackConversion', () => {

it('should handle API errors in batch mode', async () => {
nock(`${Region.NA}`)
.post('/events/v1')
.post('/adsApi/v1/create/events')
.reply(500, { error: 'Internal server error' })

// Spy on console.error to prevent error output during the test
Expand Down
Loading
Loading