Skip to content

Commit db6a41c

Browse files
authored
Return additional data in HubSpot New Deal in Stage source (#16582)
* add owner data to emitted event * pnpm-lock.yaml
1 parent 3dc9601 commit db6a41c

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

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

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import common from "../common/common.mjs";
2-
import { DEFAULT_LIMIT } from "../../common/constants.mjs";
2+
import {
3+
DEFAULT_LIMIT, DEFAULT_DEAL_PROPERTIES, API_PATH,
4+
} from "../../common/constants.mjs";
35
import sampleEmit from "./test-event.mjs";
46

57
export default {
68
...common,
79
key: "hubspot-new-deal-in-stage",
810
name: "New Deal In Stage",
911
description: "Emit new event for each new deal in a stage.",
10-
version: "0.0.26",
12+
version: "0.0.27",
1113
dedupe: "unique",
1214
type: "source",
1315
props: {
@@ -79,6 +81,7 @@ export default {
7981
direction: "DESCENDING",
8082
},
8183
],
84+
properties: DEFAULT_DEAL_PROPERTIES,
8285
},
8386
object: "deals",
8487
};
@@ -97,6 +100,9 @@ export default {
97100
for (const deal of results.results) {
98101
const ts = await this.getTs(deal);
99102
if (this.isRelevant(ts, after)) {
103+
if (deal.properties.hubspot_owner_id) {
104+
deal.properties.owner = await this.getOwner(deal.properties.hubspot_owner_id);
105+
}
100106
this.emitEvent(deal, ts);
101107
if (ts > maxTs) {
102108
maxTs = ts;
@@ -112,6 +118,12 @@ export default {
112118
await this.processDeals(params, after);
113119
}
114120
},
121+
getOwner(ownerId) {
122+
return this.hubspot.makeRequest({
123+
api: API_PATH.CRMV3,
124+
endpoint: `/owners/${ownerId}`,
125+
});
126+
},
115127
},
116128
sampleEmit,
117129
};

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

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,34 @@ export default {
22
"id": "12388054600",
33
"properties": {
44
"amount": "1",
5-
"closedate": "2024-06-24T16:37:59.812Z",
5+
"closedate": "2025-05-07T17:08:33.843Z",
66
"createdate": "2023-03-03T15:43:17.850Z",
7-
"dealname": "deal1",
8-
"dealstage": "closedwon",
9-
"hs_lastmodifieddate": "2024-06-24T16:38:00.660Z",
7+
"dealname": "deal",
8+
"dealtype": "existingbusiness",
9+
"description": null,
10+
"hs_forecast_amount": "1",
11+
"hs_forecast_probability": null,
12+
"hs_lastmodifieddate": "2025-05-07T17:08:39.305Z",
13+
"hs_manual_forecast_category": null,
14+
"hs_next_step": null,
1015
"hs_object_id": "12388054600",
11-
"pipeline": "default"
16+
"hubspot_owner_id": "41488296",
17+
"hubspot_team_id": null,
18+
"num_associated_contacts": "0",
19+
"owner": {
20+
"id": "41488296",
21+
"email": "",
22+
"type": "PERSON",
23+
"firstName": "",
24+
"lastName": "",
25+
"userId": 9555737,
26+
"userIdIncludingInactive": 9555737,
27+
"createdAt": "2019-12-18T20:08:52.952Z",
28+
"updatedAt": "2025-02-04T16:53:50.082Z",
29+
"archived": false
30+
}
1231
},
1332
"createdAt": "2023-03-03T15:43:17.850Z",
14-
"updatedAt": "2024-06-24T16:38:00.660Z",
33+
"updatedAt": "2025-05-07T17:08:39.305Z",
1534
"archived": false
1635
}

0 commit comments

Comments
 (0)