Error: Unknown field metrics.conversions - Google Ads Scripts Account Summary Report - Adding new columns - google-ads-api

I want to add new columns to the Account Summary Report: https://developers.google.com/google-ads/scripts/docs/solutions/account-summary
But I'm getting an error.
'report_fields': [
{'columnName': 'metrics.cost_micros', 'displayName': 'Cost'},
{'columnName': 'metrics.average_cpc', 'displayName': 'Avg. CPC'},
{'columnName': 'metrics.ctr', 'displayName': 'CTR'},
{'columnName': 'metrics.search_impression_share', 'displayName': 'Search Impr. share'},
{'columnName': 'metrics.impressions', 'displayName': 'Impressions'},
{'columnName': 'metrics.clicks', 'displayName': 'Clicks'},
{'columnName': 'metrics.conversions', 'displayName': 'Conversions'},
{'columnName': 'metrics.conversions_value', 'displayName': 'Revenue'},
{'columnName': 'metrics.cost_per_conversion', 'displayName': 'CPA'},
{'columnName': 'metrics.conversions_from_interactions_rate', 'displayName': 'CVR'}
--- Error---
Error: Unknown field metrics.conversions
at format (Code:174:13)
at Code:97:33
at Array.map (<anonymous>)
at main (Code:96:55)

The Ads Script code you linked to contains a function which correctly formats the different metrics being downloaded:
function format(column, value) {
switch (column) {
case 'metrics.clicks':
case 'metrics.impressions':
return value;
case 'metrics.ctr':
return formatPercentage(value);
case 'metrics.average_cpc':
case 'metrics.cost_micros':
return formatMicros(value);
case 'metrics.search_impression_share':
return formatImpressionShare(value);
default:
throw new Error(`Unknown field ${column}`);
}
}
You'll notice that every metric is individually listed. If you add metrics.conversions to the set of fields being downloaded, you'll need to adjust the format function as well—otherwise you'll encounter the "Error: Unknown field metrics.conversions" exception which is thrown in the default case.
As metrics.conversions is a regular number, you can just add a case for it at the top:
function format(column, value) {
switch (column) {
case 'metrics.clicks':
case 'metrics.impressions':
case 'metrics.conversions':
return value;
case 'metrics.ctr':
return formatPercentage(value);
case 'metrics.average_cpc':
case 'metrics.cost_micros':
return formatMicros(value);
case 'metrics.search_impression_share':
return formatImpressionShare(value);
default:
throw new Error(`Unknown field ${column}`);
}
}

Related

NestJs Multer upload file with fileFilter cause infinite pending

i have an issue witch Multer and NestJS to upload file. I try to check if file already exist to return an error. it's working well but if i try to re-upload a file after that, i have infinite pending request. (if i remove the filter i have no problem but i overwrite the file)
here my controller code:
#UseGuards(JwtAuthGuard)
#UseGuards(RolesGuard)
#Role('SCENARISTE')
#Post('upload/sound')
#UseInterceptors(FileInterceptor('file', {
storage: diskStorage({
destination: 'files/sounds',
filename: function (req, file, callback) {
return callback(null, file.originalname);
}
}),
fileFilter: (req, file, callback) => {
if (existsSync(join('files/sounds', file.originalname))) {
return callback(new NotAcceptableException(ErrorType.FILE_ALREADY_EXIST), false);
} else {
return callback(null, true);
}
},
}))
uploadSound(#UploadedFile() file: Express.Multer.File) {
const fileReponse = {
originalname: file.originalname,
mimetype: file.mimetype,
filename: file.filename,
size: file.size,
destination: file.destination,
fieldname: file.fieldname,
path: file.path
};
return fileReponse;
}
thank in advance for your help
may be the first request not close/stop correctly ?
According to Multer's documantion, whenever you want to throw an error, you must call the callback by passing the first argument with an error, and leave the second argument or pass the false value.
Hence, try to change your code like this:
return callback(new NotAcceptableException(ErrorType.FILE_ALREADY_EXIST));

Getting index out of range error when creating metaplex metadata account

Why am I getting the following error when trying to create a metadata account using createCreateMetadataAccountV2Instruction from the #metaplex-foundation/mpl-token-metadata library?
SendTransactionError: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete
at Connection.sendEncodedTransaction (C:\xampp\htdocs\sol-tools\node_modules\#solana\web3.js\src\connection.ts:4464:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Connection.sendRawTransaction (C:\xampp\htdocs\sol-tools\node_modules\#solana\web3.js\src\connection.ts:4423:20)
at async Connection.sendTransaction (C:\xampp\htdocs\sol-tools\node_modules\#solana\web3.js\src\connection.ts:4411:12)
at async sendAndConfirmTransaction (C:\xampp\htdocs\sol-tools\node_modules\#solana\web3.js\src\util\send-and-confirm-transaction.ts:31:21)
at async addMetadataToToken (C:\xampp\htdocs\sol-tools\src\lib\metadata.ts:86:16)
at async Command.<anonymous> (C:\xampp\htdocs\sol-tools\src\cli.ts:48:7) {
logs: [
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]',
'Program log: Instruction: Create Metadata Accounts v2',
"Program log: panicked at 'range end index 36 out of range for slice of length 0', program/src/utils.rs:231:27",
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 6223 of 1400000 compute units',
'Program failed to complete: BPF program panicked',
'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: Program failed to complete'
]
}
Here's my code:
import {
createCreateMetadataAccountV2Instruction,
PROGRAM_ID,
} from '#metaplex-foundation/mpl-token-metadata'
import {
Connection,
Keypair,
PublicKey,
sendAndConfirmTransaction,
Transaction,
} from '#solana/web3.js'
export const addMetadataToToken = async (
connection: Connection,
tokenMint: PublicKey,
tokenOwner: Keypair,
name: string,
symbol: string,
arweaveLink: string
) => {
const seed1 = Buffer.from('metadata', 'utf8')
const seed2 = PROGRAM_ID.toBuffer()
const seed3 = tokenMint.toBuffer()
const [metadataPDA, _bump] = PublicKey.findProgramAddressSync(
[seed1, seed2, seed3],
PROGRAM_ID
)
const accounts = {
metadata: metadataPDA,
mint: tokenMint,
mintAuthority: tokenOwner.publicKey,
payer: tokenOwner.publicKey,
updateAuthority: tokenOwner.publicKey,
}
const dataV2 = {
name,
symbol,
uri: arweaveLink,
// we don't need these
sellerFeeBasisPoints: 0,
creators: null,
collection: null,
uses: null,
}
const args = {
createMetadataAccountArgsV2: {
data: dataV2,
isMutable: true,
},
}
const ix = createCreateMetadataAccountV2Instruction(accounts, args)
const tx = new Transaction()
tx.add(ix)
const txid = await sendAndConfirmTransaction(connection, tx, [tokenOwner])
console.log(txid)
}
Turns out I was on trying to create metadata for a token on devnet, but was using a mainnet-beta rpc endpoint for the Connection class. Thus the token I was trying to create metadata for didn't exist.
This is a really Common Error Message that occurs when there is some issue with what you are passing to the program. So make sure everything that you are input to the program is correct. In 90% of the cases, it gets resolved when checking the inputs correctly.

Get error on GML options

I'm trying to create wfs-t service I have used the ol.format.WFS#writeTransaction method and serialize the WFS-t XML but my jslint always preview error at the GML format options. Is it possible that I am initializing the ol.format.WFS object incorrectly?
Or maybe I am passing the wrong options to the writeTransaction method? Or maybe it's a bug in OpenLayers4? this detail of my wfs-t service using angular http service:
private _transactWFS(feature: any, operation: any): any {
let payload;
try {
const formatWFS = new ol.format.WFS({});
const formatGML = new ol.format.GML({
featureNS: operation.featureNS,
featureType: operation.featureType,
srsName: operation.srsName
});
const xs = new XMLSerializer();
let node: any = null;
switch (operation.mode) {
case 'insert':
node = formatWFS.writeTransaction([feature], null, null, formatGML);
break;
case 'update':
node = formatWFS.writeTransaction(null, [feature], null, formatGML);
break;
case 'delete':
node = formatWFS.writeTransaction(null, null, [feature], formatGML);
break;
}
payload = xs.serializeToString(node);
} catch (error) {}
return payload;
}
lint message:
[ts]
Argument of type 'GML' is not assignable to parameter of type 'WFSWriteTransactionOptions'.
Property 'featureNS' is missing in type 'GML'.
From the OpenLayers WFS-T example:
// Word to the Wise from an anonymous OpenLayers hacker:
//
// The typename in the options list when adding/loading a wfs
// layer not should contain the namespace before, (as in the
// first typename parameter to the wfs consctructor).
//
// Specifically, in the first parameter you write typename:
// 'topp:myLayerName', and in the following option list
// typeName: 'myLayerName'.
//
// If you have topp included in the second one you will get
// namespace 14 errors when trying to insert features.
//
wfs = new OpenLayers.Layer.WFS(
"Cities",
"http://sigma.openplans.org/geoserver/wfs",
{typename: 'topp:tasmania_cities'},
{
typename: "tasmania_cities",
featureNS: "http://www.openplans.org/topp",
extractAttributes: false,
commitReport: function(str) {
OpenLayers.Console.log(str);
}
}
);
Seems to indicate you are building your WFS object wrong.
I'm give up using WFS Format for build WFS Transaction request so my problem was solved by myself, I found this lib geojson-to-wfs-t-2. This library is very legit for solving my problem.

How to use translation in global validation with redux-form validation

When trying to use validation in a global validator with this code:
errors.fieldMissing = [translate('aor.validation.fieldMissing')];
I get the following error:
Warning: Failed prop type: Invalid prop `errorText` supplied to `TextField`, expected a ReactNode.
Without the translation(), just setting the error to an array of a string, everything works as expected.
How can translation() be used in global validation?
For example(edited from AOR example posts):
<SimpleForm defaultValue={{ average_note: 0 }} validate={(values, props) => {
const errors = {};
['title', 'teaser'].forEach((field) => {
if (!values[field]) {
errors[field] = [props.translate('aor.validation.required')];
}
});
...
A short example of translate hoc and translate props:
import { translate as translator } from 'admin-on-rest';
const Title = translator(({ record, translate }) => <span>{record ? translate('title.product', { name: record.name }) : ''}</span>);

Protractor memory error

I am using the following call
expect(element(by.css('MyTableCssIdentifier')).element(by.cssContainingText("td", RowName)).getText()).toEqual(RowValue, ' Row value does not match expected')
it is giving the following error on a table with 250+ entries in it. I a getting the following error:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
It does not appear I can break the table down further (i.e. no other identifier to only use half of the table at a time or some such). I am able to return just the entire table without any issues. I have also tried wrapping in a function with the filter option:
this.getElementFromTable = function(RowName) {
return element.all(by.repeater('MyRepeaterID')).filter(function (row) {
return row.$$('td').get(1).getText().then(function (rowName) {
return rowName == RowName;
});
}).then(function (rows) {
try {
return rows[0].getText().then(function (RowValue) {
return RowValue;
});
}
catch (err) {
return Error(' element not found ')
}
});
};
This also seems to give me the same allocation error. Any suggestions?

Resources