Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import app from "../../hypeauditor.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "hypeauditor-get-instagram-report",
name: "Get Instagram Report",
description: "Returns a report about the specified Instagram user. [See the documentation](https://hypeauditor.readme.io/reference/report_instagram#requests)",
version: "0.0.1",
type: "action",
props: {
app,
username: {
propDefinition: [
app,
"username",
],
},
userId: {
propDefinition: [
app,
"userId",
],
},
},

async run({ $ }) {
if (!this.userId && !this.username) {
throw new ConfigurationError("You need to inform a Channel ID or Channel Username");
}

const response = await this.app.getInstagramReport({
$,
params: {
username: this.userId ?? this.username,
v: "2",
},

});

$.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import app from "../../hypeauditor.app.mjs";

export default {
key: "hypeauditor-get-tiktok-report",
name: "Get Tiktok Report",
description: "Returns a report about the specified Tiktok channel. [See the documentation](https://hypeauditor.readme.io/reference/get_report_tiktok)",
version: "0.0.1",
type: "action",
props: {
app,
channelUsername: {
propDefinition: [
app,
"channelUsername",
],
optional: false,
},
},

async run({ $ }) {
const response = await this.app.getTiktokReport({
$,
data: {
channel: this.channelUsername,
},
});
Comment on lines +23 to +26
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,
},
});

$.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`);

return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import app from "../../hypeauditor.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "hypeauditor-get-youtube-report",
name: "Get Youtube Report",
description: "Returns a report about the specified Youtube channel. [See the documentation](https://hypeauditor.readme.io/reference/report_youtube)",
version: "0.0.1",
type: "action",
props: {
app,
channelId: {
propDefinition: [
app,
"channelId",
],
},
channelUsername: {
propDefinition: [
app,
"channelUsername",
],
},
},

async run({ $ }) {
if (!this.channelId && !this.channelUsername) {
throw new ConfigurationError("You need to inform a Channel ID or Channel Username");
}

const response = await this.app.getYoutubeReport({
$,
data: {
channel: this.channelId ?? this.channelUsername,
},
Comment on lines +33 to +35
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,
},

});

$.export("$summary", `Successfully sent the request. Report state: '${response.result.report_state}'`);

return response;
},
};
74 changes: 70 additions & 4 deletions components/hypeauditor/hypeauditor.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,77 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "hypeauditor",
propDefinitions: {},
propDefinitions: {
username: {
type: "string",
label: "Username",
description: "Username to request the report",
optional: true,
},
userId: {
type: "string",
label: "User ID",
description: "User ID to request the report",
optional: true,
},
channelUsername: {
type: "string",
label: "Channel Username",
description: "Identify the user by their Channel Username",
optional: true,
},
channelId: {
type: "string",
label: "Channel ID",
description: "Identify the user by their Channel ID",
optional: true,
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://hypeauditor.com/api/method";
},
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",
},
});
},
Comment on lines +36 to +54
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}`);
}
},

async getInstagramReport(args = {}) {
return this._makeRequest({
path: "/auditor.report/",
method: "post",
...args,
});
},
async getYoutubeReport(args = {}) {
return this._makeRequest({
path: "/auditor.youtube/",
method: "post",
...args,
});
},
async getTiktokReport(args = {}) {
return this._makeRequest({
path: "/auditor.tiktok",
method: "post",
...args,
});
Comment on lines +69 to +74
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,
});

},
},
};
7 changes: 5 additions & 2 deletions components/hypeauditor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/hypeauditor",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream HypeAuditor Components",
"main": "hypeauditor.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
Comment on lines +15 to 17
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.

}
}
Loading