-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] google_search_console : add “Retrieve Site Performance” & “Submit URL for Indexing” actions #16378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6b15621
Add GSC Actions : Retrieve Site Perfomance Data & Submit Url For Inde…
SokolovskyiK 5cbe03a
Minor fixes: addressed CodeRabbit comments
SokolovskyiK e1c2238
Minor fixes: addressed CodeRabbit comments
SokolovskyiK 496b3b7
Merge branch 'pipedream-gsc' of https://github.com/SokolovskyiK/piped…
SokolovskyiK 173277a
Fix minor CodeRabbit suggestions
SokolovskyiK f4c36fb
Fix minor CodeRabbit suggestions
SokolovskyiK 3dec800
updates/formatting
michelle0927 de82ab9
pnpm-lock.yaml
michelle0927 127e8db
move tests to common folder
michelle0927 fbf3961
updates
michelle0927 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
components/google_search_console/actions/retrieve-site-performance-data/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # Google Search Console – Site Performance (Analytics) Action | ||
|
|
||
| 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: | ||
|
|
||
| - Top search queries | ||
| - Click-through rates | ||
| - Page impressions | ||
| - Device types, countries, and more | ||
|
|
||
| --- | ||
|
|
||
| ## Use Cases | ||
|
|
||
| - Automate SEO reporting | ||
| - Analyze organic search trends | ||
| - Filter and break down traffic by dimensions (e.g. query, device, country) | ||
|
|
||
| --- | ||
|
|
||
| ## Internals | ||
|
|
||
| - Supports all relevant props from the [Search Analytics Query API](https://developers.google.com/webmaster-tools/search-console-api-original/v3/searchanalytics/query) | ||
| - Trims and validates all input props | ||
| - Accepts optional `dimensionFilterGroups` either as an object or JSON string | ||
| - Automatically builds the POST request body using `propsMeta` metadata | ||
| - Returns the raw Search Console API response for full access to metrics | ||
| - Accumulates and displays warnings for non-blocking input issues | ||
|
|
||
| --- | ||
|
|
||
| ## Auth | ||
|
|
||
| Requires OAuth 2.0 with the following scope: https://www.googleapis.com/auth/webmasters.readonly | ||
|
|
||
|
|
||
| ## Endpoint | ||
| https://searchconsole.googleapis.com/webmasters/v3/sites/{siteUrl}/searchAnalytics/query | ||
|
|
||
|
|
||
| ## 📦 Example Request Payload | ||
|
|
||
|
|
||
|
|
||
|
|
||
| { | ||
| // The site you want to query data for. | ||
| // Must be verified in your Google Search Console account. | ||
| "siteUrl": "https://falc1.com/soda_can", | ||
|
|
||
| // The start date of the reporting period (inclusive), in YYYY-MM-DD format. | ||
| "startDate": "2025-12-22", | ||
|
|
||
| // The end date of the reporting period (inclusive), in YYYY-MM-DD format. | ||
| "endDate": "2025-12-31", | ||
|
|
||
| // 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. | ||
| "dimensions": ["query", "page", "country", "device"], | ||
|
|
||
| // The type of search data to include. | ||
| // Valid values: "web", "image", "video", "news", "googleNews", "discover" | ||
| "searchType": "web", | ||
|
|
||
| // Maximum number of rows to return (1–25,000) | ||
| "rowLimit": 10, | ||
|
|
||
| // Optional: Skips the first N rows — used for pagination. | ||
| "startRow": 0, | ||
|
|
||
| // Optional: How to group data. | ||
| // "auto" = Google's default grouping. | ||
| // "byPage" = Group by page (useful for getting per-page breakdowns). | ||
| "aggregationType": "auto", | ||
|
|
||
| // Optional: Data freshness filter. | ||
| // "final" = Only finalized data (more accurate). | ||
| // "all" = Includes fresh but possibly incomplete data. | ||
| "dataState": "final", | ||
|
|
||
| // Optional filter group(s) to restrict which rows are returned. | ||
| // Each group applies logical AND/OR across its filters. | ||
| "dimensionFilterGroups": [ | ||
| { | ||
| // Logical grouping operator for the filters inside this group. | ||
| // "and" = all filters must match | ||
| // "or" = any filter can match | ||
| "groupType": "and", | ||
|
|
||
| // List of individual filters to apply within the group | ||
| "filters": [ | ||
| { | ||
| // Which dimension to filter by (must match a dimension in your request) | ||
| "dimension": "query", | ||
|
|
||
| // Filter operator — e.g., "equals", "contains", "notEquals", etc. | ||
| "operator": "contains", | ||
|
|
||
| // Value to match against | ||
| "expression": "example" | ||
| }, | ||
| { | ||
| "dimension": "country", | ||
| "operator": "equals", | ||
| "expression": "USA" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } |
192 changes: 192 additions & 0 deletions
192
..._search_console/actions/retrieve-site-performance-data/retrieve-site-performance-data.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
|
|
||
| /** | ||
| * Fetches performance data (clicks, impressions, etc.) for a verified site | ||
| * via the Google Search Console Search Analytics API. | ||
| * | ||
| * Full usage docs in README.md | ||
| */ | ||
|
|
||
|
|
||
| import { axios } from "@pipedream/platform"; | ||
| import gsConsole from "../../google_search_console.app.mjs"; | ||
| import {removeCustomPropFields, trimIfString } from "../../common/utils.mjs" | ||
|
|
||
| /* | ||
| Define prop metadata separately, including custom fields used for extended validation | ||
| and runtime behavior. | ||
|
|
||
| These extended fields (like `extendedType`, `postBody`, etc.) are not part of the standard | ||
| Pipedream prop schema. | ||
|
|
||
| A helper function (`removeCustomPropFields`) will later strip these non-standard fields, | ||
| returning only valid Pipedream props for use in the UI. | ||
|
|
||
| Keeping the full metadata in closure allows access to helpful context (e.g. validation rules) | ||
| during runtime. | ||
| */ | ||
| const propsMeta = { | ||
|
|
||
| siteUrl: { | ||
| type: "string", | ||
| extendedType: "url", | ||
| label: "Verified Site URL", | ||
| description: "Including https:// is strongly advised", | ||
| }, | ||
| startDate: { | ||
| type: "string", | ||
| extendedType: "YYYY-MM-DD", | ||
| label: "Start Date (YYYY-MM-DD)", | ||
| postBody: true, | ||
| }, | ||
| endDate: { | ||
| type: "string", | ||
| extendedType: "YYYY-MM-DD", | ||
| label: "End Date (YYYY-MM-DD)", | ||
| postBody: true, | ||
| }, | ||
| dimensions: { | ||
| type: "string[]", | ||
| label: "Dimensions", | ||
| optional: true, | ||
| description: "e.g. ['query', 'page', 'country', 'device']", | ||
| postBody: true, | ||
| }, | ||
| searchType: { | ||
| type: "string", | ||
| label: "Search Type", | ||
| optional: true, | ||
| options: ["web", "image", "video", "news", "googleNews", "discover"], | ||
| default: "web", | ||
| postBody: true, | ||
| }, | ||
| aggregationType: { | ||
| type: "string", | ||
| label: "Aggregation Type", | ||
| optional: true, | ||
| options: ["auto", "byPage"], | ||
| postBody: true, | ||
| }, | ||
| rowLimit: { | ||
| type: "integer", | ||
| label: "Max rows to return", | ||
| default: 10, | ||
| postBody: true, | ||
| }, | ||
| startRow: { | ||
| type: "integer", | ||
| label: "Start row (for pagination)", | ||
| optional: true, | ||
| postBody: true, | ||
| }, | ||
| dimensionFilterGroups: { | ||
| type: "object", | ||
| label: "Dimension Filters", | ||
| optional: true, | ||
| description: "Follow Search Console API structure for filters", | ||
| postBody: true, | ||
| }, | ||
| dataState: { | ||
| type: "string", | ||
| label: "Data State", | ||
| optional: true, | ||
| options: ["all", "final"], | ||
| default: "final", | ||
| postBody: true, | ||
| }, | ||
|
|
||
|
|
||
|
|
||
| }; | ||
|
|
||
| export default { | ||
| name: "Retrieve Site Performance Data", | ||
| description: "Fetches search analytics from Google Search Console for a verified site.", | ||
| key: "retrieve-site-performance-data", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| gsConsole, | ||
| // Remove non-standard fields and expose only valid props to Pipedream UI | ||
| ...removeCustomPropFields(propsMeta), | ||
| }, | ||
|
|
||
|
|
||
| //=================== RUN ============================== | ||
| //====================================================== | ||
|
|
||
| async run({ $ }) { | ||
|
|
||
| /* | ||
| `dimensionFilterGroups` is expected to be an object. | ||
| If a JSON string is passed instead (e.g. from UI input), attempt to parse it. | ||
| - Returns parsed object if successful | ||
| - Returns original input if not a string | ||
| - Throws a descriptive error if JSON parsing fails | ||
| */ | ||
| this.dimensionFilterGroups = this.gsConsole.parseIfJsonString(this.dimensionFilterGroups); | ||
|
|
||
| // Prepare the POST request payload | ||
| const body = {}; | ||
|
|
||
| // Accumulator for non-blocking input warnings | ||
| const warnings = []; | ||
|
|
||
| /* | ||
| This loop: | ||
| - Trims and validates all defined props | ||
| - Skips empty optional fields | ||
| - Accumulates non-blocking warnings | ||
| - Adds valid props to the POST request payload (`body`) if marked with `postBody: true` | ||
| */ | ||
| for (let propName in propsMeta){ | ||
|
|
||
| // Just for convenience. | ||
| const meta = propsMeta[propName]; | ||
|
|
||
| // Trim the value if it's a string | ||
| this[propName] = trimIfString(this[propName]); | ||
|
|
||
| // Skip if the prop is optional and empty (null, undefined, or blank string) | ||
| if (meta.optional === true && ((this[propName] ?? '') === '')) continue; | ||
|
|
||
| // Validate input (may throw or return warning messages) | ||
| const validationResult = this.gsConsole.validateUserInput(meta, this[propName]); | ||
|
|
||
| // Push the warnings into warnings accumulator if any. | ||
| if (validationResult.warnings) warnings.push(...validationResult.warnings); | ||
|
|
||
| // Include prop in the request body if marked as postBody | ||
| if (meta.postBody === true) body[propName] = this[propName]; | ||
| }; | ||
|
|
||
| // Already trimmed earlier | ||
| const url = this.siteUrl; | ||
|
|
||
| // Response of the POST request. | ||
| let response; | ||
|
|
||
| try { | ||
| response = await axios($, { | ||
| method: "POST", | ||
| url: `https://searchconsole.googleapis.com/webmasters/v3/sites/${encodeURIComponent(url)}/searchAnalytics/query`, | ||
| headers: { | ||
| Authorization: `Bearer ${this.gsConsole.$auth.oauth_access_token}`, | ||
| "Content-Type": "application/json", | ||
| }, | ||
| data: body, | ||
| }) | ||
|
|
||
| } catch (error) { | ||
| // Identify if the error was thrown by internal validation or by the API call | ||
| const thrower = this.gsConsole.checkWhoThrewError(error); | ||
|
|
||
| throw new Error(`Failed to fetch data ( ${thrower.whoThrew} error ) : ${error.message}. ` + warnings.join("*!*")); | ||
|
|
||
| }; | ||
|
|
||
| // Output summary and any warnings for the user | ||
| $.export("$summary", ` Fetched ${response.rows?.length || 0} rows of data. ` + warnings.join("*!*")); | ||
| return response; | ||
| }, | ||
| }; | ||
|
|
31 changes: 31 additions & 0 deletions
31
components/google_search_console/actions/submit-url-for-indexing/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # 🚀 Google Indexing API – URL Submission Action | ||
|
|
||
| This action submits a specific URL to the **Google Indexing API** to notify Google that the content has been **updated** and should be re-crawled. | ||
|
|
||
| --- | ||
|
|
||
| ## ✅ Use Case | ||
|
|
||
| Use this action when: | ||
| - You’ve updated content on a page | ||
| - You want to request Google to reindex that URL as soon as possible | ||
|
|
||
| --- | ||
|
|
||
| ## 🧠 Internals | ||
|
|
||
| - Validates and trims the input URL | ||
| - Uses the `URL_UPDATED` type to inform Google of a content change | ||
| - Returns the raw API response | ||
| - Displays a user-friendly summary | ||
| - Accumulates and returns non-blocking warnings (e.g. unusual characters in the URL) | ||
|
|
||
| --- | ||
|
|
||
| ## 🔐 Auth | ||
|
|
||
| Requires OAuth 2.0 with this scope: https://www.googleapis.com/auth/indexing | ||
|
|
||
| ## 🔗 Endpoint | ||
|
|
||
| https://indexing.googleapis.com/v3/urlNotifications:publish |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.