Skip to content

Commit 4339c0d

Browse files
committed
[FEATURE] Hubspot - New form submission improvement
1 parent 25c156d commit 4339c0d

File tree

6 files changed

+51
-14
lines changed

6 files changed

+51
-14
lines changed

components/hubspot/common/constants.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const API_PATH = {
2222
AUTOMATION: "/automation/v2",
2323
DEAL: "/deals/v1",
2424
BUSINESS_UNITS: "/business-units/v3",
25+
MARKETINGV3: "/marketing/v3",
2526
};
2627

2728
/** Association categories for association types, as defined by the [Hubspot API

components/hubspot/hubspot.app.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,15 @@ export default {
712712
...opts,
713713
});
714714
},
715+
getFormDefinition({
716+
formId, ...opts
717+
} = {}) {
718+
return this.makeRequest({
719+
api: API_PATH.MARKETINGV3,
720+
endpoint: `/forms/${formId}`,
721+
...opts,
722+
});
723+
},
715724
getForms(opts = {}) {
716725
return this.makeRequest({
717726
api: API_PATH.FORMS,

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.0.1",
3+
"version": "1.0.2",
44
"description": "Pipedream Hubspot Components",
55
"main": "hubspot.app.mjs",
66
"keywords": [

components/hubspot/sources/new-form-submission/new-form-submission.mjs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default {
66
key: "hubspot-new-form-submission",
77
name: "New Form Submission",
88
description: "Emit new event for each new submission of a form.",
9-
version: "0.0.24",
9+
version: "0.0.25",
1010
dedupe: "unique",
1111
type: "source",
1212
props: {
@@ -21,6 +21,40 @@ export default {
2121
},
2222
methods: {
2323
...common.methods,
24+
async paginate(params, resourceFn, resultType = null, after = null) {
25+
let results = null;
26+
let maxTs = after || 0;
27+
while (!results || params.after) {
28+
results = await resourceFn(params);
29+
if (results.paging) {
30+
params.after = results.paging.next.after;
31+
} else {
32+
delete params.after;
33+
}
34+
if (resultType) {
35+
results = results[resultType];
36+
}
37+
38+
for (const result of results) {
39+
if (await this.isRelevant(result, after)) {
40+
const form = await this.hubspot.getFormDefinition({
41+
formId: params.formId,
42+
});
43+
this.emitEvent({
44+
form,
45+
...result,
46+
});
47+
const ts = this.getTs(result);
48+
if (ts > maxTs) {
49+
maxTs = ts;
50+
this._setAfter(ts);
51+
}
52+
} else {
53+
return;
54+
}
55+
}
56+
}
57+
},
2458
getTs(result) {
2559
return result.submittedAt;
2660
},

components/hubspot/sources/new-form-submission/test-event.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export default {
77
"objectTypeId": "0-1"
88
}
99
],
10-
"pageUrl": "https://share.hsforms.com/13MJGKokMSAmW69lIF_JiKg43od5"
10+
"pageUrl": "https://share.hsforms.com/13MJGKokMSAmW69lIF_JiKg43od5",
11+
"form": { "id": "4442beda-998a-4825-bba1-2eaa3c1f0038", "name": "Test form (March 20, 2025 5:24:26 PM EDT)", "createdAt": "2025-03-20T21:24:26.911Z", "updatedAt": "2025-03-20T21:28:40.822Z", "archived": false, "fieldGroups": [{ "groupType": "default_group", "richTextType": "text", "fields": [{ "objectTypeId": "0-1", "name": "firstname", "label": "First Name", "required": false, "hidden": false, "fieldType": "single_line_text" }, { "objectTypeId": "0-1", "name": "lastname", "label": "Last Name", "required": false, "hidden": false, "fieldType": "single_line_text" }, { "objectTypeId": "0-1", "name": "email", "label": "Email", "required": true, "hidden": false, "validation": { "blockedEmailDomains": [], "useDefaultBlockList": false }, "fieldType": "email" }] }], "configuration": { "language": "en", "cloneable": true, "postSubmitAction": { "type": "thank_you", "value": "" }, "editable": true, "archivable": true, "recaptchaEnabled": false, "notifyContactOwner": false, "notifyRecipients": ["78708658"], "createNewContactForNewEmail": false, "prePopulateKnownValues": true, "allowLinkToResetKnownValues": false, "lifecycleStages": [] }, "displayOptions": { "renderRawHtml": false, "theme": "default_style", "submitButtonText": "", "style": { "fontFamily": "arial, helvetica, sans-serif", "backgroundWidth": "100%", "labelTextColor": "#33475b", "labelTextSize": "11px", "helpTextColor": "#7C98B6", "helpTextSize": "11px", "legalConsentTextColor": "#33475b", "legalConsentTextSize": "14px", "submitColor": "#ff7a59", "submitAlignment": "left", "submitFontColor": "#ffffff", "submitSize": "12px" }, "cssClass": null }, "legalConsentOptions": { "type": "none" }, "formType": "hubspot" }
1112
}

pnpm-lock.yaml

Lines changed: 3 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)