Skip to content

Membado new components #16644

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 4 commits into from
May 14, 2025
Merged

Membado new components #16644

merged 4 commits into from
May 14, 2025

Conversation

GTFalcao
Copy link
Collaborator

@GTFalcao GTFalcao commented May 13, 2025

Closes #16568

Membado's API documentation only mentions 1 single endpoint, so I created an action component for it. Other components listed in the issue were likely AI hallucinations.

Summary by CodeRabbit

  • New Features

    • Introduced the ability to add or remove tags from a user in the Membado integration using their email address.
  • Chores

    • Updated package version and dependencies for improved compatibility and stability.

Copy link

vercel bot commented May 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 May 13, 2025 4:20am
pipedream-docs ⬜️ Ignored (Inspect) May 13, 2025 4:20am
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) May 13, 2025 4:20am

Copy link
Contributor

coderabbitai bot commented May 13, 2025

Walkthrough

A new action for adding or removing tags from a user in the Membado integration was introduced. The Membado app was refactored to centralize API request logic and expose a method for adding members. The package metadata was updated, including a version bump and a new dependency.

Changes

Files/Groups Change Summary
components/membado/actions/add-remove-tags/add-remove-tags.mjs Added new action to add or remove tags from a user by email, interfacing with the Membado API.
components/membado/membado.app.mjs Refactored to add centralized _baseRequest method, public addMember method, and removed unused code.
components/membado/package.json Updated version to 0.1.0, added @pipedream/platform dependency, and fixed JSON structure.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AddRemoveTagsAction
    participant MembadoApp
    participant MembadoAPI

    User->>AddRemoveTagsAction: Provide email, tags to add/remove
    AddRemoveTagsAction->>MembadoApp: call addMember(email, tagsAdd, tagsRemove)
    MembadoApp->>MembadoAPI: POST /add-member with email, tagsAdd, tagsRemove, API key
    MembadoAPI-->>MembadoApp: Response
    MembadoApp-->>AddRemoveTagsAction: Response
    AddRemoveTagsAction-->>User: Summary and API response
Loading

Assessment against linked issues

Objective Addressed Explanation
Add Membado actions such as create-member, create-event, record-payment (from #16568) Only an action for adding/removing tags was implemented; create-member, create-event, record-payment are missing.
Refactor Membado app to centralize API requests and expose member-related methods (from #16568)

Suggested labels

action

Poem

A hop and a skip, new tags we bestow,
Membado’s users get labels in tow!
With code refactored and actions anew,
The rabbit’s delighted—so much to do!
Version bumped up, dependencies in line,
Tagging with ease—oh, isn’t that fine?
🐇✨

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/membado/actions/add-remove-tags/add-remove-tags.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/membado/membado.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)

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.

✨ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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

🧹 Nitpick comments (3)
components/membado/actions/add-remove-tags/add-remove-tags.mjs (2)

41-47: Consider adding error handling.

The code doesn't explicitly handle potential API errors. Consider adding try/catch blocks to provide more specific error messages to users.

async run({ $ }) {
-    const response = await this.membado.addMember({
-      $,
-      data: {
-        mail: this.mail,
-        tags_add: this.tagsAdd?.join?.() ?? this.tagsAdd,
-        tags_remove: this.tagsRemove?.join?.() ?? this.tagsRemove,
-      },
-    });
+    try {
+      const response = await this.membado.addMember({
+        $,
+        data: {
+          mail: this.mail,
+          tags_add: this.tagsAdd?.join?.() ?? this.tagsAdd,
+          tags_remove: this.tagsRemove?.join?.() ?? this.tagsRemove,
+        },
+      });
+      
+      $.export(
+        "$summary",
+        `Successfully changed tags for ${this.mail}`,
+      );
+      
+      return response;
+    } catch (error) {
+      $.export("$summary", `Failed to change tags for ${this.mail}: ${error.message}`);
+      throw error;
+    }
}

-    $.export(
-      "$summary",
-      `Successfully changed tags for ${this.mail}`,
-    );
-
-    return response;

32-38: Add validation for tag parameters.

Consider adding validation to ensure at least one of tagsAdd or tagsRemove is provided, as the action doesn't make sense without adding or removing tags.

async run({ $ }) {
+    // Ensure at least one tag operation is being performed
+    if ((!this.tagsAdd || !this.tagsAdd.length) && (!this.tagsRemove || !this.tagsRemove.length)) {
+      throw new Error("At least one tag must be provided to add or remove");
+    }
+
    const response = await this.membado.addMember({
      $,
      data: {
        mail: this.mail,
        tags_add: this.tagsAdd?.join?.() ?? this.tagsAdd,
        tags_remove: this.tagsRemove?.join?.() ?? this.tagsRemove,
      },
    });
components/membado/membado.app.mjs (1)

8-23: Add error handling in the base request method.

Consider enhancing the _baseRequest method to include error handling specific to Membado's API responses.

_baseRequest({
  $, data, headers, ...args
}) {
-  return axios($, {
-    baseURL: `https://www.membado.io/api/${this.$auth.user_identifier}`,
-    data: {
-      ...data,
-      apikey: this.$auth.api_key,
-    },
-    headers: {
-      ...headers,
-      "content-type": "application/x-www-form-urlencoded",
-    },
-    ...args,
-  });
+  return axios($, {
+    baseURL: `https://www.membado.io/api/${this.$auth.user_identifier}`,
+    data: {
+      ...data,
+      apikey: this.$auth.api_key,
+    },
+    headers: {
+      ...headers,
+      "content-type": "application/x-www-form-urlencoded",
+    },
+    ...args,
+  })
+    .catch((error) => {
+      const status = error.response?.status;
+      const message = error.response?.data?.message || error.message;
+      
+      if (status === 401) {
+        throw new Error(`Authentication error: ${message}`);
+      }
+      
+      throw new Error(`Membado API error (${status}): ${message}`);
+    });
},
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 09c3714 and b121995.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • components/membado/actions/add-remove-tags/add-remove-tags.mjs (1 hunks)
  • components/membado/membado.app.mjs (1 hunks)
  • components/membado/package.json (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (8)
components/membado/package.json (2)

3-3: Version bump from 0.0.1 to 0.1.0 is appropriate.

This version increment aligns with the introduction of a new action component.


14-17: Good fix and dependency addition.

Fixed the JSON structure with the closing brace and properly added the required dependency for the axios HTTP client.

components/membado/actions/add-remove-tags/add-remove-tags.mjs (3)

3-9: Well-documented component with clear purpose.

The component has good documentation with a link to the Membado API documentation for reference.


10-30: Props are well defined with clear descriptions.

The props are appropriately defined with proper types and descriptions. Making the tag properties optional allows for flexibility in usage.


31-39:

❓ Verification inconclusive

Verify array joining behavior for tag parameters.

The code currently joins arrays without specifying a separator, which defaults to commas. Ensure that this format is expected by the Membado API.


🏁 Script executed:

#!/bin/bash
# Check for any information about the expected format for tags in the Membado app
grep -r "tags" --include="*.mjs" components/membado/

Length of output: 1039


Verify tags_add/tags_remove formatting against the Membado API docs

Ensure that the tags_add and tags_remove parameters—currently constructed via array.join() (which produces a comma-separated string)—match the format expected by the Membado API. If the API accepts a JSON array instead, remove the .join() calls and pass the raw array.

• File: components/membado/actions/add-remove-tags/add-remove-tags.mjs
Lines: 31–39

  tags_add: this.tagsAdd?.join?.() ?? this.tagsAdd,
  tags_remove: this.tagsRemove?.join?.() ?? this.tagsRemove,

• Refer to the embedded documentation link in this file for the API’s expected payload:
https://membado.zendesk.com/hc/de/articles/18155937106204-API-Documentation

components/membado/membado.app.mjs (3)

1-2: Good addition of the platform import.

This correctly imports axios from the Pipedream platform for HTTP requests.


8-23: Well-structured base request method.

The _baseRequest method properly centralizes HTTP request logic, including:

  • Setting the base URL with auth parameters
  • Merging provided data with the API key
  • Setting appropriate content type headers
  • Allowing additional request parameters to be passed through

This approach promotes code reuse and maintainability.


24-30:

✅ Verification successful

Implement additional API methods.

The addMember method is well-implemented, but consider adding additional helper methods for other Membado API endpoints if they exist, to maintain consistency in the integration.


🌐 Web query:

What endpoints are available in the Membado API?

💡 Result:

Membado API Endpoints

The Membado API currently documents the following endpoint:

/add-member

  • Purpose: Assign or remove tags from a user based on their email address. No email is sent, and no user account is created in Membado by this operation.

  • Special behavior:

    • If the user does not already exist, the tags are stored to be assigned automatically when/if the user registers in the future.
    • If a tag is linked to a course in a Membado community, the user will be invited to the respective community.
  • Method: POST

  • Key parameters:

    • apikey (string, required): Your API key.
    • mail (string, required): The user's email address.
    • tags_add (string, optional): Comma-separated tag IDs to assign.
    • tags_remove (string, optional): Comma-separated tag IDs to remove.
  • Example Usage:

    POST https://www.membado.io/api/xx/add-member
    
    Body:
    apikey: your_api_key_here
    mail: [email protected]
    tags_add: 123,456,789
    tags_remove: 101,202
    
  • Success Response: HTTP 200 OK

  • Failure Response: HTTP 400 Bad Request (possible causes: invalid/missing API key, invalid/missing parameters, or invalid tag IDs)[1].

Additional Notes

  • The base URL for the API is unique to each user and can be found in the Community Settings menu under "API", in the format:
    https://www.membado.io/api/xx
    
    where xx is your unique identifier[1].
  • Currently, only the /add-member endpoint is officially documented and available for assigning/removing tags from users. Other endpoints are not listed in the official documentation provided.

Summary

Endpoint Method Description
/add-member POST Assign or remove tags from a user by email

For further functionality (such as user creation, data retrieval, or other integrations), no other specific API endpoints are documented in the available resources as of now[1].

Citations:


No Additional Membado API Endpoints Available
The Membado API currently only documents the /add-member endpoint. Since no other endpoints exist at this time, no additional helper methods are needed. If new endpoints are released in the future, consider adding corresponding methods then.

Copy link
Collaborator

@michelle0927 michelle0927 left a comment

Choose a reason for hiding this comment

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

LGTM!

@GTFalcao GTFalcao merged commit 921ff74 into master May 14, 2025
11 checks passed
@GTFalcao GTFalcao deleted the 16568-membado-new-components branch May 14, 2025 04:39
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] membado
2 participants