Skip to content

[Components] hypeauditor #14942 #15288

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
Jan 16, 2025
Merged

[Components] hypeauditor #14942 #15288

merged 3 commits into from
Jan 16, 2025

Conversation

lcaresia
Copy link
Collaborator

@lcaresia lcaresia commented Jan 13, 2025

WHY

Summary by CodeRabbit

  • New Features

    • Added support for fetching reports from HypeAuditor for Instagram, TikTok, and YouTube.
    • Introduced new methods to retrieve social media channel analytics.
  • Improvements

    • Improved request handling with a more robust API request method.
    • Added support for multiple identifier types (username, user ID, channel username, channel ID).
  • Version Update

    • Upgraded component version from 0.0.1 to 0.1.0.

@lcaresia lcaresia self-assigned this Jan 13, 2025
Copy link

vercel bot commented Jan 13, 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 Jan 13, 2025 9:18pm
pipedream-docs ⬜️ Ignored (Inspect) Jan 13, 2025 9:18pm
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jan 13, 2025 9:18pm

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Walkthrough

This pull request introduces new modules for fetching reports from the HypeAuditor API across three different platforms: Instagram, TikTok, and YouTube. The changes include creating action modules for each platform with specific methods to retrieve reports, updating the main HypeAuditor application file with new properties and request methods, and incrementing the package version. The implementation provides a consistent approach to fetching reports by validating input parameters and making API requests.

Changes

File Change Summary
components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs New action module for fetching Instagram reports
components/hypeauditor/actions/get-tiktok-report/get-tiktok-report.mjs New action module for fetching TikTok reports
components/hypeauditor/actions/get-youtube-report/get-youtube-report.mjs New action module for fetching YouTube reports
components/hypeauditor/hypeauditor.app.mjs Added new prop definitions, _makeRequest method, and platform-specific report fetching methods
components/hypeauditor/package.json Version bumped to 0.1.0, added @pipedream/platform dependency

Sequence Diagram

sequenceDiagram
    participant User
    participant Action
    participant HypeAuditorApp
    participant HypeAuditorAPI

    User->>Action: Provide platform identifier
    Action->>HypeAuditorApp: Call report fetching method
    HypeAuditorApp->>HypeAuditorAPI: Make authenticated request
    HypeAuditorAPI-->>HypeAuditorApp: Return report data
    HypeAuditorApp-->>Action: Return full response
    Action-->>User: Provide report details
Loading

Possibly related PRs

Suggested labels

action, trigger / source

Suggested reviewers

  • jcortes

Poem

🐰 Hop, hop, through APIs we go,
Fetching reports with rabbit-like flow!
Instagram, TikTok, YouTube in sight,
HypeAuditor's data shining bright!
A digital warren of insights so clear,
Reporting magic is finally here! 🚀


📜 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 e28f3a4 and c97aca9.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
  • GitHub Check: Publish TypeScript components

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@lcaresia lcaresia linked an issue Jan 13, 2025 that may be closed by this pull request
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: 6

🧹 Nitpick comments (2)
components/hypeauditor/hypeauditor.app.mjs (1)

33-35: Consider making the base URL configurable.

The base URL is hardcoded. Consider moving it to the app's configuration to support different environments (e.g., staging, production).

-    _baseUrl() {
-      return "https://hypeauditor.com/api/method";
-    },
+    _baseUrl() {
+      return this.$auth.base_url || "https://hypeauditor.com/api/method";
+    },
components/hypeauditor/actions/get-tiktok-report/get-tiktok-report.mjs (1)

6-8: Improve documentation link formatting.

The documentation link in the description could be more descriptive.

-  description: "Returns a report about the specified Tiktok channel. [See the documentation](https://hypeauditor.readme.io/reference/get_report_tiktok)",
+  description: "Returns a report about the specified TikTok channel. [See the TikTok Report API documentation](https://hypeauditor.readme.io/reference/get_report_tiktok)",
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2e729e5 and e28f3a4.

📒 Files selected for processing (5)
  • components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs (1 hunks)
  • components/hypeauditor/actions/get-tiktok-report/get-tiktok-report.mjs (1 hunks)
  • components/hypeauditor/actions/get-youtube-report/get-youtube-report.mjs (1 hunks)
  • components/hypeauditor/hypeauditor.app.mjs (1 hunks)
  • components/hypeauditor/package.json (2 hunks)
🧰 Additional context used
🪛 GitHub Actions: Pull Request Checks
components/hypeauditor/package.json

[error] Lock file (pnpm-lock.yaml) is out of sync with package.json. Package @pipedream/platform@^3.0.3 is specified in package.json but not in lockfile.

🪛 GitHub Actions: Components Checks
components/hypeauditor/package.json

[error] Lockfile (pnpm-lock.yaml) is out of sync with package.json. Package @pipedream/platform@^3.0.3 is missing in lockfile.

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: pnpm publish
🔇 Additional comments (2)
components/hypeauditor/actions/get-instagram-report/get-instagram-report.mjs (1)

31-38: Consider making the version parameter configurable.

The version parameter is hardcoded to "2". Consider making it configurable or documenting why this specific version is required.

components/hypeauditor/package.json (1)

3-3: Version bump looks appropriate.

The minor version increment (0.0.1 → 0.1.0) aligns with semver for the addition of new features (Instagram, TikTok, and YouTube report actions) without breaking changes.

Let's verify if this follows the repository's versioning guidelines:

✅ Verification successful

Version bump follows repository patterns and semantic versioning.

The change from 0.0.1 to 0.1.0 aligns with both semantic versioning principles and the repository's common versioning patterns for stable feature releases.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check other components' version bumps for consistency
fd package.json components/ -x jq -r '. | select(.version != null) | "\(.name): \(.version)"' {} \; | sort

Length of output: 64773

🧰 Tools
🪛 GitHub Actions: Pull Request Checks

[error] Lock file (pnpm-lock.yaml) is out of sync with package.json. Package @pipedream/platform@^3.0.3 is specified in package.json but not in lockfile.

🪛 GitHub Actions: Components Checks

[error] Lockfile (pnpm-lock.yaml) is out of sync with package.json. Package @pipedream/platform@^3.0.3 is missing in lockfile.

Comment on lines +69 to +74
async getTiktokReport(args = {}) {
return this._makeRequest({
path: "/auditor.tiktok",
method: "post",
...args,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix inconsistent path format in getTiktokReport.

The getTiktokReport method uses a different path format compared to other methods (missing trailing slash).

     async getTiktokReport(args = {}) {
       return this._makeRequest({
-        path: "/auditor.tiktok",
+        path: "/auditor.tiktok/",
         method: "post",
         ...args,
       });
📝 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.

Suggested change
async getTiktokReport(args = {}) {
return this._makeRequest({
path: "/auditor.tiktok",
method: "post",
...args,
});
async getTiktokReport(args = {}) {
return this._makeRequest({
path: "/auditor.tiktok/",
method: "post",
...args,
});

Comment on lines +36 to +54
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"content-type": "application/x-www-form-urlencoded",
"x-auth-id": `${this.$auth.client_id}`,
"x-auth-token": `${this.$auth.api_token}`,
"user-agent": "pipedream/1",
},
});
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add error handling and request timeout.

The _makeRequest method lacks error handling and request timeout configuration.

     async _makeRequest(opts = {}) {
       const {
         $ = this,
         path,
         headers,
+        timeout = 10000,
         ...otherOpts
       } = opts;
-      return axios($, {
-        ...otherOpts,
-        url: this._baseUrl() + path,
-        headers: {
-          ...headers,
-          "content-type": "application/x-www-form-urlencoded",
-          "x-auth-id": `${this.$auth.client_id}`,
-          "x-auth-token": `${this.$auth.api_token}`,
-          "user-agent": "pipedream/1",
-        },
-      });
+      try {
+        return await axios($, {
+          ...otherOpts,
+          url: this._baseUrl() + path,
+          timeout,
+          headers: {
+            ...headers,
+            "content-type": "application/x-www-form-urlencoded",
+            "x-auth-id": `${this.$auth.client_id}`,
+            "x-auth-token": `${this.$auth.api_token}`,
+            "user-agent": "pipedream/1",
+          },
+        });
+      } catch (err) {
+        const statusCode = err.response?.status;
+        const message = err.response?.data?.message || err.message;
+        throw new Error(`HypeAuditor API request failed: ${statusCode} - ${message}`);
+      }
     },
📝 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.

Suggested change
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
"content-type": "application/x-www-form-urlencoded",
"x-auth-id": `${this.$auth.client_id}`,
"x-auth-token": `${this.$auth.api_token}`,
"user-agent": "pipedream/1",
},
});
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
timeout = 10000,
...otherOpts
} = opts;
try {
return await axios($, {
...otherOpts,
url: this._baseUrl() + path,
timeout,
headers: {
...headers,
"content-type": "application/x-www-form-urlencoded",
"x-auth-id": `${this.$auth.client_id}`,
"x-auth-token": `${this.$auth.api_token}`,
"user-agent": "pipedream/1",
},
});
} catch (err) {
const statusCode = err.response?.status;
const message = err.response?.data?.message || err.message;
throw new Error(`HypeAuditor API request failed: ${statusCode} - ${message}`);
}
},

Comment on lines +33 to +35
data: {
channel: this.channelId ?? this.channelUsername,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Inconsistent parameter handling between actions.

The YouTube report uses data object while Instagram uses params. This inconsistency could lead to confusion.

-      data: {
+      params: {
         channel: this.channelId ?? this.channelUsername,
       },
📝 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.

Suggested change
data: {
channel: this.channelId ?? this.channelUsername,
},
params: {
channel: this.channelId ?? this.channelUsername,
},

Comment on lines +23 to +26
data: {
channel: this.channelUsername,
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Inconsistent parameter handling in TikTok report.

The TikTok report uses data object while Instagram uses params. Maintain consistency across actions.

-      data: {
+      params: {
         channel: this.channelUsername,
       },
📝 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.

Suggested change
data: {
channel: this.channelUsername,
},
});
params: {
channel: this.channelUsername,
},
});

Comment on lines +15 to 17
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Update the lock file to include the new dependency.

The pipeline is failing because the lock file (pnpm-lock.yaml) is out of sync with package.json. The new dependency @pipedream/platform@^3.0.3 needs to be added to the lock file.

Run the following commands to fix this:

pnpm install
git add pnpm-lock.yaml
git commit -m "chore: update lock file for @pipedream/platform dependency"
🧰 Tools
🪛 GitHub Actions: Pull Request Checks

[error] Lock file (pnpm-lock.yaml) is out of sync with package.json. Package @pipedream/platform@^3.0.3 is specified in package.json but not in lockfile.

🪛 GitHub Actions: Components Checks

[error] Lockfile (pnpm-lock.yaml) is out of sync with package.json. Package @pipedream/platform@^3.0.3 is missing in lockfile.

lcaresia and others added 2 commits January 13, 2025 18:17
…ram-report.mjs

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Collaborator

@luancazarine luancazarine left a comment

Choose a reason for hiding this comment

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

Hi @lcaresia, LGTM! Ready for QA!

@vunguyenhung vunguyenhung merged commit 0cc715b into master Jan 16, 2025
11 checks passed
@vunguyenhung vunguyenhung deleted the issue-14942 branch January 16, 2025 01:53
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Components] hypeauditor
3 participants