@segment/action-destinations 3.106.0 → 3.107.0-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/amplitude/emptyObject.d.ts +2 -0
- package/dist/destinations/amplitude/emptyObject.js +7 -0
- package/dist/destinations/amplitude/emptyObject.js.map +1 -0
- package/dist/destinations/amplitude/index.js +3 -1
- package/dist/destinations/amplitude/index.js.map +1 -1
- package/dist/destinations/amplitude/logEventV2/generated-types.d.ts +77 -0
- package/dist/destinations/amplitude/logEventV2/generated-types.js +3 -0
- package/dist/destinations/amplitude/logEventV2/generated-types.js.map +1 -0
- package/dist/destinations/amplitude/logEventV2/index.d.ts +13 -0
- package/dist/destinations/amplitude/logEventV2/index.js +237 -0
- package/dist/destinations/amplitude/logEventV2/index.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/functions.d.ts +6 -0
- package/dist/destinations/google-enhanced-conversions/functions.js +55 -0
- package/dist/destinations/google-enhanced-conversions/functions.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/generated-types.d.ts +2 -1
- package/dist/destinations/google-enhanced-conversions/index.js +14 -7
- package/dist/destinations/google-enhanced-conversions/index.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/postConversion/index.js +7 -1
- package/dist/destinations/google-enhanced-conversions/postConversion/index.js.map +1 -1
- package/dist/destinations/google-enhanced-conversions/types.d.ts +23 -0
- package/dist/destinations/google-enhanced-conversions/types.js +5 -0
- package/dist/destinations/google-enhanced-conversions/types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.d.ts +11 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.js +3 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/generated-types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.d.ts +5 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.js +92 -0
- package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.d.ts +25 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.js +3 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.d.ts +5 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.js +229 -0
- package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.d.ts +20 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.js +3 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.js.map +1 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.d.ts +5 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js +286 -0
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js.map +1 -0
- package/dist/destinations/hubspot/contact/generated-types.d.ts +17 -0
- package/dist/destinations/hubspot/contact/generated-types.js +3 -0
- package/dist/destinations/hubspot/contact/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/contact/index.d.ts +5 -0
- package/dist/destinations/hubspot/contact/index.js +186 -0
- package/dist/destinations/hubspot/contact/index.js.map +1 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.d.ts +6 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.js +3 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/index.d.ts +5 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/index.js +41 -0
- package/dist/destinations/hubspot/createCustomObjectRecord/index.js.map +1 -0
- package/dist/destinations/hubspot/generated-types.d.ts +2 -0
- package/dist/destinations/hubspot/generated-types.js +3 -0
- package/dist/destinations/hubspot/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/index.d.ts +4 -0
- package/dist/destinations/hubspot/index.js +46 -0
- package/dist/destinations/hubspot/index.js.map +1 -0
- package/dist/destinations/hubspot/properties.d.ts +1 -0
- package/dist/destinations/hubspot/properties.js +5 -0
- package/dist/destinations/hubspot/properties.js.map +1 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.d.ts +10 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.js +3 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.js.map +1 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.d.ts +5 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +69 -0
- package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -0
- 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/index.js +2 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/loops/index.js +1 -1
- package/dist/destinations/loops/index.js.map +1 -1
- package/dist/destinations/salesforce/customObject/index.js +12 -1
- package/dist/destinations/salesforce/customObject/index.js.map +1 -1
- package/dist/destinations/salesforce/sf-operations.d.ts +3 -0
- package/dist/destinations/salesforce/sf-operations.js +42 -0
- package/dist/destinations/salesforce/sf-operations.js.map +1 -1
- package/dist/destinations/salesforce/sf-properties.js +2 -1
- package/dist/destinations/salesforce/sf-properties.js.map +1 -1
- package/package.json +2 -3
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const functions_1 = require("../functions");
|
|
5
|
+
const types_1 = require("../types");
|
|
6
|
+
const action = {
|
|
7
|
+
title: 'Upload Conversion Adjustment',
|
|
8
|
+
description: 'Upload a conversion adjustment to the Google Ads API.',
|
|
9
|
+
fields: {
|
|
10
|
+
conversion_action: {
|
|
11
|
+
label: 'Conversion Action ID',
|
|
12
|
+
description: 'The ID of the conversion action associated with this conversion. To find the Conversion Action ID, click on your conversion in Google Ads and get the value for `ctId` in the URL. For example, if the URL is `https://ads.google.com/aw/conversions/detail?ocid=00000000&ctId=570000000`, your Conversion Action ID is `570000000`.',
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
adjustment_type: {
|
|
17
|
+
label: 'Adjustment Type',
|
|
18
|
+
description: 'The adjustment type. See [Google’s documentation](https://developers.google.com/google-ads/api/reference/rpc/v11/ConversionAdjustmentTypeEnum.ConversionAdjustmentType) for details on each type.',
|
|
19
|
+
type: 'string',
|
|
20
|
+
choices: [
|
|
21
|
+
{ label: 'UNSPECIFIED', value: 'UNSPECIFIED' },
|
|
22
|
+
{ label: 'UNKNOWN', value: 'UNKNOWN' },
|
|
23
|
+
{ label: `RETRACTION`, value: 'RETRACTION' },
|
|
24
|
+
{ label: 'RESTATEMENT', value: 'RESTATEMENT' },
|
|
25
|
+
{ label: `ENHANCEMENT`, value: 'ENHANCEMENT' }
|
|
26
|
+
],
|
|
27
|
+
required: true
|
|
28
|
+
},
|
|
29
|
+
adjustment_timestamp: {
|
|
30
|
+
label: 'Adjustment Timestamp',
|
|
31
|
+
description: 'The date time at which the adjustment occurred. Must be after the conversion timestamp. The timezone must be specified. The format is "yyyy-mm-dd hh:mm:ss+|-hh:mm", e.g. "2019-01-01 12:32:45-08:00".',
|
|
32
|
+
type: 'string',
|
|
33
|
+
required: true,
|
|
34
|
+
default: {
|
|
35
|
+
'@path': '$.timestamp'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
order_id: {
|
|
39
|
+
label: 'Order ID',
|
|
40
|
+
description: 'The order ID of the conversion to be adjusted. If the conversion was reported with an order ID specified, that order ID must be used as the identifier here. Required for ENHANCEMENT adjustments.',
|
|
41
|
+
type: 'string',
|
|
42
|
+
default: {
|
|
43
|
+
'@if': {
|
|
44
|
+
exists: { '@path': '$.properties.orderId' },
|
|
45
|
+
then: { '@path': '$.properties.orderId' },
|
|
46
|
+
else: { '@path': '$.properties.order_id' }
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
gclid: {
|
|
51
|
+
label: 'GCLID',
|
|
52
|
+
description: 'Google click ID associated with the original conversion for this adjustment. This is used for the GCLID Date Time Pair. Required for non-ENHANCEMENT adjustments. If adjustment is ENHANCEMENT, this value is optional but may be set in addition to the order ID.',
|
|
53
|
+
type: 'string'
|
|
54
|
+
},
|
|
55
|
+
conversion_timestamp: {
|
|
56
|
+
label: 'Conversion Timestamp',
|
|
57
|
+
description: 'The date time at which the original conversion for this adjustment occurred. The timezone must be specified. The format is "yyyy-mm-dd hh:mm:ss+|-hh:mm", e.g. "2019-01-01 12:32:45-08:00". This is used for the GCLID Date Time Pair. Required for non-ENHANCEMENT adjustments. If adjustment is ENHANCEMENT, this value is optional but may be set in addition to the order ID.',
|
|
58
|
+
type: 'string'
|
|
59
|
+
},
|
|
60
|
+
restatement_value: {
|
|
61
|
+
label: 'Restatement Value',
|
|
62
|
+
description: 'The restated conversion value. This is the value of the conversion after restatement. For example, to change the value of a conversion from 100 to 70, an adjusted value of 70 should be reported. Required for RESTATEMENT adjustments.',
|
|
63
|
+
type: 'number'
|
|
64
|
+
},
|
|
65
|
+
restatement_currency_code: {
|
|
66
|
+
label: 'Restatement Currency Code',
|
|
67
|
+
description: 'The currency of the restated value. If not provided, then the default currency from the conversion action is used, and if that is not set then the account currency is used. This is the ISO 4217 3-character currency code, e.g. USD or EUR.',
|
|
68
|
+
type: 'string'
|
|
69
|
+
},
|
|
70
|
+
email_address: {
|
|
71
|
+
label: 'Email Address',
|
|
72
|
+
description: 'Email address of the individual who triggered the conversion event. Segment will hash this value before sending to Google.',
|
|
73
|
+
type: 'string',
|
|
74
|
+
format: 'email',
|
|
75
|
+
default: {
|
|
76
|
+
'@if': {
|
|
77
|
+
exists: { '@path': '$.properties.email' },
|
|
78
|
+
then: { '@path': '$.properties.email' },
|
|
79
|
+
else: { '@path': '$.context.traits.email' }
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
phone_number: {
|
|
84
|
+
label: 'Phone Number',
|
|
85
|
+
description: 'Phone number of the individual who triggered the conversion event, in E.164 standard format, e.g. +14150000000. Segment will hash this value before sending to Google.',
|
|
86
|
+
type: 'string',
|
|
87
|
+
default: {
|
|
88
|
+
'@if': {
|
|
89
|
+
exists: { '@path': '$.properties.phone' },
|
|
90
|
+
then: { '@path': '$.properties.phone' },
|
|
91
|
+
else: { '@path': '$.context.traits.phone' }
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
first_name: {
|
|
96
|
+
label: 'First Name',
|
|
97
|
+
description: 'First name of the user who performed the conversion. Segment will hash this value before sending to Google.',
|
|
98
|
+
type: 'string',
|
|
99
|
+
default: {
|
|
100
|
+
'@if': {
|
|
101
|
+
exists: { '@path': '$.properties.firstName' },
|
|
102
|
+
then: { '@path': '$.properties.firstName' },
|
|
103
|
+
else: { '@path': '$.context.traits.firstName' }
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
last_name: {
|
|
108
|
+
label: 'Last Name',
|
|
109
|
+
description: 'Last name of the user who performed the conversion. Segment will hash this value before sending to Google.',
|
|
110
|
+
type: 'string',
|
|
111
|
+
default: {
|
|
112
|
+
'@if': {
|
|
113
|
+
exists: { '@path': '$.properties.lastName' },
|
|
114
|
+
then: { '@path': '$.properties.lastName' },
|
|
115
|
+
else: { '@path': '$.context.traits.lastName' }
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
city: {
|
|
120
|
+
label: 'City',
|
|
121
|
+
description: 'City of the user who performed the conversion.',
|
|
122
|
+
type: 'string',
|
|
123
|
+
default: {
|
|
124
|
+
'@if': {
|
|
125
|
+
exists: { '@path': '$.properties.address.city,' },
|
|
126
|
+
then: { '@path': '$.properties.address.city,' },
|
|
127
|
+
else: { '@path': '$.context.traits.address.city' }
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
state: {
|
|
132
|
+
label: 'State',
|
|
133
|
+
description: 'State of the user who performed the conversion.',
|
|
134
|
+
type: 'string',
|
|
135
|
+
default: {
|
|
136
|
+
'@if': {
|
|
137
|
+
exists: { '@path': '$.properties.address.state,' },
|
|
138
|
+
then: { '@path': '$.properties.address.state,' },
|
|
139
|
+
else: { '@path': '$.context.traits.address.state' }
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
country: {
|
|
144
|
+
label: 'Country',
|
|
145
|
+
description: '2-letter country code in ISO-3166-1 alpha-2 of the user who performed the conversion.',
|
|
146
|
+
type: 'string',
|
|
147
|
+
default: {
|
|
148
|
+
'@if': {
|
|
149
|
+
exists: { '@path': '$.properties.address.country,' },
|
|
150
|
+
then: { '@path': '$.properties.address.country,' },
|
|
151
|
+
else: { '@path': '$.context.traits.address.country' }
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
postal_code: {
|
|
156
|
+
label: 'Postal Code',
|
|
157
|
+
description: 'Postal code of the user who performed the conversion.',
|
|
158
|
+
type: 'string',
|
|
159
|
+
default: {
|
|
160
|
+
'@if': {
|
|
161
|
+
exists: { '@path': '$.properties.address.postalCode,' },
|
|
162
|
+
then: { '@path': '$.properties.address.postalCode,' },
|
|
163
|
+
else: { '@path': '$.context.traits.address.postalCode' }
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
street_address: {
|
|
168
|
+
label: 'Street Address',
|
|
169
|
+
description: 'Street address of the user who performed the conversion. Segment will hash this value before sending to Google.',
|
|
170
|
+
type: 'string',
|
|
171
|
+
default: {
|
|
172
|
+
'@if': {
|
|
173
|
+
exists: { '@path': '$.properties.address.street,' },
|
|
174
|
+
then: { '@path': '$.properties.address.street,' },
|
|
175
|
+
else: { '@path': '$.context.traits.address.street' }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
user_agent: {
|
|
180
|
+
label: 'User Agent',
|
|
181
|
+
description: 'The user agent to enhance the original conversion. User agent can only be specified in enhancements with user identifiers. This should match the user agent of the request that sent the original conversion so the conversion and its enhancement are either both attributed as same-device or both attributed as cross-device.',
|
|
182
|
+
type: 'string',
|
|
183
|
+
default: {
|
|
184
|
+
'@path': '$.context.userAgent'
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
perform: async (request, { settings, payload }) => {
|
|
189
|
+
if (!settings.customerId) {
|
|
190
|
+
throw new actions_core_1.IntegrationError('Customer ID is required for this action. Please set it in destination settings.', 'Missing required fields.', 400);
|
|
191
|
+
}
|
|
192
|
+
settings.customerId = settings.customerId.replace(/-/g, '');
|
|
193
|
+
const validations = {
|
|
194
|
+
ENHANCEMENT: {
|
|
195
|
+
validation: (payload) => !payload.order_id,
|
|
196
|
+
error: {
|
|
197
|
+
message: 'Order ID required for enhancements'
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
RESTATEMENT: {
|
|
201
|
+
validation: (payload) => !payload.restatement_value,
|
|
202
|
+
error: {
|
|
203
|
+
message: 'Restatement value required for restatements'
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
RETRACTION: {
|
|
207
|
+
validation: (payload) => !payload.gclid || !payload.conversion_timestamp,
|
|
208
|
+
error: {
|
|
209
|
+
message: 'GCLID and conversion timestamp required for chosen conversion type'
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
UNKNOWN: {
|
|
213
|
+
validation: (payload) => !payload.gclid || !payload.conversion_timestamp,
|
|
214
|
+
error: {
|
|
215
|
+
message: 'GCLID and conversion timestamp required for chosen conversion type'
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
UNSPECIFIED: {
|
|
219
|
+
validation: (payload) => !payload.gclid || !payload.conversion_timestamp,
|
|
220
|
+
error: {
|
|
221
|
+
message: 'GCLID and conversion timestamp required for chosen conversion type'
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
const key = payload.adjustment_type;
|
|
226
|
+
if (validations[key].validation(payload)) {
|
|
227
|
+
throw new actions_core_1.IntegrationError(validations[key].error.message, 'INVALID_ARGUMENT', 400);
|
|
228
|
+
}
|
|
229
|
+
const request_object = {
|
|
230
|
+
conversionAction: `customers/${settings.customerId}/conversionActions/${payload.conversion_action}`,
|
|
231
|
+
adjustmentType: payload.adjustment_type,
|
|
232
|
+
adjustmentDateTime: payload.adjustment_timestamp.replace(/T/, ' ').replace(/\..+/, '+00:00'),
|
|
233
|
+
orderId: payload.order_id,
|
|
234
|
+
gclidDateTimePair: {
|
|
235
|
+
gclid: payload.gclid,
|
|
236
|
+
conversionDateTime: payload.conversion_timestamp
|
|
237
|
+
},
|
|
238
|
+
restatementValue: {
|
|
239
|
+
adjustedValue: payload.restatement_value,
|
|
240
|
+
currencyCode: payload.restatement_currency_code
|
|
241
|
+
},
|
|
242
|
+
userIdentifiers: [],
|
|
243
|
+
userAgent: payload.user_agent
|
|
244
|
+
};
|
|
245
|
+
if (payload.email_address) {
|
|
246
|
+
request_object.userIdentifiers.push({ hashedEmail: functions_1.hash(payload.email_address) });
|
|
247
|
+
}
|
|
248
|
+
if (payload.phone_number) {
|
|
249
|
+
request_object.userIdentifiers.push({ hashedPhoneNumber: functions_1.hash(payload.phone_number) });
|
|
250
|
+
}
|
|
251
|
+
const containsAddressInfo = payload.first_name ||
|
|
252
|
+
payload.last_name ||
|
|
253
|
+
payload.city ||
|
|
254
|
+
payload.state ||
|
|
255
|
+
payload.country ||
|
|
256
|
+
payload.postal_code ||
|
|
257
|
+
payload.street_address;
|
|
258
|
+
if (containsAddressInfo) {
|
|
259
|
+
request_object.userIdentifiers.push({
|
|
260
|
+
addressInfo: {
|
|
261
|
+
hashedFirstName: functions_1.hash(payload.first_name),
|
|
262
|
+
hashedLastName: functions_1.hash(payload.last_name),
|
|
263
|
+
hashedStreetAddress: functions_1.hash(payload.street_address),
|
|
264
|
+
city: payload.city,
|
|
265
|
+
state: payload.state,
|
|
266
|
+
countryCode: payload.country,
|
|
267
|
+
postalCode: payload.postal_code
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
const response = await request(`${types_1.GoogleAdsAPI}/${settings.customerId}:uploadConversionAdjustments`, {
|
|
272
|
+
method: 'post',
|
|
273
|
+
headers: {
|
|
274
|
+
'developer-token': `${process.env.ADWORDS_DEVELOPER_TOKEN}`
|
|
275
|
+
},
|
|
276
|
+
json: {
|
|
277
|
+
conversionAdjustments: [request_object],
|
|
278
|
+
partialFailure: true
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
functions_1.handleGoogleErrors(response);
|
|
282
|
+
return response;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
exports.default = action;
|
|
286
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.ts"],"names":[],"mappings":";;AAAA,wDAA0E;AAC1E,4CAAuD;AAGvD,oCAA6D;AAG7D,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,8BAA8B;IACrC,WAAW,EAAE,uDAAuD;IACpE,MAAM,EAAE;QACN,iBAAiB,EAAE;YACjB,KAAK,EAAE,sBAAsB;YAC7B,WAAW,EACT,sUAAsU;YACxU,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,eAAe,EAAE;YACf,KAAK,EAAE,iBAAiB;YACxB,WAAW,EACT,mMAAmM;YACrM,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,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B,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
email: string;
|
|
3
|
+
company?: string;
|
|
4
|
+
firstname?: string;
|
|
5
|
+
lastname?: string;
|
|
6
|
+
phone?: string;
|
|
7
|
+
address?: string;
|
|
8
|
+
city?: string;
|
|
9
|
+
state?: string;
|
|
10
|
+
country?: string;
|
|
11
|
+
zip?: string;
|
|
12
|
+
website?: string;
|
|
13
|
+
lifecyclestage?: string;
|
|
14
|
+
properties?: {
|
|
15
|
+
[k: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/contact/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const properties_1 = require("../properties");
|
|
5
|
+
const action = {
|
|
6
|
+
title: 'Upsert Contact',
|
|
7
|
+
description: 'Create or update a contact in HubSpot.',
|
|
8
|
+
defaultSubscription: 'type = "identify"',
|
|
9
|
+
fields: {
|
|
10
|
+
email: {
|
|
11
|
+
label: 'Email',
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'The contact’s email. Email is used to uniquely identify contact records in HubSpot. If an existing contact is found with this email, we will update the contact. If a contact is not found, we will create a new contact.',
|
|
14
|
+
required: true,
|
|
15
|
+
format: 'email',
|
|
16
|
+
default: {
|
|
17
|
+
'@path': '$.traits.email'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
company: {
|
|
21
|
+
label: 'Company Name',
|
|
22
|
+
type: 'string',
|
|
23
|
+
description: 'The contact’s company.',
|
|
24
|
+
default: {
|
|
25
|
+
'@path': '$.traits.company'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
firstname: {
|
|
29
|
+
label: 'First Name',
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'The contact’s first name.',
|
|
32
|
+
default: {
|
|
33
|
+
'@if': {
|
|
34
|
+
exists: { '@path': '$.traits.first_name' },
|
|
35
|
+
then: { '@path': '$.traits.first_name' },
|
|
36
|
+
else: { '@path': '$.traits.firstName' }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
lastname: {
|
|
41
|
+
label: 'Last Name',
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'The contact’s last name.',
|
|
44
|
+
default: {
|
|
45
|
+
'@if': {
|
|
46
|
+
exists: { '@path': '$.traits.last_name' },
|
|
47
|
+
then: { '@path': '$.traits.last_name' },
|
|
48
|
+
else: { '@path': '$.traits.lastName' }
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
phone: {
|
|
53
|
+
label: 'Phone',
|
|
54
|
+
type: 'string',
|
|
55
|
+
description: 'The contact’s phone number.',
|
|
56
|
+
default: {
|
|
57
|
+
'@path': '$.traits.phone'
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
address: {
|
|
61
|
+
label: 'Street Address',
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: "The contact's street address, including apartment or unit number.",
|
|
64
|
+
default: {
|
|
65
|
+
'@path': '$.traits.address.street'
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
city: {
|
|
69
|
+
label: 'City',
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: "The contact's city of residence.",
|
|
72
|
+
default: {
|
|
73
|
+
'@path': '$.traits.address.city'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
state: {
|
|
77
|
+
label: 'State',
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: "The contact's state of residence.",
|
|
80
|
+
default: {
|
|
81
|
+
'@path': '$.traits.address.state'
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
country: {
|
|
85
|
+
label: 'Country',
|
|
86
|
+
type: 'string',
|
|
87
|
+
description: "The contact's country of residence.",
|
|
88
|
+
default: {
|
|
89
|
+
'@path': '$.traits.address.country'
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
zip: {
|
|
93
|
+
label: 'Postal Code',
|
|
94
|
+
type: 'string',
|
|
95
|
+
description: "The contact's zip code.",
|
|
96
|
+
default: {
|
|
97
|
+
'@if': {
|
|
98
|
+
exists: { '@path': '$.traits.address.postalCode' },
|
|
99
|
+
then: { '@path': '$.traits.address.postalCode' },
|
|
100
|
+
else: { '@path': '$.traits.address.postal_code' }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
website: {
|
|
105
|
+
label: 'Website',
|
|
106
|
+
type: 'string',
|
|
107
|
+
description: 'The contact’s company/other website.',
|
|
108
|
+
default: {
|
|
109
|
+
'@path': '$.traits.website'
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
lifecyclestage: {
|
|
113
|
+
label: 'Lifecycle Stage',
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'The contact’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.'
|
|
116
|
+
},
|
|
117
|
+
properties: {
|
|
118
|
+
label: 'Other properties',
|
|
119
|
+
type: 'object',
|
|
120
|
+
description: 'Any other default or custom contact properties. 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).',
|
|
121
|
+
defaultObjectUI: 'keyvalue:only'
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
perform: async (request, { payload, transactionContext }) => {
|
|
125
|
+
const contactProperties = {
|
|
126
|
+
company: payload.company,
|
|
127
|
+
firstname: payload.firstname,
|
|
128
|
+
lastname: payload.lastname,
|
|
129
|
+
phone: payload.phone,
|
|
130
|
+
address: payload.address,
|
|
131
|
+
city: payload.city,
|
|
132
|
+
state: payload.state,
|
|
133
|
+
country: payload.country,
|
|
134
|
+
zip: payload.zip,
|
|
135
|
+
lifecyclestage: payload.lifecyclestage?.toLowerCase(),
|
|
136
|
+
...payload.properties
|
|
137
|
+
};
|
|
138
|
+
try {
|
|
139
|
+
const response = await updateContact(request, payload.email, contactProperties);
|
|
140
|
+
transactionContext?.setTransaction('contact_id', response.data.id);
|
|
141
|
+
if (payload.lifecyclestage) {
|
|
142
|
+
const currentLCS = response.data.properties['lifecyclestage'];
|
|
143
|
+
const hasLCSChanged = currentLCS == payload.lifecyclestage.toLowerCase();
|
|
144
|
+
if (hasLCSChanged)
|
|
145
|
+
return response;
|
|
146
|
+
await updateContact(request, payload.email, { lifecylestage: '' });
|
|
147
|
+
return updateContact(request, payload.email, contactProperties);
|
|
148
|
+
}
|
|
149
|
+
return response;
|
|
150
|
+
}
|
|
151
|
+
catch (ex) {
|
|
152
|
+
if (!(ex instanceof actions_core_1.HTTPError))
|
|
153
|
+
throw ex;
|
|
154
|
+
const error = ex;
|
|
155
|
+
const statusCode = error.response.status;
|
|
156
|
+
if (statusCode == 404) {
|
|
157
|
+
const result = await createContact(request, { email: payload.email, ...contactProperties });
|
|
158
|
+
transactionContext?.setTransaction('contact_id', result.data.id);
|
|
159
|
+
return result;
|
|
160
|
+
}
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
async function createContact(request, contactProperties) {
|
|
166
|
+
return request(`${properties_1.HubSpotBaseURL}/crm/v3/objects/contacts`, {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
json: {
|
|
169
|
+
properties: {
|
|
170
|
+
...contactProperties
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
async function updateContact(request, email, properties) {
|
|
176
|
+
return request(`${properties_1.HubSpotBaseURL}/crm/v3/objects/contacts/${email}?idProperty=email`, {
|
|
177
|
+
method: 'PATCH',
|
|
178
|
+
json: {
|
|
179
|
+
properties: {
|
|
180
|
+
...properties
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
exports.default = action;
|
|
186
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/contact/index.ts"],"names":[],"mappings":";;AACA,wDAAiD;AAEjD,8CAA8C;AAQ9C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,wCAAwC;IACrD,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,2NAA2N;YAC7N,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP,OAAO,EAAE,gBAAgB;aAC1B;SACF;QACD,OAAO,EAAE;YACP,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wBAAwB;YACrC,OAAO,EAAE;gBACP,OAAO,EAAE,kBAAkB;aAC5B;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,2BAA2B;YACxC,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE;oBAC1C,IAAI,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE;oBACxC,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;iBACxC;aACF;SACF;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,WAAW;YAClB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,0BAA0B;YACvC,OAAO,EAAE;gBACP,KAAK,EAAE;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,EAAE;YACJ,UAAU,EAAE;gBACV,GAAG,UAAU;aACd;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/createCustomObjectRecord/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
4
|
+
const hubspotDefinedObjects = ['contacts', 'companies', 'deals', 'tickets'];
|
|
5
|
+
const customObjectExpression = new RegExp('^[a-zA-Z0-9]+_[a-zA-Z][a-zA-Z0-9_-]+$');
|
|
6
|
+
const action = {
|
|
7
|
+
title: 'Create Custom Object',
|
|
8
|
+
description: 'Create or Update a Custom Object in HubSpot',
|
|
9
|
+
fields: {
|
|
10
|
+
objectType: {
|
|
11
|
+
label: 'Object Type',
|
|
12
|
+
description: 'The CRM object schema to use for creating a record. This can be a standard object (i.e. tickets, deals) or ***fullyQualifiedName*** of a custom object. Custom objects and their schema must be predefined in HubSpot.',
|
|
13
|
+
type: 'string',
|
|
14
|
+
required: true
|
|
15
|
+
},
|
|
16
|
+
properties: {
|
|
17
|
+
label: 'Properties',
|
|
18
|
+
description: 'Properties to send to HubSpot. Please make sure to include the object’s required properties. Any custom properties must be predefined in HubSpot. More information in [HubSpot documentation](https://knowledge.hubspot.com/crm-setup/manage-your-properties#create-custom-properties).',
|
|
19
|
+
type: 'object',
|
|
20
|
+
required: true,
|
|
21
|
+
defaultObjectUI: 'keyvalue:only',
|
|
22
|
+
allowNull: false
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
perform: async (request, { payload }) => {
|
|
26
|
+
if (Object.keys(payload.properties).length === 0) {
|
|
27
|
+
throw new actions_core_1.IntegrationError('At-least one Custom Object property should be mapped', 'Object properties are not defined', 400);
|
|
28
|
+
}
|
|
29
|
+
if (!customObjectExpression.test(payload.objectType) && !hubspotDefinedObjects.includes(payload.objectType)) {
|
|
30
|
+
throw new actions_core_1.IntegrationError('Custom Object is not in valid format. Please make sure that you are using either a valid format of object’s fullyQualifiedName (eg: p11223344_myobject) or a supported HubSpot defined object (ie: deals, tickets, contacts and companies).', 'Custom Object is not in valid format', 400);
|
|
31
|
+
}
|
|
32
|
+
return request(`https://api.hubapi.com/crm/v3/objects/${payload.objectType}`, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
json: {
|
|
35
|
+
properties: { ...payload.properties }
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.default = action;
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/createCustomObjectRecord/index.ts"],"names":[],"mappings":";;AACA,wDAAwD;AAKxD,MAAM,qBAAqB,GAAa,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AAKrF,MAAM,sBAAsB,GAAG,IAAI,MAAM,CAAC,uCAAuC,CAAC,CAAA;AAElF,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EAAE,6CAA6C;IAC1D,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,wNAAwN;YAC1N,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EACT,yRAAyR;YAC3R,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,eAAe;YAChC,SAAS,EAAE,KAAK;SACjB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAEtC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YAChD,MAAM,IAAI,+BAAgB,CACxB,sDAAsD,EACtD,mCAAmC,EACnC,GAAG,CACJ,CAAA;SACF;QAGD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC3G,MAAM,IAAI,+BAAgB,CACxB,6OAA6O,EAC7O,sCAAsC,EACtC,GAAG,CACJ,CAAA;SACF;QAED,OAAO,OAAO,CAAC,yCAAyC,OAAO,CAAC,UAAU,EAAE,EAAE;YAC5E,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE;aACtC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/generated-types.ts"],"names":[],"mappings":""}
|