Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Apr 9, 2025

Resolves #16177

Summary by CodeRabbit

  • New Features

    • Introduced ad search functionalities across platforms, allowing users to retrieve Google Ads by company domain, perform Meta ad searches with keyword and country filters, and search TikTok ads by keyword.
  • Chores

    • Upgraded the package version and updated dependencies for improved stability and performance.

@vercel
Copy link

vercel bot commented Apr 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Ignored (Inspect) Visit Preview Apr 10, 2025 3:37pm
pipedream-docs ⬜️ Ignored (Inspect) Apr 10, 2025 3:37pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 10, 2025 3:37pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 9, 2025

Walkthrough

This 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

File(s) Change Summary
components/adyntel/actions/google-ads-by-company/*.mjs, components/adyntel/actions/meta-ad-search/*.mjs, components/adyntel/actions/tiktok-search/*.mjs Added new modules for Google Ads by Company, Meta Ad Search, and TikTok Search with defined metadata, input properties, and asynchronous run methods calling respective adyntel API methods.
components/adyntel/adyntel.app.mjs Updated module in the adyntel app: added keyword and countryCode properties, removed authKeys(), added methods (_baseUrl, _makeRequest, metaAdSearch, getGoogleAds, getTiktokAds) to handle API calls.
components/adyntel/package.json Updated version (from "0.0.1" to "0.1.0") and added dependency on @pipedream/platform with version constraint "^3.0.3".
components/facebook_graph_api/facebook_graph_api.app.mjs, components/gather/gather.app.mjs Added newline character at the end of the files.

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
Loading

Assessment against linked issues

Objective Addressed Explanation
Meta Ad Search endpoint accepts keyword and optional country_code [#16177]
Google Ads by Company endpoint accepts a company domain [#16177]
TikTok Ads Search endpoint accepts a keyword [#16177]

Suggested labels

ai-assisted

Suggested reviewers

  • jcortes

Poem

I'm a little rabbit hopping with glee,
New ad searches bloom for all to see.
Google, Meta, and TikTok join the chase,
In neat code lines, they find their place.
With carrots and code, I cheer this spree! 🥕✨

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

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

components/facebook_graph_api/facebook_graph_api.app.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)

components/gather/gather.app.mjs

Oops! Something went wrong! :(

ESLint: 8.57.1

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'jsonc-eslint-parser' imported from /eslint.config.mjs
at packageResolve (node:internal/modules/esm/resolve:839:9)
at moduleResolve (node:internal/modules/esm/resolve:908:18)
at defaultResolve (node:internal/modules/esm/resolve:1038:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:557:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:525:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:246:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4585648 and eedc837.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • components/facebook_graph_api/facebook_graph_api.app.mjs (1 hunks)
  • components/gather/gather.app.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • components/facebook_graph_api/facebook_graph_api.app.mjs
  • components/gather/gather.app.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 keyword and countryCode properties are clearly defined with appropriate types, labels, and descriptions. The countryCode is 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 _makeRequest method 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d5fd08 and 4585648.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is 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 axios import 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 mjs

Length 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 getGoogleAds across the codebase match the endpoint’s expected requirements.

GTFalcao
GTFalcao previously approved these changes Apr 9, 2025
Copy link
Collaborator

@GTFalcao GTFalcao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@michelle0927
Copy link
Collaborator Author

/approve

@GTFalcao GTFalcao merged commit 89cb048 into master Apr 11, 2025
11 checks passed
@GTFalcao GTFalcao deleted the issue-16177 branch April 11, 2025 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Components] adyntel

3 participants