@pipedream/google_ads 0.2.1 → 0.3.1

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/README.md CHANGED
@@ -18,3 +18,44 @@ and campaigns programmatically. With the API, you can automate common tasks,
18
18
  such as creating and managing campaigns, adding and removing keywords, and
19
19
  adjusting bids. You can also use the API to get information about your
20
20
  campaigns, such as campaign stats, keyword stats, and ad performance.
21
+
22
+ ## Customizing API requests with the Pipedream proxy
23
+
24
+ The Pipedream components interact with Google Ads API through Pipedream's proxy service, which handles authentication and developer token requirements.
25
+
26
+ The component accepts a standard Google Ads API request object with the following structure:
27
+
28
+ ```javascript
29
+ const googleAdsReq = {
30
+ method: "get|post|put|delete", // HTTP method
31
+ url: "/v16/...", // Google Ads API endpoint path
32
+ headers: {
33
+ "Authorization": `Bearer ${this.googleAds.$auth.oauth_access_token}`
34
+ },
35
+ data: {} // Optional request body for POST/PUT requests
36
+ }
37
+ ```
38
+
39
+ To make different API calls while using the proxy:
40
+
41
+ 1. Modify the `url` path to match your desired Google Ads API endpoint
42
+ 2. Update the `method` to match the required HTTP method
43
+ 3. Add any necessary request body data in the `data` field
44
+ 4. Include any required headers (Authorization is automatically included)
45
+
46
+ Example for a custom query:
47
+
48
+ ```javascript
49
+ const googleAdsReq = {
50
+ method: "post",
51
+ url: "/v16/customers/1234567890/googleAds:search",
52
+ headers: {
53
+ "Authorization": `Bearer ${this.googleAds.$auth.oauth_access_token}`
54
+ },
55
+ data: {
56
+ query: "SELECT campaign.id, campaign.name FROM campaign"
57
+ }
58
+ }
59
+ ```
60
+
61
+ The proxy endpoint will remain the same: `https://eolid4dq1k0t9hi.m.pipedream.net`
@@ -7,7 +7,7 @@ export default {
7
7
  key: "google_ads-add-contact-to-list-by-email",
8
8
  name: "Add Contact to Customer List by Email",
9
9
  description: "Adds a contact to a specific customer list in Google Ads. Lists typically update in 6 to 12 hours after operation. [See the documentation](https://developers.google.com/google-ads/api/docs/remarketing/audience-segments/customer-match/get-started)",
10
- version: "0.1.0",
10
+ version: "0.1.2",
11
11
  type: "action",
12
12
  props: {
13
13
  ...common.props,
@@ -1,5 +1,5 @@
1
1
  const DEFAULT_DOCS =
2
- "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList";
2
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList";
3
3
 
4
4
  export const getAdditionalFields = (docsLink = DEFAULT_DOCS) => ({
5
5
  type: "object",
@@ -57,7 +57,7 @@ const USER_LIST_CRM_BASED_PROPS = {
57
57
  type: "string",
58
58
  label: "App ID",
59
59
  description:
60
- "A string that uniquely identifies a mobile application from which the data was collected. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#CrmBasedUserListInfo) for more details.",
60
+ "A string that uniquely identifies a mobile application from which the data was collected. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#CrmBasedUserListInfo) for more details.",
61
61
  optional: true,
62
62
  },
63
63
  };
@@ -74,7 +74,7 @@ const USER_LIST_RULE_BASED_PROPS = {
74
74
  type: "object",
75
75
  label: "Flexible Rule Customer List",
76
76
  description:
77
- "Flexible rule representation of visitors with one or multiple actions. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#FlexibleRuleUserListInfo) on how to build this object. Values will be parsed as JSON where applicable.",
77
+ "Flexible rule representation of visitors with one or multiple actions. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#FlexibleRuleUserListInfo) on how to build this object. Values will be parsed as JSON where applicable.",
78
78
  optional: true,
79
79
  },
80
80
  };
@@ -84,7 +84,7 @@ const USER_LIST_LOGICAL_PROPS = {
84
84
  type: "string[]",
85
85
  label: "Rules",
86
86
  description:
87
- "Logical list rules that define this customer list. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#UserListLogicalRuleInfo) on how to build each object. Values will be parsed as JSON where applicable.",
87
+ "Logical list rules that define this customer list. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#UserListLogicalRuleInfo) on how to build each object. Values will be parsed as JSON where applicable.",
88
88
  },
89
89
  };
90
90
 
@@ -92,7 +92,7 @@ const USER_LIST_BASIC_PROPS = {
92
92
  conversionActions: {
93
93
  type: "string[]",
94
94
  label: "Conversion action(s)",
95
- description: "One or more [conversion actions](https://developers.google.com/google-ads/api/rest/reference/rest/v16/ConversionAction) to build the list with.",
95
+ description: "One or more [conversion actions](https://developers.google.com/google-ads/api/rest/reference/rest/v18/ConversionAction) to build the list with.",
96
96
  optional: true,
97
97
  options: async() => {
98
98
  const {
@@ -115,7 +115,7 @@ const USER_LIST_BASIC_PROPS = {
115
115
  remarketingActions: {
116
116
  type: "string[]",
117
117
  label: "Remarketing action(s)",
118
- description: "One or more [remarketing actions](https://developers.google.com/google-ads/api/rest/reference/rest/v16/RemarketingAction).",
118
+ description: "One or more [remarketing actions](https://developers.google.com/google-ads/api/rest/reference/rest/v18/RemarketingAction).",
119
119
  optional: true,
120
120
  options: async() => {
121
121
  const {
@@ -198,21 +198,21 @@ export const USER_LIST_TYPE_OPTIONS = [
198
198
  label: "CRM-based - a list of provided customers",
199
199
  value: USER_LIST_TYPES.CRM_BASED,
200
200
  docsLink:
201
- "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#CrmBasedUserListInfo",
201
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#CrmBasedUserListInfo",
202
202
  props: USER_LIST_CRM_BASED_PROPS,
203
203
  },
204
204
  {
205
205
  label: "Rule-Based - a customer list generated by a rule",
206
206
  value: USER_LIST_TYPES.RULE_BASED,
207
207
  docsLink:
208
- "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#RuleBasedUserListInfo",
208
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#RuleBasedUserListInfo",
209
209
  props: USER_LIST_RULE_BASED_PROPS,
210
210
  },
211
211
  {
212
212
  label: "Logical - a custom combination of customer lists",
213
213
  value: USER_LIST_TYPES.LOGICAL,
214
214
  docsLink:
215
- "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#LogicalUserListInfo",
215
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#LogicalUserListInfo",
216
216
  props: USER_LIST_LOGICAL_PROPS,
217
217
  },
218
218
  {
@@ -220,7 +220,7 @@ export const USER_LIST_TYPE_OPTIONS = [
220
220
  "Basic - a customer list targeting as a collection of conversions or remarketing actions",
221
221
  value: USER_LIST_TYPES.BASIC,
222
222
  docsLink:
223
- "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#BasicUserListInfo",
223
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#BasicUserListInfo",
224
224
  props: USER_LIST_BASIC_PROPS,
225
225
  },
226
226
  {
@@ -228,7 +228,7 @@ export const USER_LIST_TYPE_OPTIONS = [
228
228
  "Lookalike - a list composed of customers similar to those of a configurable seed",
229
229
  value: USER_LIST_TYPES.LOOKALIKE,
230
230
  docsLink:
231
- "https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#LookalikeUserListInfo",
231
+ "https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#LookalikeUserListInfo",
232
232
  props: USER_LIST_LOOKALIKE_PROPS,
233
233
  },
234
234
  ];
@@ -14,9 +14,8 @@ export default {
14
14
  ...common,
15
15
  key: "google_ads-create-customer-list",
16
16
  name: "Create Customer List",
17
- description:
18
- "Create a new customer list in Google Ads. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList)",
19
- version: "0.0.1",
17
+ description: "Create a new customer list in Google Ads. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList)",
18
+ version: "0.0.3",
20
19
  type: "action",
21
20
  props: {
22
21
  ...common.props,
@@ -34,8 +33,7 @@ export default {
34
33
  listType: {
35
34
  type: "string",
36
35
  label: "List Type",
37
- description:
38
- "The [type of customer list](https://developers.google.com/google-ads/api/rest/reference/rest/v16/UserList#CrmBasedUserListInfo) to create.",
36
+ description: "The [type of customer list](https://developers.google.com/google-ads/api/rest/reference/rest/v18/UserList#CrmBasedUserListInfo) to create.",
39
37
  options: USER_LIST_TYPE_OPTIONS.map(({
40
38
  label, value,
41
39
  }) => ({
@@ -95,6 +93,10 @@ export default {
95
93
  additionalProps() {
96
94
  const { listType } = this;
97
95
 
96
+ if (!listType) {
97
+ return {};
98
+ }
99
+
98
100
  const option = USER_LIST_TYPE_OPTIONS.find(
99
101
  ({ value }) => value === listType,
100
102
  );
@@ -0,0 +1,55 @@
1
+ export const DATE_RANGE_OPTIONS = [
2
+ {
3
+ value: "CUSTOM",
4
+ label: "Specify a custom date range",
5
+ },
6
+ {
7
+ value: "TODAY",
8
+ label: "Today only",
9
+ },
10
+ {
11
+ value: "YESTERDAY",
12
+ label: "Yesterday only",
13
+ },
14
+ {
15
+ value: "LAST_7_DAYS",
16
+ label: "The last 7 days not including today",
17
+ },
18
+ {
19
+ value: "LAST_BUSINESS_WEEK",
20
+ label:
21
+ "The 5 day business week, Monday through Friday, of the previous business week",
22
+ },
23
+ {
24
+ value: "THIS_MONTH",
25
+ label: "All days in the current month",
26
+ },
27
+ {
28
+ value: "LAST_MONTH",
29
+ label: "All days in the previous month",
30
+ },
31
+ {
32
+ value: "LAST_14_DAYS",
33
+ label: "The last 14 days not including today",
34
+ },
35
+ {
36
+ value: "LAST_30_DAYS",
37
+ label: "The last 30 days not including today",
38
+ },
39
+ {
40
+ value: "THIS_WEEK_SUN_TODAY",
41
+ label: "The period between the previous Sunday and the current day",
42
+ },
43
+ {
44
+ value: "THIS_WEEK_MON_TODAY",
45
+ label: "The period between the previous Monday and the current day",
46
+ },
47
+ {
48
+ value: "LAST_WEEK_SUN_SAT",
49
+ label: "The 7-day period starting with the previous Sunday",
50
+ },
51
+ {
52
+ value: "LAST_WEEK_MON_SUN",
53
+ label: "The 7-day period starting with the previous Monday",
54
+ },
55
+ ];
@@ -4,6 +4,8 @@ import { ad } from "../../common/resources/ad.mjs";
4
4
  import { campaign } from "../../common/resources/campaign.mjs";
5
5
  import { customer } from "../../common/resources/customer.mjs";
6
6
  import { ConfigurationError } from "@pipedream/platform";
7
+ import { DATE_RANGE_OPTIONS } from "./common-constants.mjs";
8
+ import { checkPrefix } from "../../common/utils.mjs";
7
9
 
8
10
  const RESOURCES = [
9
11
  adGroup,
@@ -16,8 +18,8 @@ export default {
16
18
  ...common,
17
19
  key: "google_ads-create-report",
18
20
  name: "Create Report",
19
- description: "Generates a report from your Google Ads data. [See the documentation](https://developers.google.com/google-ads/api/fields/v16/overview)",
20
- version: "0.0.2",
21
+ description: "Generates a report from your Google Ads data. [See the documentation](https://developers.google.com/google-ads/api/fields/v18/overview)",
22
+ version: "0.1.1",
21
23
  type: "action",
22
24
  props: {
23
25
  ...common.props,
@@ -41,12 +43,62 @@ export default {
41
43
  docsAlert: {
42
44
  type: "alert",
43
45
  alertType: "info",
44
- content: `[See the documentation](https://developers.google.com/google-ads/api/fields/v16/${value}) for more information on available fields, segments and metrics.`,
46
+ content: `[See the documentation](https://developers.google.com/google-ads/api/fields/v18/${value}) for more information on available fields, segments and metrics.`,
45
47
  },
48
+ objectFilter: {
49
+ type: "string[]",
50
+ label: `Filter by ${label}s`,
51
+ description: `Select the ${label}s to generate a report for (or leave blank for all ${label}s)`,
52
+ optional: true,
53
+ useQuery: true,
54
+ options: async ({
55
+ query, prevContext: { nextPageToken: pageToken },
56
+ }) => {
57
+ const {
58
+ accountId, customerClientId, resource,
59
+ } = this;
60
+ const {
61
+ results, nextPageToken,
62
+ } = await this.googleAds.listResources({
63
+ accountId,
64
+ customerClientId,
65
+ resource,
66
+ query,
67
+ pageToken,
68
+ });
69
+ const options = results?.map?.((item) => this.getResourceOption(item, resource));
70
+ return {
71
+ options,
72
+ context: {
73
+ nextPageToken,
74
+ },
75
+ };
76
+ },
77
+ },
78
+ dateRange: {
79
+ type: "string",
80
+ label: "Date Range",
81
+ description: "Select a date range for the report",
82
+ options: DATE_RANGE_OPTIONS,
83
+ optional: true,
84
+ reloadProps: true,
85
+ },
86
+ ...(this.dateRange === "CUSTOM" && {
87
+ startDate: {
88
+ type: "string",
89
+ label: "Start Date",
90
+ description: "The start date, in `YYYY-MM-DD` format",
91
+ },
92
+ endDate: {
93
+ type: "string",
94
+ label: "End Date",
95
+ description: "The end date, in `YYYY-MM-DD` format",
96
+ },
97
+ }),
46
98
  fields: {
47
99
  type: "string[]",
48
100
  label: "Fields",
49
- description: `${label} data fields to obtain`,
101
+ description: "Select any fields you want to include in your report.",
50
102
  options: resource.fields,
51
103
  optional: true,
52
104
  reloadProps: true,
@@ -54,15 +106,18 @@ export default {
54
106
  segments: {
55
107
  type: "string[]",
56
108
  label: "Segments",
57
- description: `${label} segments to obtain [more info on the documentation](https://developers.google.com/google-ads/api/fields/v16/segments)`,
109
+ description: "Select any segments you want to include in your report. See the documentation [here](https://developers.google.com/google-ads/api/fields/v18/segments)",
58
110
  options: resource.segments,
111
+ default: [
112
+ "segments.date",
113
+ ],
59
114
  optional: true,
60
115
  reloadProps: true,
61
116
  },
62
117
  metrics: {
63
118
  type: "string[]",
64
119
  label: "Metrics",
65
- description: `${label} metrics to obtain [more info on the documentation](https://developers.google.com/google-ads/api/fields/v16/metrics)`,
120
+ description: "Select any metrics you want to include in your report. See the documentation [here](https://developers.google.com/google-ads/api/fields/v18/metrics)",
66
121
  options: resource.metrics,
67
122
  optional: true,
68
123
  reloadProps: true,
@@ -114,17 +169,48 @@ export default {
114
169
  };
115
170
  },
116
171
  methods: {
172
+ getResourceOption(item, resource) {
173
+ let label, value;
174
+ switch (resource) {
175
+ case "campaign":
176
+ label = item.campaign.name;
177
+ value = item.campaign.id;
178
+ break;
179
+
180
+ case "customer":
181
+ label = item.customer.descriptiveName;
182
+ value = item.customer.id;
183
+ break;
184
+
185
+ case "ad_group":
186
+ label = item.adGroup.name;
187
+ value = item.adGroup.id;
188
+ break;
189
+
190
+ case "ad_group_ad":
191
+ label = item.adGroupAd.ad.name;
192
+ value = item.adGroupAd.ad.id;
193
+ break;
194
+ }
195
+
196
+ return {
197
+ label,
198
+ value,
199
+ };
200
+ },
117
201
  buildQuery() {
118
202
  const {
119
- resource, limit, orderBy, direction,
203
+ resource, fields, segments, metrics, limit, orderBy, direction, objectFilter, dateRange,
120
204
  } = this;
121
- const fields = this.fields?.map((i) => `${resource}.${i}`) ?? [];
122
- const segments = this.segments?.map((i) => `segments.${i}`) ?? [];
123
- const metrics = this.metrics?.map((i) => `metrics.${i}`) ?? [];
205
+
206
+ const filteredSegments = dateRange
207
+ ? segments
208
+ : segments?.filter((i) => i !== "segments.date");
209
+
124
210
  const selection = [
125
- ...fields,
126
- ...segments,
127
- ...metrics,
211
+ ...checkPrefix(fields, resource),
212
+ ...checkPrefix(filteredSegments, "segments"),
213
+ ...checkPrefix(metrics, "metrics"),
128
214
  ];
129
215
 
130
216
  if (!selection.length) {
@@ -132,8 +218,22 @@ export default {
132
218
  }
133
219
 
134
220
  let query = `SELECT ${selection.join(", ")} FROM ${resource}`;
221
+ if (objectFilter) {
222
+ query += ` WHERE ${resource === "ad_group_ad"
223
+ ? "ad_group_ad.ad"
224
+ : resource}.id IN (${objectFilter.join?.(", ") ?? objectFilter})`;
225
+ }
226
+ if (dateRange) {
227
+ const dateClause = dateRange === "CUSTOM"
228
+ ? `BETWEEN '${this.startDate}' AND '${this.endDate}'`
229
+ : `DURING ${dateRange}`;
230
+ query += ` ${objectFilter
231
+ ? "AND"
232
+ : "WHERE"} segments.date ${dateClause}`;
233
+ }
234
+
135
235
  if (orderBy && direction) {
136
- query += ` ORDER BY ${`${resource}.${orderBy}`} ${direction}`;
236
+ query += ` ORDER BY ${orderBy} ${direction}`;
137
237
  }
138
238
  if (limit) {
139
239
  query += ` LIMIT ${limit}`;
@@ -155,7 +255,7 @@ export default {
155
255
 
156
256
  const { length } = results;
157
257
 
158
- $.export("$summary", `Sucessfully obtained ${length} result${length === 1
258
+ $.export("$summary", `Successfully obtained ${length} result${length === 1
159
259
  ? ""
160
260
  : "s"}`);
161
261
  return {
@@ -7,8 +7,8 @@ export default {
7
7
  ...common,
8
8
  key: "google_ads-send-offline-conversion",
9
9
  name: "Send Offline Conversion",
10
- description: "Send an event from to Google Ads to track offline conversions. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v16/ConversionAction)",
11
- version: "0.0.1",
10
+ description: "Send an event from to Google Ads to track offline conversions. [See the documentation](https://developers.google.com/google-ads/api/rest/reference/rest/v18/ConversionAction)",
11
+ version: "0.0.3",
12
12
  type: "action",
13
13
  props: {
14
14
  ...common.props,
@@ -20,10 +20,10 @@ export default {
20
20
  type: {
21
21
  type: "string",
22
22
  label: "Type",
23
- description: "[The type](https://developers.google.com/google-ads/api/rest/reference/rest/v16/ConversionAction#ConversionActionType) of the conversion action.",
23
+ description: "[The type](https://developers.google.com/google-ads/api/rest/reference/rest/v18/ConversionAction#ConversionActionType) of the conversion action.",
24
24
  options: CONVERSION_TYPE_OPTIONS,
25
25
  },
26
- additionalFields: getAdditionalFields("https://developers.google.com/google-ads/api/rest/reference/rest/v16/ConversionAction"),
26
+ additionalFields: getAdditionalFields("https://developers.google.com/google-ads/api/rest/reference/rest/v18/ConversionAction"),
27
27
  },
28
28
  async run({ $ }) {
29
29
  const {
@@ -20,6 +20,7 @@ function listUserLists() {
20
20
  const fields = [
21
21
  "id",
22
22
  "name",
23
+ "type",
23
24
  ].map((s) => `user_list.${s}`).join(", ");
24
25
 
25
26
  return `SELECT ${fields} FROM user_list`;
@@ -73,7 +74,7 @@ function listCampaigns({
73
74
  const defaultFields = [
74
75
  "id",
75
76
  "name",
76
- ];
77
+ ].map((s) => `campaign.${s}`);
77
78
  if (typeof fields === "string") {
78
79
  fields = fields.split(",").map((s) => s.trim());
79
80
  }
@@ -91,7 +92,22 @@ function listCampaigns({
91
92
  ? ` WHERE ${savedIds.map((id) => `campaign.id != ${id}`).join(" AND ")}`
92
93
  : "";
93
94
 
94
- return `SELECT ${fields.map((s) => `campaign.${s}`).join(", ")} FROM campaign${filter}`;
95
+ return `SELECT ${fields.join(", ")} FROM campaign${filter}`;
96
+ }
97
+
98
+ function listResources(resource, query) {
99
+ const name = resource === "customer"
100
+ ? "descriptive_name"
101
+ : "name";
102
+ const fieldResource = resource === "ad_group_ad"
103
+ ? "ad_group_ad.ad"
104
+ : resource;
105
+
106
+ let result = `SELECT ${fieldResource}.id, ${fieldResource}.${name} FROM ${resource}`;
107
+ if (query) {
108
+ result += ` WHERE ${fieldResource}.${name} LIKE '%${query}%'`;
109
+ }
110
+ return result;
95
111
  }
96
112
 
97
113
  export const QUERIES = {
@@ -101,5 +117,6 @@ export const QUERIES = {
101
117
  listLeadForms,
102
118
  listLeadFormSubmissionData,
103
119
  listRemarketingActions,
120
+ listResources,
104
121
  listUserLists,
105
122
  };
@@ -1,3 +1,5 @@
1
+ import { getOption } from "../utils.mjs";
2
+
1
3
  const fields = [
2
4
  "action_items",
3
5
  "ad.added_by_google_ads",
@@ -213,7 +215,7 @@ const fields = [
213
215
  "primary_status_reasons",
214
216
  "resource_name",
215
217
  "status",
216
- ];
218
+ ].map((f) => getOption(f, "ad_group_ad"));
217
219
 
218
220
  const segments = [
219
221
  "ad_destination_type",
@@ -226,20 +228,14 @@ const segments = [
226
228
  "conversion_lag_bucket",
227
229
  "conversion_or_adjustment_lag_bucket",
228
230
  "date",
229
- "day_of_week",
230
231
  "device",
231
232
  "external_conversion_source",
232
233
  "keyword.ad_group_criterion",
233
234
  "keyword.info.match_type",
234
235
  "keyword.info.text",
235
- "month",
236
- "month_of_year",
237
236
  "new_versus_returning_customers",
238
- "quarter",
239
237
  "slot",
240
- "week",
241
- "year",
242
- ];
238
+ ].map((f) => getOption(f, "segments"));
243
239
 
244
240
  const metrics = [
245
241
  "absolute_top_impression_percentage",
@@ -319,7 +315,7 @@ const metrics = [
319
315
  "video_view_rate",
320
316
  "video_views",
321
317
  "view_through_conversions",
322
- ];
318
+ ].map((f) => getOption(f, "metrics"));
323
319
 
324
320
  const resourceOption = {
325
321
  label: "Ad",
@@ -1,3 +1,5 @@
1
+ import { getOption } from "../utils.mjs";
2
+
1
3
  const fields = [
2
4
  "ad_rotation_mode",
3
5
  "audience_setting.use_audience_grouped",
@@ -31,7 +33,7 @@ const fields = [
31
33
  "tracking_url_template",
32
34
  "type",
33
35
  "url_custom_parameters",
34
- ];
36
+ ].map((f) => getOption(f, "ad_group"));
35
37
 
36
38
  const segments = [
37
39
  "ad_destination_type",
@@ -47,18 +49,12 @@ const segments = [
47
49
  "conversion_lag_bucket",
48
50
  "conversion_or_adjustment_lag_bucket",
49
51
  "date",
50
- "day_of_week",
51
52
  "device",
52
53
  "external_conversion_source",
53
54
  "hour",
54
- "month",
55
- "month_of_year",
56
55
  "new_versus_returning_customers",
57
- "quarter",
58
56
  "slot",
59
- "week",
60
- "year",
61
- ];
57
+ ].map((f) => getOption(f, "segments"));
62
58
 
63
59
  const metrics = [
64
60
  "absolute_top_impression_percentage",
@@ -159,7 +155,7 @@ const metrics = [
159
155
  "video_view_rate",
160
156
  "video_views",
161
157
  "view_through_conversions",
162
- ];
158
+ ].map((f) => getOption(f, "metrics"));
163
159
 
164
160
  const resourceOption = {
165
161
  label: "Ad Group",
@@ -1,3 +1,5 @@
1
+ import { getOption } from "../utils.mjs";
2
+
1
3
  const fields = [
2
4
  "accessible_bidding_strategy",
3
5
  "ad_serving_optimization_status",
@@ -93,7 +95,7 @@ const fields = [
93
95
  "vanity_pharma.vanity_pharma_display_url_mode",
94
96
  "vanity_pharma.vanity_pharma_text",
95
97
  "video_brand_safety_suitability",
96
- ];
98
+ ].map((f) => getOption(f, "campaign"));
97
99
 
98
100
  const segments = [
99
101
  "ad_destination_type",
@@ -111,14 +113,10 @@ const segments = [
111
113
  "conversion_or_adjustment_lag_bucket",
112
114
  "conversion_value_rule_primary_dimension",
113
115
  "date",
114
- "day_of_week",
115
116
  "device",
116
117
  "external_conversion_source",
117
118
  "hour",
118
- "month",
119
- "month_of_year",
120
119
  "new_versus_returning_customers",
121
- "quarter",
122
120
  "recommendation_type",
123
121
  "sk_ad_network_ad_event_type",
124
122
  "sk_ad_network_attribution_credit",
@@ -130,9 +128,7 @@ const segments = [
130
128
  "sk_ad_network_source_type",
131
129
  "sk_ad_network_user_type",
132
130
  "slot",
133
- "week",
134
- "year",
135
- ];
131
+ ].map((f) => getOption(f, "segments"));
136
132
 
137
133
  const metrics = [
138
134
  "absolute_top_impression_percentage",
@@ -274,7 +270,7 @@ const metrics = [
274
270
  "view_through_conversions_from_location_asset_other_engagement",
275
271
  "view_through_conversions_from_location_asset_store_visits",
276
272
  "view_through_conversions_from_location_asset_website",
277
- ];
273
+ ].map((f) => getOption(f, "metrics"));
278
274
 
279
275
  const resourceOption = {
280
276
  label: "Campaign",
@@ -1,3 +1,5 @@
1
+ import { getOption } from "../utils.mjs";
2
+
1
3
  const fields = [
2
4
  "auto_tagging_enabled",
3
5
  "call_reporting_setting.call_conversion_action",
@@ -32,7 +34,7 @@ const fields = [
32
34
  "time_zone",
33
35
  "tracking_url_template",
34
36
  "video_brand_safety_suitability",
35
- ];
37
+ ].map((f) => getOption(f, "customer"));
36
38
 
37
39
  const segments = [
38
40
  "ad_network_type",
@@ -46,14 +48,10 @@ const segments = [
46
48
  "conversion_or_adjustment_lag_bucket",
47
49
  "conversion_value_rule_primary_dimension",
48
50
  "date",
49
- "day_of_week",
50
51
  "device",
51
52
  "external_conversion_source",
52
53
  "hour",
53
- "month",
54
- "month_of_year",
55
54
  "new_versus_returning_customers",
56
- "quarter",
57
55
  "recommendation_type",
58
56
  "sk_ad_network_ad_event_type",
59
57
  "sk_ad_network_attribution_credit",
@@ -65,9 +63,7 @@ const segments = [
65
63
  "sk_ad_network_source_type",
66
64
  "sk_ad_network_user_type",
67
65
  "slot",
68
- "week",
69
- "year",
70
- ];
66
+ ].map((f) => getOption(f, "segments"));
71
67
 
72
68
  const metrics = [
73
69
  "absolute_top_impression_percentage",
@@ -166,7 +162,7 @@ const metrics = [
166
162
  "view_through_conversions_from_location_asset_other_engagement",
167
163
  "view_through_conversions_from_location_asset_store_visits",
168
164
  "view_through_conversions_from_location_asset_website",
169
- ];
165
+ ].map((f) => getOption(f, "metrics"));
170
166
 
171
167
  const resourceOption = {
172
168
  label: "Customer",
package/common/utils.mjs CHANGED
@@ -30,3 +30,19 @@ export function parseStringObject(value = "{}") {
30
30
  **${err.toString()}**`);
31
31
  }
32
32
  }
33
+
34
+ export function getOption(label, prefix) {
35
+ return {
36
+ label,
37
+ value: `${prefix}.${label}`,
38
+ };
39
+ }
40
+
41
+ export function checkPrefix(value, prefix) {
42
+ const checkStr = (s) => s && (s?.startsWith?.(prefix)
43
+ ? s
44
+ : `${prefix}.${s}`);
45
+ return Array.isArray(value ?? [])
46
+ ? (value ?? []).map(checkStr)
47
+ : checkStr(value);
48
+ }
@@ -21,7 +21,7 @@ export default {
21
21
  accountId,
22
22
  customerClientId,
23
23
  });
24
- return response?.map(({
24
+ return response?.filter(({ userList: { type } }) => type === "CRM_BASED")?.map(({
25
25
  userList: {
26
26
  id, name,
27
27
  },
@@ -34,7 +34,7 @@ export default {
34
34
  accountId: {
35
35
  type: "string",
36
36
  label: "Use Google Ads As",
37
- description: "Select an account from the list of [customers directly accessible by the authenticated user](https://developers.google.com/google-ads/api/rest/reference/rest/v16/customers/listAccessibleCustomers). This is usually a **Manager Account**, used as `login-customer-id`",
37
+ description: "Select an account from the list of [customers directly accessible by the authenticated user](https://developers.google.com/google-ads/api/rest/reference/rest/v18/customers/listAccessibleCustomers). This is usually a **Manager Account**, used as `login-customer-id`",
38
38
  async options() {
39
39
  const response = await this.listAccessibleCustomers();
40
40
  return response?.map(((resourceName) => ({
@@ -46,7 +46,7 @@ export default {
46
46
  customerClientId: {
47
47
  type: "string",
48
48
  label: "Managed Account",
49
- description: "Select a [customer client](https://developers.google.com/google-ads/api/reference/rpc/v16/CustomerClient) from the list of [customers linked to the selected account](https://developers.google.com/google-ads/api/docs/account-management/get-account-hierarchy).",
49
+ description: "Select a [customer client](https://developers.google.com/google-ads/api/reference/rpc/v18/CustomerClient) from the list of [customers linked to the selected account](https://developers.google.com/google-ads/api/docs/account-management/get-account-hierarchy).",
50
50
  useQuery: true,
51
51
  optional: true,
52
52
  async options({
@@ -71,7 +71,7 @@ export default {
71
71
  leadFormId: {
72
72
  type: "string",
73
73
  label: "Lead Form ID",
74
- description: "Select a [Lead Form](https://developers.google.com/google-ads/api/rest/reference/rest/v16/Asset#LeadFormAsset) to watch for new entries.",
74
+ description: "Select a [Lead Form](https://developers.google.com/google-ads/api/rest/reference/rest/v18/Asset#LeadFormAsset) to watch for new entries.",
75
75
  async options({
76
76
  accountId, customerClientId,
77
77
  }) {
@@ -121,83 +121,102 @@ export default {
121
121
  }) {
122
122
  console.log("Executing query: ", query);
123
123
  const response = await this._makeRequest({
124
- path: "/v16/customers/{customerClientId}/googleAds:search",
124
+ path: "/v18/customers/{customerClientId}/googleAds:search",
125
125
  method: "post",
126
126
  data: {
127
127
  query,
128
128
  },
129
129
  ...args,
130
130
  });
131
- return response.results;
131
+ return response;
132
132
  },
133
133
  async listAccessibleCustomers() {
134
134
  const response = await this._makeRequest({
135
- path: "/v16/customers:listAccessibleCustomers",
135
+ path: "/v18/customers:listAccessibleCustomers",
136
136
  });
137
137
  return response.resourceNames;
138
138
  },
139
139
  async listCustomerClients({
140
140
  query, ...args
141
141
  }) {
142
- return this.search({
142
+ const { results } = await this.search({
143
143
  query: QUERIES.listCustomerClients(query),
144
144
  ...args,
145
145
  });
146
+ return results;
146
147
  },
147
148
  async createReport(args) {
148
- return this.search(args);
149
+ const { results } = await this.search(args);
150
+ return results;
149
151
  },
150
152
  async createUserList(args) {
151
153
  const response = await this._makeRequest({
152
- path: "v16/customers/{customerClientId}/userLists:mutate",
154
+ path: "v18/customers/{customerClientId}/userLists:mutate",
153
155
  method: "post",
154
156
  ...args,
155
157
  });
156
158
  return response;
157
159
  },
158
160
  async listUserLists(args) {
159
- return this.search({
161
+ const { results } = await this.search({
160
162
  query: QUERIES.listUserLists(),
161
163
  ...args,
162
164
  });
165
+ return results;
163
166
  },
164
167
  async listConversionActions(args) {
165
- return this.search({
168
+ const { results } = await this.search({
166
169
  query: QUERIES.listConversionActions(),
167
170
  ...args,
168
171
  });
172
+ return results;
169
173
  },
170
174
  async listRemarketingActions(args) {
171
- return this.search({
175
+ const { results } = await this.search({
172
176
  query: QUERIES.listRemarketingActions(),
173
177
  ...args,
174
178
  });
179
+ return results;
175
180
  },
176
181
  async listLeadForms(args) {
177
- return this.search({
182
+ const { results } = await this.search({
178
183
  query: QUERIES.listLeadForms(),
179
184
  ...args,
180
185
  });
186
+ return results;
181
187
  },
182
188
  async listCampaigns({
183
189
  query, ...args
184
190
  }) {
185
- return this.search({
191
+ const { results } = await this.search({
186
192
  query: QUERIES.listCampaigns(query),
187
193
  ...args,
188
194
  });
195
+ return results;
196
+ },
197
+ async listResources({
198
+ resource, query, pageToken, ...args
199
+ }) {
200
+ return this.search({
201
+ query: QUERIES.listResources(resource, query),
202
+ params: {
203
+ pageToken,
204
+ },
205
+ ...args,
206
+ });
189
207
  },
190
208
  async getLeadFormData({
191
209
  leadFormId, ...args
192
210
  }) {
193
- return this.search({
211
+ const { results } = await this.search({
194
212
  query: QUERIES.listLeadFormSubmissionData(leadFormId),
195
213
  ...args,
196
214
  });
215
+ return results;
197
216
  },
198
217
  async createConversionAction(args) {
199
218
  const response = await this._makeRequest({
200
- path: "v16/customers/{customerClientId}/conversionActions:mutate",
219
+ path: "v18/customers/{customerClientId}/conversionActions:mutate",
201
220
  method: "post",
202
221
  ...args,
203
222
  });
@@ -208,14 +227,14 @@ export default {
208
227
  }) {
209
228
  return this._makeRequest({
210
229
  method: "POST",
211
- path: `/v16/${path}:addOperations`,
230
+ path: `/v18/${path}:addOperations`,
212
231
  ...opts,
213
232
  });
214
233
  },
215
234
  async createOfflineUserDataJob(opts = {}) {
216
235
  return this._makeRequest({
217
236
  method: "POST",
218
- path: "/v16/customers/{customerClientId}/offlineUserDataJobs:create",
237
+ path: "/v18/customers/{customerClientId}/offlineUserDataJobs:create",
219
238
  ...opts,
220
239
  });
221
240
  },
@@ -224,7 +243,7 @@ export default {
224
243
  }) {
225
244
  return this._makeRequest({
226
245
  method: "POST",
227
- path: `/v16/${path}:run`,
246
+ path: `/v18/${path}:run`,
228
247
  ...args,
229
248
  });
230
249
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/google_ads",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "Pipedream Google Ads Components",
5
5
  "main": "google_ads.app.mjs",
6
6
  "keywords": [
@@ -13,7 +13,7 @@
13
13
  "access": "public"
14
14
  },
15
15
  "dependencies": {
16
- "@pipedream/platform": "^1.6.5",
16
+ "@pipedream/platform": "^3.0.3",
17
17
  "crypto": "^1.0.1"
18
18
  }
19
19
  }
@@ -6,8 +6,8 @@ export default {
6
6
  ...common,
7
7
  key: "google_ads-new-campaign-created",
8
8
  name: "New Campaign Created",
9
- description: "Emit new event when a new campaign is created. [See the documentation](https://developers.google.com/google-ads/api/fields/v16/campaign)",
10
- version: "0.0.1",
9
+ description: "Emit new event when a new campaign is created. [See the documentation](https://developers.google.com/google-ads/api/fields/v18/campaign)",
10
+ version: "0.0.3",
11
11
  type: "source",
12
12
  dedupe: "unique",
13
13
  sampleEmit,
@@ -15,17 +15,16 @@ export default {
15
15
  ...common.props,
16
16
  customerClientId: {
17
17
  ...common.props.customerClientId,
18
- optional: false,
19
18
  },
20
19
  fields: {
21
20
  type: "string[]",
22
21
  label: "Extra Fields",
23
- description: "Additional [campaign fields](https://developers.google.com/google-ads/api/fields/v16/campaign) to emit in the event",
22
+ description: "Additional [campaign fields](https://developers.google.com/google-ads/api/fields/v18/campaign) to emit in the event",
24
23
  options: campaign.fields,
25
24
  optional: true,
26
25
  default: [
27
- "id",
28
- "name",
26
+ "campaign.id",
27
+ "campaign.name",
29
28
  ],
30
29
  },
31
30
  },
@@ -7,8 +7,8 @@ export default {
7
7
  ...common,
8
8
  key: "google_ads-new-lead-form-entry",
9
9
  name: "New Lead Form Entry",
10
- description: "Emit new event for new leads on a Lead Form. [See the documentation](https://developers.google.com/google-ads/api/fields/v16/lead_form_submission_data)",
11
- version: "0.0.1",
10
+ description: "Emit new event for new leads on a Lead Form. [See the documentation](https://developers.google.com/google-ads/api/fields/v18/lead_form_submission_data)",
11
+ version: "0.0.3",
12
12
  type: "source",
13
13
  dedupe: "unique",
14
14
  sampleEmit,
@@ -29,7 +29,7 @@ export default {
29
29
  docsAlert: {
30
30
  type: "alert",
31
31
  alertType: "info",
32
- content: "If needed, see Google's documentation on [submission fields](https://developers.google.com/google-ads/api/reference/rpc/v16/LeadFormSubmissionField) and [custom submission fields](https://developers.google.com/google-ads/api/reference/rpc/v16/CustomLeadFormSubmissionField).",
32
+ content: "If needed, see Google's documentation on [submission fields](https://developers.google.com/google-ads/api/reference/rpc/v18/LeadFormSubmissionField) and [custom submission fields](https://developers.google.com/google-ads/api/reference/rpc/v18/CustomLeadFormSubmissionField).",
33
33
  },
34
34
  },
35
35
  methods: {