@segment/action-destinations 3.113.0 → 3.113.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/destinations/clevertap/index.js +1 -1
- package/dist/destinations/criteo-audiences/addUserToAudience/index.js +5 -5
- package/dist/destinations/criteo-audiences/addUserToAudience/index.js.map +1 -1
- package/dist/destinations/criteo-audiences/criteo-audiences.d.ts +2 -2
- package/dist/destinations/criteo-audiences/criteo-audiences.js +10 -5
- package/dist/destinations/criteo-audiences/criteo-audiences.js.map +1 -1
- package/dist/destinations/criteo-audiences/removeUserFromAudience/index.js +5 -5
- package/dist/destinations/criteo-audiences/removeUserFromAudience/index.js.map +1 -1
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +3 -3
- package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -1
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js +1 -1
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -1
- package/dist/destinations/hubspot/index.js +3 -5
- package/dist/destinations/hubspot/index.js.map +1 -1
- package/dist/destinations/hubspot/properties.d.ts +1 -3
- package/dist/destinations/hubspot/properties.js +2 -4
- package/dist/destinations/hubspot/properties.js.map +1 -1
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +1 -1
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -1
- package/dist/destinations/hubspot/testHelper.d.ts +7 -0
- package/dist/destinations/hubspot/testHelper.js +24 -0
- package/dist/destinations/hubspot/testHelper.js.map +1 -0
- package/dist/destinations/hubspot/upsertContact/index.js +2 -2
- package/dist/destinations/hubspot/upsertContact/index.js.map +1 -1
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js +8 -37
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js.map +1 -1
- package/dist/destinations/index.js +2 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/linkedin-audiences/updateAudience/index.js +5 -3
- package/dist/destinations/linkedin-audiences/updateAudience/index.js.map +1 -1
- package/dist/destinations/mixpanel/groupIdentifyUser/index.js +1 -1
- package/dist/destinations/mixpanel/groupIdentifyUser/index.js.map +1 -1
- package/dist/destinations/mixpanel/identifyUser/generated-types.d.ts +0 -1
- package/dist/destinations/mixpanel/identifyUser/index.js +0 -9
- package/dist/destinations/mixpanel/identifyUser/index.js.map +1 -1
- package/dist/destinations/mixpanel/index.js +1 -1
- package/dist/destinations/mixpanel/mixpanel-properties.js.map +1 -1
- package/dist/destinations/mixpanel/trackEvent/functions.js.map +1 -1
- package/dist/destinations/mixpanel/trackEvent/index.js.map +1 -1
- package/dist/destinations/mixpanel/trackPurchase/index.js +3 -1
- package/dist/destinations/mixpanel/trackPurchase/index.js.map +1 -1
- package/dist/destinations/qualtrics/qualtricsApiClient.js +1 -2
- package/dist/destinations/qualtrics/qualtricsApiClient.js.map +1 -1
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/generated-types.d.ts +7 -0
- package/dist/destinations/{hubspot/upsertCompany → salesforce-marketing-cloud/apiEvent}/generated-types.js +0 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.d.ts +5 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.js +20 -0
- package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/generated-types.d.ts +3 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/index.d.ts +5 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/index.js +23 -0
- package/dist/destinations/salesforce-marketing-cloud/contact/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.d.ts +12 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.d.ts +5 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js +35 -0
- package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.d.ts +11 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.js.map +1 -0
- package/dist/destinations/{hubspot/upsertCompany → salesforce-marketing-cloud/dataExtension}/index.d.ts +0 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js +23 -0
- package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/generated-types.d.ts +7 -0
- package/dist/destinations/salesforce-marketing-cloud/generated-types.js +3 -0
- package/dist/destinations/salesforce-marketing-cloud/generated-types.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/index.d.ts +4 -0
- package/dist/destinations/salesforce-marketing-cloud/index.js +77 -0
- package/dist/destinations/salesforce-marketing-cloud/index.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.d.ts +3 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js +31 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js.map +1 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.d.ts +10 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.js +59 -0
- package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.js.map +1 -0
- package/dist/destinations/sendgrid/sendgrid-properties.js +1 -2
- package/dist/destinations/sendgrid/sendgrid-properties.js.map +1 -1
- package/package.json +4 -4
- package/dist/destinations/hubspot/errors.d.ts +0 -17
- package/dist/destinations/hubspot/errors.js +0 -30
- package/dist/destinations/hubspot/errors.js.map +0 -1
- package/dist/destinations/hubspot/upsertCompany/generated-types.d.ts +0 -21
- package/dist/destinations/hubspot/upsertCompany/generated-types.js.map +0 -1
- package/dist/destinations/hubspot/upsertCompany/index.js +0 -321
- package/dist/destinations/hubspot/upsertCompany/index.js.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.upsertRows = void 0;
|
|
4
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
+
function upsertRows(request, subdomain, payloads) {
|
|
6
|
+
const { key, id } = payloads[0];
|
|
7
|
+
if (!key && !id) {
|
|
8
|
+
throw new actions_core_1.IntegrationError(`In order to send an event to a data extension either Data Extension ID or Data Extension Key must be defined.`, 'Misconfigured required field', 400);
|
|
9
|
+
}
|
|
10
|
+
const rows = [];
|
|
11
|
+
payloads.forEach((payload) => {
|
|
12
|
+
rows.push({
|
|
13
|
+
keys: payload.keys,
|
|
14
|
+
values: payload.values
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
if (key) {
|
|
18
|
+
return request(`https://${subdomain}.rest.marketingcloudapis.com/hub/v1/dataevents/key:${key}/rowset`, {
|
|
19
|
+
method: 'post',
|
|
20
|
+
json: rows
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
return request(`https://${subdomain}.rest.marketingcloudapis.com/hub/v1/dataevents/${id}/rowset`, {
|
|
25
|
+
method: 'post',
|
|
26
|
+
json: rows
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.upsertRows = upsertRows;
|
|
31
|
+
//# sourceMappingURL=sfmc-operations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sfmc-operations.js","sourceRoot":"","sources":["../../../src/destinations/salesforce-marketing-cloud/sfmc-operations.ts"],"names":[],"mappings":";;;AAAA,wDAAuE;AAGvE,SAAgB,UAAU,CAAC,OAAsB,EAAE,SAAiB,EAAE,QAAmB;IACvF,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAE/B,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE;QACf,MAAM,IAAI,+BAAgB,CACxB,+GAA+G,EAC/G,8BAA8B,EAC9B,GAAG,CACJ,CAAA;KACF;IACD,MAAM,IAAI,GAA0B,EAAE,CAAA;IACtC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAgB,EAAE,EAAE;QACpC,IAAI,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IACF,IAAI,GAAG,EAAE;QACP,OAAO,OAAO,CAAC,WAAW,SAAS,sDAAsD,GAAG,SAAS,EAAE;YACrG,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;SACX,CAAC,CAAA;KACH;SAAM;QACL,OAAO,OAAO,CAAC,WAAW,SAAS,kDAAkD,EAAE,SAAS,EAAE;YAChG,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI;SACX,CAAC,CAAA;KACH;AACH,CAAC;AA5BD,gCA4BC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InputField } from '@segment/actions-core/src/destination-kit/types';
|
|
2
|
+
export declare const contactKey: InputField;
|
|
3
|
+
export declare const contactKeyAPIEvent: InputField;
|
|
4
|
+
export declare const key: InputField;
|
|
5
|
+
export declare const id: InputField;
|
|
6
|
+
export declare const keys: InputField;
|
|
7
|
+
export declare const values: InputField;
|
|
8
|
+
export declare const eventDefinitionKey: InputField;
|
|
9
|
+
export declare const eventData: InputField;
|
|
10
|
+
export declare const enable_batching: InputField;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enable_batching = exports.eventData = exports.eventDefinitionKey = exports.values = exports.keys = exports.id = exports.key = exports.contactKeyAPIEvent = exports.contactKey = void 0;
|
|
4
|
+
exports.contactKey = {
|
|
5
|
+
label: 'Contact Key',
|
|
6
|
+
description: 'The unique identifier that you assign to a contact. This will be used to create a contact if one does not already exist with this Contact Key.',
|
|
7
|
+
type: 'string',
|
|
8
|
+
default: { '@path': '$.userId' }
|
|
9
|
+
};
|
|
10
|
+
exports.contactKeyAPIEvent = {
|
|
11
|
+
label: 'Contact Key',
|
|
12
|
+
description: 'The unique identifier that identifies a subscriber or a contact.',
|
|
13
|
+
type: 'string',
|
|
14
|
+
default: { '@path': '$.userId' },
|
|
15
|
+
required: true
|
|
16
|
+
};
|
|
17
|
+
exports.key = {
|
|
18
|
+
label: 'Data Extension Key',
|
|
19
|
+
description: 'The key of the data extension that you want to store contact information in. The data extension must be predefined in SFMC. Segment recommends storing all contact information in a single data extension. The key is required if a Data Extension ID is not provided.',
|
|
20
|
+
type: 'string'
|
|
21
|
+
};
|
|
22
|
+
exports.id = {
|
|
23
|
+
label: 'Data Extension ID',
|
|
24
|
+
description: 'The ID of the data extension that you want to store contact information in. The data extension must be predefined in SFMC. Segment recommends storing all contact information in a single data extension. The ID is required if a Data Extension Key is not provided.',
|
|
25
|
+
type: 'string'
|
|
26
|
+
};
|
|
27
|
+
exports.keys = {
|
|
28
|
+
label: 'Data Extension Primary Keys',
|
|
29
|
+
description: 'The primary key(s) that uniquely identify a contact in the data extension. At a minimum, Contact Key must exist in your data extension as a Primary Key. On the left-hand side, input the SFMC key name. On the right-hand side, map the Segment field that contains the corresponding value. When multiple primary keys are provided, SFMC will update an existing row if all primary keys match, otherwise a new row will be created.',
|
|
30
|
+
type: 'object',
|
|
31
|
+
required: true,
|
|
32
|
+
defaultObjectUI: 'keyvalue:only',
|
|
33
|
+
additionalProperties: true
|
|
34
|
+
};
|
|
35
|
+
exports.values = {
|
|
36
|
+
label: 'Contact Fields',
|
|
37
|
+
description: 'The fields in the data extension that contain data about a contact, such as Email, Last Name, etc. Fields must be created in the data extension before sending data for it. On the left-hand side, input the SFMC field name exactly how it appears in the data extension. On the right-hand side, map the Segment field that contains the corresponding value.',
|
|
38
|
+
type: 'object',
|
|
39
|
+
defaultObjectUI: 'keyvalue:only'
|
|
40
|
+
};
|
|
41
|
+
exports.eventDefinitionKey = {
|
|
42
|
+
label: 'Event Definition Key',
|
|
43
|
+
description: 'The unique key for an event definition in Salesforce Marketing Cloud. The event defintion must be predefined in SFMC. ',
|
|
44
|
+
type: 'string',
|
|
45
|
+
required: true
|
|
46
|
+
};
|
|
47
|
+
exports.eventData = {
|
|
48
|
+
label: 'Event Data',
|
|
49
|
+
description: 'The properties of the event. Fields must be created in the event definition schema before sending data for it. On the left-hand side, input the SFMC field name exactly how it appears in the event definition schema. On the right-hand side, map the Segment field that contains the corresponding value.',
|
|
50
|
+
type: 'object',
|
|
51
|
+
defaultObjectUI: 'keyvalue:only'
|
|
52
|
+
};
|
|
53
|
+
exports.enable_batching = {
|
|
54
|
+
label: 'Batch data to SFMC',
|
|
55
|
+
description: 'If true, data is batched before sending to the SFMC Data Extension.',
|
|
56
|
+
type: 'boolean',
|
|
57
|
+
default: false
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=sfmc-properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sfmc-properties.js","sourceRoot":"","sources":["../../../src/destinations/salesforce-marketing-cloud/sfmc-properties.ts"],"names":[],"mappings":";;;AAEa,QAAA,UAAU,GAAe;IACpC,KAAK,EAAE,aAAa;IACpB,WAAW,EACT,gJAAgJ;IAClJ,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;CACjC,CAAA;AAEY,QAAA,kBAAkB,GAAe;IAC5C,KAAK,EAAE,aAAa;IACpB,WAAW,EAAE,kEAAkE;IAC/E,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;IAChC,QAAQ,EAAE,IAAI;CACf,CAAA;AAEY,QAAA,GAAG,GAAe;IAC7B,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EACT,wQAAwQ;IAC1Q,IAAI,EAAE,QAAQ;CACf,CAAA;AACY,QAAA,EAAE,GAAe;IAC5B,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EACT,uQAAuQ;IACzQ,IAAI,EAAE,QAAQ;CACf,CAAA;AACY,QAAA,IAAI,GAAe;IAC9B,KAAK,EAAE,6BAA6B;IACpC,WAAW,EACT,yaAAya;IAC3a,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;IACd,eAAe,EAAE,eAAe;IAChC,oBAAoB,EAAE,IAAI;CAC3B,CAAA;AACY,QAAA,MAAM,GAAe;IAChC,KAAK,EAAE,gBAAgB;IACvB,WAAW,EACT,iWAAiW;IACnW,IAAI,EAAE,QAAQ;IACd,eAAe,EAAE,eAAe;CACjC,CAAA;AACY,QAAA,kBAAkB,GAAe;IAC5C,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EACT,wHAAwH;IAC1H,IAAI,EAAE,QAAQ;IACd,QAAQ,EAAE,IAAI;CACf,CAAA;AACY,QAAA,SAAS,GAAe;IACnC,KAAK,EAAE,YAAY;IACnB,WAAW,EACT,6SAA6S;IAC/S,IAAI,EAAE,QAAQ;IACd,eAAe,EAAE,eAAe;CACjC,CAAA;AAEY,QAAA,eAAe,GAAe;IACzC,KAAK,EAAE,oBAAoB;IAC3B,WAAW,EAAE,qEAAqE;IAClF,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,KAAK;CACf,CAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertPayload = exports.fetchAccountCustomFields = exports.customFields = void 0;
|
|
4
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
5
4
|
exports.customFields = {
|
|
6
5
|
label: 'Other Fields',
|
|
7
6
|
description: `
|
|
@@ -41,7 +40,7 @@ const convertCustomFieldNamesToIds = (customFields, accountCustomFields) => {
|
|
|
41
40
|
actualKey = matchingCustomField.id;
|
|
42
41
|
}
|
|
43
42
|
else {
|
|
44
|
-
throw new
|
|
43
|
+
throw new Error(`Unknown custom field '${key}'. To see your defined custom fields, visit https://mc.sendgrid.com/custom-fields`);
|
|
45
44
|
}
|
|
46
45
|
result[actualKey] = customFields[key];
|
|
47
46
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendgrid-properties.js","sourceRoot":"","sources":["../../../src/destinations/sendgrid/sendgrid-properties.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"sendgrid-properties.js","sourceRoot":"","sources":["../../../src/destinations/sendgrid/sendgrid-properties.ts"],"names":[],"mappings":";;;AAGa,QAAA,YAAY,GAAe;IACtC,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE;;;;;;;;GAQZ;IACD,IAAI,EAAE,QAAQ;IACd,eAAe,EAAE,UAAU;CAC5B,CAAA;AAaM,MAAM,wBAAwB,GAAG,KAAK,EAAE,OAAsB,EAA0B,EAAE;IAC/F,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,yDAAyD,CAAC,CAAA;IACzF,MAAM,IAAI,GAAY,QAAQ,CAAC,IAAe,CAAA;IAC9C,MAAM,YAAY,GAAkB,IAAI,CAAC,aAA8B,CAAA;IAGvE,IAAI,YAAY,KAAK,SAAS,EAAE;QAC9B,OAAO,EAAE,CAAA;KACV;IAED,OAAO,YAAY,CAAC,GAAG,CAErB,CAAC,EAAE,EAAE,EAAE,IAAI,EAAe,EAAe,EAAE;QACzC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAA;IACrB,CAAC,CACF,CAAA;AACH,CAAC,CAAA;AAhBY,QAAA,wBAAwB,4BAgBpC;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,MAAM,mBAAmB,GAAG,YAAY;QACtC,CAAC,CAAC,4BAA4B,CAAC,YAAY,EAAE,mBAAmB,CAAC;QACjE,CAAC,CAAC,YAAY,CAAA;IAEhB,OAAO,EAAE,GAAG,IAAI,EAAE,qBAAqB,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAA;AAC5G,CAAC,CAAA;AATY,QAAA,cAAc,kBAS1B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@segment/action-destinations",
|
|
3
3
|
"description": "Destination Actions engine and definitions.",
|
|
4
|
-
"version": "3.113.
|
|
4
|
+
"version": "3.113.1-alpha.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@amplitude/ua-parser-js": "^0.7.25",
|
|
40
40
|
"@segment/a1-notation": "^2.1.4",
|
|
41
|
-
"@segment/actions-core": "^3.41.
|
|
42
|
-
"@segment/actions-shared": "^1.24.
|
|
41
|
+
"@segment/actions-core": "^3.41.1-alpha.2",
|
|
42
|
+
"@segment/actions-shared": "^1.24.1-alpha.1",
|
|
43
43
|
"cheerio": "^1.0.0-rc.10",
|
|
44
44
|
"dayjs": "^1.10.7",
|
|
45
45
|
"escape-goat": "^3",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"lcov"
|
|
66
66
|
]
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "563763473c51ddb13df733263bb97dfa1b4230d2"
|
|
69
69
|
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { IntegrationError, RetryableError, HTTPError } from '@segment/actions-core';
|
|
2
|
-
export declare class HubSpotError extends HTTPError {
|
|
3
|
-
response: Response & {
|
|
4
|
-
data: {
|
|
5
|
-
status: string;
|
|
6
|
-
message: string;
|
|
7
|
-
correlationId: string;
|
|
8
|
-
category: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export declare const MissingIdentityCallThrowableError: IntegrationError;
|
|
13
|
-
export declare const CompanySearchThrowableError: IntegrationError;
|
|
14
|
-
export declare const RestrictedPropertyThrowableError: IntegrationError;
|
|
15
|
-
export declare const MultipleCompaniesInSearchResultThrowableError: IntegrationError;
|
|
16
|
-
export declare const SegmentUniqueIdentifierMissingRetryableError: RetryableError;
|
|
17
|
-
export declare function isSegmentUniqueIdentifierPropertyError(error: HubSpotError, segmentUniqueIdentifierProperty: string): boolean;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSegmentUniqueIdentifierPropertyError = exports.SegmentUniqueIdentifierMissingRetryableError = exports.MultipleCompaniesInSearchResultThrowableError = exports.RestrictedPropertyThrowableError = exports.CompanySearchThrowableError = exports.MissingIdentityCallThrowableError = exports.HubSpotError = void 0;
|
|
4
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
-
const properties_1 = require("./properties");
|
|
6
|
-
class HubSpotError extends actions_core_1.HTTPError {
|
|
7
|
-
}
|
|
8
|
-
exports.HubSpotError = HubSpotError;
|
|
9
|
-
exports.MissingIdentityCallThrowableError = new actions_core_1.IntegrationError('Identify (Upsert Contact) must be called before Group (Upsert Company) for the HubSpot Cloud (Actions) destination.', 'Missing Identity Call', 400);
|
|
10
|
-
exports.CompanySearchThrowableError = new actions_core_1.IntegrationError('HubSpot returned 400 error while performing a company search. Please check if ’Company Search Fields’ contains valid properties defined in HubSpot.', 'Company Search Failed', 400);
|
|
11
|
-
exports.RestrictedPropertyThrowableError = new actions_core_1.IntegrationError(`Segment uses ’${properties_1.SEGMENT_UNIQUE_IDENTIFIER}’ property internally to map Segment Groups to HubSpot Companies. This property shouldn’t be defined explicitly.`, 'Payload Validation Failed', 400);
|
|
12
|
-
exports.MultipleCompaniesInSearchResultThrowableError = new actions_core_1.IntegrationError(`The search criteria defined by Company Search Fields returned more than one companies. The update request will be rejected.`, 'Search Criteria Not Unique', 400);
|
|
13
|
-
exports.SegmentUniqueIdentifierMissingRetryableError = new actions_core_1.RetryableError(`The ’${properties_1.SEGMENT_UNIQUE_IDENTIFIER}’ property doesn't exist in HubSpot. Segment will attempt to create the property and retry the action.`);
|
|
14
|
-
function isSegmentUniqueIdentifierPropertyError(error, segmentUniqueIdentifierProperty) {
|
|
15
|
-
if (error?.response?.status !== 400) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
try {
|
|
19
|
-
const errorMessage = error?.response?.data?.message?.replace('Property values were not valid: ', '');
|
|
20
|
-
const errorList = JSON.parse(errorMessage);
|
|
21
|
-
return (errorList.length === 1 &&
|
|
22
|
-
errorList[0].name === segmentUniqueIdentifierProperty &&
|
|
23
|
-
errorList[0].error === 'PROPERTY_DOESNT_EXIST');
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
exports.isSegmentUniqueIdentifierPropertyError = isSegmentUniqueIdentifierPropertyError;
|
|
30
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/errors.ts"],"names":[],"mappings":";;;AAAA,wDAAmF;AACnF,6CAAwD;AAExD,MAAa,YAAa,SAAQ,wBAAS;CAS1C;AATD,oCASC;AACY,QAAA,iCAAiC,GAAG,IAAI,+BAAgB,CACnE,qHAAqH,EACrH,uBAAuB,EACvB,GAAG,CACJ,CAAA;AAEY,QAAA,2BAA2B,GAAG,IAAI,+BAAgB,CAC7D,qJAAqJ,EACrJ,uBAAuB,EACvB,GAAG,CACJ,CAAA;AAEY,QAAA,gCAAgC,GAAG,IAAI,+BAAgB,CAClE,iBAAiB,sCAAyB,kHAAkH,EAC5J,2BAA2B,EAC3B,GAAG,CACJ,CAAA;AAEY,QAAA,6CAA6C,GAAG,IAAI,+BAAgB,CAC/E,6HAA6H,EAC7H,4BAA4B,EAC5B,GAAG,CACJ,CAAA;AAEY,QAAA,4CAA4C,GAAG,IAAI,6BAAc,CAC5E,QAAQ,sCAAyB,wGAAwG,CAC1I,CAAA;AAED,SAAgB,sCAAsC,CACpD,KAAmB,EACnB,+BAAuC;IAEvC,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE;QACnC,OAAO,KAAK,CAAA;KACb;IAED,IAAI;QACF,MAAM,YAAY,GAAG,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAA;QACpG,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;QAE1C,OAAO,CACL,SAAS,CAAC,MAAM,KAAK,CAAC;YACtB,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,+BAA+B;YACrD,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,uBAAuB,CAC/C,CAAA;KACF;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAA;KACb;AACH,CAAC;AApBD,wFAoBC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface Payload {
|
|
2
|
-
groupid: string;
|
|
3
|
-
companysearchfields: {
|
|
4
|
-
[k: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
name: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
createdate?: string;
|
|
9
|
-
address?: string;
|
|
10
|
-
city?: string;
|
|
11
|
-
state?: string;
|
|
12
|
-
zip?: string;
|
|
13
|
-
domain?: string;
|
|
14
|
-
phone?: string;
|
|
15
|
-
numberofemployees?: number;
|
|
16
|
-
industry?: string;
|
|
17
|
-
lifecyclestage?: string;
|
|
18
|
-
properties?: {
|
|
19
|
-
[k: string]: unknown;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertCompany/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const properties_1 = require("../properties");
|
|
4
|
-
const errors_1 = require("../errors");
|
|
5
|
-
var CompanySearchFilterOperator;
|
|
6
|
-
(function (CompanySearchFilterOperator) {
|
|
7
|
-
CompanySearchFilterOperator["EQ"] = "EQ";
|
|
8
|
-
CompanySearchFilterOperator["NEQ"] = "NEQ";
|
|
9
|
-
CompanySearchFilterOperator["LT"] = "LT";
|
|
10
|
-
CompanySearchFilterOperator["LTE"] = "LTE";
|
|
11
|
-
CompanySearchFilterOperator["GT"] = "GT";
|
|
12
|
-
CompanySearchFilterOperator["GTE"] = "GTE";
|
|
13
|
-
CompanySearchFilterOperator["BETWEEN"] = "BETWEEN";
|
|
14
|
-
CompanySearchFilterOperator["IN"] = "IN";
|
|
15
|
-
CompanySearchFilterOperator["NOT_IN"] = "NOT_IN";
|
|
16
|
-
CompanySearchFilterOperator["HAS_PROPERTY"] = "HAS_PROPERTY";
|
|
17
|
-
CompanySearchFilterOperator["NOT_HAS_PROPERTY"] = "NOT_HAS_PROPERTY";
|
|
18
|
-
CompanySearchFilterOperator["CONTAINS_TOKEN"] = "CONTAINS_TOKEN";
|
|
19
|
-
CompanySearchFilterOperator["NOT_CONTAINS_TOKEN"] = "NOT_CONTAINS_TOKEN";
|
|
20
|
-
})(CompanySearchFilterOperator || (CompanySearchFilterOperator = {}));
|
|
21
|
-
const action = {
|
|
22
|
-
title: 'Upsert Company',
|
|
23
|
-
description: 'Create or update a company in HubSpot.',
|
|
24
|
-
defaultSubscription: 'type = "group"',
|
|
25
|
-
fields: {
|
|
26
|
-
groupid: {
|
|
27
|
-
label: 'Group ID',
|
|
28
|
-
description: `Used for constructing the unique ${properties_1.SEGMENT_UNIQUE_IDENTIFIER} for HubSpot.`,
|
|
29
|
-
type: 'hidden',
|
|
30
|
-
required: true,
|
|
31
|
-
default: {
|
|
32
|
-
'@if': {
|
|
33
|
-
exists: { '@path': '$.groupId' },
|
|
34
|
-
then: { '@path': '$.groupId' },
|
|
35
|
-
else: { '@path': '$.context.groupId' }
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
companysearchfields: {
|
|
40
|
-
label: 'Company Search Fields',
|
|
41
|
-
description: 'The unique field(s) used to search for an existing company in HubSpot to update. By default, Segment creates a custom property to store groupId for each company and uses this property to search for companies. If a company is not found, the fields provided here are then used to search. If a company is still not found, a new one is created.',
|
|
42
|
-
type: 'object',
|
|
43
|
-
required: true,
|
|
44
|
-
defaultObjectUI: 'keyvalue:only'
|
|
45
|
-
},
|
|
46
|
-
name: {
|
|
47
|
-
label: 'Company Name',
|
|
48
|
-
description: 'The name of the company.',
|
|
49
|
-
type: 'string',
|
|
50
|
-
required: true,
|
|
51
|
-
default: {
|
|
52
|
-
'@path': '$.traits.name'
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
description: {
|
|
56
|
-
label: 'Company Description',
|
|
57
|
-
description: 'A short statement about the company’s mission and goals.',
|
|
58
|
-
type: 'string',
|
|
59
|
-
default: {
|
|
60
|
-
'@path': '$.traits.description'
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
createdate: {
|
|
64
|
-
label: 'Company Create Date',
|
|
65
|
-
description: 'The date the company was added to your account.',
|
|
66
|
-
type: 'string',
|
|
67
|
-
default: {
|
|
68
|
-
'@path': '$.traits.createdAt'
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
address: {
|
|
72
|
-
label: 'Street Address',
|
|
73
|
-
description: 'The street address of the company.',
|
|
74
|
-
type: 'string',
|
|
75
|
-
default: {
|
|
76
|
-
'@path': '$.traits.address.street'
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
city: {
|
|
80
|
-
label: 'City',
|
|
81
|
-
description: 'The city where the company is located.',
|
|
82
|
-
type: 'string',
|
|
83
|
-
default: {
|
|
84
|
-
'@path': '$.traits.address.city'
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
state: {
|
|
88
|
-
label: 'State',
|
|
89
|
-
description: 'The state or region where the company is located.',
|
|
90
|
-
type: 'string',
|
|
91
|
-
default: {
|
|
92
|
-
'@path': '$.traits.address.state'
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
zip: {
|
|
96
|
-
label: 'Postal Code',
|
|
97
|
-
description: 'The postal or zip code of the company.',
|
|
98
|
-
type: 'string',
|
|
99
|
-
default: {
|
|
100
|
-
'@if': {
|
|
101
|
-
exists: { '@path': '$.traits.address.postalCode' },
|
|
102
|
-
then: { '@path': '$.traits.address.postalCode' },
|
|
103
|
-
else: { '@path': '$.traits.address.postal_code' }
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
domain: {
|
|
108
|
-
label: 'Domain',
|
|
109
|
-
description: 'The company’s website domain.',
|
|
110
|
-
type: 'string',
|
|
111
|
-
default: {
|
|
112
|
-
'@path': '$.traits.website'
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
phone: {
|
|
116
|
-
label: 'Phone',
|
|
117
|
-
description: 'The company’s primary phone number.',
|
|
118
|
-
type: 'string',
|
|
119
|
-
default: {
|
|
120
|
-
'@path': '$.traits.phone'
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
numberofemployees: {
|
|
124
|
-
label: 'Number of Employees',
|
|
125
|
-
description: 'The total number of people who work for the company.',
|
|
126
|
-
type: 'integer',
|
|
127
|
-
default: {
|
|
128
|
-
'@path': '$.traits.employees'
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
industry: {
|
|
132
|
-
label: 'Industry',
|
|
133
|
-
description: 'The type of business the company performs.',
|
|
134
|
-
type: 'string',
|
|
135
|
-
default: {
|
|
136
|
-
'@path': '$.traits.industry'
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
lifecyclestage: {
|
|
140
|
-
label: 'Lifecycle Stage',
|
|
141
|
-
description: 'The company’s stage within the marketing/sales process. See more information on default and custom stages in [HubSpot’s documentation](https://knowledge.hubspot.com/contacts/use-lifecycle-stages). Segment supports moving status forwards or backwards.',
|
|
142
|
-
type: 'string'
|
|
143
|
-
},
|
|
144
|
-
properties: {
|
|
145
|
-
label: 'Other Properties',
|
|
146
|
-
description: `Any other default or custom company properties. On the left-hand side, input the internal name of the property as seen in your HubSpot account. On the right-hand side, map the Segment field that contains the value. Custom properties must be predefined in HubSpot. See more information in [HubSpot’s documentation](https://knowledge.hubspot.com/crm-setup/manage-your-properties#create-custom-properties). Important: Do not use ’${properties_1.SEGMENT_UNIQUE_IDENTIFIER}’ here as it is an internal property and will result in an an error.`,
|
|
147
|
-
type: 'object',
|
|
148
|
-
defaultObjectUI: 'keyvalue:only',
|
|
149
|
-
allowNull: false
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
perform: async (request, { payload, transactionContext }) => {
|
|
153
|
-
if (payload.properties?.[properties_1.SEGMENT_UNIQUE_IDENTIFIER]) {
|
|
154
|
-
throw errors_1.RestrictedPropertyThrowableError;
|
|
155
|
-
}
|
|
156
|
-
if (!transactionContext?.transaction?.contact_id) {
|
|
157
|
-
throw errors_1.MissingIdentityCallThrowableError;
|
|
158
|
-
}
|
|
159
|
-
const companyProperties = {
|
|
160
|
-
name: payload.name,
|
|
161
|
-
description: payload.description,
|
|
162
|
-
createdate: payload.createdate,
|
|
163
|
-
address: payload.address,
|
|
164
|
-
city: payload.city,
|
|
165
|
-
state: payload.state,
|
|
166
|
-
zip: payload.zip,
|
|
167
|
-
domain: payload.domain,
|
|
168
|
-
phone: payload.phone,
|
|
169
|
-
numberofemployees: payload.numberofemployees,
|
|
170
|
-
industry: payload.industry,
|
|
171
|
-
lifecyclestage: payload.lifecyclestage?.toLocaleLowerCase(),
|
|
172
|
-
[properties_1.SEGMENT_UNIQUE_IDENTIFIER]: payload.groupid,
|
|
173
|
-
...payload.properties
|
|
174
|
-
};
|
|
175
|
-
let companyId = '';
|
|
176
|
-
try {
|
|
177
|
-
const updateCompanyResponse = await updateCompany(request, payload.groupid, companyProperties, properties_1.SEGMENT_UNIQUE_IDENTIFIER);
|
|
178
|
-
companyId = updateCompanyResponse.data.id;
|
|
179
|
-
}
|
|
180
|
-
catch (e) {
|
|
181
|
-
const error = e;
|
|
182
|
-
if (errors_1.isSegmentUniqueIdentifierPropertyError(error, properties_1.SEGMENT_UNIQUE_IDENTIFIER)) {
|
|
183
|
-
await createSegmentUniqueIdentifierProperty(request);
|
|
184
|
-
throw errors_1.SegmentUniqueIdentifierMissingRetryableError;
|
|
185
|
-
}
|
|
186
|
-
if (error?.response?.status !== 404 &&
|
|
187
|
-
!errors_1.isSegmentUniqueIdentifierPropertyError(error, properties_1.SEGMENT_UNIQUE_IDENTIFIER)) {
|
|
188
|
-
throw e;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (!companyId) {
|
|
192
|
-
let searchCompanyResponse = null;
|
|
193
|
-
if (typeof payload.companysearchfields === 'object' && Object.keys(payload.companysearchfields).length > 0) {
|
|
194
|
-
try {
|
|
195
|
-
searchCompanyResponse = await searchCompany(request, { ...payload.companysearchfields });
|
|
196
|
-
}
|
|
197
|
-
catch (e) {
|
|
198
|
-
if (e?.response?.status === 400) {
|
|
199
|
-
throw errors_1.CompanySearchThrowableError;
|
|
200
|
-
}
|
|
201
|
-
throw e;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (!searchCompanyResponse || searchCompanyResponse.data.total === 0) {
|
|
205
|
-
const createCompanyWrapper = function () {
|
|
206
|
-
return createCompany(request, companyProperties);
|
|
207
|
-
};
|
|
208
|
-
companyId = await upsertCompanyWithRetry(request, createCompanyWrapper);
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
if (searchCompanyResponse.data.total > 1) {
|
|
212
|
-
throw errors_1.MultipleCompaniesInSearchResultThrowableError;
|
|
213
|
-
}
|
|
214
|
-
companyId = searchCompanyResponse.data.results[0].id;
|
|
215
|
-
const updateCompanyWrapper = function () {
|
|
216
|
-
return updateCompany(request, companyId, companyProperties);
|
|
217
|
-
};
|
|
218
|
-
await upsertCompanyWithRetry(request, updateCompanyWrapper);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
await associateCompanyToContact(request, companyId, transactionContext?.transaction?.['contact_id'], properties_1.ASSOCIATION_TYPE);
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
function searchCompany(request, companySearchFields) {
|
|
225
|
-
const responseProperties = ['name', 'domain', 'lifecyclestage', properties_1.SEGMENT_UNIQUE_IDENTIFIER];
|
|
226
|
-
const responseSortBy = ['name'];
|
|
227
|
-
const companySearchPayload = {
|
|
228
|
-
filterGroups: [],
|
|
229
|
-
properties: [...responseProperties],
|
|
230
|
-
sorts: [...responseSortBy]
|
|
231
|
-
};
|
|
232
|
-
for (const [key, value] of Object.entries(companySearchFields)) {
|
|
233
|
-
companySearchPayload.filterGroups.push({
|
|
234
|
-
filters: [
|
|
235
|
-
{
|
|
236
|
-
propertyName: key,
|
|
237
|
-
operator: CompanySearchFilterOperator.EQ,
|
|
238
|
-
value
|
|
239
|
-
}
|
|
240
|
-
]
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/companies/search`, {
|
|
244
|
-
method: 'POST',
|
|
245
|
-
json: {
|
|
246
|
-
...companySearchPayload
|
|
247
|
-
}
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
function createCompany(request, properties) {
|
|
251
|
-
return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/companies`, {
|
|
252
|
-
method: 'POST',
|
|
253
|
-
json: {
|
|
254
|
-
properties: {
|
|
255
|
-
...properties
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
function updateCompany(request, uniqueIdentifier, properties, idProperty) {
|
|
261
|
-
const updateCompanyURL = `${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/companies/${uniqueIdentifier}` + (idProperty ? `?idProperty=${idProperty}` : '');
|
|
262
|
-
return request(updateCompanyURL, {
|
|
263
|
-
method: 'PATCH',
|
|
264
|
-
json: {
|
|
265
|
-
properties: {
|
|
266
|
-
...properties
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
function createSegmentUniqueIdentifierProperty(request) {
|
|
272
|
-
const segmentUniqueIdentifierProperty = {
|
|
273
|
-
name: properties_1.SEGMENT_UNIQUE_IDENTIFIER,
|
|
274
|
-
label: 'Segment Group ID',
|
|
275
|
-
description: 'Unique Property to map Segment Group ID with a HubSpot Company Object',
|
|
276
|
-
groupName: 'companyinformation',
|
|
277
|
-
type: 'string',
|
|
278
|
-
fieldType: 'text',
|
|
279
|
-
hidden: true,
|
|
280
|
-
displayOrder: -1,
|
|
281
|
-
hasUniqueValue: true,
|
|
282
|
-
formField: false
|
|
283
|
-
};
|
|
284
|
-
return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/properties/companies`, {
|
|
285
|
-
method: 'POST',
|
|
286
|
-
json: {
|
|
287
|
-
...segmentUniqueIdentifierProperty
|
|
288
|
-
}
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
function associateCompanyToContact(request, companyId, contactId, associationType) {
|
|
292
|
-
return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/companies/${companyId}/associations/contacts/${contactId}/${associationType}`, {
|
|
293
|
-
method: 'PUT'
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
async function upsertCompanyWithRetry(request, upsertCompanyFunction) {
|
|
297
|
-
try {
|
|
298
|
-
const upsertCompanyResponse = await upsertCompanyFunction();
|
|
299
|
-
return upsertCompanyResponse.data.id;
|
|
300
|
-
}
|
|
301
|
-
catch (e) {
|
|
302
|
-
const error = e;
|
|
303
|
-
if (errors_1.isSegmentUniqueIdentifierPropertyError(error, properties_1.SEGMENT_UNIQUE_IDENTIFIER)) {
|
|
304
|
-
try {
|
|
305
|
-
await createSegmentUniqueIdentifierProperty(request);
|
|
306
|
-
}
|
|
307
|
-
catch (e) {
|
|
308
|
-
if (e?.response?.status !== 409) {
|
|
309
|
-
throw e;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
const upsertCompanyResponse = await upsertCompanyFunction();
|
|
313
|
-
return upsertCompanyResponse.data.id;
|
|
314
|
-
}
|
|
315
|
-
else {
|
|
316
|
-
throw e;
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
exports.default = action;
|
|
321
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertCompany/index.ts"],"names":[],"mappings":";;AAGA,8CAA6F;AAC7F,sCAQkB;AAElB,IAAK,2BAcJ;AAdD,WAAK,2BAA2B;IAC9B,wCAAS,CAAA;IACT,0CAAW,CAAA;IACX,wCAAS,CAAA;IACT,0CAAW,CAAA;IACX,wCAAS,CAAA;IACT,0CAAW,CAAA;IACX,kDAAmB,CAAA;IACnB,wCAAS,CAAA;IACT,gDAAiB,CAAA;IACjB,4DAA6B,CAAA;IAC7B,oEAAqC,CAAA;IACrC,gEAAiC,CAAA;IACjC,wEAAyC,CAAA;AAC3C,CAAC,EAdI,2BAA2B,KAA3B,2BAA2B,QAc/B;AAkFD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,wCAAwC;IACrD,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,OAAO,EAAE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