Skip to content

Commit 02493fa

Browse files
authored
Merging pull request #18664
* fetch contact will all properties * bump versions
1 parent 905ac86 commit 02493fa

File tree

27 files changed

+140
-27
lines changed

27 files changed

+140
-27
lines changed

components/hubspot/hubspot.app.mjs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,5 +1614,37 @@ export default {
16141614
...opts,
16151615
});
16161616
},
1617+
async getContactWithAllProperties({
1618+
contactId, ...opts
1619+
}) {
1620+
const properties = await this.getContactProperties();
1621+
const allPropertyNames = properties.map((prop) => prop.name);
1622+
1623+
return this.makeRequest({
1624+
api: API_PATH.CRMV3,
1625+
endpoint: `/objects/contacts/${contactId}`,
1626+
params: {
1627+
properties: allPropertyNames.join(","),
1628+
},
1629+
...opts,
1630+
});
1631+
},
1632+
async batchGetContactsWithAllProperties({
1633+
contactIds, ...opts
1634+
}) {
1635+
const properties = await this.getContactProperties();
1636+
const allPropertyNames = properties.map((prop) => prop.name);
1637+
1638+
return this.batchGetObjects({
1639+
objectType: "contacts",
1640+
data: {
1641+
inputs: contactIds.map((id) => ({
1642+
id,
1643+
})),
1644+
properties: allPropertyNames,
1645+
},
1646+
...opts,
1647+
});
1648+
},
16171649
},
16181650
};

components/hubspot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/hubspot",
3-
"version": "1.7.12",
3+
"version": "1.7.14",
44
"description": "Pipedream Hubspot Components",
55
"main": "hubspot.app.mjs",
66
"keywords": [

components/hubspot/sources/delete-blog-article/delete-blog-article.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "hubspot-delete-blog-article",
77
name: "Deleted Blog Posts",
88
description: "Emit new event for each deleted blog post.",
9-
version: "0.0.34",
9+
version: "0.0.35",
1010
dedupe: "unique",
1111
type: "source",
1212
methods: {

components/hubspot/sources/new-company-property-change/new-company-property-change.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "hubspot-new-company-property-change",
88
name: "New Company Property Change",
99
description: "Emit new event when a specified property is provided or updated on a company. [See the documentation](https://developers.hubspot.com/docs/api/crm/companies)",
10-
version: "0.0.27",
10+
version: "0.0.28",
1111
dedupe: "unique",
1212
type: "source",
1313
props: {

components/hubspot/sources/new-contact-added-to-list/new-contact-added-to-list.mjs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
name: "New Contact Added to List",
1313
description:
1414
"Emit new event when a contact is added to a HubSpot list. [See the documentation](https://developers.hubspot.com/docs/reference/api/crm/lists#get-%2Fcrm%2Fv3%2Flists%2F%7Blistid%7D%2Fmemberships%2Fjoin-order)",
15-
version: "0.0.6",
15+
version: "0.0.7",
1616
type: "source",
1717
dedupe: "unique",
1818
props: {
@@ -55,6 +55,14 @@ export default {
5555
label: "Additional contact properties to retrieve",
5656
optional: true,
5757
},
58+
fetchAllProperties: {
59+
type: "boolean",
60+
label: "Fetch all contact properties",
61+
description:
62+
"When enabled, fetches all available contact properties instead of just default and selected properties. This provides complete contact data but may increase API usage.",
63+
optional: true,
64+
default: false,
65+
},
5866
},
5967
methods: {
6068
...common.methods,
@@ -95,6 +103,40 @@ export default {
95103
async getContactDetails(contactIds) {
96104
if (!contactIds.length) return {};
97105

106+
if (this.fetchAllProperties) {
107+
const chunks = [];
108+
const chunkSize = 100;
109+
for (let i = 0; i < contactIds.length; i += chunkSize) {
110+
chunks.push(contactIds.slice(i, i + chunkSize));
111+
}
112+
113+
const contactMap = {};
114+
115+
try {
116+
for (const chunk of chunks) {
117+
try {
118+
const { results } = await this.hubspot.batchGetContactsWithAllProperties({
119+
contactIds: chunk,
120+
});
121+
122+
results.forEach((contact) => {
123+
contactMap[contact.id] = contact;
124+
});
125+
} catch (error) {
126+
console.warn(
127+
`Error fetching contact details for chunk of ${chunk.length} contacts:`,
128+
error,
129+
);
130+
}
131+
}
132+
133+
return contactMap;
134+
} catch (error) {
135+
console.warn("Error processing contact details:", error);
136+
return {};
137+
}
138+
}
139+
98140
const { properties = [] } = this;
99141
const allProperties = [
100142
...DEFAULT_CONTACT_PROPERTIES,

components/hubspot/sources/new-contact-property-change/new-contact-property-change.mjs

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
name: "New Contact Property Change",
99
description:
1010
"Emit new event when a specified property is provided or updated on a contact. [See the documentation](https://developers.hubspot.com/docs/api/crm/contacts)",
11-
version: "0.0.30",
11+
version: "0.0.31",
1212
dedupe: "unique",
1313
type: "source",
1414
props: {
@@ -38,6 +38,14 @@ export default {
3838
optional: true,
3939
default: true,
4040
},
41+
fetchAllProperties: {
42+
type: "boolean",
43+
label: "Fetch all contact properties",
44+
description:
45+
"When enabled, fetches all available contact properties instead of just the watched property. This provides complete contact data but may increase API usage.",
46+
optional: true,
47+
default: false,
48+
},
4149
},
4250
methods: {
4351
...common.methods,
@@ -111,7 +119,38 @@ export default {
111119
}
112120
return params;
113121
},
114-
batchGetContacts(inputs) {
122+
async batchGetContacts(inputs) {
123+
if (this.fetchAllProperties) {
124+
const { results } = await this.hubspot.batchGetContactsWithAllProperties({
125+
contactIds: inputs.map((input) => input.id),
126+
});
127+
128+
const { results: contactsWithHistory } = await this.hubspot.batchGetObjects({
129+
objectType: "contacts",
130+
data: {
131+
properties: [
132+
this.property,
133+
],
134+
propertiesWithHistory: [
135+
this.property,
136+
],
137+
inputs,
138+
},
139+
});
140+
141+
const mergedResults = results.map((contact) => {
142+
const contactWithHistory = contactsWithHistory.find((c) => c.id === contact.id);
143+
return {
144+
...contact,
145+
propertiesWithHistory: contactWithHistory?.propertiesWithHistory || {},
146+
};
147+
});
148+
149+
return {
150+
results: mergedResults,
151+
};
152+
}
153+
115154
return this.hubspot.batchGetObjects({
116155
objectType: "contacts",
117156
data: {

components/hubspot/sources/new-custom-object-property-change/new-custom-object-property-change.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "New Custom Object Property Change",
88
description:
99
"Emit new event when a specified property is provided or updated on a custom object.",
10-
version: "0.0.19",
10+
version: "0.0.20",
1111
dedupe: "unique",
1212
type: "source",
1313
props: {

components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default {
1313
key: "hubspot-new-deal-in-stage",
1414
name: "New Deal In Stage",
1515
description: "Emit new event for each new deal in a stage.",
16-
version: "0.1.0",
16+
version: "0.1.1",
1717
dedupe: "unique",
1818
type: "source",
1919
props: {

components/hubspot/sources/new-deal-property-change/new-deal-property-change.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "hubspot-new-deal-property-change",
88
name: "New Deal Property Change",
99
description: "Emit new event when a specified property is provided or updated on a deal. [See the documentation](https://developers.hubspot.com/docs/api/crm/deals)",
10-
version: "0.0.28",
10+
version: "0.0.30",
1111
dedupe: "unique",
1212
type: "source",
1313
props: {

components/hubspot/sources/new-email-event/new-email-event.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
key: "hubspot-new-email-event",
99
name: "New Email Event",
1010
description: "Emit new event for each new Hubspot email event.",
11-
version: "0.0.37",
11+
version: "0.0.38",
1212
dedupe: "unique",
1313
type: "source",
1414
props: {

0 commit comments

Comments
 (0)