@segment/action-destinations 3.113.1-alpha.10 → 3.113.1-alpha.11
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/google-enhanced-conversions/uploadConversionAdjustment/generated-types.d.ts +1 -1
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js +5 -3
- package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/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 +9 -38
- 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/generated-types.d.ts +0 -2
- package/dist/destinations/linkedin-audiences/index.js +20 -49
- package/dist/destinations/linkedin-audiences/index.js.map +1 -1
- package/dist/destinations/linkedin-audiences/linkedin-properties.d.ts +1 -0
- package/dist/destinations/linkedin-audiences/linkedin-properties.js +5 -0
- package/dist/destinations/linkedin-audiences/linkedin-properties.js.map +1 -0
- package/dist/destinations/linkedin-audiences/updateAudience/generated-types.d.ts +2 -0
- package/dist/destinations/linkedin-audiences/updateAudience/index.js +67 -28
- 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 -20
- package/dist/destinations/hubspot/upsertCompany/generated-types.js.map +0 -1
- package/dist/destinations/hubspot/upsertCompany/index.js +0 -312
- package/dist/destinations/hubspot/upsertCompany/index.js.map +0 -1
- package/dist/destinations/linkedin-audiences/api/index.d.ts +0 -13
- package/dist/destinations/linkedin-audiences/api/index.js +0 -62
- package/dist/destinations/linkedin-audiences/api/index.js.map +0 -1
- package/dist/destinations/linkedin-audiences/constants.d.ts +0 -2
- package/dist/destinations/linkedin-audiences/constants.js +0 -6
- package/dist/destinations/linkedin-audiences/constants.js.map +0 -1
- package/dist/destinations/linkedin-audiences/types.d.ts +0 -28
- package/dist/destinations/linkedin-audiences/types.js +0 -11
- package/dist/destinations/linkedin-audiences/types.js.map +0 -1
|
@@ -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,20 +0,0 @@
|
|
|
1
|
-
export interface Payload {
|
|
2
|
-
groupid: string;
|
|
3
|
-
companysearchfields: {
|
|
4
|
-
[k: string]: unknown;
|
|
5
|
-
};
|
|
6
|
-
name: string;
|
|
7
|
-
description?: string;
|
|
8
|
-
address?: string;
|
|
9
|
-
city?: string;
|
|
10
|
-
state?: string;
|
|
11
|
-
zip?: string;
|
|
12
|
-
domain?: string;
|
|
13
|
-
phone?: string;
|
|
14
|
-
numberofemployees?: number;
|
|
15
|
-
industry?: string;
|
|
16
|
-
lifecyclestage?: string;
|
|
17
|
-
properties?: {
|
|
18
|
-
[k: string]: unknown;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertCompany/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -1,312 +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
|
-
address: {
|
|
64
|
-
label: 'Street Address',
|
|
65
|
-
description: 'The street address of the company.',
|
|
66
|
-
type: 'string',
|
|
67
|
-
default: {
|
|
68
|
-
'@path': '$.traits.address.street'
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
city: {
|
|
72
|
-
label: 'City',
|
|
73
|
-
description: 'The city where the company is located.',
|
|
74
|
-
type: 'string',
|
|
75
|
-
default: {
|
|
76
|
-
'@path': '$.traits.address.city'
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
state: {
|
|
80
|
-
label: 'State',
|
|
81
|
-
description: 'The state or region where the company is located.',
|
|
82
|
-
type: 'string',
|
|
83
|
-
default: {
|
|
84
|
-
'@path': '$.traits.address.state'
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
zip: {
|
|
88
|
-
label: 'Postal Code',
|
|
89
|
-
description: 'The postal or zip code of the company.',
|
|
90
|
-
type: 'string',
|
|
91
|
-
default: {
|
|
92
|
-
'@if': {
|
|
93
|
-
exists: { '@path': '$.traits.address.postalCode' },
|
|
94
|
-
then: { '@path': '$.traits.address.postalCode' },
|
|
95
|
-
else: { '@path': '$.traits.address.postal_code' }
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
domain: {
|
|
100
|
-
label: 'Domain',
|
|
101
|
-
description: 'The company’s website domain.',
|
|
102
|
-
type: 'string',
|
|
103
|
-
default: {
|
|
104
|
-
'@path': '$.traits.website'
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
phone: {
|
|
108
|
-
label: 'Phone',
|
|
109
|
-
description: 'The company’s primary phone number.',
|
|
110
|
-
type: 'string',
|
|
111
|
-
default: {
|
|
112
|
-
'@path': '$.traits.phone'
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
numberofemployees: {
|
|
116
|
-
label: 'Number of Employees',
|
|
117
|
-
description: 'The total number of people who work for the company.',
|
|
118
|
-
type: 'integer',
|
|
119
|
-
default: {
|
|
120
|
-
'@path': '$.traits.employees'
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
industry: {
|
|
124
|
-
label: 'Industry',
|
|
125
|
-
description: 'The type of business the company performs.',
|
|
126
|
-
type: 'string',
|
|
127
|
-
default: {
|
|
128
|
-
'@path': '$.traits.industry'
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
lifecyclestage: {
|
|
132
|
-
label: 'Lifecycle Stage',
|
|
133
|
-
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.',
|
|
134
|
-
type: 'string'
|
|
135
|
-
},
|
|
136
|
-
properties: {
|
|
137
|
-
label: 'Other Properties',
|
|
138
|
-
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.`,
|
|
139
|
-
type: 'object',
|
|
140
|
-
defaultObjectUI: 'keyvalue:only',
|
|
141
|
-
allowNull: false
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
perform: async (request, { payload, transactionContext }) => {
|
|
145
|
-
if (payload.properties?.[properties_1.SEGMENT_UNIQUE_IDENTIFIER]) {
|
|
146
|
-
throw errors_1.RestrictedPropertyThrowableError;
|
|
147
|
-
}
|
|
148
|
-
if (!transactionContext?.transaction?.contact_id) {
|
|
149
|
-
throw errors_1.MissingIdentityCallThrowableError;
|
|
150
|
-
}
|
|
151
|
-
const companyProperties = {
|
|
152
|
-
name: payload.name,
|
|
153
|
-
description: payload.description,
|
|
154
|
-
address: payload.address,
|
|
155
|
-
city: payload.city,
|
|
156
|
-
state: payload.state,
|
|
157
|
-
zip: payload.zip,
|
|
158
|
-
domain: payload.domain,
|
|
159
|
-
phone: payload.phone,
|
|
160
|
-
numberofemployees: payload.numberofemployees,
|
|
161
|
-
industry: payload.industry,
|
|
162
|
-
lifecyclestage: payload.lifecyclestage?.toLocaleLowerCase(),
|
|
163
|
-
[properties_1.SEGMENT_UNIQUE_IDENTIFIER]: payload.groupid,
|
|
164
|
-
...payload.properties
|
|
165
|
-
};
|
|
166
|
-
let companyId = '';
|
|
167
|
-
try {
|
|
168
|
-
const updateCompanyResponse = await updateCompany(request, payload.groupid, companyProperties, properties_1.SEGMENT_UNIQUE_IDENTIFIER);
|
|
169
|
-
companyId = updateCompanyResponse.data.id;
|
|
170
|
-
}
|
|
171
|
-
catch (e) {
|
|
172
|
-
const error = e;
|
|
173
|
-
if (errors_1.isSegmentUniqueIdentifierPropertyError(error, properties_1.SEGMENT_UNIQUE_IDENTIFIER)) {
|
|
174
|
-
await createSegmentUniqueIdentifierProperty(request);
|
|
175
|
-
throw errors_1.SegmentUniqueIdentifierMissingRetryableError;
|
|
176
|
-
}
|
|
177
|
-
if (error?.response?.status !== 404 &&
|
|
178
|
-
!errors_1.isSegmentUniqueIdentifierPropertyError(error, properties_1.SEGMENT_UNIQUE_IDENTIFIER)) {
|
|
179
|
-
throw e;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (!companyId) {
|
|
183
|
-
let searchCompanyResponse = null;
|
|
184
|
-
if (typeof payload.companysearchfields === 'object' && Object.keys(payload.companysearchfields).length > 0) {
|
|
185
|
-
try {
|
|
186
|
-
searchCompanyResponse = await searchCompany(request, { ...payload.companysearchfields });
|
|
187
|
-
}
|
|
188
|
-
catch (e) {
|
|
189
|
-
if (e?.response?.status === 400) {
|
|
190
|
-
throw errors_1.CompanySearchThrowableError;
|
|
191
|
-
}
|
|
192
|
-
throw e;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (!searchCompanyResponse || searchCompanyResponse.data.total === 0) {
|
|
196
|
-
const createCompanyWrapper = function () {
|
|
197
|
-
return createCompany(request, companyProperties);
|
|
198
|
-
};
|
|
199
|
-
companyId = await upsertCompanyWithRetry(request, createCompanyWrapper);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
if (searchCompanyResponse.data.total > 1) {
|
|
203
|
-
throw errors_1.MultipleCompaniesInSearchResultThrowableError;
|
|
204
|
-
}
|
|
205
|
-
companyId = searchCompanyResponse.data.results[0].id;
|
|
206
|
-
const updateCompanyWrapper = function () {
|
|
207
|
-
return updateCompany(request, companyId, companyProperties);
|
|
208
|
-
};
|
|
209
|
-
await upsertCompanyWithRetry(request, updateCompanyWrapper);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
await associateCompanyToContact(request, companyId, transactionContext?.transaction?.['contact_id'], properties_1.ASSOCIATION_TYPE);
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
function searchCompany(request, companySearchFields) {
|
|
216
|
-
const responseProperties = ['name', 'domain', 'lifecyclestage', properties_1.SEGMENT_UNIQUE_IDENTIFIER];
|
|
217
|
-
const responseSortBy = ['name'];
|
|
218
|
-
const companySearchPayload = {
|
|
219
|
-
filterGroups: [],
|
|
220
|
-
properties: [...responseProperties],
|
|
221
|
-
sorts: [...responseSortBy]
|
|
222
|
-
};
|
|
223
|
-
for (const [key, value] of Object.entries(companySearchFields)) {
|
|
224
|
-
companySearchPayload.filterGroups.push({
|
|
225
|
-
filters: [
|
|
226
|
-
{
|
|
227
|
-
propertyName: key,
|
|
228
|
-
operator: CompanySearchFilterOperator.EQ,
|
|
229
|
-
value
|
|
230
|
-
}
|
|
231
|
-
]
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/companies/search`, {
|
|
235
|
-
method: 'POST',
|
|
236
|
-
json: {
|
|
237
|
-
...companySearchPayload
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
function createCompany(request, properties) {
|
|
242
|
-
return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/companies`, {
|
|
243
|
-
method: 'POST',
|
|
244
|
-
json: {
|
|
245
|
-
properties: {
|
|
246
|
-
...properties
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
function updateCompany(request, uniqueIdentifier, properties, idProperty) {
|
|
252
|
-
const updateCompanyURL = `${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/companies/${uniqueIdentifier}` + (idProperty ? `?idProperty=${idProperty}` : '');
|
|
253
|
-
return request(updateCompanyURL, {
|
|
254
|
-
method: 'PATCH',
|
|
255
|
-
json: {
|
|
256
|
-
properties: {
|
|
257
|
-
...properties
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
function createSegmentUniqueIdentifierProperty(request) {
|
|
263
|
-
const segmentUniqueIdentifierProperty = {
|
|
264
|
-
name: properties_1.SEGMENT_UNIQUE_IDENTIFIER,
|
|
265
|
-
label: 'Segment Group ID',
|
|
266
|
-
description: 'Unique Property to map Segment Group ID with a HubSpot Company Object',
|
|
267
|
-
groupName: 'companyinformation',
|
|
268
|
-
type: 'string',
|
|
269
|
-
fieldType: 'text',
|
|
270
|
-
hidden: true,
|
|
271
|
-
displayOrder: -1,
|
|
272
|
-
hasUniqueValue: true,
|
|
273
|
-
formField: false
|
|
274
|
-
};
|
|
275
|
-
return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/properties/companies`, {
|
|
276
|
-
method: 'POST',
|
|
277
|
-
json: {
|
|
278
|
-
...segmentUniqueIdentifierProperty
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
function associateCompanyToContact(request, companyId, contactId, associationType) {
|
|
283
|
-
return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/companies/${companyId}/associations/contacts/${contactId}/${associationType}`, {
|
|
284
|
-
method: 'PUT'
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
async function upsertCompanyWithRetry(request, upsertCompanyFunction) {
|
|
288
|
-
try {
|
|
289
|
-
const upsertCompanyResponse = await upsertCompanyFunction();
|
|
290
|
-
return upsertCompanyResponse.data.id;
|
|
291
|
-
}
|
|
292
|
-
catch (e) {
|
|
293
|
-
const error = e;
|
|
294
|
-
if (errors_1.isSegmentUniqueIdentifierPropertyError(error, properties_1.SEGMENT_UNIQUE_IDENTIFIER)) {
|
|
295
|
-
try {
|
|
296
|
-
await createSegmentUniqueIdentifierProperty(request);
|
|
297
|
-
}
|
|
298
|
-
catch (e) {
|
|
299
|
-
if (e?.response?.status !== 409) {
|
|
300
|
-
throw e;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
const upsertCompanyResponse = await upsertCompanyFunction();
|
|
304
|
-
return upsertCompanyResponse.data.id;
|
|
305
|
-
}
|
|
306
|
-
else {
|
|
307
|
-
throw e;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
exports.default = action;
|
|
312
|
-
//# 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;YACP,KAAK,EAAE,UAAU;YACjB,WAAW,EAAE,oCAAoC,sCAAyB,eAAe;YACzF,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;oBAChC,IAAI,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE;oBAC9B,IAAI,EAAE,EAAE,OAAO,EAAE,mB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B,CAAC,IAAI,CAAC,EAAE,CAAA;SACrC;aAAM;YACL,MAAM,CAAC,CAAA;SACR;KACF;AACH,CAAC;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { RequestClient, ModifiedResponse } from '@segment/actions-core';
|
|
2
|
-
import type { Settings } from '../generated-types';
|
|
3
|
-
import type { Payload } from '../updateAudience/generated-types';
|
|
4
|
-
import type { ProfileAPIResponse, AdAccountUserResponse } from '../types';
|
|
5
|
-
export declare class LinkedInAudiences {
|
|
6
|
-
request: RequestClient;
|
|
7
|
-
constructor(request: RequestClient);
|
|
8
|
-
getProfile(): Promise<ModifiedResponse<ProfileAPIResponse>>;
|
|
9
|
-
getAdAccountUserProfile(settings: Settings, userId: string): Promise<ModifiedResponse<AdAccountUserResponse>>;
|
|
10
|
-
getDmpSegment(settings: Settings, payload: Payload): Promise<ModifiedResponse>;
|
|
11
|
-
createDmpSegment(settings: Settings, payload: Payload): Promise<ModifiedResponse>;
|
|
12
|
-
batchUpdate(dmpSegmentId: string, elements: Record<string, string>[]): Promise<ModifiedResponse>;
|
|
13
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkedInAudiences = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
class LinkedInAudiences {
|
|
6
|
-
constructor(request) {
|
|
7
|
-
this.request = request;
|
|
8
|
-
}
|
|
9
|
-
async getProfile() {
|
|
10
|
-
return this.request(`${constants_1.BASE_URL}/me`, {
|
|
11
|
-
method: 'GET'
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
async getAdAccountUserProfile(settings, userId) {
|
|
15
|
-
return this.request(`${constants_1.BASE_URL}/adAccountUsers/account=urn:li:sponsoredAccount:${settings.ad_account_id}&user=urn:li:person:${userId}`, {
|
|
16
|
-
method: 'GET'
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
async getDmpSegment(settings, payload) {
|
|
20
|
-
return this.request(`${constants_1.BASE_URL}/dmpSegments`, {
|
|
21
|
-
method: 'GET',
|
|
22
|
-
searchParams: {
|
|
23
|
-
q: 'account',
|
|
24
|
-
account: `urn:li:sponsoredAccount:${settings.ad_account_id}`,
|
|
25
|
-
sourceSegmentId: payload.source_segment_id || '',
|
|
26
|
-
sourcePlatform: 'SEGMENT'
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
async createDmpSegment(settings, payload) {
|
|
31
|
-
return this.request(`${constants_1.BASE_URL}/dmpSegments`, {
|
|
32
|
-
method: 'POST',
|
|
33
|
-
json: {
|
|
34
|
-
name: payload.dmp_segment_name,
|
|
35
|
-
sourcePlatform: 'SEGMENT',
|
|
36
|
-
sourceSegmentId: payload.source_segment_id,
|
|
37
|
-
account: `urn:li:sponsoredAccount:${settings.ad_account_id}`,
|
|
38
|
-
accessPolicy: 'PRIVATE',
|
|
39
|
-
type: 'USER',
|
|
40
|
-
destinations: [
|
|
41
|
-
{
|
|
42
|
-
destination: 'LINKEDIN'
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
async batchUpdate(dmpSegmentId, elements) {
|
|
49
|
-
return this.request(`${constants_1.BASE_URL}/dmpSegments/${dmpSegmentId}/users`, {
|
|
50
|
-
method: 'POST',
|
|
51
|
-
headers: {
|
|
52
|
-
'X-RestLi-Method': 'BATCH_CREATE'
|
|
53
|
-
},
|
|
54
|
-
json: {
|
|
55
|
-
elements
|
|
56
|
-
},
|
|
57
|
-
throwHttpErrors: false
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.LinkedInAudiences = LinkedInAudiences;
|
|
62
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../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E;oBACZ;wBACE,WAAW,EAAE,UAAU;qBACxB;iBACF;aACF;SACF,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,YAAoB,EAAE,QAAkC;QACxE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,oBAAQ,gBAAgB,YAAY,QAAQ,EAAE;YACnE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,iBAAiB,EAAE,cAAc;aAClC;YACD,IAAI,EAAE;gBACJ,QAAQ;aACT;YACD,eAAe,EAAE,KAAK;SACvB,CAAC,CAAA;IACJ,CAAC;CACF;AAjED,8CAiEC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BASE_URL = exports.LINKEDIN_API_VERSION = void 0;
|
|
4
|
-
exports.LINKEDIN_API_VERSION = '202207';
|
|
5
|
-
exports.BASE_URL = 'https://api.linkedin.com/rest';
|
|
6
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAC/B,QAAA,QAAQ,GAAG,+BAA+B,CAAA"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { HTTPError } from '@segment/actions-core';
|
|
2
|
-
export interface RefreshTokenResponse {
|
|
3
|
-
access_token: string;
|
|
4
|
-
scope: string;
|
|
5
|
-
expires_in: number;
|
|
6
|
-
token_type: string;
|
|
7
|
-
}
|
|
8
|
-
export interface ProfileAPIResponse {
|
|
9
|
-
id: string;
|
|
10
|
-
}
|
|
11
|
-
export interface AdAccountUserResponse {
|
|
12
|
-
role: string;
|
|
13
|
-
}
|
|
14
|
-
export declare class LinkedInRefreshTokenError extends HTTPError {
|
|
15
|
-
response: Response & {
|
|
16
|
-
data: {
|
|
17
|
-
error: string;
|
|
18
|
-
error_description: string;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export declare class LinkedInTestAuthenticationError extends HTTPError {
|
|
23
|
-
response: Response & {
|
|
24
|
-
data: {
|
|
25
|
-
message: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkedInTestAuthenticationError = exports.LinkedInRefreshTokenError = void 0;
|
|
4
|
-
const actions_core_1 = require("@segment/actions-core");
|
|
5
|
-
class LinkedInRefreshTokenError extends actions_core_1.HTTPError {
|
|
6
|
-
}
|
|
7
|
-
exports.LinkedInRefreshTokenError = LinkedInRefreshTokenError;
|
|
8
|
-
class LinkedInTestAuthenticationError extends actions_core_1.HTTPError {
|
|
9
|
-
}
|
|
10
|
-
exports.LinkedInTestAuthenticationError = LinkedInTestAuthenticationError;
|
|
11
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/types.ts"],"names":[],"mappings":";;;AAAA,wDAAiD;AAiBjD,MAAa,yBAA0B,SAAQ,wBAAS;CAOvD;AAPD,8DAOC;AAED,MAAa,+BAAgC,SAAQ,wBAAS;CAM7D;AAND,0EAMC"}
|