-
Notifications
You must be signed in to change notification settings - Fork 5.5k
HubSpot new action #18143
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
HubSpot new action #18143
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughAdds a new HubSpot action to fetch emails associated with a given CRM object, introduces default email property constants, and bumps the HubSpot package version. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant A as Get Associated Emails Action
participant HS as HubSpot API
U->>A: Provide objectType, objectId, additionalProperties, limit
A->>A: Compose properties = DEFAULT_EMAIL_PROPERTIES + additionalProperties
A->>HS: getAssociations(objectType, objectId -> toObjectType="emails", limit)
alt No associations
A-->>U: summary: "No emails found with this association", return []
else Associations found
A->>HS: batchGetObjects(objectType="emails", inputs(ids), properties)
HS-->>A: email objects
A->>A: Sort emails by hs_timestamp desc
A-->>U: summary: "Successfully retrieved N email(s)", return emails
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (9)
components/hubspot/common/constants.mjs (1)
175-184: Default email property set may be heavy and include PII; consider slimming the defaults
hs_email_htmlandhs_email_headerscan be large and may include PII. Since the action already supportsadditionalProperties, consider a leaner default set to reduce payload and accidental exposure, leaving heavy fields opt-in.Apply this diff if you want a lighter default:
const DEFAULT_EMAIL_PROPERTIES = [ "hs_timestamp", "hs_email_direction", - "hs_email_html", "hs_email_status", "hs_email_subject", "hs_email_text", "hs_attachment_ids", - "hs_email_headers", ];components/hubspot/actions/get-associated-emails/get-associated-emails.mjs (8)
4-10: Scope aligns with “emails” only; linked issue requests a generic engagements actionThis action fulfills the email use case, but Issue #18117 asked for a generic “Get Associated Engagements” with an
engagementTypeprop. Consider a follow-up generic action (or a shared internal helper) that this action can reuse, to fully close the issue and prevent duplication across email/meetings/calls/etc.Would you like me to propose a small internal helper (e.g., getAssociatedEngagements) and a generic action scaffold?
7-7: Description/link accuracyThe description references the generic “search” docs, while this action uses associations + batch read. Clarify wording and mention custom objects since
includeCustom: trueis enabled.Apply this diff to tighten the copy:
- description: "Retrieves emails associated with a specific object (contact, company, or deal). [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/search)", + description: "Retrieves emails associated with a HubSpot object (contact, company, deal, or custom object). See HubSpot docs on associations and CRM objects.",
20-22: Prop description: call out custom objects explicitlyMinor copy improvement to match
includeCustom: true.- description: "The type of the object the emails are associated with", + description: "Type of the associated object (contact, company, deal, or custom object)",
23-34: Avoid mixingtypewithpropDefinitionfor the same propIn Pipedream components,
propDefinitionusually sets the type. The explicittype: "string"can be redundant or conflict with the definition. Safer to rely solely onpropDefinition.objectId: { - type: "string", label: "Object ID", description: "The ID of the object to get associated emails for", propDefinition: [ hubspot, "objectIds", ({ objectType }) => ({ objectType, }), ], },
52-55: Deduplicate properties to avoid repeated fieldsIf users pass properties already in the defaults, we’ll send duplicates unnecessarily. Use a Set.
- const properties = [ - ...DEFAULT_EMAIL_PROPERTIES, - ...(this.additionalProperties || []), - ]; + const properties = [...new Set([ + ...DEFAULT_EMAIL_PROPERTIES, + ...(this.additionalProperties || []), + ])];
71-74: Clarify empty-results check
if (!results?.length > 0)is truthy for empty arrays, but relies on tricky operator precedence. Prefer the clearerif (!results?.length).- if (!results?.length > 0) { + if (!results?.length) { $.export("$summary", "No emails found with this association"); return []; }
76-79: Deduplicate associated IDs before batch fetchingGuard against duplicate associations returning the same email ID.
- const emailIds = results.map((association) => ({ - id: association.toObjectId, - })); + const uniqueIds = [...new Set(results.map((a) => a.toObjectId))]; + const emailIds = uniqueIds.map((id) => ({ id }));
90-95: Sorting byhs_timestampis fine; consider a stable tie-breakerOptional: For equal timestamps or missing values, tie-break by
idto keep results deterministic across runs.Example:
- const sortedEmails = emails?.sort((a, b) => { + const sortedEmails = emails?.sort((a, b) => { const timestampA = new Date(a.properties?.hs_timestamp || 0).getTime(); const timestampB = new Date(b.properties?.hs_timestamp || 0).getTime(); - return timestampB - timestampA; + if (timestampB !== timestampA) return timestampB - timestampA; + return String(b.id ?? "").localeCompare(String(a.id ?? "")); }) || [];
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (3)
components/hubspot/actions/get-associated-emails/get-associated-emails.mjs(1 hunks)components/hubspot/common/constants.mjs(2 hunks)components/hubspot/package.json(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
components/hubspot/actions/get-associated-emails/get-associated-emails.mjs (1)
components/hubspot/common/constants.mjs (1)
DEFAULT_EMAIL_PROPERTIES(175-184)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Publish TypeScript components
- GitHub Check: Lint Code Base
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
🔇 Additional comments (4)
components/hubspot/package.json (1)
3-3: Minor version bump aligns with a new action — LGTMAdding a new action warrants a minor bump. No other changes here.
components/hubspot/common/constants.mjs (1)
239-241: Exporting DEFAULT_EMAIL_PROPERTIES is consistent and usefulMaking the default email properties available to other actions/utilities looks good.
components/hubspot/actions/get-associated-emails/get-associated-emails.mjs (2)
61-69: Associations fetch looks correctUsing
toObjectType: "emails"with a limit is consistent with the flow of first collecting associated IDs.Also verify that the association result shape contains
toObjectIdin your helper’s return (some APIs returntoObjectIdvs. nested structures). The script above will help find the helper implementation.
96-101: Nice: succinct summary and return shapeExporting a concise summary and returning the sorted array matches Pipedream action UX expectations.
components/hubspot/actions/get-associated-emails/get-associated-emails.mjs
Show resolved
Hide resolved
components/hubspot/actions/get-associated-emails/get-associated-emails.mjs
Show resolved
Hide resolved
michelle0927
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Closes #18117
This was created specifically for the email use case, as the action becomes overly complex when dealing with all engagement types
Summary by CodeRabbit
New Features
Chores