Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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 @@ -616,5 +616,42 @@ describe('GoogleEnhancedConversions', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(201)
})

it('strips hyphens from customerId in batch API URL and conversionAction', async () => {
const hyphenatedCustomerId = '123-456-7890'
const strippedCustomerId = '1234567890'

const events: SegmentEvent[] = [
createTestEvent({
timestamp,
event: 'Test Event 1',
properties: {
email: '[email protected]',
orderId: '1234',
total: '200',
currency: 'USD'
}
})
]

nock(`https://googleads.googleapis.com/${API_VERSION}/customers/${strippedCustomerId}:uploadCallConversions`)
.post('')
.reply(201, { results: [{}] })

const responses = await testDestination.testBatchAction('uploadCallConversion', {
events,
mapping: { conversion_action: '12345', caller_id: '+1234567890', call_timestamp: timestamp },
useDefaultMappings: true,
settings: {
customerId: hyphenatedCustomerId
}
})

expect(responses.length).toBe(1)
expect(responses[0].status).toBe(201)

const body = JSON.parse(responses[0].options.body as string)
expect(body.conversions[0].conversionAction).toBe(`customers/${strippedCustomerId}/conversionActions/12345`)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -756,5 +756,47 @@ describe('GoogleEnhancedConversions', () => {
expect((e as Error).message).toBe('Unsupported Sync Mode "upsert"')
}
})

it('strips hyphens from customerId in batch API URL and conversionAction', async () => {
const hyphenatedCustomerId = '123-456-7890'
const strippedCustomerId = '1234567890'

const events: SegmentEvent[] = [
createTestEvent({
timestamp,
event: 'Test Event 1',
properties: {
email: '[email protected]',
orderId: '1234',
total: '200',
currency: 'USD'
}
})
]

nock(`https://googleads.googleapis.com/${API_VERSION}/customers/${strippedCustomerId}:uploadCallConversions`)
.post('')
.reply(201, { results: [{}] })

const responses = await testDestination.testBatchAction('uploadCallConversion2', {
events,
mapping: {
conversion_action: '12345',
caller_id: '+1234567890',
call_timestamp: timestamp,
__segment_internal_sync_mode: 'add'
},
useDefaultMappings: true,
settings: {
customerId: hyphenatedCustomerId
}
})

expect(responses.length).toBe(1)
expect(responses[0].status).toBe(201)

const body = JSON.parse(responses[0].options.body as string)
expect(body.conversions[0].conversionAction).toBe(`customers/${strippedCustomerId}/conversionActions/12345`)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -1793,5 +1793,46 @@ describe('GoogleEnhancedConversions', () => {
expect(responses.length).toBe(1)
expect(responses[0].status).toBe(201)
})

it('strips hyphens from customerId in batch API URL and conversionAction', async () => {
const hyphenatedCustomerId = '123-456-7890'
const strippedCustomerId = '1234567890'

const events: SegmentEvent[] = [
createTestEvent({
timestamp,
event: 'Test Event 1',
properties: {
gclid: '54321',
email: '[email protected]',
orderId: '1234',
total: '200',
currency: 'USD'
}
})
]

nock(`https://googleads.googleapis.com/${API_VERSION}/customers/${strippedCustomerId}:uploadClickConversions`)
.post('')
.reply(201, { results: [{}] })

const responses = await testDestination.testBatchAction('uploadClickConversion2', {
events,
mapping: {
conversion_action: '12345',
__segment_internal_sync_mode: 'add'
},
useDefaultMappings: true,
settings: {
customerId: hyphenatedCustomerId
}
})

expect(responses.length).toBe(1)
expect(responses[0].status).toBe(201)

const body = JSON.parse(responses[0].options.body as string)
expect(body.conversions[0].conversionAction).toBe(`customers/${strippedCustomerId}/conversionActions/12345`)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -1335,5 +1335,72 @@ describe('GoogleEnhancedConversions', () => {
expect(e.message).toBe("Email provided doesn't seem to be in a valid format.")
}
})

it('strips hyphens from customerId in batch API URL and conversionAction', async () => {
const hyphenatedCustomerId = '123-456-7890'
const strippedCustomerId = '1234567890'

const events: SegmentEvent[] = [
createTestEvent({
timestamp,
event: 'Test Event 1',
properties: {
gclid: '54321',
email: '[email protected]',
orderId: '1234',
phone: '1234567890',
firstName: 'Jane',
lastName: 'Doe',
currency: 'USD',
value: '123',
address: {
street: '123 Street SW',
city: 'San Diego',
state: 'CA',
postalCode: '982004'
}
}
})
]

nock(
`https://googleads.googleapis.com/${API_VERSION}/customers/${strippedCustomerId}:uploadConversionAdjustments`
)
.post('')
.reply(201, { results: [{}] })

const responses = await testDestination.testBatchAction('uploadConversionAdjustment2', {
events,
mapping: {
gclid: {
'@path': '$.properties.gclid'
},
conversion_action: '12345',
adjustment_type: 'ENHANCEMENT',
conversion_timestamp: {
'@path': '$.timestamp'
},
restatement_value: {
'@path': '$.properties.value'
},
restatement_currency_code: {
'@path': '$.properties.currency'
},
__segment_internal_sync_mode: 'add'
},
useDefaultMappings: true,
settings: {
customerId: hyphenatedCustomerId
}
})

expect(responses.length).toBe(1)
expect(responses[0].status).toBe(201)

const body = JSON.parse(responses[0].options.body as string)
expect(body.conversionAdjustments[0].conversionAction).toBe(
`customers/${strippedCustomerId}/conversionActions/12345`
)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,10 @@ const action: ActionDefinition<Settings, Payload> = {
)

const response: ModifiedResponse<PartialErrorResponse> = await request(
`https://googleads.googleapis.com/${getApiVersion(features, statsContext)}/customers/${
settings.customerId
}:uploadCallConversions`,
`https://googleads.googleapis.com/${getApiVersion(
features,
statsContext
)}/customers/${customerId}:uploadCallConversions`,
{
method: 'post',
headers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const action: ActionDefinition<Settings, Payload> = {
const request_objects: CallConversionRequestObjectInterface[] = await Promise.all(
payload.map(async (payloadItem) => {
const request_object: CallConversionRequestObjectInterface = {
conversionAction: `customers/${settings.customerId}/conversionActions/${payloadItem.conversion_action}`,
conversionAction: `customers/${customerId}/conversionActions/${payloadItem.conversion_action}`,
callerId: payloadItem.caller_id,
callStartDateTime: convertTimestamp(payloadItem.call_timestamp),
conversionDateTime: convertTimestamp(payloadItem.conversion_timestamp),
Expand Down Expand Up @@ -257,9 +257,10 @@ const action: ActionDefinition<Settings, Payload> = {
)

const response: ModifiedResponse<PartialErrorResponse> = await request(
`https://googleads.googleapis.com/${getApiVersion(features, statsContext)}/customers/${
settings.customerId
}:uploadCallConversions`,
`https://googleads.googleapis.com/${getApiVersion(
features,
statsContext
)}/customers/${customerId}:uploadCallConversions`,
{
method: 'post',
headers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const action: ActionDefinition<Settings, Payload> = {
session_start_time_usec: {
label: 'Session Start Time',
description:
"The timestamp of when the user's session began on your website. This helps track the duration of user visits. The format should be a full ISO 8601 string. For example \"2025-11-18T08:52:17.023Z\".",
'The timestamp of when the user\'s session began on your website. This helps track the duration of user visits. The format should be a full ISO 8601 string. For example "2025-11-18T08:52:17.023Z".',
type: 'string',
format: 'date-time'
},
Expand Down Expand Up @@ -367,7 +367,7 @@ const action: ActionDefinition<Settings, Payload> = {
}

const { session_attributes_encoded, user_ip_address } = payload

const request_object: ClickConversionRequestObjectInterface = {
conversionAction: `customers/${settings.customerId}/conversionActions/${payload.conversion_action}`,
conversionDateTime: convertTimestamp(payload.conversion_timestamp),
Expand Down Expand Up @@ -486,7 +486,7 @@ const action: ActionDefinition<Settings, Payload> = {
const { session_attributes_encoded, user_ip_address } = payloadItem

const request_object: ClickConversionRequestObjectInterface = {
conversionAction: `customers/${settings.customerId}/conversionActions/${payloadItem.conversion_action}`,
conversionAction: `customers/${customerId}/conversionActions/${payloadItem.conversion_action}`,
conversionDateTime: convertTimestamp(payloadItem.conversion_timestamp),
gclid: payloadItem.gclid,
gbraid: payloadItem.gbraid,
Expand Down Expand Up @@ -559,9 +559,10 @@ const action: ActionDefinition<Settings, Payload> = {
)

const response: ModifiedResponse<PartialErrorResponse> = await request(
`https://googleads.googleapis.com/${getApiVersion(features, statsContext)}/customers/${
settings.customerId
}:uploadClickConversions`,
`https://googleads.googleapis.com/${getApiVersion(
features,
statsContext
)}/customers/${customerId}:uploadClickConversions`,
{
method: 'post',
headers: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ const action: ActionDefinition<Settings, Payload> = {
}

const request_object: ConversionAdjustmentRequestObjectInterface = {
conversionAction: `customers/${settings.customerId}/conversionActions/${payloadItem.conversion_action}`,
conversionAction: `customers/${customerId}/conversionActions/${payloadItem.conversion_action}`,
adjustmentType: payloadItem.adjustment_type,
adjustmentDateTime: convertTimestamp(payloadItem.adjustment_timestamp),
orderId: payloadItem.order_id,
Expand Down
Loading