google-ads-api 19.0.0-rest-beta → 19.0.1-rest-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +2 -2
- package/build/src/customer.d.ts +2 -2
- package/build/src/customer.js +3 -2
- package/build/src/query.d.ts +2 -2
- package/build/src/types.d.ts +16 -1
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
### Upcoming Breaking Changes
|
|
4
|
+
|
|
5
|
+
From v20 onwards this library will use the REST api for report, reportStream, search and searchStream. This will result in minor breaking changes to reporting calls:
|
|
6
|
+
|
|
7
|
+
- Fields with the enum value `0` will now be `undefined` instead
|
|
8
|
+
- Array-fields (such as `final_urls`) with the value `[]` will now be `undefined` instead
|
|
9
|
+
|
|
10
|
+
While these changes are inconvenient, the performance of the REST api is significantly better than the gRPC api, particularly for responses with many rows.
|
|
11
|
+
|
|
12
|
+
To prepare for this change, we recommend you use the install the `19.0.0-rest-beta` version of this library and test your application with it.
|
|
13
|
+
|
|
14
|
+
## 19.0.1
|
|
15
|
+
|
|
16
|
+
- Fix issue with type interface for search_settings not showing any valid fields.
|
|
17
|
+
|
|
18
|
+
## 19.0.0
|
|
19
|
+
|
|
20
|
+
### Version Upgrade
|
|
21
|
+
|
|
22
|
+
- Upgraded google-ads-api version to v19. Refer to Google ads release notes [here](https://developers.google.com/google-ads/api/docs/release-notes) for changes.
|
|
23
|
+
|
|
24
|
+
### Library Changes
|
|
25
|
+
|
|
26
|
+
- We currently do not support `return_total_results_count` on search_settings for SearchGoogleAdsRequest. Please use `reportCount()` instead. This has been reflected in the `RequestOptions` type:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
export type RequestOptions = Omit<
|
|
30
|
+
services.ISearchGoogleAdsRequest,
|
|
31
|
+
"customer_id" | "query" | "search_settings"
|
|
32
|
+
> & {
|
|
33
|
+
search_settings?: Omit<
|
|
34
|
+
services.ISearchSettings,
|
|
35
|
+
"return_total_results_count"
|
|
36
|
+
>;
|
|
37
|
+
};
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For more information please see the `SearchSettings` reference on the Google document [here](https://developers.google.com/google-ads/api/reference/rpc/v19/SearchSettings).
|
package/README.md
CHANGED
|
@@ -444,7 +444,7 @@ const [summaryRow, ...response] = await customer.report({
|
|
|
444
444
|
entity: "campaign",
|
|
445
445
|
metrics: ["metrics.clicks", "metrics.all_conversions"],
|
|
446
446
|
search_settings: {
|
|
447
|
-
return_summary_row:
|
|
447
|
+
return_summary_row: true,
|
|
448
448
|
},
|
|
449
449
|
});
|
|
450
450
|
```
|
|
@@ -456,7 +456,7 @@ const stream = customer.reportStream({
|
|
|
456
456
|
entity: "campaign",
|
|
457
457
|
metrics: ["metrics.clicks", "metrics.all_conversions"],
|
|
458
458
|
search_settings: {
|
|
459
|
-
return_summary_row:
|
|
459
|
+
return_summary_row: true,
|
|
460
460
|
},
|
|
461
461
|
});
|
|
462
462
|
|
package/build/src/customer.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ClientOptions } from "./client";
|
|
|
3
3
|
import { Hooks } from "./hooks";
|
|
4
4
|
import { services } from "./protos";
|
|
5
5
|
import ServiceFactory from "./protos/autogen/serviceFactory";
|
|
6
|
-
import { CustomerOptions, MutateOperation, MutateOptions, ReportOptions, RequestOptions } from "./types";
|
|
6
|
+
import { CustomerOptions, MutateOperation, MutateOptions, ReportOptions, ReportOptionsWithTotalResults, RequestOptions } from "./types";
|
|
7
7
|
export declare class Customer extends ServiceFactory {
|
|
8
8
|
constructor(clientOptions: ClientOptions, customerOptions: CustomerOptions, hooks?: Hooks);
|
|
9
9
|
/**
|
|
@@ -30,7 +30,7 @@ export declare class Customer extends ServiceFactory {
|
|
|
30
30
|
@description Get the total row count of a report.
|
|
31
31
|
@hooks none
|
|
32
32
|
*/
|
|
33
|
-
reportCount(options: Readonly<
|
|
33
|
+
reportCount(options: Readonly<ReportOptionsWithTotalResults>): Promise<number | undefined>;
|
|
34
34
|
/**
|
|
35
35
|
@description Stream query using ReportOptions. If a generic type is provided, it must be the type of a single row.
|
|
36
36
|
If a summary row is requested then this will be the last emitted row of the stream.
|
package/build/src/customer.js
CHANGED
|
@@ -55,7 +55,8 @@ class Customer extends serviceFactory_1.default {
|
|
|
55
55
|
@hooks none
|
|
56
56
|
*/
|
|
57
57
|
async reportCount(options) {
|
|
58
|
-
|
|
58
|
+
// must get at least one row
|
|
59
|
+
const { gaqlQuery, requestOptions } = (0, query_1.buildQuery)({ ...options, limit: 1 });
|
|
59
60
|
// We do not allow this field in reportOptions, however it is still a valid request option
|
|
60
61
|
requestOptions.search_settings = { return_total_results_count: true };
|
|
61
62
|
const useHooks = false; // to avoid cacheing conflicts
|
|
@@ -147,7 +148,7 @@ class Customer extends serviceFactory_1.default {
|
|
|
147
148
|
When possible, use the searchStream method to avoid the overhead of pagination.
|
|
148
149
|
*/
|
|
149
150
|
if (requestOptions.page_size === undefined &&
|
|
150
|
-
requestOptions.search_settings?.
|
|
151
|
+
!requestOptions.search_settings?.return_summary_row) {
|
|
151
152
|
// If no pagination or summary options are set, we can use the non-paginated search method.
|
|
152
153
|
const { response } = await this.useStreamToImitateRegularSearch(gaqlQuery, requestOptions);
|
|
153
154
|
return { response };
|
package/build/src/query.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fields } from "./protos";
|
|
2
|
-
import { ConstraintKey, ConstraintOperation, ConstraintValue, ReportOptions, RequestOptions, SortOrder } from "./types";
|
|
2
|
+
import { ConstraintKey, ConstraintOperation, ConstraintValue, ReportOptions, RequestOptions, RequestOptionsWithTotalResults, SortOrder } from "./types";
|
|
3
3
|
declare enum QueryKeywords {
|
|
4
4
|
SELECT = "SELECT",
|
|
5
5
|
FROM = "FROM",
|
|
@@ -57,6 +57,6 @@ export declare function buildOrderClause(order: Readonly<ReportOptions["order"]>
|
|
|
57
57
|
export declare function buildRequestOptions(reportOptions: Readonly<ReportOptions>): RequestOptions;
|
|
58
58
|
export declare function buildQuery(reportOptions: Readonly<ReportOptions>): {
|
|
59
59
|
gaqlQuery: Query;
|
|
60
|
-
requestOptions:
|
|
60
|
+
requestOptions: RequestOptionsWithTotalResults;
|
|
61
61
|
};
|
|
62
62
|
export {};
|
package/build/src/types.d.ts
CHANGED
|
@@ -27,6 +27,20 @@ export interface ReportOptions extends RequestOptions {
|
|
|
27
27
|
from_date?: string;
|
|
28
28
|
to_date?: string;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Add back optional return_total_results_count as it is still a valid request option
|
|
32
|
+
*/
|
|
33
|
+
type SearchSettingsWithOptionalTotalCount = {
|
|
34
|
+
search_settings?: Pick<services.ISearchSettings, "return_total_results_count" | "return_summary_row">;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Request Options with optional total count in search_settings
|
|
38
|
+
*/
|
|
39
|
+
export type RequestOptionsWithTotalResults = Omit<RequestOptions, "search_settings"> & SearchSettingsWithOptionalTotalCount;
|
|
40
|
+
/**
|
|
41
|
+
* Report Options with optional total count in search_settings
|
|
42
|
+
*/
|
|
43
|
+
export type ReportOptionsWithTotalResults = Omit<ReportOptions, "search_settings"> & SearchSettingsWithOptionalTotalCount;
|
|
30
44
|
export type DateConstant = "TODAY" | "YESTERDAY" | "LAST_7_DAYS" | "LAST_BUSINESS_WEEK" | "THIS_MONTH" | "LAST_MONTH" | "LAST_14_DAYS" | "LAST_30_DAYS" | "THIS_WEEK_SUN_TODAY" | "THIS_WEEK_MON_TODAY" | "LAST_WEEK_SUN_SAT" | "LAST_WEEK_MON_SUN";
|
|
31
45
|
export declare const dateConstants: DateConstant[];
|
|
32
46
|
export type SortOrder = "ASC" | "DESC";
|
|
@@ -48,7 +62,7 @@ export type ConstraintType2 = {
|
|
|
48
62
|
export type Constraint = string | ConstraintType1 | ConstraintType2;
|
|
49
63
|
export type Constraints = Constraint[] | ConstraintType2;
|
|
50
64
|
export type RequestOptions = Omit<services.ISearchGoogleAdsRequest, "customer_id" | "query" | "search_settings"> & {
|
|
51
|
-
search_settings?: Omit<services.
|
|
65
|
+
search_settings?: Omit<services.ISearchSettings, "return_total_results_count">;
|
|
52
66
|
};
|
|
53
67
|
export type MutateOptions = Omit<services.IMutateGoogleAdsRequest, "customer_id" | "mutate_operations">;
|
|
54
68
|
export type MutateOperation<T> = {
|
|
@@ -58,3 +72,4 @@ export type MutateOperation<T> = {
|
|
|
58
72
|
exempt_policy_violation_keys?: services.AdGroupCriterionOperation["exempt_policy_violation_keys"];
|
|
59
73
|
} & Partial<Omit<T, "toJSON">>;
|
|
60
74
|
export type PageToken = services.ISearchGoogleAdsResponse["next_page_token"];
|
|
75
|
+
export {};
|
package/package.json
CHANGED