Skip to content

Commit 992dd26

Browse files
committed
gaarf-js: added debug logging for raw objects from API response via env var GAARF_DUMP_API_ROW, GAARF_DUMP_ROW
version updated to 3.1.1 Change-Id: I8d317ee86035ab5f751a87badc64dd1aac9acdea
1 parent b73d838 commit 992dd26

10 files changed

+39
-25
lines changed

js/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 3.1.1 - 2025-04-17
4+
5+
- Fix: added `override:true` while importing user functions into mathjs
6+
- added debug logging for raw objects from API response via env var GAARF_DUMP_API_ROW
7+
38
## 3.1.0 - 2025-04-08
49

510
- support Google Ads API v19 (updated google-ads-api to v19)

js/dist/cli.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/lib/ads-api-client.js

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/lib/ads-api-client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/lib/ads-query-executor.js

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dist/lib/ads-query-executor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "google-ads-api-report-fetcher",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "Google Ads API Report Fetcher (gaarf)",
55
"main": "./dist/index.js",
66
"types": "./src/index.ts",
@@ -22,6 +22,7 @@
2222
"scripts": {
2323
"clean": "shx rm -rf dist/*",
2424
"tsc": "tsc",
25+
"compile": "tsc",
2526
"start": "node -r ts-node/register src/cli.ts $@",
2627
"gts": "gts",
2728
"lint": "gts lint",

js/src/lib/ads-api-client.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ export interface IGoogleAdsApiClient {
7777

7878
export type GoogleAdsApiConfig = {
7979
// ClientOptions:
80-
client_id: string;
81-
client_secret: string;
80+
client_id?: string;
81+
client_secret?: string;
8282
developer_token: string;
8383
// CustomerOptions:
84-
refresh_token: string;
84+
refresh_token?: string;
8585
login_customer_id?: string;
8686
linked_customer_id?: string;
8787
customer_id?: string[] | string;
@@ -167,8 +167,8 @@ export class GoogleAdsRpcApiClient
167167
constructor(adsConfig: GoogleAdsApiConfig) {
168168
super(adsConfig, ApiType.gRPC);
169169
this.client = new GoogleAdsApi({
170-
client_id: adsConfig.client_id,
171-
client_secret: adsConfig.client_secret,
170+
client_id: adsConfig.client_id!,
171+
client_secret: adsConfig.client_secret!,
172172
developer_token: adsConfig.developer_token,
173173
});
174174
this.customers = {};
@@ -184,7 +184,7 @@ export class GoogleAdsRpcApiClient
184184
customer = this.client.Customer({
185185
customer_id: customerId,
186186
login_customer_id: this.adsConfig.login_customer_id,
187-
refresh_token: this.adsConfig.refresh_token,
187+
refresh_token: this.adsConfig.refresh_token!,
188188
});
189189
this.customers[customerId] = customer;
190190
}
@@ -309,10 +309,6 @@ export class GoogleAdsRpcApiClient
309309
// NOTE: we're iterating over the stream instead of returning it
310310
// for the sake of error handling
311311
const stream = customer.queryStream(query);
312-
// this.logger.debug('Created AsyncGenerator from queryStream', {
313-
// customerId,
314-
// query,
315-
// });
316312
for await (const row of stream) {
317313
yield row as Record<string, unknown>;
318314
}
@@ -405,9 +401,9 @@ export class GoogleAdsRestApiClient
405401
// working under a user account (with refreshToken)
406402
// Refresh if within 5 minutes of expiration
407403
const {access_token, expires_in} = await this.refreshAccessToken(
408-
this.adsConfig.client_id,
409-
this.adsConfig.client_secret,
410-
this.adsConfig.refresh_token
404+
this.adsConfig.client_id!,
405+
this.adsConfig.client_secret!,
406+
this.adsConfig.refresh_token!
411407
);
412408
this.currentToken = access_token;
413409
this.tokenExpiration = Date.now() + expires_in * 1000;

js/src/lib/ads-query-executor.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ export class AdsQueryExecutor {
372372
): Promise<QueryResult> {
373373
return executeWithRetry(
374374
async () => {
375+
const dumpRawRow = process.env.GAARF_DUMP_API_ROW;
376+
const dumpRow = process.env.GAARF_DUMP_ROW;
375377
const stream = this.executeNativeQuery(query, customerId);
376378
if (process.env.DUMP_MEMORY) {
377379
this.logger.debug(getMemoryUsage('Query executed'));
@@ -382,9 +384,15 @@ export class AdsQueryExecutor {
382384
// NOTE: as we're iterating over an AsyncGenerator any error if happens
383385
// will be thrown on iterating not on creating of the generator
384386
for await (const row of stream) {
387+
if (dumpRawRow) {
388+
console.log(row);
389+
}
385390
const parsedRow = <unknown[]>this.parser.parseRow(row, query, false);
391+
if (dumpRow) {
392+
console.log(parsedRow);
393+
}
386394
rowCount++;
387-
// NOTE: to descrease memory consumption we won't accumulate data if a writer was supplied
395+
// NOTE: to decrease memory consumption we won't accumulate data if a writer was supplied
388396
if (writer) {
389397
await writer.addRow(customerId, parsedRow, row);
390398
if (process.env.DUMP_MEMORY && rowCount % 10 === 0) {

0 commit comments

Comments
 (0)