Skip to content

Commit 31e4b0a

Browse files
authored
[Source] Issue 18428 - Improve New contact Property change trigger (#18429)
* Issue 18428 * bump HS version * adjust history logic * cr 1 * add pnpm lock * bump hs versions
1 parent f5742b2 commit 31e4b0a

File tree

7 files changed

+610
-732
lines changed

7 files changed

+610
-732
lines changed

components/cockpit/cockpit.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

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

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

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ export default {
66
...common,
77
key: "hubspot-new-contact-property-change",
88
name: "New Contact Property Change",
9-
description: "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)",
10-
version: "0.0.29",
9+
description:
10+
"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",
1112
dedupe: "unique",
1213
type: "source",
1314
props: {
@@ -21,6 +22,22 @@ export default {
2122
return properties.map((property) => property.name);
2223
},
2324
},
25+
skipFirstRun: {
26+
type: "boolean",
27+
label: "Skip existing contacts when first activated",
28+
description:
29+
"When enabled, this trigger will ignore all existing contacts and only watch for property changes that happen after activation. When disabled, it will process all existing contacts on first run.",
30+
optional: true,
31+
default: false,
32+
},
33+
requirePropertyHistory: {
34+
type: "boolean",
35+
label: "Only trigger on actual property changes",
36+
description:
37+
"When enabled, only fires when a contact property is actually modified. When disabled, may also trigger for newly created contacts even if the property wasn't changed.",
38+
optional: true,
39+
default: true,
40+
},
2441
},
2542
methods: {
2643
...common.methods,
@@ -43,6 +60,20 @@ export default {
4360
};
4461
},
4562
isRelevant(contact, updatedAfter) {
63+
if (this.requirePropertyHistory) {
64+
const history = contact.propertiesWithHistory?.[this.property];
65+
if (!history || history.length === 0) {
66+
return false;
67+
}
68+
69+
const propertyTimestamp = history[0].timestamp;
70+
const createDate = contact.properties.createdate;
71+
72+
if (propertyTimestamp === createDate) {
73+
return false;
74+
}
75+
}
76+
4677
return this.getTs(contact) > updatedAfter;
4778
},
4879
getParams(after) {
@@ -95,6 +126,11 @@ export default {
95126
});
96127
},
97128
async processResults(after, params) {
129+
if (this.skipFirstRun && !after) {
130+
this._setAfter(Date.now());
131+
return;
132+
}
133+
98134
const properties = await this.hubspot.getContactProperties();
99135
const propertyNames = properties.map((property) => property.name);
100136
if (!propertyNames.includes(this.property)) {

components/kobotoolbox/kobotoolbox.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/misp/misp.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

components/signl4/signl4.app.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ export default {
88
console.log(Object.keys(this.$auth));
99
},
1010
},
11-
};
11+
};

0 commit comments

Comments
 (0)