Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Jan 24, 2025

Resolves #15393

Summary by CodeRabbit

  • Version Updates

    • Updated version numbers for multiple HubSpot components across actions, sources, and core app files
    • Package version incremented from 0.13.1 to 0.13.2
  • New Features

    • Added rate limiting mechanism to HubSpot API requests to improve API compliance
  • Minor Changes

    • Added updateIfExists property to contact creation action
    • Updated lead creation to include association with primary contact

These updates represent minor improvements and version maintenance for the HubSpot integration.

@vercel
Copy link

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

Walkthrough

This pull request introduces a rate-limiting mechanism to the HubSpot integration by implementing Bottleneck in the hubspot.app.mjs file. The changes include adding a rate limiter to control API requests, ensuring a minimum time of 250 milliseconds between requests and a maximum of one concurrent request. Additionally, multiple components have had their version numbers incrementally updated, reflecting minor updates across the HubSpot integration.

Changes

File Change Summary
components/hubspot/hubspot.app.mjs Added Bottleneck rate limiter for API requests
components/hubspot/sources/common/common.mjs Removed existing rate-limiting methods
components/hubspot/package.json Version updated from "0.13.1" to "0.13.2"
Multiple HubSpot action and source files Version numbers incrementally updated

Assessment against linked issues

Objective Addressed Explanation
Use Bottleneck for all requests [#15393]

Possibly related PRs

Suggested labels

rate-limiting, hubspot-integration, api-optimization

Suggested reviewers

  • GTFalcao
  • jcortes

Poem

🐰 Hop, hop, rate limit's here to stay,
Bottleneck dancing in a rhythmic sway,
API calls now flow with grace,
No more requests in a frantic race,
HubSpot integration's smooth ballet! 🚀


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.

@michelle0927 michelle0927 marked this pull request as ready for review January 24, 2025 21:27
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 (1)
components/hubspot/hubspot.app.mjs (1)

16-21: Centralized rate limiter setup looks good.
Instantiating a Bottleneck limiter and wrapping axios should provide consistent rate-limiting across the app.

Consider using built-in retry or backoff options to handle 429 rate limit errors gracefully, in case HubSpot’s limit is exceeded.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4546757 and 515d539.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (49)
  • components/hubspot/actions/add-contact-to-list/add-contact-to-list.mjs (1 hunks)
  • components/hubspot/actions/batch-create-or-update-contact/batch-create-or-update-contact.mjs (1 hunks)
  • components/hubspot/actions/create-associations/create-associations.mjs (1 hunks)
  • components/hubspot/actions/create-communication/create-communication.mjs (1 hunks)
  • components/hubspot/actions/create-company/create-company.mjs (1 hunks)
  • components/hubspot/actions/create-custom-object/create-custom-object.mjs (1 hunks)
  • components/hubspot/actions/create-deal/create-deal.mjs (1 hunks)
  • components/hubspot/actions/create-engagement/create-engagement.mjs (1 hunks)
  • components/hubspot/actions/create-lead/create-lead.mjs (1 hunks)
  • components/hubspot/actions/create-or-update-contact/create-or-update-contact.mjs (1 hunks)
  • components/hubspot/actions/create-ticket/create-ticket.mjs (1 hunks)
  • components/hubspot/actions/enroll-contact-into-workflow/enroll-contact-into-workflow.mjs (1 hunks)
  • components/hubspot/actions/get-company/get-company.mjs (1 hunks)
  • components/hubspot/actions/get-contact/get-contact.mjs (1 hunks)
  • components/hubspot/actions/get-deal/get-deal.mjs (1 hunks)
  • components/hubspot/actions/get-file-public-url/get-file-public-url.mjs (1 hunks)
  • components/hubspot/actions/search-crm/search-crm.mjs (1 hunks)
  • components/hubspot/actions/update-company/update-company.mjs (1 hunks)
  • components/hubspot/actions/update-contact/update-contact.mjs (1 hunks)
  • components/hubspot/actions/update-custom-object/update-custom-object.mjs (1 hunks)
  • components/hubspot/actions/update-deal/update-deal.mjs (1 hunks)
  • components/hubspot/actions/update-lead/update-lead.mjs (1 hunks)
  • components/hubspot/hubspot.app.mjs (2 hunks)
  • components/hubspot/package.json (1 hunks)
  • components/hubspot/sources/common/common.mjs (2 hunks)
  • components/hubspot/sources/delete-blog-article/delete-blog-article.mjs (1 hunks)
  • components/hubspot/sources/new-company-property-change/new-company-property-change.mjs (1 hunks)
  • components/hubspot/sources/new-contact-property-change/new-contact-property-change.mjs (1 hunks)
  • components/hubspot/sources/new-custom-object-property-change/new-custom-object-property-change.mjs (1 hunks)
  • components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs (1 hunks)
  • components/hubspot/sources/new-deal-property-change/new-deal-property-change.mjs (1 hunks)
  • components/hubspot/sources/new-email-event/new-email-event.mjs (1 hunks)
  • components/hubspot/sources/new-email-subscriptions-timeline/new-email-subscriptions-timeline.mjs (1 hunks)
  • components/hubspot/sources/new-engagement/new-engagement.mjs (1 hunks)
  • components/hubspot/sources/new-event/new-event.mjs (1 hunks)
  • components/hubspot/sources/new-form-submission/new-form-submission.mjs (1 hunks)
  • components/hubspot/sources/new-note/new-note.mjs (1 hunks)
  • components/hubspot/sources/new-or-updated-blog-article/new-or-updated-blog-article.mjs (1 hunks)
  • components/hubspot/sources/new-or-updated-company/new-or-updated-company.mjs (1 hunks)
  • components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs (1 hunks)
  • components/hubspot/sources/new-or-updated-crm-object/new-or-updated-crm-object.mjs (1 hunks)
  • components/hubspot/sources/new-or-updated-custom-object/new-or-updated-custom-object.mjs (1 hunks)
  • components/hubspot/sources/new-or-updated-deal/new-or-updated-deal.mjs (1 hunks)
  • components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs (1 hunks)
  • components/hubspot/sources/new-or-updated-product/new-or-updated-product.mjs (1 hunks)
  • components/hubspot/sources/new-social-media-message/new-social-media-message.mjs (1 hunks)
  • components/hubspot/sources/new-task/new-task.mjs (1 hunks)
  • components/hubspot/sources/new-ticket-property-change/new-ticket-property-change.mjs (1 hunks)
  • components/hubspot/sources/new-ticket/new-ticket.mjs (1 hunks)
✅ Files skipped from review due to trivial changes (45)
  • components/hubspot/sources/new-ticket-property-change/new-ticket-property-change.mjs
  • components/hubspot/sources/new-or-updated-custom-object/new-or-updated-custom-object.mjs
  • components/hubspot/sources/new-or-updated-blog-article/new-or-updated-blog-article.mjs
  • components/hubspot/actions/create-engagement/create-engagement.mjs
  • components/hubspot/actions/update-contact/update-contact.mjs
  • components/hubspot/sources/new-task/new-task.mjs
  • components/hubspot/sources/new-ticket/new-ticket.mjs
  • components/hubspot/actions/update-company/update-company.mjs
  • components/hubspot/package.json
  • components/hubspot/actions/create-ticket/create-ticket.mjs
  • components/hubspot/sources/new-engagement/new-engagement.mjs
  • components/hubspot/sources/new-email-subscriptions-timeline/new-email-subscriptions-timeline.mjs
  • components/hubspot/sources/new-form-submission/new-form-submission.mjs
  • components/hubspot/actions/create-company/create-company.mjs
  • components/hubspot/actions/create-deal/create-deal.mjs
  • components/hubspot/actions/get-file-public-url/get-file-public-url.mjs
  • components/hubspot/actions/add-contact-to-list/add-contact-to-list.mjs
  • components/hubspot/sources/new-or-updated-product/new-or-updated-product.mjs
  • components/hubspot/actions/create-custom-object/create-custom-object.mjs
  • components/hubspot/actions/create-communication/create-communication.mjs
  • components/hubspot/actions/update-custom-object/update-custom-object.mjs
  • components/hubspot/actions/get-contact/get-contact.mjs
  • components/hubspot/sources/new-or-updated-company/new-or-updated-company.mjs
  • components/hubspot/sources/new-or-updated-contact/new-or-updated-contact.mjs
  • components/hubspot/sources/delete-blog-article/delete-blog-article.mjs
  • components/hubspot/sources/new-event/new-event.mjs
  • components/hubspot/sources/new-email-event/new-email-event.mjs
  • components/hubspot/sources/new-custom-object-property-change/new-custom-object-property-change.mjs
  • components/hubspot/sources/new-company-property-change/new-company-property-change.mjs
  • components/hubspot/actions/get-deal/get-deal.mjs
  • components/hubspot/actions/update-lead/update-lead.mjs
  • components/hubspot/actions/enroll-contact-into-workflow/enroll-contact-into-workflow.mjs
  • components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs
  • components/hubspot/sources/new-social-media-message/new-social-media-message.mjs
  • components/hubspot/actions/search-crm/search-crm.mjs
  • components/hubspot/actions/update-deal/update-deal.mjs
  • components/hubspot/sources/new-note/new-note.mjs
  • components/hubspot/actions/get-company/get-company.mjs
  • components/hubspot/sources/new-deal-property-change/new-deal-property-change.mjs
  • components/hubspot/sources/new-or-updated-deal/new-or-updated-deal.mjs
  • components/hubspot/sources/new-or-updated-crm-object/new-or-updated-crm-object.mjs
  • components/hubspot/sources/new-contact-property-change/new-contact-property-change.mjs
  • components/hubspot/actions/batch-create-or-update-contact/batch-create-or-update-contact.mjs
  • components/hubspot/sources/new-or-updated-line-item/new-or-updated-line-item.mjs
  • components/hubspot/actions/create-associations/create-associations.mjs
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components
🔇 Additional comments (7)
components/hubspot/sources/common/common.mjs (2)

71-71: Confirm request throttling strategy.
By removing the rate limiter here, this loop may now send API requests in a tight loop without throttling, which could risk hitting rate limits if the new limiter isn’t applied upstream.

Ensure that the request logic in hubspot.app.mjs fully protects this paging process from overloading HubSpot’s rate limits.


109-109: Maintain consistency in pagination approach.
This line parallels the logic at line 71. Double-check that removing the old rate-limiting mechanism doesn’t result in undesired behavior (e.g., spamming requests).

Would you like me to generate a script to scan for unthrottled function calls in the codebase?

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

482-482: 🛠️ Refactor suggestion

Verify correct usage of wrapped axios.
Calling axiosRateLimiter($, { … }) ensures controlled concurrency. Confirm all critical methods use this wrapper instead of raw axios calls.

You could run a repository-wide search for direct axios usage to ensure all calls route through the limiter.

components/hubspot/actions/create-or-update-contact/create-or-update-contact.mjs (2)

9-9: Version bump looks consistent

The version bump from 0.0.14 to 0.0.15 aligns with the coordinated release across multiple HubSpot actions.


Line range hint 12-17: Ensure logic is implemented for the new updateIfExists prop

The newly introduced boolean prop updateIfExists suggests the action should handle an error from the HubSpot create call and attempt an update if this prop is enabled. However, no supporting logic here or in common.methods (as far as shown) confirms this behavior.

Would you like me to propose sample error-handling code to fully implement this feature?

components/hubspot/actions/create-lead/create-lead.mjs (2)

12-12: Version increment validated

The jump from 0.0.4 to 0.0.5 is in line with the broader versioning updates across the HubSpot suite.


Line range hint 23-45: Confirm robust handling of contactId association

The added association block correctly targets this.contactId for linking a contact to the new lead. However, consider validating that this.contactId is defined and valid before making the API request. This helps avoid unexpected errors if the prop is empty or invalid.

Below is a suggestion for a mild safeguard:

 createObject(opts) {
+  if (!this.contactId) {
+    throw new Error("A valid Contact ID is required to associate the lead");
+  }
   return this.hubspot.createObject({
     ...
✅ Verification successful

The review comment's validation suggestion is appropriate and necessary

The contactId validation is indeed missing and should be added. While the prop is properly defined using HubSpot's objectId propDefinition, an explicit validation before creating the association would prevent orphaned leads and provide clearer error messages to users.

The suggested code change is a good safeguard:

 createObject(opts) {
+  if (!this.contactId) {
+    throw new Error("A valid Contact ID is required to associate the lead");
+  }
   return this.hubspot.createObject({
     ...
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Get the complete create-lead component implementation
cat components/hubspot/actions/create-lead/create-lead.mjs

# Search for similar contact association patterns in other HubSpot components
rg -l "associationTypeId.*578" components/hubspot/

# Check HubSpot client implementation for object creation
fd "hubspot.*\.(js|mjs)$" components/hubspot/common/ -x cat {}

Length of output: 1650


Script:

#!/bin/bash
# Check the common create object implementation
cat components/hubspot/actions/common/common-create-object.mjs

Length of output: 3115

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 @michelle0927, LGTM! Ready for QA!

@michelle0927 michelle0927 merged commit 993149f into master Feb 3, 2025
11 checks passed
@michelle0927 michelle0927 deleted the issue-15393 branch February 3, 2025 16: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.

Hubspot - Use Bottleneck for all requests

3 participants