-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
In v19 a bug was introduced.
A last field in a query is corrupted.
For instance, given a query from the following sample, the last field is 'metrics.conversions_value'. In a response we'll:
metrics: { conversions_valuefromasset_group_assetwherecampaign: null }
(conversions_valuefromasset_group_assetwherecampaign
instead just conversions_value
)
If I add another metric:
const query = `SELECT asset_group.id, metrics.conversions_value, metrics.conversions
FROM asset_group_asset WHERE campaign.advertising_channel_type = 'PERFORMANCE_MAX'
then the result will be:
metrics: {
conversions_value: 67.98,
conversionsfromasset_group_assetwherecampaign: null
}
Something is wrong with newlines.
If I put all query in one line, it works as expected:
const query =
SELECT asset_group.id, metrics.conversions_value, metrics.conversions FROM asset_group_asset WHERE campaign.advertising_channel_type = 'PERFORMANCE_MAX' ;
import fs from 'fs';
import {Customer, errors, GoogleAdsApi} from 'google-ads-api';
import yaml from 'js-yaml';
const query = `SELECT asset_group.id, metrics.conversions_value
FROM asset_group_asset WHERE campaign.advertising_channel_type = 'PERFORMANCE_MAX'
AND campaign.status = 'ENABLED'
AND asset_group.status = 'ENABLED'
AND asset_group_asset.status = 'ENABLED'
AND asset_group_asset.source = 'ADVERTISER'`;
function getCustomer(config, customerId) {
const client = new GoogleAdsApi({
client_id: config.client_id,
client_secret: config.client_secret,
developer_token: config.developer_token,
});
const customer = client.Customer({
customer_id: customerId,
login_customer_id: config.login_customer_id,
refresh_token: config.refresh_token,
});
return customer;
}
async function main() {
const content = fs.readFileSync('google-ads.yaml')
const config = yaml.load(content)
const customerId = 8986667998
const customer = getCustomer(config, customerId);
const res = await customer.query(query);
console.log(res);
}
main().catch(console.error);
Metadata
Metadata
Assignees
Labels
No labels