Skip to content

Commit 8e92533

Browse files
amazon capi stage test
1 parent c5224ee commit 8e92533

File tree

9 files changed

+158
-144
lines changed

9 files changed

+158
-144
lines changed

packages/destination-actions/src/destinations/amazon-conversions-api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const destination: DestinationDefinition<Settings> = {
5757
return {
5858
headers: {
5959
authorization: `Bearer ${auth?.accessToken}`,
60-
'Amazon-Advertising-API-ClientID': process.env.ACTIONS_AMAZON_CONVERSIONS_API_CLIENT_ID || ''
60+
'Amazon-Ads-ClientId': process.env.ACTIONS_AMAZON_CONVERSIONS_API_CLIENT_ID || ''
6161
}
6262
}
6363
},

packages/destination-actions/src/destinations/amazon-conversions-api/trackConversion/__tests__/fields.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ describe('trackConversion fields', () => {
4040
expect(fields.unitsSold?.type).toBe('integer')
4141
expect(fields.clientDedupeId?.type).toBe('string')
4242
expect(fields.dataProcessingOptions?.type).toBe('string')
43-
expect(fields.dataProcessingOptions?.multiple).toBe(true)
4443
expect(fields.consent?.type).toBe('object')
4544
expect(fields.customAttributes?.type).toBe('object')
4645
expect(fields.enable_batching.type).toBe('boolean')
@@ -74,13 +73,15 @@ describe('trackConversion fields', () => {
7473
expect(fields.currencyCode?.depends_on).toBeDefined()
7574
expect(fields.currencyCode?.depends_on?.conditions).toBeDefined()
7675
expect(fields.currencyCode?.depends_on?.conditions?.[0]).toMatchObject({
76+
fieldKey: 'eventType',
7777
operator: 'is',
7878
value: 'OFF_AMAZON_PURCHASES'
7979
})
8080

8181
expect(fields.unitsSold?.depends_on).toBeDefined()
8282
expect(fields.unitsSold?.depends_on?.conditions).toBeDefined()
8383
expect(fields.unitsSold?.depends_on?.conditions?.[0]).toMatchObject({
84+
fieldKey: 'eventType',
8485
operator: 'is',
8586
value: 'OFF_AMAZON_PURCHASES'
8687
})

packages/destination-actions/src/destinations/amazon-conversions-api/trackConversion/__tests__/index.test.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('trackConversion', () => {
3939
describe('perform', () => {
4040
it('should send event data successfully', async () => {
4141
nock(`${Region.NA}`)
42-
.post('/events/v1')
42+
.post('/adsApi/v1/create/events')
4343
.reply(200, { success: true })
4444

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

7272
await expect(
@@ -95,7 +95,7 @@ describe('trackConversion', () => {
9595
settings,
9696
mapping: {
9797
name: 'test_conversion',
98-
// Missing eventType
98+
// Missing conversionType
9999
eventActionSource: 'website',
100100
countryCode: 'US',
101101
timestamp: '2023-01-01T12:00:00Z',
@@ -130,14 +130,10 @@ describe('trackConversion', () => {
130130
it('should process a batch of events successfully', async () => {
131131
// Mock a 207 multi-status response
132132
nock(`${Region.NA}`)
133-
.post('/events/v1')
133+
.post('/adsApi/v1/create/events')
134134
.reply(207, {
135-
success: [
136-
{ index: 1, message: 'Success' }
137-
],
138-
error: [
139-
{ index: 2, httpStatusCode: '400', subErrors: [{ errorMessage: 'Invalid event' }] }
140-
]
135+
success: [{ index: 0, event: null }],
136+
error: [{ index: 1, errors: [{ code: "BAD_REQUEST", message: 'Invalid data' }] }]
141137
})
142138

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

@@ -221,7 +217,7 @@ describe('trackConversion', () => {
221217

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

227223
// Spy on console.error to prevent error output during the test

0 commit comments

Comments
 (0)