-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New Components - adyntel #16231
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
New Components - adyntel #16231
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
WalkthroughThis pull request introduces three new action modules for retrieving ads—Google Ads by Company, Meta Ad Search, and TikTok Search. Each module defines its metadata, input properties, and an asynchronous run method that calls corresponding functions in the adyntel module. The adyntel application module itself has been updated: new search properties (keyword, countryCode) were added, the old authKeys method was removed, and new internal methods (_baseUrl, _makeRequest) are now used to structure API requests for the new endpoints. The package version and dependencies have been updated accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Action
participant Adyntel
participant API
Client->>Action: Trigger ad search action (meta/google/tiktok)
Action->>Adyntel: Invoke corresponding search method with inputs
Adyntel->>API: _makeRequest(method, endpoint, data)
API-->>Adyntel: Return API response
Adyntel-->>Action: Pass back results
Action-->>Client: Return formatted response
Assessment against linked issues
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/facebook_graph_api/facebook_graph_api.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/gather/gather.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 📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
⏰ Context from checks skipped due to timeout of 90000ms (3)
🪧 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: 0
🧹 Nitpick comments (7)
components/adyntel/actions/tiktok-search/tiktok-search.mjs (1)
9-17: Consider adding keyword validation.While the keyword property is correctly defined using the adyntel propDefinition, there's no validation to ensure it's not empty or has a valid format before making the API call.
You might want to add validation before the API call:
async run({ $ }) { + if (!this.keyword || this.keyword.trim() === "") { + throw new Error("Keyword cannot be empty"); + } const response = await this.adyntel.getTiktokAds({components/adyntel/actions/meta-ad-search/meta-ad-search.mjs (1)
24-36: Consider refactoring the summary string template.The template literal for the summary message spans multiple lines, which might impact readability. Consider refactoring to improve clarity.
- $.export("$summary", `Successfully performed Meta ad search with keyword: \`${this.keyword}\`${this.countryCode - ? ` and country code: \`${this.countryCode}\`` - : ""}`); + const countryCodeText = this.countryCode ? ` and country code: \`${this.countryCode}\`` : ""; + $.export("$summary", `Successfully performed Meta ad search with keyword: \`${this.keyword}\`${countryCodeText}`);components/adyntel/actions/google-ads-by-company/google-ads-by-company.mjs (1)
11-15: Consider adding validation for companyDomain format.The companyDomain has specific format requirements (no "https://" or "www."), but there's no validation to ensure users provide it in the correct format.
async run({ $ }) { + // Validate domain format + const domainRegex = /^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$/; + if (!domainRegex.test(this.companyDomain)) { + throw new Error("Company domain must be in 'company.com' format without 'https://' or 'www.' prefixes"); + } const response = await this.adyntel.getGoogleAds({components/adyntel/adyntel.app.mjs (4)
6-18: Well-defined property definitions.The
keywordandcountryCodeproperties are clearly defined with appropriate types, labels, and descriptions. ThecountryCodeis correctly marked as optional.Consider adding validation or providing a dropdown list of available country codes to ensure users enter valid ISO country codes (e.g., 'US', 'CA', 'UK').
23-40: Well-structured request method with proper authentication.The
_makeRequestmethod effectively centralizes request logic and handles authentication by including the API key and email in each request. The parameter destructuring with defaults and spreading of additional options provides good flexibility.Consider adding basic error handling to improve resilience:
_makeRequest({ $ = this, method = "POST", path = "/", data = {}, ...otherOpts }) { return axios($, { ...otherOpts, method, url: `${this._baseUrl()}${path}`, data: { ...data, api_key: this.$auth.api_key, email: this.$auth.username, }, + }).catch(err => { + const status = err.response?.status; + const message = err.response?.data?.message || err.message; + throw new Error(`Adyntel API error (${status}): ${message}`); + }); }); },
41-46: Consistent pattern for Facebook/Meta ad search.The method follows a good pattern of reusing the centralized request logic.
Consider adding JSDoc comments to document the expected parameters and return values:
+ /** + * Search for Facebook/Meta ads using keywords + * @param {Object} opts - Options for the request + * @param {string} opts.data.keyword - The keyword to search by + * @param {string} [opts.data.countryCode] - Country code to limit results + * @returns {Promise<Object>} - The response from the Meta ad search API + */ metaAdSearch(opts = {}) { return this._makeRequest({ path: "/facebook_ad_search", ...opts, }); },
53-58: Consistent pattern for TikTok ads retrieval.The method maintains the consistent pattern established across all endpoints, which is good for maintainability.
For consistency with the other endpoint methods, consider verifying that these methods all expect the same parameter structure. If they differ in expected parameters, it would be helpful to document the differences.
📜 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/adyntel/actions/google-ads-by-company/google-ads-by-company.mjs(1 hunks)components/adyntel/actions/meta-ad-search/meta-ad-search.mjs(1 hunks)components/adyntel/actions/tiktok-search/tiktok-search.mjs(1 hunks)components/adyntel/adyntel.app.mjs(1 hunks)components/adyntel/package.json(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Publish TypeScript components
🔇 Additional comments (12)
components/adyntel/package.json (2)
3-3: Version bump is appropriate for the new features.The version update from 0.0.1 to 0.1.0 correctly follows semantic versioning for the addition of new functionality without breaking existing features.
14-17: Dependencies properly added.The addition of the @pipedream/platform dependency and properly structured JSON with closing braces are appropriate for the new components being introduced.
components/adyntel/actions/tiktok-search/tiktok-search.mjs (2)
3-8: Component metadata is well-defined.The action module's metadata (key, name, description, version, type) is appropriately structured with a clear description and documentation link.
18-27: The run method is correctly implemented.The async run method correctly uses the adyntel module's getTiktokAds function, passes the keyword in the data object, and returns the response. The summary message is well-formatted for user feedback.
components/adyntel/actions/meta-ad-search/meta-ad-search.mjs (2)
3-8: Component metadata is well-defined.The action module's metadata (key, name, description, version, type) is appropriately structured with a clear description and documentation link.
9-23: Props are correctly defined.Both keyword and countryCode properties are correctly defined using propDefinitions from the adyntel module.
components/adyntel/actions/google-ads-by-company/google-ads-by-company.mjs (3)
3-8: Component metadata is well-defined.The action module's metadata (key, name, description, version, type) is appropriately structured with a clear description and documentation link.
9-27: Props are well-defined with clear descriptions.The properties are clearly defined with detailed descriptions, especially the companyDomain which includes specific format requirements. The mediaType property correctly includes options and is marked as optional.
28-38: The run method is correctly implemented.The async run method correctly uses the adyntel module's getGoogleAds function, passes the company_domain and media_type in the expected snake_case format, and returns the response. The summary message provides appropriate user feedback.
components/adyntel/adyntel.app.mjs (3)
1-2: Appropriate import for HTTP requests.The
axiosimport from the Pipedream platform is correctly used for making API requests.
20-22: Clean implementation of base URL.Extracting the base URL into a dedicated method follows good practices for maintainability.
47-52:❓ Verification inconclusive
Consistent pattern for Google ads retrieval.
The method follows the same good pattern for reuse and maintainability.
Let's verify the expected parameters for the Google ads endpoint:
🏁 Script executed:
#!/bin/bash # Let's look for any usage of this method in the components rg -A 10 "getGoogleAds" --type js --type mjsLength of output: 72
Attention: Manual verification required for file type filtering in usage search
The implementation in
components/adyntel/adyntel.app.mjs(lines 47–52) follows the established, reusable pattern for Google ads retrieval. However, the original search command—using--type mjs—yielded an error (unrecognized file type: mjs), which prevents verifying the expected parameters for the Google ads endpoint. Please re-run the usage search with an adjusted command, for example:#!/bin/bash # Verify usage in .mjs files using a glob pattern instead of an unrecognized file type rg -A 10 "getGoogleAds" --glob '*.mjs' # (Optionally, check usage in .js files as well) rg -A 10 "getGoogleAds" --glob '*.js'This will help confirm that the parameters passed to
getGoogleAdsacross the codebase match the endpoint’s expected requirements.
GTFalcao
left a comment
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.
LGTM
|
/approve |
Resolves #16177
Summary by CodeRabbit
New Features
Chores