@segment/action-destinations 3.112.1-alpha.8 → 3.112.1-alpha.9

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.
Files changed (42) hide show
  1. package/dist/destinations/hubspot/index.js +3 -5
  2. package/dist/destinations/hubspot/index.js.map +1 -1
  3. package/dist/destinations/hubspot/properties.d.ts +1 -3
  4. package/dist/destinations/hubspot/properties.js +2 -4
  5. package/dist/destinations/hubspot/properties.js.map +1 -1
  6. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +2 -2
  7. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -1
  8. package/dist/destinations/hubspot/testHelper.d.ts +7 -0
  9. package/dist/destinations/hubspot/testHelper.js +24 -0
  10. package/dist/destinations/hubspot/testHelper.js.map +1 -0
  11. package/dist/destinations/hubspot/upsertContact/index.js +5 -5
  12. package/dist/destinations/hubspot/upsertContact/index.js.map +1 -1
  13. package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js +10 -39
  14. package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js.map +1 -1
  15. package/dist/destinations/linkedin-audiences/api/index.d.ts +13 -0
  16. package/dist/destinations/linkedin-audiences/api/index.js +62 -0
  17. package/dist/destinations/linkedin-audiences/api/index.js.map +1 -0
  18. package/dist/destinations/linkedin-audiences/constants.d.ts +2 -0
  19. package/dist/destinations/linkedin-audiences/constants.js +6 -0
  20. package/dist/destinations/linkedin-audiences/constants.js.map +1 -0
  21. package/dist/destinations/linkedin-audiences/generated-types.d.ts +2 -0
  22. package/dist/destinations/linkedin-audiences/index.js +49 -20
  23. package/dist/destinations/linkedin-audiences/index.js.map +1 -1
  24. package/dist/destinations/linkedin-audiences/types.d.ts +28 -0
  25. package/dist/destinations/linkedin-audiences/types.js +11 -0
  26. package/dist/destinations/linkedin-audiences/types.js.map +1 -0
  27. package/dist/destinations/linkedin-audiences/updateAudience/generated-types.d.ts +0 -2
  28. package/dist/destinations/linkedin-audiences/updateAudience/index.js +26 -63
  29. package/dist/destinations/linkedin-audiences/updateAudience/index.js.map +1 -1
  30. package/package.json +5 -4
  31. package/dist/destinations/hubspot/errors.d.ts +0 -17
  32. package/dist/destinations/hubspot/errors.js +0 -30
  33. package/dist/destinations/hubspot/errors.js.map +0 -1
  34. package/dist/destinations/hubspot/upsertCompany/generated-types.d.ts +0 -21
  35. package/dist/destinations/hubspot/upsertCompany/generated-types.js +0 -3
  36. package/dist/destinations/hubspot/upsertCompany/generated-types.js.map +0 -1
  37. package/dist/destinations/hubspot/upsertCompany/index.d.ts +0 -5
  38. package/dist/destinations/hubspot/upsertCompany/index.js +0 -321
  39. package/dist/destinations/hubspot/upsertCompany/index.js.map +0 -1
  40. package/dist/destinations/linkedin-audiences/linkedin-properties.d.ts +0 -1
  41. package/dist/destinations/linkedin-audiences/linkedin-properties.js +0 -5
  42. package/dist/destinations/linkedin-audiences/linkedin-properties.js.map +0 -1
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const actions_core_1 = require("@segment/actions-core");
4
4
  const crypto_1 = require("crypto");
5
- const actions_core_2 = require("@segment/actions-core");
5
+ const api_1 = require("../api");
6
6
  const action = {
7
7
  title: 'Sync To LinkedIn DMP Segment',
8
8
  description: 'Syncs contacts from a Personas Audience to a LinkedIn DMP Segment.',
@@ -29,12 +29,6 @@ const action = {
29
29
  '@path': '$.context.traits.email'
30
30
  }
31
31
  },
32
- send_email: {
33
- label: 'Send Email',
34
- description: 'Whether to send `email` to LinkedIn.',
35
- type: 'boolean',
36
- default: true
37
- },
38
32
  google_advertising_id: {
39
33
  label: 'User Google Advertising ID',
40
34
  description: "The user's Google Advertising ID to send to LinkedIn.",
@@ -43,12 +37,6 @@ const action = {
43
37
  '@path': '$.context.device.advertisingId'
44
38
  }
45
39
  },
46
- send_google_advertising_id: {
47
- label: 'Send Google Advertising ID',
48
- description: 'Whether to send Google Advertising ID to LinkedIn.',
49
- type: 'boolean',
50
- default: true
51
- },
52
40
  source_segment_id: {
53
41
  label: 'LinkedIn Source Segment ID',
54
42
  description: "A Segment-specific key associated with the LinkedIn DMP Segment. This is the lookup key Segment uses to fetch the DMP Segment from LinkedIn's API.",
@@ -80,66 +68,41 @@ const action = {
80
68
  }
81
69
  };
82
70
  async function processPayload(request, settings, payloads) {
83
- if (payloads[0].source_segment_id !== payloads[0].personas_audience_key) {
84
- throw new actions_core_2.IntegrationError('The value of `source_segment_id` and `personas_audience_key` must match.', 'Invalid settings.', 400);
71
+ validate(settings, payloads);
72
+ const linkedinApiClient = new api_1.LinkedInAudiences(request);
73
+ const dmpSegmentId = await getDmpSegmentId(linkedinApiClient, settings, payloads[0]);
74
+ const elements = extractUsers(settings, payloads);
75
+ if (elements.length < 1) {
76
+ return;
85
77
  }
86
- const dmpSegmentId = await getDmpSegmentId(request, settings, payloads[0]);
87
- const elements = extractUsers(payloads);
88
- const res = await request(`https://api.linkedin.com/rest/dmpSegments/${dmpSegmentId}/users`, {
89
- method: 'POST',
90
- headers: {
91
- 'X-RestLi-Method': 'BATCH_CREATE'
92
- },
93
- json: {
94
- elements
95
- },
96
- throwHttpErrors: false
97
- });
78
+ const res = await linkedinApiClient.batchUpdate(dmpSegmentId, elements);
98
79
  if (res.status !== 200) {
99
80
  throw new actions_core_1.RetryableError('Error while attempting to update LinkedIn DMP Segment. This batch will be retried.');
100
81
  }
101
82
  return res;
102
83
  }
103
- async function getDmpSegmentId(request, settings, payload) {
104
- const res = await getDmpSegment(request, settings, payload);
84
+ function validate(settings, payloads) {
85
+ if (payloads[0].source_segment_id !== payloads[0].personas_audience_key) {
86
+ throw new actions_core_1.IntegrationError('The value of `source_segment_id` and `personas_audience_key` must match.', 'INVALID_SETTINGS', 400);
87
+ }
88
+ if (!settings.send_google_advertising_id && !settings.send_email) {
89
+ throw new actions_core_1.IntegrationError('At least one of `Send Email` or `Send Google Advertising ID` must be set to `true`.', 'INVALID_SETTINGS.', 400);
90
+ }
91
+ }
92
+ async function getDmpSegmentId(linkedinApiClient, settings, payload) {
93
+ const res = await linkedinApiClient.getDmpSegment(settings, payload);
105
94
  const body = await res.json();
106
95
  if (body.elements?.length > 0) {
107
96
  return body.elements[0].id;
108
97
  }
109
- return createDmpSegment(request, settings, payload);
98
+ return createDmpSegment(linkedinApiClient, settings, payload);
110
99
  }
111
- async function getDmpSegment(request, settings, payload) {
112
- return request('https://api.linkedin.com/rest/dmpSegments', {
113
- method: 'GET',
114
- searchParams: {
115
- q: 'account',
116
- account: `urn:li:sponsoredAccount:${settings.ad_account_id}`,
117
- sourceSegmentId: payload.source_segment_id || '',
118
- sourcePlatform: 'SEGMENT'
119
- }
120
- });
121
- }
122
- async function createDmpSegment(request, settings, payload) {
123
- const res = await request('https://api.linkedin.com/rest/dmpSegments', {
124
- method: 'POST',
125
- json: {
126
- name: payload.dmp_segment_name,
127
- sourcePlatform: 'SEGMENT',
128
- sourceSegmentId: payload.source_segment_id,
129
- account: `urn:li:sponsoredAccount:${settings.ad_account_id}`,
130
- accessPolicy: 'PRIVATE',
131
- type: 'USER',
132
- destinations: [
133
- {
134
- destination: 'LINKEDIN'
135
- }
136
- ]
137
- }
138
- });
100
+ async function createDmpSegment(linkedinApiClient, settings, payload) {
101
+ const res = await linkedinApiClient.createDmpSegment(settings, payload);
139
102
  const headers = res.headers.toJSON();
140
103
  return headers['x-linkedin-id'];
141
104
  }
142
- function extractUsers(payloads) {
105
+ function extractUsers(settings, payloads) {
143
106
  const elements = [];
144
107
  payloads.forEach((payload) => {
145
108
  if (!payload.email && !payload.google_advertising_id) {
@@ -147,7 +110,7 @@ function extractUsers(payloads) {
147
110
  }
148
111
  elements.push({
149
112
  action: getAction(payload),
150
- userIds: getUserIds(payload)
113
+ userIds: getUserIds(settings, payload)
151
114
  });
152
115
  });
153
116
  return elements;
@@ -160,15 +123,15 @@ function getAction(payload) {
160
123
  return 'REMOVE';
161
124
  }
162
125
  }
163
- function getUserIds(payload) {
126
+ function getUserIds(settings, payload) {
164
127
  const users = [];
165
- if (payload.email) {
128
+ if (payload.email && settings.send_email === true) {
166
129
  users.push({
167
130
  idType: 'SHA256_EMAIL',
168
131
  idValue: crypto_1.createHash('sha256').update(payload.email).digest('hex')
169
132
  });
170
133
  }
171
- if (payload.google_advertising_id) {
134
+ if (payload.google_advertising_id && settings.send_google_advertising_id === true) {
172
135
  users.push({
173
136
  idType: 'GOOGLE_AID',
174
137
  idValue: payload.google_advertising_id
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-audiences/updateAudience/index.ts"],"names":[],"mappings":";;AAEA,wDAAsD;AAGtD,mCAAmC;AACnC,wDAAwD;AAExD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,8BAA8B;IACrC,WAAW,EAAE,oEAAoE;IACjF,MAAM,EAAE;QACN,gBAAgB,EAAE;YAChB,KAAK,EAAE,0BAA0B;YACjC,WAAW,EAAE,+CAA+C;YAC5D,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,2BAA2B;aACrC;SACF;QACD,eAAe,EAAE;YACf,KAAK,EAAE,iBAAiB;YACxB,WAAW,EAAE,0DAA0D;YACvE,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;QACD,KAAK,EAAE;YACL,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,+CAA+C;YAC5D,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,wBAAwB;aAClC;SACF;QACD,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,sCAAsC;YACnD,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;QACD,qBAAqB,EAAE;YACrB,KAAK,EAAE,4BAA4B;YACnC,WAAW,EAAE,uDAAuD;YACpE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,gCAAgC;aAC1C;SACF;QACD,0BAA0B,EAAE;YA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AK,EAAE;QACjB,KAAK,CAAC,IAAI,CAAC;YACT,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE,mBAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;SAClE,CAAC,CAAA;KACH;IAED,IAAI,OAAO,CAAC,qBAAqB,EAAE;QACjC,KAAK,CAAC,IAAI,CAAC;YACT,MAAM,EAAE,YAAY;YACpB,OAAO,EAAE,OAAO,CAAC,qBAAqB;SACvC,CAAC,CAAA;KACH;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,kBAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-audiences/updateAudience/index.ts"],"names":[],"mappings":";;AACA,wDAAuF;AAGvF,mCAAmC;AACnC,gCAA0C;AAE1C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,8BAA8B;IACrC,WAAW,EAAE,oEAAoE;IACjF,MAAM,EAAE;QACN,gBAAgB,EAAE;YAChB,KAAK,EAAE,0BAA0B;YACjC,WAAW,EAAE,+CAA+C;YAC5D,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,2BAA2B;aACrC;SACF;QACD,eAAe,EAAE;YACf,KAAK,EAAE,iBAAiB;YACxB,WAAW,EAAE,0DAA0D;YACvE,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,IAAI;SACd;QACD,KAAK,EAAE;YACL,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,+CAA+C;YAC5D,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,wBAAwB;aAClC;SACF;QACD,qBAAqB,EAAE;YACrB,KAAK,EAAE,4BAA4B;YACnC,WAAW,EAAE,uDAAuD;YACpE,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,gCAAgC;aAC1C;SACF;QACD,iBAAiB,EA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C,CAAC,CAAA;KACH;IAED,OAAO,KAAK,CAAA;AACd,CAAC;AAED,kBAAe,MAAM,CAAA"}
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.112.1-alpha.8",
4
+ "version": "3.112.1-alpha.9",
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.40.0",
42
- "@segment/actions-shared": "^1.23.0",
41
+ "@segment/actions-core": "^3.40.1-alpha.10",
42
+ "@segment/actions-shared": "^1.23.1-alpha.9",
43
43
  "cheerio": "^1.0.0-rc.10",
44
44
  "dayjs": "^1.10.7",
45
45
  "escape-goat": "^3",
@@ -64,5 +64,6 @@
64
64
  "coverageReporters": [
65
65
  "lcov"
66
66
  ]
67
- }
67
+ },
68
+ "gitHead": "e62aad28f924dd85cd9ca149537d5c08475c730d"
68
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,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=generated-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertCompany/generated-types.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { ActionDefinition } from '@segment/actions-core';
2
- import type { Settings } from '../generated-types';
3
- import type { Payload } from './generated-types';
4
- declare const action: ActionDefinition<Settings, Payload>;
5
- export default action;
@@ -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,CA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,OAAO,OAAO,CACZ,GAAG,6BAAgB,6BAA6B,SAAS,0BAA0B,SAAS,IAAI,eAAe,EAAE,EACjH;QACE,MAAM,EAAE,KAAK;KACd,CACF,CAAA;AACH,CAAC;AAQD,KAAK,UAAU,sBAAsB,CAAC,OAAsB,EAAE,qBAA4C;IACxG,IAAI;QACF,MAAM,qBAAqB,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC3D,OAAO,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAA;KACrC;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,KAAK,GAAG,CAAiB,CAAA;QAC/B,IAAI,+CAAsC,CAAC,KAAK,EAAE,sCAAyB,CAAC,EAAE;YAI5E,IAAI;gBAEF,MAAM,qCAAqC,CAAC,OAAO,CAAC,CAAA;aACrD;YAAC,OAAO,CAAC,EAAE;gBAGV,IAAK,CAAe,EAAE,QAAQ,EAAE,MAAM,KAAK,GAAG,EAAE;oBAC9C,MAAM,CAAC,CAAA;iBACR;aACF;YAGD,MAAM,qBAAqB,GAAG,MAAM,qBAAqB,EAAE,CAAA;YAC3D,OAAO,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAA;SACrC;aAAM;YACL,MAAM,CAAC,CAAA;SACR;KACF;AACH,CAAC;AAED,kBAAe,MAAM,CAAA"}
@@ -1 +0,0 @@
1
- export declare const LINKEDIN_API_VERSION = "202207";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LINKEDIN_API_VERSION = void 0;
4
- exports.LINKEDIN_API_VERSION = '202207';
5
- //# sourceMappingURL=linkedin-properties.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"linkedin-properties.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/linkedin-properties.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,QAAQ,CAAA"}