From 34cd63a271815d5f4e72f6907b6a5a4011d2b501 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Wed, 24 Sep 2025 23:15:31 -0300 Subject: [PATCH 1/5] Adding max initial events to "New Deal in Stage" --- components/hubspot/package.json | 2 +- .../sources/new-deal-in-stage/new-deal-in-stage.mjs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/components/hubspot/package.json b/components/hubspot/package.json index 3d5b3d9355927..099559c918d64 100644 --- a/components/hubspot/package.json +++ b/components/hubspot/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/hubspot", - "version": "1.7.10", + "version": "1.7.11", "description": "Pipedream Hubspot Components", "main": "hubspot.app.mjs", "keywords": [ diff --git a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs index de17a175f57b0..b7b9811523ce0 100644 --- a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs +++ b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs @@ -11,7 +11,7 @@ export default { key: "hubspot-new-deal-in-stage", name: "New Deal In Stage", description: "Emit new event for each new deal in a stage.", - version: "0.0.41", + version: "0.0.42", dedupe: "unique", type: "source", props: { @@ -89,6 +89,8 @@ export default { }, async processDeals(params, after) { let maxTs = after || 0; + let initialEventsEmitted = 0; + const maxInitialEvents = 25; do { const results = await this.hubspot.searchCRM(params); @@ -111,6 +113,9 @@ export default { maxTs = ts; this._setAfter(ts); } + if (!after && ++initialEventsEmitted >= maxInitialEvents) { + return; + } } } From dfb21bbbd8cafc8f60302d5360e67965c204825d Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Thu, 25 Sep 2025 01:55:54 -0300 Subject: [PATCH 2/5] Adjusting new-deal-in-stage --- .../new-deal-in-stage/new-deal-in-stage.mjs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs index b7b9811523ce0..e00ac2b3fce95 100644 --- a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs +++ b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs @@ -6,12 +6,14 @@ import { import common from "../common/common.mjs"; import sampleEmit from "./test-event.mjs"; +const MAX_INITIAL_EVENTS = 25; + export default { ...common, key: "hubspot-new-deal-in-stage", name: "New Deal In Stage", description: "Emit new event for each new deal in a stage.", - version: "0.0.42", + version: "0.1.0", dedupe: "unique", type: "source", props: { @@ -87,10 +89,8 @@ export default { object: "deals", }; }, - async processDeals(params, after) { + async processDeals(params, after, initialEventsEmitted) { let maxTs = after || 0; - let initialEventsEmitted = 0; - const maxInitialEvents = 25; do { const results = await this.hubspot.searchCRM(params); @@ -113,22 +113,27 @@ export default { maxTs = ts; this._setAfter(ts); } - if (!after && ++initialEventsEmitted >= maxInitialEvents) { - return; + if (!after && ++initialEventsEmitted >= MAX_INITIAL_EVENTS) { + return initialEventsEmitted; } } } // first run, get only first page if (!after) { - return; + break; } } while (params.after); + return initialEventsEmitted; }, async processResults(after) { + let initialEventsEmitted = 0; for (const stage of this.stages) { const params = this.getStageParams(stage); - await this.processDeals(params, after); + initialEventsEmitted += await this.processDeals(params, after, initialEventsEmitted); + if (initialEventsEmitted >= MAX_INITIAL_EVENTS) { + return; + } } }, getOwner(ownerId) { From 4081e2ec52097afeb19d0bd5a64c39b8e867094f Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Fri, 26 Sep 2025 20:50:54 -0300 Subject: [PATCH 3/5] Adjusting subsequent runs of 'new deal in stage' --- .../new-deal-in-stage/new-deal-in-stage.mjs | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs index e00ac2b3fce95..dd6e579fadfb9 100644 --- a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs +++ b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs @@ -61,16 +61,26 @@ export default { getParams() { return null; }, - getStageParams(stage) { - const filter = { - propertyName: "dealstage", - operator: "EQ", - value: stage, - }; + getAllStagesParams(after) { + const filters = [ + { + propertyName: "dealstage", + operator: "IN", + values: this.stages, + }, + ]; + + // Add time filter for subsequent runs to only get recently modified deals + if (after) { + filters.push({ + propertyName: "hs_lastmodifieddate", + operator: "GT", + value: after, + }); + } + const filterGroup = { - filters: [ - filter, - ], + filters, }; return { data: { @@ -89,8 +99,9 @@ export default { object: "deals", }; }, - async processDeals(params, after, initialEventsEmitted) { + async processDeals(params, after) { let maxTs = after || 0; + let initialEventsEmitted = 0; do { const results = await this.hubspot.searchCRM(params); @@ -114,7 +125,7 @@ export default { this._setAfter(ts); } if (!after && ++initialEventsEmitted >= MAX_INITIAL_EVENTS) { - return initialEventsEmitted; + return; } } } @@ -124,17 +135,10 @@ export default { break; } } while (params.after); - return initialEventsEmitted; }, async processResults(after) { - let initialEventsEmitted = 0; - for (const stage of this.stages) { - const params = this.getStageParams(stage); - initialEventsEmitted += await this.processDeals(params, after, initialEventsEmitted); - if (initialEventsEmitted >= MAX_INITIAL_EVENTS) { - return; - } - } + const params = this.getAllStagesParams(after); + await this.processDeals(params, after); }, getOwner(ownerId) { return this.hubspot.makeRequest({ From be684506005966c0565faa7bd81000bfeb8ffa81 Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Fri, 26 Sep 2025 20:56:31 -0300 Subject: [PATCH 4/5] Version bumps --- components/hubspot/package.json | 2 +- .../hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/hubspot/package.json b/components/hubspot/package.json index 099559c918d64..0fd17122fcf76 100644 --- a/components/hubspot/package.json +++ b/components/hubspot/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/hubspot", - "version": "1.7.11", + "version": "1.7.12", "description": "Pipedream Hubspot Components", "main": "hubspot.app.mjs", "keywords": [ diff --git a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs index dd6e579fadfb9..73c1bd7993284 100644 --- a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs +++ b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs @@ -13,7 +13,7 @@ export default { key: "hubspot-new-deal-in-stage", name: "New Deal In Stage", description: "Emit new event for each new deal in a stage.", - version: "0.1.0", + version: "0.0.42", dedupe: "unique", type: "source", props: { From 4fa5d8bf9a3783e41c4b6151b20f466df54d369e Mon Sep 17 00:00:00 2001 From: GTFalcao Date: Mon, 29 Sep 2025 02:38:57 -0300 Subject: [PATCH 5/5] Version bump --- .../hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs index 73c1bd7993284..dd6e579fadfb9 100644 --- a/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs +++ b/components/hubspot/sources/new-deal-in-stage/new-deal-in-stage.mjs @@ -13,7 +13,7 @@ export default { key: "hubspot-new-deal-in-stage", name: "New Deal In Stage", description: "Emit new event for each new deal in a stage.", - version: "0.0.42", + version: "0.1.0", dedupe: "unique", type: "source", props: {