@segment/action-destinations 3.113.1-alpha.0 → 3.113.1-alpha.3
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/generated-types.d.ts +1 -0
- package/dist/destinations/engage-messaging-twilio/sendSms/index.js +22 -2
- 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 +6 -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
|
@@ -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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