Skip to content

Commit f4c36fb

Browse files
committed
Fix minor CodeRabbit suggestions
1 parent 173277a commit f4c36fb

File tree

6 files changed

+53
-55
lines changed

6 files changed

+53
-55
lines changed
Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Google Search Console – Site Performance (Analytics) Action
1+
# Google Search Console – Site Performance (Analytics) Action
22

33
This action queries **search performance data** for a verified website using the [Google Search Console API](https://developers.google.com/webmaster-tools/search-console-api-original/v3/searchanalytics/query). It allows you to extract insights like:
44

@@ -9,15 +9,15 @@ This action queries **search performance data** for a verified website using the
99

1010
---
1111

12-
## Use Cases
12+
## Use Cases
1313

1414
- Automate SEO reporting
1515
- Analyze organic search trends
1616
- Filter and break down traffic by dimensions (e.g. query, device, country)
1717

1818
---
1919

20-
## Internals
20+
## Internals
2121

2222
- Supports all relevant props from the [Search Analytics Query API](https://developers.google.com/webmaster-tools/search-console-api-original/v3/searchanalytics/query)
2323
- Trims and validates all input props
@@ -28,83 +28,81 @@ This action queries **search performance data** for a verified website using the
2828

2929
---
3030

31-
## Auth
31+
## Auth
3232

33-
Requires OAuth 2.0 with the following scope: https://www.googleapis.com/auth/webmasters.readonly
33+
Requires OAuth 2.0 with the following scope: `https://www.googleapis.com/auth/webmasters.readonly`
3434

3535

36-
## Endpoint
37-
https://searchconsole.googleapis.com/webmasters/v3/sites/{siteUrl}/searchAnalytics/query
36+
## Endpoint
37+
`https://searchconsole.googleapis.com/webmasters/v3/sites/{siteUrl}/searchAnalytics/query`
3838

3939

4040
## 📦 Example Request Payload
4141

4242

4343

44-
44+
```json
4545
{
46-
// The site you want to query data for.
47-
// Must be verified in your Google Search Console account.
48-
"siteUrl": "https://falc1.com/soda_can",
4946

50-
// The start date of the reporting period (inclusive), in YYYY-MM-DD format.
47+
"siteUrl": "https://falc1.com/page",
48+
5149
"startDate": "2025-12-22",
5250

53-
// The end date of the reporting period (inclusive), in YYYY-MM-DD format.
5451
"endDate": "2025-12-31",
5552

56-
// The dimensions you want to break down the data by.
57-
// Valid values: "query", "page", "country", "device", "searchAppearance", "date".
58-
// Order matters — it affects how rows are grouped in the response.
5953
"dimensions": ["query", "page", "country", "device"],
6054

61-
// The type of search data to include.
62-
// Valid values: "web", "image", "video", "news", "googleNews", "discover"
6355
"searchType": "web",
6456

65-
// Maximum number of rows to return (1–25,000)
6657
"rowLimit": 10,
6758

68-
// Optional: Skips the first N rows — used for pagination.
6959
"startRow": 0,
7060

71-
// Optional: How to group data.
72-
// "auto" = Google's default grouping.
73-
// "byPage" = Group by page (useful for getting per-page breakdowns).
7461
"aggregationType": "auto",
7562

76-
// Optional: Data freshness filter.
77-
// "final" = Only finalized data (more accurate).
78-
// "all" = Includes fresh but possibly incomplete data.
7963
"dataState": "final",
8064

81-
// Optional filter group(s) to restrict which rows are returned.
82-
// Each group applies logical AND/OR across its filters.
8365
"dimensionFilterGroups": [
8466
{
85-
// Logical grouping operator for the filters inside this group.
86-
// "and" = all filters must match
87-
// "or" = any filter can match
67+
8868
"groupType": "and",
8969

90-
// List of individual filters to apply within the group
9170
"filters": [
9271
{
93-
// Which dimension to filter by (must match a dimension in your request)
72+
9473
"dimension": "query",
9574

96-
// Filter operator — e.g., "equals", "contains", "notEquals", etc.
9775
"operator": "contains",
9876

99-
// Value to match against
10077
"expression": "example"
10178
},
10279
{
10380
"dimension": "country",
81+
10482
"operator": "equals",
83+
10584
"expression": "USA"
10685
}
10786
]
10887
}
10988
]
110-
}
89+
}
90+
```
91+
92+
### Field Descriptions
93+
94+
**siteUrl**: The site you want to query data for. Must be verified in your Google Search Console account.
95+
**startDate**: The start date of the reporting period (inclusive), in YYYY-MM-DD format.
96+
**endDate**: The end date of the reporting period (inclusive), in YYYY-MM-DD format.
97+
**dimensions**: The dimensions you want to break down the data by. Valid values: "query", "page", "country", "device", "searchAppearance", "date". Order matters — it affects how rows are grouped in the response.
98+
**searchType**: The type of search data to include. Valid values: "web", "image", "video", "news", "googleNews", "discover"
99+
**rowLimit**: Maximum number of rows to return (1–25,000)
100+
**startRow**: Optional: Skips the first N rows — used for pagination.
101+
**aggregationType**: Optional: How to group data. "auto" = Google's default grouping. "byPage" = Group by page (useful for getting per-page breakdowns).
102+
**dataState**: Optional: Data freshness filter. "final" = Only finalized data (more accurate). "all" = Includes fresh but possibly incomplete data.
103+
**dimensionFilterGroups**: Optional filter group(s) to restrict which rows are returned. Each group applies logical AND/OR across its filters.
104+
**groupType**: Logical grouping operator for the filters inside this group. "and" = all filters must match, "or" = any filter can match
105+
**filters**: List of individual filters to apply within the group
106+
**dimension**: Which dimension to filter by (must match a dimension in your request)
107+
**operator**: Filter operator — e.g., "equals", "contains", "notEquals", etc.
108+
**expression**: Value to match against

components/google_search_console/actions/retrieve-site-performance-data/retrieve-site-performance-data.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,12 @@ export default {
180180
// Identify if the error was thrown by internal validation or by the API call
181181
const thrower = this.gsConsole.checkWhoThrewError(error);
182182

183-
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("*!*"));
183+
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("\n- "));
184184

185185
};
186186

187187
// Output summary and any warnings for the user
188-
$.export("$summary", ` Fetched ${response.rows?.length || 0} rows of data. ` + warnings.join("*!*"));
188+
$.export("$summary", ` Fetched ${response.rows?.length || 0} rows of data. ` + warnings.join("\n- "));
189189
return response;
190190
},
191191
};

components/google_search_console/actions/submit-url-for-indexing/submit-url-for-indexing.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { axios } from "@pipedream/platform";
77
import gsConsole from "../../google_search_console.app.mjs";
8-
import {trimIfString } from "../../common/utils.mjs"
8+
import { trimIfString } from "../../common/utils.mjs"
99

1010

1111

@@ -57,7 +57,7 @@ export default {
5757
url: "https://indexing.googleapis.com/v3/urlNotifications:publish",
5858
headers: {
5959

60-
Authorization: `Bearer ${this.gsConsole.$auth.oauth_access_token}`,
60+
Authorization: `Bearer ${this.gsConsole.$auth.oauth_access_token}`,
6161
"Content-Type": "application/json",
6262
},
6363
data: {
@@ -75,11 +75,11 @@ export default {
7575
*/
7676
const thrower = gsConsole.methods.checkWhoThrewError(error);
7777

78-
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("*!*"));
78+
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("\n- "));
7979

8080
};
8181
// Output a summary message and any accumulated warnings
82-
$.export("$summary", ` URL submitted to Google: ${this.siteUrl}` + warnings.join("*!*"));
82+
$.export("$summary", ` URL submitted to Google: ${this.siteUrl}` + warnings.join("\n- "));
8383
// Return the raw API response
8484
return response;
8585
},

components/google_search_console/common/methods.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ throwIfNotObjectOrArray(input, reason) {
193193
if (dubiousMatches) {
194194
const uniqueChars = [...new Set(dubiousMatches)].join(" ");
195195

196-
warnings.push(`*!* URL contains dubious or non-standard characters " ${uniqueChars} " ` +
197-
`that may be rejected by Google. Proceed only if you know what you are doing. ${this._reasonMsg(reason)}*!*`) ;
196+
warnings.push(` URL contains dubious or non-standard characters " ${uniqueChars} " ` +
197+
`that may be rejected by Google. Proceed only if you know what you are doing. ${this._reasonMsg(reason)}`) ;
198198
};
199199

200200
// urlObject for further use if the next check passes.
@@ -206,8 +206,8 @@ throwIfNotObjectOrArray(input, reason) {
206206
// Warn if user typed only one slash (e.g., https:/)
207207
if (/^(https?):\/(?!\/)/.test(input)) {
208208

209-
warnings.push(`*!* It looks like you're missing one slash after "${urlObject.protocol}".` +
210-
`Did you mean "${urlObject.protocol}//..."? ${this._reasonMsg(reason)} *!*`);
209+
warnings.push(` It looks like you're missing one slash after "${urlObject.protocol}".` +
210+
`Did you mean "${urlObject.protocol}//..."? ${this._reasonMsg(reason)} `);
211211

212212
};
213213

@@ -217,11 +217,11 @@ throwIfNotObjectOrArray(input, reason) {
217217
// If it works then there was no protocol in the input string;
218218
urlObject = new URL("http://" + trimmedInput);
219219

220-
warnings.push(`*!* URL does not have http or https protocol *!*"`);
220+
warnings.push(` URL does not have http or https protocol "`);
221221

222222
} catch(err) {
223223
// If after all checks we are here that means that the url contain potentially unacceptable characters.
224-
warnings.push(`*!* URL contains potentionally unacceptable characters*!*" ${this._reasonMsg(reason)}`);
224+
warnings.push(` URL contains potentionally unacceptable characters" ${this._reasonMsg(reason)}`);
225225

226226
};
227227

components/google_search_console/tests/action-tests/test-retrieve-site-performance-data.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ const testAction = {
176176
*/
177177
for (let propName in propsMeta){
178178

179-
console.log("===VALUE", this[propName]); // TEST ONLY
179+
console.log("===VALUE", this[propName]);
180180
const meta = propsMeta[propName];
181181

182182
// Trim the input if it's a string
@@ -195,7 +195,7 @@ const testAction = {
195195
// If the prop should be included in the POST request, add it to the body
196196
if (meta.postBody === true) body[propName] = this[propName];
197197

198-
console.log(" SUCCESS"); // TEST ONLY
198+
console.log(" SUCCESS");
199199
};
200200

201201
// Trimmed in loop above
@@ -220,12 +220,12 @@ const testAction = {
220220
// Check who threw the error. Internal code or the request. To ease debugging.
221221
const thrower = gsConsole.methods.checkWhoThrewError(error);
222222

223-
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. `);
223+
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("\n- "));
224224

225225
};
226226

227227

228-
$.export("$summary", ` Fetched ${response.rows?.length || 0} rows of data. ` + warnings.join("*!*"));
228+
$.export("$summary", ` Fetched ${response.rows?.length || 0} rows of data. ` + warnings.join("\n- "));
229229
return response;
230230
},
231231
};

components/google_search_console/tests/action-tests/test-submit-url-for-indexing.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const testAction = { // TEST ONLY. Replace to export in real code
6161
url: "https://indexing.googleapis.com/v3/urlNotifications:publish",
6262
headers: {
6363
// Tested with real hardcoded token that had required scopes.
64-
Authorization: `Bearer *HARDCODED TOKEN HERE*`,
64+
Authorization: `Bearer *HARDCODED TOKEN HERE*`, // Replace with a token from get-token.mjs with scope: "https://www.googleapis.com/auth/indexing".
6565
"Content-Type": "application/json",
6666
},
6767
data: {
@@ -73,11 +73,11 @@ const testAction = { // TEST ONLY. Replace to export in real code
7373
// Check who threw the error. Internal code or the request. To ease debugging.
7474
const thrower = gsConsole.methods.checkWhoThrewError(error);
7575

76-
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("*!*"));
76+
throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("\n- "));
7777

7878
};
7979

80-
$.export("$summary", ` URL submitted to Google: ${this.siteUrl}` + warnings.join("*!*"));
80+
$.export("$summary", ` URL submitted to Google: ${this.siteUrl}` + warnings.join("\n- "));
8181
return response;
8282
},
8383
};

0 commit comments

Comments
 (0)