@segment/action-destinations 3.112.1-alpha.5 → 3.112.1-alpha.6

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 (38) hide show
  1. package/dist/destinations/hubspot/errors.d.ts +17 -0
  2. package/dist/destinations/hubspot/errors.js +30 -0
  3. package/dist/destinations/hubspot/errors.js.map +1 -0
  4. package/dist/destinations/hubspot/index.js +5 -3
  5. package/dist/destinations/hubspot/index.js.map +1 -1
  6. package/dist/destinations/hubspot/properties.d.ts +3 -1
  7. package/dist/destinations/hubspot/properties.js +4 -2
  8. package/dist/destinations/hubspot/properties.js.map +1 -1
  9. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +1 -1
  10. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -1
  11. package/dist/destinations/hubspot/upsertCompany/generated-types.d.ts +21 -0
  12. package/dist/destinations/{linkedin-audiences/types.js → hubspot/upsertCompany/generated-types.js} +1 -1
  13. package/dist/destinations/hubspot/upsertCompany/generated-types.js.map +1 -0
  14. package/dist/destinations/hubspot/upsertCompany/index.d.ts +5 -0
  15. package/dist/destinations/hubspot/upsertCompany/index.js +321 -0
  16. package/dist/destinations/hubspot/upsertCompany/index.js.map +1 -0
  17. package/dist/destinations/hubspot/upsertContact/index.js +2 -2
  18. package/dist/destinations/hubspot/upsertContact/index.js.map +1 -1
  19. package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js +2 -1
  20. package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js.map +1 -1
  21. package/dist/destinations/linkedin-audiences/generated-types.d.ts +0 -2
  22. package/dist/destinations/linkedin-audiences/index.js +18 -44
  23. package/dist/destinations/linkedin-audiences/index.js.map +1 -1
  24. package/dist/destinations/linkedin-audiences/linkedin-properties.d.ts +1 -0
  25. package/dist/destinations/linkedin-audiences/linkedin-properties.js +5 -0
  26. package/dist/destinations/linkedin-audiences/linkedin-properties.js.map +1 -0
  27. package/dist/destinations/linkedin-audiences/updateAudience/generated-types.d.ts +2 -0
  28. package/dist/destinations/linkedin-audiences/updateAudience/index.js +63 -26
  29. package/dist/destinations/linkedin-audiences/updateAudience/index.js.map +1 -1
  30. package/package.json +4 -5
  31. package/dist/destinations/linkedin-audiences/api/index.d.ts +0 -13
  32. package/dist/destinations/linkedin-audiences/api/index.js +0 -62
  33. package/dist/destinations/linkedin-audiences/api/index.js.map +0 -1
  34. package/dist/destinations/linkedin-audiences/constants.d.ts +0 -2
  35. package/dist/destinations/linkedin-audiences/constants.js +0 -6
  36. package/dist/destinations/linkedin-audiences/constants.js.map +0 -1
  37. package/dist/destinations/linkedin-audiences/types.d.ts +0 -12
  38. package/dist/destinations/linkedin-audiences/types.js.map +0 -1
@@ -0,0 +1,17 @@
1
+ import { IntegrationError, RetryableError, HTTPError } from '@segment/actions-core';
2
+ export declare class UpsertCompanyError 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: UpsertCompanyError, segmentUniqueIdentifierProperty: string): boolean;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSegmentUniqueIdentifierPropertyError = exports.SegmentUniqueIdentifierMissingRetryableError = exports.MultipleCompaniesInSearchResultThrowableError = exports.RestrictedPropertyThrowableError = exports.CompanySearchThrowableError = exports.MissingIdentityCallThrowableError = exports.UpsertCompanyError = void 0;
4
+ const actions_core_1 = require("@segment/actions-core");
5
+ const properties_1 = require("./properties");
6
+ class UpsertCompanyError extends actions_core_1.HTTPError {
7
+ }
8
+ exports.UpsertCompanyError = UpsertCompanyError;
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/errors.ts"],"names":[],"mappings":";;;AAAA,wDAAmF;AACnF,6CAAwD;AAExD,MAAa,kBAAmB,SAAQ,wBAAS;CAShD;AATD,gDASC;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,KAAyB,EACzB,+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"}
@@ -5,20 +5,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const sendCustomBehavioralEvent_1 = __importDefault(require("./sendCustomBehavioralEvent"));
7
7
  const upsertContact_1 = __importDefault(require("./upsertContact"));
8
+ const upsertCompany_1 = __importDefault(require("./upsertCompany"));
8
9
  const upsertCustomObjectRecord_1 = __importDefault(require("./upsertCustomObjectRecord"));
9
10
  const properties_1 = require("./properties");
10
11
  const destination = {
11
- name: 'Hubspot Cloud Mode (Actions)',
12
+ name: 'HubSpot Cloud Mode (Actions)',
12
13
  slug: 'actions-hubspot-cloud',
13
14
  mode: 'cloud',
14
15
  authentication: {
15
16
  scheme: 'oauth2',
16
17
  fields: {},
17
18
  testAuthentication: (request) => {
18
- return request(`${properties_1.hubSpotBaseURL}/crm/v3/objects/contacts?limit=1`);
19
+ return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/contacts?limit=1`);
19
20
  },
20
21
  refreshAccessToken: async (request, { auth }) => {
21
- const res = await request(`${properties_1.hubSpotBaseURL}/oauth/v1/token`, {
22
+ const res = await request(`${properties_1.HUBSPOT_BASE_URL}/oauth/v1/token`, {
22
23
  method: 'POST',
23
24
  body: new URLSearchParams({
24
25
  refresh_token: auth.refreshToken,
@@ -40,6 +41,7 @@ const destination = {
40
41
  actions: {
41
42
  sendCustomBehavioralEvent: sendCustomBehavioralEvent_1.default,
42
43
  upsertContact: upsertContact_1.default,
44
+ upsertCompany: upsertCompany_1.default,
43
45
  upsertCustomObjectRecord: upsertCustomObjectRecord_1.default
44
46
  }
45
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/index.ts"],"names":[],"mappings":";;;;;AAGA,4FAAmE;AACnE,oEAA2C;AAC3C,0FAAiE;AACjE,6CAA6C;AAK7C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,EAAE;QACV,kBAAk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O,OAAO,CAAC,GAAG,6BAAgB,kCAAkC,CAAC,CAAA;QACvE,CAAC;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAE9C,MAAM,GAAG,GAAG,MAAM,OAAO,CAAuB,GAAG,6BAAgB,iBAAiB,EAAE;gBACpF,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,eAAe,CAAC;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,SAAS,EAAE,IAAI,CAAC,QAAQ;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,UAAU,EAAE,eAAe;iBAC5B,CAAC;aACH,CAAC,CAAA;YAEF,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,CAAA;QAChD,CAAC;KACF;IACD,aAAa,CAAC,EAAE,IAAI,EAAE;QACpB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,EAAE,WAAW,EAAE;aAC7C;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,yBAAyB,EAAzB,mCAAyB;QACzB,aAAa,EAAb,uBAAa;QACb,aAAa,EAAb,uBAAa;QACb,wBAAwB,EAAxB,kCAAwB;KACzB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -1 +1,3 @@
1
- export declare const hubSpotBaseURL = "https://api.hubapi.com";
1
+ export declare const HUBSPOT_BASE_URL = "https://api.hubapi.com";
2
+ export declare const SEGMENT_UNIQUE_IDENTIFIER = "segment_group_id";
3
+ export declare const ASSOCIATION_TYPE = "company_to_contact";
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hubSpotBaseURL = void 0;
4
- exports.hubSpotBaseURL = 'https://api.hubapi.com';
3
+ exports.ASSOCIATION_TYPE = exports.SEGMENT_UNIQUE_IDENTIFIER = exports.HUBSPOT_BASE_URL = void 0;
4
+ exports.HUBSPOT_BASE_URL = 'https://api.hubapi.com';
5
+ exports.SEGMENT_UNIQUE_IDENTIFIER = 'segment_group_id';
6
+ exports.ASSOCIATION_TYPE = 'company_to_contact';
5
7
  //# sourceMappingURL=properties.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/properties.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,wBAAwB,CAAA"}
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/properties.ts"],"names":[],"mappings":";;;AACa,QAAA,gBAAgB,GAAG,wBAAwB,CAAA;AAG3C,QAAA,yBAAyB,GAAG,kBAAkB,CAAA;AAG9C,QAAA,gBAAgB,GAAG,oBAAoB,CAAA"}
@@ -59,7 +59,7 @@ const action = {
59
59
  objectId: payload.objectId,
60
60
  properties: payload.properties
61
61
  };
62
- return request(`${properties_1.hubSpotBaseURL}/events/v3/send`, {
62
+ return request(`${properties_1.HUBSPOT_BASE_URL}/events/v3/send`, {
63
63
  method: 'post',
64
64
  json: event
65
65
  });
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/sendCustomBehavioralEvent/index.ts"],"names":[],"mappings":";;AAEA,8CAA8C;AAY9C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,8BAA8B;IACrC,WAAW,EAAE,4CAA4C;IACzD,mBAAmB,EAAE,gBAAgB;IACrC,MAAM,EAAE;QACN,SAAS,EAAE;YACT,KAAK,EAAE,YAAY;YACnB,WAAW,EACT,gRAAgR;YAClR,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,UAAU,EAAE;YACV,KAAK,EAAE,iBAAiB;YACxB,WAAW,EAAE,sFAAsF;YACnG,IAAI,EAAE,UAAU;YAChB,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;aACvB;SACF;QACD,KAAK,EAAE;YACL,KAAK,EAAE,eAAe;YACtB,WAAW,EACT,kHAAkH;YACpH,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;oBACzC,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;oBACvC,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;iBAC5C;aACF;SACF;QACD,GAAG,EAAE;YACH,KAAK,EAAE,YAAY;YACnB,WAAW,EACT,wHAAwH;YAC1H,IAAI,EAAE,QAAQ;SACf;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,WAAW;YAClB,WAAW,EACT,qLAAqL;YACvL,IAAI,EAAE,QAAQ;SACf;QACD,UAAU,EAAE;YACV,KAAK,EAAE,kBAAkB;YACzB,WAAW,EACT,yNAAyN;YAC3N,IAAI,EAAE,QAAQ;YACd,eAAe,EAAE,eAAe;SACjC;KACF;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAChC,MAAM,KAAK,GAA0B;YACnC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAA;QACD,OAAO,OAAO,CAAC,GAAG,2BAAc,iBAAiB,EAAE;YACjD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,KAAK;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/sendCustomBehavioralEvent/index.ts"],"names":[],"mappings":";;AAEA,8CAAgD;AAYhD,MAAM,MAAM,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AAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;SAC/B,CAAA;QACD,OAAO,OAAO,CAAC,GAAG,6BAAgB,iBAAiB,EAAE;YACnD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,KAAK;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,21 @@
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 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertCompany/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,321 @@
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. 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: Please 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
@@ -0,0 +1 @@
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,mBAAmB,EAAE;iBACvC;aACF;SACF;QACD,mBAAmB,EAAE;YACnB,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EACT,sVAAsV;YACxV,IAAI,EAAE,QAAQ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AM,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"}
@@ -160,7 +160,7 @@ const action = {
160
160
  }
161
161
  };
162
162
  async function createContact(request, contactProperties) {
163
- return request(`${properties_1.hubSpotBaseURL}/crm/v3/objects/contacts`, {
163
+ return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/contacts`, {
164
164
  method: 'POST',
165
165
  json: {
166
166
  properties: {
@@ -170,7 +170,7 @@ async function createContact(request, contactProperties) {
170
170
  });
171
171
  }
172
172
  async function updateContact(request, email, properties) {
173
- return request(`${properties_1.hubSpotBaseURL}/crm/v3/objects/contacts/${email}?idProperty=email`, {
173
+ return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/contacts/${email}?idProperty=email`, {
174
174
  method: 'PATCH',
175
175
  json: {
176
176
  properties: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertContact/index.ts"],"names":[],"mappings":";;AAAA,wDAAiD;AAGjD,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;S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,EAAE;QAC3E,MAAM,EAAE,MAAM;QACd,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,GAAG,iBAAiB;aACrB;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,KAAK,UAAU,aAAa,CAAC,OAAsB,EAAE,KAAa,EAAE,UAAsC;IACxG,OAAO,OAAO,CAAkB,GAAG,2BAAc,4BAA4B,KAAK,mBAAmB,EAAE;QACrG,MAAM,EAAE,OAAO;QACf,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,GAAG,UAAU;aACd;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,kBAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertContact/index.ts"],"names":[],"mappings":";;AAAA,wDAAiD;AAIjD,8CAAgD;AAOhD,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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;QACvG,MAAM,EAAE,OAAO;QACf,IAAI,EAAE;YACJ,UAAU,EAAE;gBACV,GAAG,UAAU;aACd;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAED,kBAAe,MAAM,CAAA"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const actions_core_1 = require("@segment/actions-core");
4
+ const properties_1 = require("../properties");
4
5
  const hubspotDefinedObjects = ['deals', 'tickets'];
5
6
  const customObjectExpression = new RegExp('^[a-zA-Z0-9]+_[a-zA-Z][a-zA-Z0-9_-]+$');
6
7
  const action = {
@@ -26,7 +27,7 @@ const action = {
26
27
  if (!customObjectExpression.test(payload.objectType) && !hubspotDefinedObjects.includes(payload.objectType)) {
27
28
  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 (i.e.: deals, tickets).', 'Custom Object is not in valid format', 400);
28
29
  }
29
- return request(`https://api.hubapi.com/crm/v3/objects/${payload.objectType}`, {
30
+ return request(`${properties_1.HUBSPOT_BASE_URL}/crm/v3/objects/${payload.objectType}`, {
30
31
  method: 'POST',
31
32
  json: {
32
33
  properties: { ...payload.properties }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertCustomObjectRecord/index.ts"],"names":[],"mappings":";;AACA,wDAAwD;AAKxD,MAAM,qBAAqB,GAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAK5D,MAAM,sBAAsB,GAAG,IAAI,MAAM,CAAC,uCAAuC,CAAC,CAAA;AAIlF,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,6BAA6B;IACpC,WAAW,EAAE,0DAA0D;IACvE,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,+YAA+Y;YACjZ,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,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,uNAAuN,EACvN,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"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/upsertCustomObjectRecord/index.ts"],"names":[],"mappings":";;AACA,wDAAwD;AAGxD,8CAAgD;AAGhD,MAAM,qBAAqB,GAAa,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAK5D,MAAM,sBAAsB,GAAG,IAAI,MAAM,CAAC,uCAAuC,CAAC,CAAA;AAIlF,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,6BAA6B;IACpC,WAAW,EAAE,0DAA0D;IACvE,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,+YAA+Y;YACjZ,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,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,uNAAuN,EACvN,sCAAsC,EACtC,GAAG,CACJ,CAAA;SACF;QAED,OAAO,OAAO,CAAC,GAAG,6BAAgB,mBAAmB,OAAO,CAAC,UAAU,EAAE,EAAE;YACzE,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"}
@@ -1,5 +1,3 @@
1
1
  export interface Settings {
2
2
  ad_account_id: string;
3
- send_email: boolean;
4
- send_google_advertising_id: boolean;
5
3
  }
@@ -3,12 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const actions_core_1 = require("@segment/actions-core");
7
6
  const updateAudience_1 = __importDefault(require("./updateAudience"));
8
- const constants_1 = require("./constants");
7
+ const linkedin_properties_1 = require("./linkedin-properties");
9
8
  const https_1 = __importDefault(require("https"));
10
- const api_1 = require("./api");
11
- const actions_core_2 = require("@segment/actions-core");
12
9
  const destination = {
13
10
  name: 'Linkedin Audiences',
14
11
  slug: 'actions-linkedin-audiences',
@@ -21,33 +18,17 @@ const destination = {
21
18
  description: 'The id of the LinkedIn Ad Account where batches should be synced.',
22
19
  type: 'string',
23
20
  required: true
24
- },
25
- send_email: {
26
- label: 'Send Email',
27
- description: 'Whether to send `email` to LinkedIn. This setting applies to mappings you create in this destination instance.',
28
- type: 'boolean',
29
- default: true,
30
- required: true
31
- },
32
- send_google_advertising_id: {
33
- label: 'Send Google Advertising ID',
34
- description: 'Whether to send Google Advertising ID to LinkedIn. This setting applies to all mappings you create in this destination instance.',
35
- type: 'boolean',
36
- default: true,
37
- required: true
38
21
  }
39
22
  },
40
23
  testAuthentication: async (request, { settings, auth }) => {
41
24
  if (!auth?.accessToken) {
42
- throw new actions_core_1.InvalidAuthenticationError('Please authenticate via Oauth before updating other settings and/or enabling the destination.');
25
+ throw new Error('Please authenticate via Oauth before updating other settings and/or enabling the destination.');
43
26
  }
44
- if (!settings.send_email && !settings.send_google_advertising_id) {
45
- throw new Error('At least one of `Send Email` or `Send Google Advertising ID` must be set to `true`.');
46
- }
47
- const linkedinApiClient = new api_1.LinkedInAudiences(request);
48
27
  let firstRes;
49
28
  try {
50
- firstRes = await linkedinApiClient.getProfile();
29
+ firstRes = await request(`https://api.linkedin.com/rest/me`, {
30
+ method: 'GET'
31
+ });
51
32
  }
52
33
  catch (e) {
53
34
  if (e.message === 'Unauthorized') {
@@ -58,7 +39,9 @@ const destination = {
58
39
  const userId = firstRes?.data?.id;
59
40
  let secondRes;
60
41
  try {
61
- secondRes = await linkedinApiClient.getAdAccountUserProfile(settings, userId);
42
+ secondRes = await request(`https://api.linkedin.com/rest/adAccountUsers/account=urn:li:sponsoredAccount:${settings.ad_account_id}&user=urn:li:person:${userId}`, {
43
+ method: 'GET'
44
+ });
62
45
  }
63
46
  catch (e) {
64
47
  if (e.message === 'Not Found') {
@@ -73,24 +56,15 @@ const destination = {
73
56
  return true;
74
57
  },
75
58
  refreshAccessToken: async (request, { auth }) => {
76
- let res;
77
- try {
78
- res = await request('https://www.linkedin.com/oauth/v2/accessToken', {
79
- method: 'POST',
80
- body: new URLSearchParams({
81
- refresh_token: auth.refreshToken,
82
- client_id: auth.clientId,
83
- client_secret: auth.clientSecret,
84
- grant_type: 'refresh_token'
85
- })
86
- });
87
- }
88
- catch (e) {
89
- if (e.response?.data?.error === 'invalid_grant') {
90
- throw new actions_core_2.IntegrationError('Invalid Authentication', 'EXPIRED_REFRESH_TOKEN', 401);
91
- }
92
- throw e;
93
- }
59
+ const res = await request('https://www.linkedin.com/oauth/v2/accessToken', {
60
+ method: 'POST',
61
+ body: new URLSearchParams({
62
+ refresh_token: auth.refreshToken,
63
+ client_id: auth.clientId,
64
+ client_secret: auth.clientSecret,
65
+ grant_type: 'refresh_token'
66
+ })
67
+ });
94
68
  return { accessToken: res?.data?.access_token };
95
69
  }
96
70
  },
@@ -99,7 +73,7 @@ const destination = {
99
73
  return {
100
74
  headers: {
101
75
  authorization: `Bearer ${auth?.accessToken}`,
102
- 'LinkedIn-Version': constants_1.LINKEDIN_API_VERSION
76
+ 'LinkedIn-Version': linkedin_properties_1.LINKEDIN_API_VERSION
103
77
  },
104
78
  agent
105
79
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAkE;AAElE,sEAA6C;AAC7C,2CAAkD;AAClD,kDAAyB;AACzB,+BAAyC;AAGzC,wDAAwD;AAExD,MAAM,WAAW,GAAoC;IAEnD,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,4BAA4B;IAClC,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,aAAa,EAAE;gBACb,KAAK,EAAE,wBAAwB;gBAC/B,WAAW,EAAE,mEAAmE;gBAChF,IAAI,EAAE,QAAQ;gBACd,QAAQ,EAAE,IAAI;aACf;YACD,UAAU,EAAE;gBACV,KAAK,EAAE,YAAY;gBACnB,WAAW,EACT,gHAAgH;gBAClH,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,IAAI;gBACb,QA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H,CACpH,CAAA;iBACF;gBACD,MAAM,CAAC,CAAA;aACR;YAED,MAAM,QAAQ,GAAG,SAAS,EAAE,IAAI,CAAC,IAAI,CAAA;YAErC,IAAI,QAAQ,KAAK,QAAQ,EAAE;gBACzB,MAAM,IAAI,KAAK,CACb,gJAAgJ,CACjJ,CAAA;aACF;YAED,OAAO,IAAI,CAAA;QACb,CAAC;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAC9C,MAAM,GAAG,GAAG,MAAM,OAAO,CAAuB,+CAA+C,EAAE;gBAC/F,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,eAAe,CAAC;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,SAAS,EAAE,IAAI,CAAC,QAAQ;oBACxB,aAAa,EAAE,IAAI,CAAC,YAAY;oBAChC,UAAU,EAAE,eAAe;iBAC5B,CAAC;aACH,CAAC,CAAA;YAEF,OAAO,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,EAAE,CAAA;QACjD,CAAC;KACF;IACD,aAAa,CAAC,EAAE,IAAI,EAAE;QAGpB,MAAM,KAAK,GAAG,IAAI,eAAK,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAElD,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,EAAE,WAAW,EAAE;gBAC5C,kBAAkB,EAAE,0CAAoB;aACzC;YACD,KAAK;SACN,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const LINKEDIN_API_VERSION = "202207";
@@ -0,0 +1,5 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linkedin-properties.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/linkedin-properties.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,QAAQ,CAAA"}
@@ -2,7 +2,9 @@ export interface Payload {
2
2
  dmp_segment_name?: string;
3
3
  enable_batching?: boolean;
4
4
  email?: string;
5
+ send_email?: boolean;
5
6
  google_advertising_id?: string;
7
+ send_google_advertising_id?: boolean;
6
8
  source_segment_id?: string;
7
9
  personas_audience_key: string;
8
10
  event_name?: string;
@@ -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 api_1 = require("../api");
5
+ const actions_core_2 = require("@segment/actions-core");
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,6 +29,12 @@ 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
+ },
32
38
  google_advertising_id: {
33
39
  label: 'User Google Advertising ID',
34
40
  description: "The user's Google Advertising ID to send to LinkedIn.",
@@ -37,6 +43,12 @@ const action = {
37
43
  '@path': '$.context.device.advertisingId'
38
44
  }
39
45
  },
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
+ },
40
52
  source_segment_id: {
41
53
  label: 'LinkedIn Source Segment ID',
42
54
  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.",
@@ -68,41 +80,66 @@ const action = {
68
80
  }
69
81
  };
70
82
  async function processPayload(request, settings, payloads) {
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;
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);
77
85
  }
78
- const res = await linkedinApiClient.batchUpdate(dmpSegmentId, elements);
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
+ });
79
98
  if (res.status !== 200) {
80
99
  throw new actions_core_1.RetryableError('Error while attempting to update LinkedIn DMP Segment. This batch will be retried.');
81
100
  }
82
101
  return res;
83
102
  }
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);
103
+ async function getDmpSegmentId(request, settings, payload) {
104
+ const res = await getDmpSegment(request, settings, payload);
94
105
  const body = await res.json();
95
106
  if (body.elements?.length > 0) {
96
107
  return body.elements[0].id;
97
108
  }
98
- return createDmpSegment(linkedinApiClient, settings, payload);
109
+ return createDmpSegment(request, settings, payload);
99
110
  }
100
- async function createDmpSegment(linkedinApiClient, settings, payload) {
101
- const res = await linkedinApiClient.createDmpSegment(settings, payload);
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
+ });
102
139
  const headers = res.headers.toJSON();
103
140
  return headers['x-linkedin-id'];
104
141
  }
105
- function extractUsers(settings, payloads) {
142
+ function extractUsers(payloads) {
106
143
  const elements = [];
107
144
  payloads.forEach((payload) => {
108
145
  if (!payload.email && !payload.google_advertising_id) {
@@ -110,7 +147,7 @@ function extractUsers(settings, payloads) {
110
147
  }
111
148
  elements.push({
112
149
  action: getAction(payload),
113
- userIds: getUserIds(settings, payload)
150
+ userIds: getUserIds(payload)
114
151
  });
115
152
  });
116
153
  return elements;
@@ -123,15 +160,15 @@ function getAction(payload) {
123
160
  return 'REMOVE';
124
161
  }
125
162
  }
126
- function getUserIds(settings, payload) {
163
+ function getUserIds(payload) {
127
164
  const users = [];
128
- if (payload.email && settings.send_email === true) {
165
+ if (payload.email) {
129
166
  users.push({
130
167
  idType: 'SHA256_EMAIL',
131
168
  idValue: crypto_1.createHash('sha256').update(payload.email).digest('hex')
132
169
  });
133
170
  }
134
- if (payload.google_advertising_id && settings.send_google_advertising_id === true) {
171
+ if (payload.google_advertising_id) {
135
172
  users.push({
136
173
  idType: 'GOOGLE_AID',
137
174
  idValue: payload.google_advertising_id
@@ -1 +1 @@
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,EAAE;YACjB,KAAK,EAAE,4BAA4B;YACnC,WAAW,EACT,oJAAoJ;YACtJ,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,2BAA2B;aACrC;SACF;QACD,qBAAqB,EAAE;YACrB,KAAK,EAAE,+BAA+B;YACtC,WAAW,EACT,mMAAmM;YACrM,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,UAAU,EAAE;YACV,K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YACpD,OAAM;SACP;QAED,QAAQ,CAAC,IAAI,CAAC;YACZ,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC;YAC1B,OAAO,EAAE,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC;SACvC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED,SAAS,SAAS,CAAC,OAAgB;IACjC,IAAI,OAAO,CAAC,UAAU,KAAK,kBAAkB,EAAE;QAC7C,OAAO,KAAK,CAAA;KACb;SAAM,IAAI,OAAO,CAAC,UAAU,KAAK,iBAAiB,EAAE;QACnD,OAAO,QAAQ,CAAA;KAChB;AACH,CAAC;AAED,SAAS,UAAU,CAAC,QAAkB,EAAE,OAAgB;IACtD,MAAM,KAAK,GAAG,EAAE,CAAA;IAEhB,IAAI,OAAO,CAAC,KAAK,IAAI,QAAQ,CAAC,UAAU,KAAK,IAAI,EAAE;QACjD,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,IAAI,QAAQ,CAAC,0BAA0B,KAAK,IAAI,EAAE;QACjF,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":";;AAEA,wDAAsD;AAGtD,mCAAmC;AACnC,wDAAwD;AAExD,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,8BAA8B;IACrC,WAAW,EAAE,oE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ions engine and definitions.",
4
- "version": "3.112.1-alpha.5",
4
+ "version": "3.112.1-alpha.6",
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.1-alpha.5",
42
- "@segment/actions-shared": "^1.23.1-alpha.5",
41
+ "@segment/actions-core": "^3.40.0",
42
+ "@segment/actions-shared": "^1.23.0",
43
43
  "cheerio": "^1.0.0-rc.10",
44
44
  "dayjs": "^1.10.7",
45
45
  "escape-goat": "^3",
@@ -64,6 +64,5 @@
64
64
  "coverageReporters": [
65
65
  "lcov"
66
66
  ]
67
- },
68
- "gitHead": "5b349d07522eaf52dce384303582e687a684577b"
67
+ }
69
68
  }
@@ -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":["../../../../src/destinations/linkedin-audiences/api/index.ts"],"names":[],"mappings":";;;AAGA,4CAAuC;AAGvC,MAAa,iBAAiB;IAG5B,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,oBAAQ,K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;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,2 +0,0 @@
1
- export declare const LINKEDIN_API_VERSION = "202207";
2
- export declare const BASE_URL = "https://api.linkedin.com/rest";
@@ -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,12 +0,0 @@
1
- export interface RefreshTokenResponse {
2
- access_token: string;
3
- scope: string;
4
- expires_in: number;
5
- token_type: string;
6
- }
7
- export interface ProfileAPIResponse {
8
- id: string;
9
- }
10
- export interface AdAccountUserResponse {
11
- role: string;
12
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/types.ts"],"names":[],"mappings":""}