Skip to content

[Components] goodbits #13479 #16351

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

Merged
merged 3 commits into from
Apr 28, 2025
Merged

[Components] goodbits #13479 #16351

merged 3 commits into from
Apr 28, 2025

Conversation

lcaresia
Copy link
Collaborator

@lcaresia lcaresia commented Apr 17, 2025

WHY

Summary by CodeRabbit

  • New Features

    • Introduced Goodbits integration with actions to create links, create subscribers, and update subscriber status.
    • Added support for subscriber and link attributes such as email, name, status, URL, title, description, and thumbnail options.
  • Chores

    • Updated package metadata and dependencies for the Goodbits integration.
  • Other

    • Removed obsolete files and updated internal structure for improved maintainability.

@lcaresia lcaresia self-assigned this Apr 17, 2025
Copy link

vercel bot commented Apr 17, 2025

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

Name Status Preview Comments Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 25, 2025 0:44am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
pipedream-docs ⬜️ Ignored (Inspect) Apr 25, 2025 0:44am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Apr 25, 2025 0:44am

@lcaresia lcaresia linked an issue Apr 17, 2025 that may be closed by this pull request
Copy link
Contributor

coderabbitai bot commented Apr 17, 2025

Walkthrough

This update introduces a new Goodbits app integration and three associated action modules for creating subscribers, updating subscriber status, and creating links. The new integration centralizes property definitions and API communication methods, utilizing axios for HTTP requests and supporting authentication via API key. Supporting constants are added for subscriber statuses. The previous TypeScript-based app definition is removed, along with its .gitignore file. The package metadata is updated to reflect these changes, including dependency and entry point adjustments.

Changes

File(s) Change Summary
components/goodbits/goodbits.app.mjs New Goodbits app integration module: defines property definitions for subscribers and links, and encapsulates API methods for creating subscribers, updating subscriber status, and creating links via axios-based HTTP requests.
components/goodbits/actions/create-link/create-link.mjs
components/goodbits/actions/create-subscriber/create-subscriber.mjs
components/goodbits/actions/update-subscriber-status/update-subscriber-status.mjs
New action modules: provide actions to create a link, create a subscriber, and update subscriber status using the new Goodbits app integration.
components/goodbits/common/constants.mjs New module exporting a STATUS_OPTIONS array of subscriber status strings.
components/goodbits/app/goodbits.app.ts Removed legacy TypeScript Goodbits app definition.
components/goodbits/.gitignore Deleted .gitignore file that previously ignored .js, .mjs files and the dist directory.
components/goodbits/package.json Downgraded version, changed main entry point, removed "files" field, fixed "publishConfig", and added @pipedream/platform dependency.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ActionModule as Action Module
    participant GoodbitsApp as Goodbits App Integration
    participant GoodbitsAPI as Goodbits API

    User->>ActionModule: Trigger action (e.g., Create Subscriber)
    ActionModule->>GoodbitsApp: Call method (e.g., createSubscriber)
    GoodbitsApp->>GoodbitsAPI: Send HTTP request with auth
    GoodbitsAPI-->>GoodbitsApp: API response
    GoodbitsApp-->>ActionModule: Return result
    ActionModule-->>User: Output summary and data
Loading

Poem

In the warren of code, a new app appears,
Goodbits now hops with actions and cheers!
Subscribers and links, statuses too,
Constants and methods, all shiny and new.
The old files are gone, the package is neat—
With every new feature, our burrow’s complete!
🐇✨

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/goodbits/actions/create-subscriber/create-subscriber.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/goodbits/actions/update-subscriber-status/update-subscriber-status.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/goodbits/goodbits.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 572de72 and 01e8891.

📒 Files selected for processing (3)
  • components/goodbits/actions/create-subscriber/create-subscriber.mjs (1 hunks)
  • components/goodbits/actions/update-subscriber-status/update-subscriber-status.mjs (1 hunks)
  • components/goodbits/goodbits.app.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • components/goodbits/actions/create-subscriber/create-subscriber.mjs
  • components/goodbits/goodbits.app.mjs
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (3)
components/goodbits/actions/update-subscriber-status/update-subscriber-status.mjs (3)

25-33: The method call now uses updateSubscriberStatus instead of unsubscribeSubscriber.

Great job refactoring the method name from unsubscribeSubscriber to updateSubscriberStatus - this more accurately reflects the action's purpose of updating a subscriber's status rather than just unsubscribing them.


28-32: Data structure now includes a subscriber wrapper object.

The data structure has been updated to include a nested subscriber object containing the status field. This appears to be the correct format for the Goodbits API based on the documentation referenced in the description.


3-37: This component follows good Pipedream practices.

The component is well structured with appropriate key, name, description, version, type, and props. The documentation link in the description is helpful for users to reference.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @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.

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: 4

🧹 Nitpick comments (5)
components/goodbits/package.json (1)

3-3: Version downgraded from 0.0.2 to 0.0.1?

The version has been changed from 0.0.2 to 0.0.1, which is unusual as versions typically increase, not decrease. If this is a complete rewrite of the component, consider starting at 0.1.0 instead to indicate a significant change.

components/goodbits/actions/create-link/create-link.mjs (1)

42-55: Add error handling to run method

The run method correctly calls the app's createLink method and handles the success case. Consider adding error handling to provide more descriptive error messages to users when the API request fails.

async run({ $ }) {
  try {
    const response = await this.app.createLink({
      $,
      data: {
        url: this.url,
        title: this.title,
        description: this.description,
        fetch_remote_thumbnail_url: this.fetchRemoteThumbnailUrl,
        image_candidates: this.imageCandidates,
      },
    });
    $.export("$summary", "Successfully created new link");
    return response;
+  } catch (error) {
+    $.export("$summary", `Failed to create link: ${error.message}`);
+    throw error;
+  }
},
components/goodbits/actions/create-subscriber/create-subscriber.mjs (1)

39-39: Fix summary message to include the subscriber's name or remove "named".

The summary message ends with "named" but doesn't actually include the subscriber's name, making the message incomplete.

- $.export("$summary", "Successfully created new subscriber named");
+ $.export("$summary", `Successfully created new subscriber: ${this.email}`);
components/goodbits/goodbits.app.mjs (2)

97-103: Consider adding data type validation for the createLink method.

The createLink method accepts arbitrary arguments but the endpoint likely requires specific data structures. Consider adding validation or more explicit parameters.

async createLink(args = {}) {
+  const { data } = args;
+  // Validate required fields
+  if (data && !data.url) {
+    throw new Error("URL is required for creating a link");
+  }
  return this._makeRequest({
    path: "/links",
    method: "post",
    ...args,
  });
}

1-105: Maintain consistent Content-Type headers across API requests.

The current implementation doesn't explicitly set the Content-Type header, which might be required by the Goodbits API for POST and PUT requests.

Consider updating the _makeRequest method to include a default Content-Type header for POST and PUT requests:

async _makeRequest(opts = {}) {
  const {
    $ = this,
    path,
    headers,
+   method,
    ...otherOpts
  } = opts;
+  
+  // Set default Content-Type for POST and PUT requests
+  const defaultHeaders = {};
+  if (method === "post" || method === "put") {
+    defaultHeaders["Content-Type"] = "application/json";
+  }

  return axios($, {
    ...otherOpts,
    url: this._baseUrl() + path,
+   method,
    headers: {
      "Authorization": `${this.$auth.api_key}`,
+     ...defaultHeaders,
      ...headers,
    },
  });
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0dc0ec4 and 572de72.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • components/goodbits/.gitignore (0 hunks)
  • components/goodbits/actions/create-link/create-link.mjs (1 hunks)
  • components/goodbits/actions/create-subscriber/create-subscriber.mjs (1 hunks)
  • components/goodbits/actions/update-subscriber-status/update-subscriber-status.mjs (1 hunks)
  • components/goodbits/app/goodbits.app.ts (0 hunks)
  • components/goodbits/common/constants.mjs (1 hunks)
  • components/goodbits/goodbits.app.mjs (1 hunks)
  • components/goodbits/package.json (1 hunks)
💤 Files with no reviewable changes (2)
  • components/goodbits/.gitignore
  • components/goodbits/app/goodbits.app.ts
⏰ 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 (6)
components/goodbits/package.json (2)

5-5: Main entry point updated correctly

The main entry point has been appropriately updated to reflect the new file structure without the dist directory.


14-17: Dependencies added correctly

The publishConfig bracket fix and addition of the @pipedream/platform dependency look good. This properly integrates with the Pipedream ecosystem.

components/goodbits/common/constants.mjs (1)

1-8: Well-structured constants module

This is a clean implementation of a constants module with a default export. Centralizing the subscriber status options will make maintenance easier and ensure consistency across the component.

components/goodbits/actions/create-link/create-link.mjs (1)

3-9: Well-defined action metadata

The action is well structured with clear key, name, description, and version information. The reference to documentation is helpful for users.

components/goodbits/actions/update-subscriber-status/update-subscriber-status.mjs (1)

3-9: Well-defined action metadata

The action metadata is properly structured with clear key, name, description, and version information. Documentation reference is helpful.

components/goodbits/goodbits.app.mjs (1)

76-76:

✅ Verification successful

Verify the authorization header format.

Ensure that the authorization header format is correct for the Goodbits API. Many APIs require a format like "Bearer {token}" or "Basic {credentials}".


🌐 Web query:

What is the correct authorization header format for Goodbits API?

💡 Result:

Goodbits API Authorization Header Format

To correctly authenticate API requests to the Goodbits API, you must include an HTTP header called Authorization with your API key as its value. According to the official Goodbits documentation, the format is:

Authorization: <your_api_key>

This means:

  • The header key is Authorization
  • The header value is simply your API key without any "Bearer", "Basic", or other prefix[1]

For example, using curl:

curl -H "Authorization: YOUR_API_KEY" https://api.goodbits.io/v1/some-endpoint

This format differs from the more common Bearer token style seen in many other APIs.

"To authenticate the API request, an authorization header key 'Authorization' is required. This will authenticate the newsletter and scope the ..." [1]

Summary Table

Header Value Example
Authorization YOUR_API_KEY Authorization: abcd1234xyZ

Note: Always refer to the [official Goodbits support documentation][1] for up-to-date details and security best practices.

[1]

Citations:


Authorization header format confirmed

The Goodbits API expects the Authorization header value to be only your API key (no Bearer or other prefix). The existing line:

"Authorization": `${this.$auth.api_key}`,

matches the documented format. No changes needed.

Comment on lines 24 to 34
async run({ $ }) {
const response = await this.app.unsubscribeSubscriber({
$,
email: this.email,
data: {
status: this.status,
},
});
$.export("$summary", "Successfully uptated subscriber status");
return response;
},
Copy link
Contributor

@coderabbitai coderabbitai bot Apr 17, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Fix typo in success message and consider method naming

There's a typo in the success message: "uptated" should be "updated". Also, the method name "unsubscribeSubscriber" doesn't fully reflect the action's purpose of updating a subscriber's status (not just unsubscribing).

async run({ $ }) {
  const response = await this.app.unsubscribeSubscriber({
    $,
    email: this.email,
    data: {
      status: this.status,
    },
  });
-  $.export("$summary", "Successfully uptated subscriber status");
+  $.export("$summary", "Successfully updated subscriber status");
  return response;
},

Verify if the method name in the app file matches the actual functionality:


🏁 Script executed:

#!/bin/bash
# Check if the method name in the app file is 'unsubscribeSubscriber' or 'updateSubscriberStatus'
grep -A 10 "unsubscribeSubscriber\|updateSubscriberStatus" components/goodbits/goodbits.app.mjs

Length of output: 357


Fix typo in success message and improve method naming

  • In components/goodbits/actions/update-subscriber-status/update-subscriber-status.mjs:
    • Correct the typo in the summary export.
  • In components/goodbits/goodbits.app.mjs:
    • The unsubscribeSubscriber method actually issues a PUT to update subscriber data. Consider renaming it (e.g. to updateSubscriberStatus or updateSubscriber) to better reflect its behavior—and update all callers accordingly.
 async run({ $ }) {
   const response = await this.app.unsubscribeSubscriber({
     $,
     email: this.email,
     data: {
       status: this.status,
     },
   });
-  $.export("$summary", "Successfully uptated subscriber status");
+  $.export("$summary", "Successfully updated subscriber status");
   return response;
 },
📝 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 run({ $ }) {
const response = await this.app.unsubscribeSubscriber({
$,
email: this.email,
data: {
status: this.status,
},
});
$.export("$summary", "Successfully uptated subscriber status");
return response;
},
async run({ $ }) {
const response = await this.app.unsubscribeSubscriber({
$,
email: this.email,
data: {
status: this.status,
},
});
$.export("$summary", "Successfully updated subscriber status");
return response;
},

Copy link
Collaborator

Choose a reason for hiding this comment

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

typo!

Copy link
Contributor

Choose a reason for hiding this comment

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

@jcortes Yes, there's a typo in the success message! As suggested in my previous comment, changing "uptated" to "updated" in the summary export will fix this issue:

- $.export("$summary", "Successfully uptated subscriber status");
+ $.export("$summary", "Successfully updated subscriber status");

Would you like me to address any other aspects of the code as well?

Copy link
Collaborator

@jcortes jcortes 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 there are only two suggested changes other than that lgtm! Ready for QA!

@@ -1,16 +1,18 @@
{
"name": "@pipedream/goodbits",
"version": "0.0.2",
"version": "0.0.1",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"version": "0.0.1",
"version": "0.1.0",

Comment on lines 24 to 34
async run({ $ }) {
const response = await this.app.unsubscribeSubscriber({
$,
email: this.email,
data: {
status: this.status,
},
});
$.export("$summary", "Successfully uptated subscriber status");
return response;
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

typo!

@GTFalcao
Copy link
Collaborator

The package version still needs to be updated to 0.1.0 as per @jcortes 's suggestion.

@lcaresia
Copy link
Collaborator Author

/approve

@lcaresia lcaresia merged commit acb8255 into master Apr 28, 2025
11 checks passed
@lcaresia lcaresia deleted the issue-13479 branch April 28, 2025 17:23
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] goodbits
3 participants