-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Fix filter handling for Google Search Console action #16467
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
WalkthroughThis update enhances the Google Search Console integration by expanding documentation, refining user input options, and improving error handling. The README now explains domain and subdomain handling, filtering, and advanced usage. The retrieve-site-performance-data action introduces new props for granular filtering and dynamic construction of dimension filters, along with improved error messages. The submit-url-for-indexing action adds a notification type selector and clearer error reporting. The app module now supports dynamic, paginated selection of verified sites via a new prop definition and supporting methods. The package version is incremented to 0.8.0. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant RetrieveAction as Retrieve Site Performance Data Action
participant App as Google Search Console App
participant GSCAPI as Google Search Console API
User->>RetrieveAction: Select siteUrl (from dynamic options), set filters
RetrieveAction->>App: Fetch siteUrl options (paginated)
App->>GSCAPI: GET /webmasters/v3/sites
GSCAPI-->>App: List of verified sites
App-->>RetrieveAction: siteUrl options
RetrieveAction->>RetrieveAction: Build dimensionFilterGroups based on props
RetrieveAction->>App: getSitePerformanceData(siteUrl, filters)
App->>GSCAPI: Query performance data
GSCAPI-->>App: Data response
App-->>RetrieveAction: Data
RetrieveAction-->>User: Return results or error message
sequenceDiagram
participant User
participant SubmitAction as Submit URL for Indexing Action
participant App as Google Search Console App
participant GSCAPI as Google Indexing API
User->>SubmitAction: Provide siteUrl and select notificationType
SubmitAction->>SubmitAction: Trim and validate siteUrl
alt Valid URL
SubmitAction->>App: Submit URL with notificationType
App->>GSCAPI: POST indexing request
GSCAPI-->>App: Response
App-->>SubmitAction: Result
SubmitAction-->>User: Success message (with warnings if any)
else Invalid or Error
SubmitAction-->>User: Detailed error message
end
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
components/google_search_console/actions/retrieve-site-performance-data/retrieve-site-performance-data.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/google_search_console/google_search_console.app.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs components/google_search_console/actions/submit-url-for-indexing/submit-url-for-indexing.mjsOops! Something went wrong! :( ESLint: 8.57.1 Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
components/google_search_console/actions/retrieve-site-performance-data/retrieve-site-performance-data.mjs (2)
172-172: Consider error handling for parseIfJsonStringThe
parseIfJsonStringmethod is used to parse advanced filters, but there's no error handling if parsing fails. Consider adding a try/catch block to provide a more meaningful error message:-dimensionFilterGroups = googleSearchConsole.parseIfJsonString(advancedDimensionFilters); +try { + dimensionFilterGroups = googleSearchConsole.parseIfJsonString(advancedDimensionFilters); +} catch (error) { + throw new Error(`Invalid format for advancedDimensionFilters: ${error.message}`); +}
198-201: Nice touch with the summary message pluralization!The conditional pluralization of "row" based on the count makes for a more polished user experience.
For even more conciseness, consider using the plural() utility if available in your codebase:
-$.export("$summary", `Fetched ${rowCount} ${rowCount === 1 ? "row" : "rows"} of data.`); +$.export("$summary", `Fetched ${rowCount} ${plural(rowCount, "row", "rows")} of data.`);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
components/google_search_console/README.md(1 hunks)components/google_search_console/actions/retrieve-site-performance-data/retrieve-site-performance-data.mjs(5 hunks)components/google_search_console/actions/submit-url-for-indexing/submit-url-for-indexing.mjs(2 hunks)components/google_search_console/google_search_console.app.mjs(2 hunks)components/google_search_console/package.json(1 hunks)
🧰 Additional context used
🪛 LanguageTool
components/google_search_console/README.md
[style] ~3-~3: Consider an alternative adjective to strengthen your wording.
Context: ...ormance, integrate with other tools for deeper analysis, or keep tabs on your SEO stra...
(DEEP_PROFOUND)
[style] ~37-~37: Consider an alternative adjective to strengthen your wording.
Context: ...for maintaining an evolving dataset for deeper analysis, historical reference, or shar...
(DEEP_PROFOUND)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: pnpm publish
- GitHub Check: Verify TypeScript components
- GitHub Check: Lint Code Base
- GitHub Check: Publish TypeScript components
🔇 Additional comments (21)
components/google_search_console/google_search_console.app.mjs (3)
7-17: The propDefinitions implementation looks good!This addition introduces a reusable
siteUrlprop definition that allows users to select verified sites from their Google Search Console. The implementation includes pagination support through theprevContextparameter, which is a best practice for handling potentially large lists of options.
34-40: Well-implemented API method for retrieving sitesThe
getSitesmethod is cleanly implemented, leveraging the existing_makeRequestmethod for authentication and properly structured to accept additional parameters.
41-62: Great implementation of the site options list with paginationThe
listSiteOptionsmethod properly handles pagination through page tokens and transforms the API response into a format suitable for dropdown selection in the UI. The default empty array forsiteEntryprovides protection against undefined values.components/google_search_console/package.json (1)
3-3: Version bump is appropriate for the new featuresThe increment from 0.7.1 to 0.8.0 follows semantic versioning principles, as these changes add new functionality without breaking existing API contracts.
components/google_search_console/README.md (3)
3-3: Improved introduction with clear value propositionThis enhanced introduction clearly explains the capabilities of the Google Search Console API and its benefits for Pipedream users, setting appropriate expectations.
🧰 Tools
🪛 LanguageTool
[style] ~3-~3: Consider an alternative adjective to strengthen your wording.
Context: ...ormance, integrate with other tools for deeper analysis, or keep tabs on your SEO stra...(DEEP_PROFOUND)
5-32: Excellent documentation on domain properties and filteringThis new section provides valuable instructions for working with domain properties and subdomains in Google Search Console, addressing a potentially confusing topic. The documentation clearly explains:
- The difference between URL and domain properties
- How to filter for specific subdomains
- How to get data for individual pages
- Advanced filtering options
This will significantly improve the user experience when working with these features.
35-39: Well-formatted example use casesThe example use cases have been preserved but are now better formatted, making them easier to read and understand.
🧰 Tools
🪛 LanguageTool
[style] ~37-~37: Consider an alternative adjective to strengthen your wording.
Context: ...for maintaining an evolving dataset for deeper analysis, historical reference, or shar...(DEEP_PROFOUND)
components/google_search_console/actions/submit-url-for-indexing/submit-url-for-indexing.mjs (9)
8-8: Version update reflects the feature enhancementThe version bump from 0.0.2 to 0.0.3 properly indicates the addition of new features.
15-16: Improved description for the siteUrl propertyThe enhanced description clarifies that the URL must be a canonical URL verified in Google Search Console, which helps prevent user errors.
17-32: Great addition of notification type selectionAdding the
notificationTypeprop gives users control over whether they're notifying Google about an updated or deleted URL. The well-labeled options with clear descriptions and sensible default value make this easy to use.
35-38: Clean property extraction and URL trimmingThe destructuring of properties and trimming of the URL input are well-implemented. Trimming the URL is a good defensive programming practice to handle potential user input errors.
42-43: Proper use of trimmed URL for validationThe code correctly uses the trimmed URL when checking if the URL is valid, ensuring consistent validation.
52-53: Using trimmed URL and selected notification typeThe code now properly submits the trimmed URL and uses the user-selected notification type instead of a hardcoded value, making the action more flexible.
59-68: Enhanced error handling with specific error messagesThe improved error handling provides detailed, context-specific error messages for common HTTP status codes:
- 403 (Access denied) - Suggests checking if the URL belongs to a property the user has access to
- 400 (Invalid request) - Advises the user to ensure the URL is canonical and verified
This will greatly help users troubleshoot issues without needing to understand HTTP status codes.
71-74: Better formatting of warning messagesThe code now formats warnings as bullet points when they exist, improving readability in the output summary.
77-77: Clean summary message with conditionally appended warningsThe summary export message now includes the trimmed URL and appends any warnings in a clean, readable format.
components/google_search_console/actions/retrieve-site-performance-data/retrieve-site-performance-data.mjs (5)
8-8: Good refactoring of the siteUrl property and version increment!Converting the
siteUrlfrom a simple string input to a propDefinition that references the app's method improves usability by providing a dynamic list of verified sites. The updated description also clearly explains how to handle subdomains, which is a common source of confusion for users.Also applies to: 13-17
34-41: Nice addition of explicit dimension options!Adding a fixed set of selectable options for dimensions prevents errors from invalid values and makes the UI more user-friendly by showing available choices.
81-120: Well-designed filtering options with clear documentation!The new filtering properties (
subdomainFilter,filterDimension,filterOperator, andadvancedDimensionFilters) provide a good balance between simplicity for common use cases and flexibility for advanced scenarios. The descriptions effectively explain each property's purpose.
189-193: Excellent enhancement to error handling!Adding a specific error message for 403 errors with guidance on how to properly access subdomains is very helpful for users. This type of contextual error handling significantly improves the user experience.
181-183:❓ Verification inconclusive
Verify API behavior with undefined dimensionFilterGroups
The code passes
dimensionFilterGroupsdirectly to the API, but when neithersubdomainFilternoradvancedDimensionFiltersis provided, this value will beundefined.If the API requires this field to be an object (even if empty) rather than undefined, consider initializing it with an empty structure.
🏁 Script executed:
#!/bin/bash # Check the Google Search Console API documentation or examples to verify behavior with undefined filterGroups cd components/google_search_console && grep -r "dimensionFilterGroups" --include="*.mjs" . | grep -v "retrieve-site-performance-data.mjs"Length of output: 134
Verify API behavior with undefined
dimensionFilterGroupsWe didn’t find any other references in the codebase. When neither
subdomainFilternoradvancedDimensionFiltersis supplied,dimensionFilterGroupswill beundefined. Please confirm via the Google Search Console API docs or your integration tests whether omitting this field is acceptable. If the API requires an array (even if empty), consider defaulting it:
- Location:
components/google_search_console/actions/retrieve-site-performance-data/retrieve-site-performance-data.mjs
Lines 181–183Suggested change:
- ...body, - dimensionFilterGroups, + ...body, + dimensionFilterGroups: dimensionFilterGroups ?? [],
| // Build dimension filters based on user input | ||
| let dimensionFilterGroups; | ||
|
|
||
| if (subdomainFilter) { | ||
| // If user provided a subdomain filter, create the filter structure | ||
| dimensionFilterGroups = { | ||
| filterGroups: [ | ||
| { | ||
| filters: [ | ||
| { | ||
| dimension: filterDimension || "page", | ||
| operator: filterOperator || "contains", | ||
| expression: subdomainFilter, | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }; | ||
| } else if (advancedDimensionFilters) { | ||
| // If user provided advanced filters, use those | ||
| dimensionFilterGroups = googleSearchConsole.parseIfJsonString(advancedDimensionFilters); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Good implementation of dynamic filter construction!
The approach to dynamically build dimension filters based on user input is clean and maintainable. However, there's one potential edge case to address:
Consider handling the case where both subdomainFilter and advancedDimensionFilters are provided:
if (subdomainFilter) {
// If user provided a subdomain filter, create the filter structure
dimensionFilterGroups = {
filterGroups: [
{
filters: [
{
dimension: filterDimension || "page",
operator: filterOperator || "contains",
expression: subdomainFilter,
},
],
},
],
};
} else if (advancedDimensionFilters) {
// If user provided advanced filters, use those
dimensionFilterGroups = googleSearchConsole.parseIfJsonString(advancedDimensionFilters);
+} else {
+ dimensionFilterGroups = undefined;
}This would make the intention explicit when neither filter is provided.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Build dimension filters based on user input | |
| let dimensionFilterGroups; | |
| if (subdomainFilter) { | |
| // If user provided a subdomain filter, create the filter structure | |
| dimensionFilterGroups = { | |
| filterGroups: [ | |
| { | |
| filters: [ | |
| { | |
| dimension: filterDimension || "page", | |
| operator: filterOperator || "contains", | |
| expression: subdomainFilter, | |
| }, | |
| ], | |
| }, | |
| ], | |
| }; | |
| } else if (advancedDimensionFilters) { | |
| // If user provided advanced filters, use those | |
| dimensionFilterGroups = googleSearchConsole.parseIfJsonString(advancedDimensionFilters); | |
| } | |
| // Build dimension filters based on user input | |
| let dimensionFilterGroups; | |
| if (subdomainFilter) { | |
| // If user provided a subdomain filter, create the filter structure | |
| dimensionFilterGroups = { | |
| filterGroups: [ | |
| { | |
| filters: [ | |
| { | |
| dimension: filterDimension || "page", | |
| operator: filterOperator || "contains", | |
| expression: subdomainFilter, | |
| }, | |
| ], | |
| }, | |
| ], | |
| }; | |
| } else if (advancedDimensionFilters) { | |
| // If user provided advanced filters, use those | |
| dimensionFilterGroups = googleSearchConsole.parseIfJsonString(advancedDimensionFilters); | |
| } else { | |
| // Explicitly handle the case where neither filter is provided | |
| dimensionFilterGroups = undefined; | |
| } |
WHY
Summary by CodeRabbit
New Features
Improvements
Documentation