@segment/action-destinations 3.110.1-apha.5 → 3.110.2-alpha.0

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 (162) hide show
  1. package/dist/destinations/actions-pardot/prospects/index.js.map +1 -1
  2. package/dist/destinations/adobe-target/adobeTarget_operations.d.ts +1 -1
  3. package/dist/destinations/adobe-target/adobeTarget_operations.js +18 -14
  4. package/dist/destinations/adobe-target/adobeTarget_operations.js.map +1 -1
  5. package/dist/destinations/amplitude/logEvent/generated-types.d.ts +0 -21
  6. package/dist/destinations/amplitude/logEvent/index.js +10 -96
  7. package/dist/destinations/amplitude/logEvent/index.js.map +1 -1
  8. package/dist/destinations/cordial/addProductToCart/index.js +1 -1
  9. package/dist/destinations/cordial/addProductToCart/index.js.map +1 -1
  10. package/dist/destinations/cordial/index.js +1 -1
  11. package/dist/destinations/cordial/index.js.map +1 -1
  12. package/dist/destinations/cordial/removeProductFromCart/index.js.map +1 -1
  13. package/dist/destinations/cordial/upsertOrder/index.js +8 -8
  14. package/dist/destinations/cordial/upsertOrder/index.js.map +1 -1
  15. package/dist/destinations/customerio/trackEvent/index.js.map +1 -1
  16. package/dist/destinations/engage-messaging-sendgrid/generated-types.d.ts +0 -1
  17. package/dist/destinations/engage-messaging-sendgrid/index.js +0 -5
  18. package/dist/destinations/engage-messaging-sendgrid/index.js.map +1 -1
  19. package/dist/destinations/engage-messaging-sendgrid/sendEmail/generated-types.d.ts +1 -0
  20. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js +8 -6
  21. package/dist/destinations/engage-messaging-sendgrid/sendEmail/index.js.map +1 -1
  22. package/dist/destinations/engage-messaging-twilio/sendSms/index.js.map +1 -1
  23. package/dist/destinations/facebook-conversions-api/addToCart/index.js +1 -5
  24. package/dist/destinations/facebook-conversions-api/addToCart/index.js.map +1 -1
  25. package/dist/destinations/facebook-conversions-api/custom/index.js +1 -5
  26. package/dist/destinations/facebook-conversions-api/custom/index.js.map +1 -1
  27. package/dist/destinations/facebook-conversions-api/fb-capi-properties.d.ts +2 -1
  28. package/dist/destinations/facebook-conversions-api/fb-capi-properties.js +8 -6
  29. package/dist/destinations/facebook-conversions-api/fb-capi-properties.js.map +1 -1
  30. package/dist/destinations/facebook-conversions-api/initiateCheckout/index.js +1 -5
  31. package/dist/destinations/facebook-conversions-api/initiateCheckout/index.js.map +1 -1
  32. package/dist/destinations/facebook-conversions-api/pageView/index.js +1 -5
  33. package/dist/destinations/facebook-conversions-api/pageView/index.js.map +1 -1
  34. package/dist/destinations/facebook-conversions-api/purchase/index.js +1 -5
  35. package/dist/destinations/facebook-conversions-api/purchase/index.js.map +1 -1
  36. package/dist/destinations/facebook-conversions-api/search/index.js +1 -5
  37. package/dist/destinations/facebook-conversions-api/search/index.js.map +1 -1
  38. package/dist/destinations/facebook-conversions-api/viewContent/index.js +1 -5
  39. package/dist/destinations/facebook-conversions-api/viewContent/index.js.map +1 -1
  40. package/dist/destinations/google-enhanced-conversions/functions.d.ts +4 -1
  41. package/dist/destinations/google-enhanced-conversions/functions.js +22 -1
  42. package/dist/destinations/google-enhanced-conversions/functions.js.map +1 -1
  43. package/dist/destinations/google-enhanced-conversions/index.js +2 -2
  44. package/dist/destinations/google-enhanced-conversions/index.js.map +1 -1
  45. package/dist/destinations/google-enhanced-conversions/postConversion/index.js +1 -1
  46. package/dist/destinations/google-enhanced-conversions/postConversion/index.js.map +1 -1
  47. package/dist/destinations/google-enhanced-conversions/types.d.ts +8 -0
  48. package/dist/destinations/google-enhanced-conversions/types.js +2 -0
  49. package/dist/destinations/google-enhanced-conversions/types.js.map +1 -1
  50. package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.js +17 -31
  51. package/dist/destinations/google-enhanced-conversions/uploadCallConversion/index.js.map +1 -1
  52. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/generated-types.d.ts +1 -1
  53. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.js +30 -49
  54. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/index.js.map +1 -1
  55. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/generated-types.d.ts +1 -1
  56. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js +60 -43
  57. package/dist/destinations/google-enhanced-conversions/uploadConversionAdjustment/index.js.map +1 -1
  58. package/dist/destinations/hubspot/contact/generated-types.d.ts +17 -0
  59. package/dist/destinations/{google-enhanced-conversions/uploadClickConversion/types.js → hubspot/contact/generated-types.js} +1 -1
  60. package/dist/destinations/hubspot/contact/generated-types.js.map +1 -0
  61. package/dist/destinations/hubspot/contact/index.d.ts +5 -0
  62. package/dist/destinations/hubspot/contact/index.js +186 -0
  63. package/dist/destinations/hubspot/contact/index.js.map +1 -0
  64. package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.d.ts +6 -0
  65. package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.js +3 -0
  66. package/dist/destinations/hubspot/createCustomObjectRecord/generated-types.js.map +1 -0
  67. package/dist/destinations/hubspot/createCustomObjectRecord/index.d.ts +5 -0
  68. package/dist/destinations/hubspot/createCustomObjectRecord/index.js +41 -0
  69. package/dist/destinations/hubspot/createCustomObjectRecord/index.js.map +1 -0
  70. package/dist/destinations/hubspot/generated-types.d.ts +2 -0
  71. package/dist/destinations/hubspot/generated-types.js +3 -0
  72. package/dist/destinations/hubspot/generated-types.js.map +1 -0
  73. package/dist/destinations/hubspot/index.d.ts +4 -0
  74. package/dist/destinations/hubspot/index.js +46 -0
  75. package/dist/destinations/hubspot/index.js.map +1 -0
  76. package/dist/destinations/hubspot/properties.d.ts +1 -0
  77. package/dist/destinations/hubspot/properties.js +5 -0
  78. package/dist/destinations/hubspot/properties.js.map +1 -0
  79. package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.d.ts +10 -0
  80. package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.js +3 -0
  81. package/dist/destinations/hubspot/sendCustomBehavioralEvent/generated-types.js.map +1 -0
  82. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.d.ts +5 -0
  83. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js +69 -0
  84. package/dist/destinations/hubspot/sendCustomBehavioralEvent/index.js.map +1 -0
  85. package/dist/destinations/hubspot/testHelper.d.ts +7 -0
  86. package/dist/destinations/hubspot/testHelper.js +24 -0
  87. package/dist/destinations/hubspot/testHelper.js.map +1 -0
  88. package/dist/destinations/index.js +1 -1
  89. package/dist/destinations/index.js.map +1 -1
  90. package/dist/destinations/linkedin-audiences/index.js +9 -7
  91. package/dist/destinations/linkedin-audiences/index.js.map +1 -1
  92. package/dist/destinations/linkedin-audiences/updateAudience/index.js +19 -10
  93. package/dist/destinations/linkedin-audiences/updateAudience/index.js.map +1 -1
  94. package/dist/destinations/loops/createContact/generated-types.d.ts +3 -0
  95. package/dist/destinations/loops/createContact/generated-types.js +3 -0
  96. package/dist/destinations/loops/createContact/generated-types.js.map +1 -0
  97. package/dist/destinations/loops/createContact/index.d.ts +5 -0
  98. package/dist/destinations/loops/createContact/index.js +33 -0
  99. package/dist/destinations/loops/createContact/index.js.map +1 -0
  100. package/dist/destinations/loops/generated-types.d.ts +3 -0
  101. package/dist/destinations/loops/generated-types.js +3 -0
  102. package/dist/destinations/loops/generated-types.js.map +1 -0
  103. package/dist/destinations/loops/index.d.ts +4 -0
  104. package/dist/destinations/loops/index.js +35 -0
  105. package/dist/destinations/loops/index.js.map +1 -0
  106. package/dist/destinations/mixpanel/index.js +1 -1
  107. package/dist/destinations/mixpanel/trackEvent/index.js.map +1 -1
  108. package/dist/destinations/salesforce/customObject/index.js +12 -1
  109. package/dist/destinations/salesforce/customObject/index.js.map +1 -1
  110. package/dist/destinations/salesforce/lead/index.js +1 -2
  111. package/dist/destinations/salesforce/lead/index.js.map +1 -1
  112. package/dist/destinations/salesforce/sf-operations.d.ts +3 -0
  113. package/dist/destinations/salesforce/sf-operations.js +42 -0
  114. package/dist/destinations/salesforce/sf-operations.js.map +1 -1
  115. package/dist/destinations/salesforce/sf-properties.js +2 -1
  116. package/dist/destinations/salesforce/sf-properties.js.map +1 -1
  117. package/dist/destinations/salesforce-marketing-cloud/apiEvent/generated-types.d.ts +7 -0
  118. package/dist/destinations/salesforce-marketing-cloud/apiEvent/generated-types.js +3 -0
  119. package/dist/destinations/salesforce-marketing-cloud/apiEvent/generated-types.js.map +1 -0
  120. package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.d.ts +5 -0
  121. package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.js +20 -0
  122. package/dist/destinations/salesforce-marketing-cloud/apiEvent/index.js.map +1 -0
  123. package/dist/destinations/salesforce-marketing-cloud/contact/generated-types.d.ts +1 -0
  124. package/dist/destinations/salesforce-marketing-cloud/contact/index.js +16 -4
  125. package/dist/destinations/salesforce-marketing-cloud/contact/index.js.map +1 -1
  126. package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.d.ts +12 -0
  127. package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.js +3 -0
  128. package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/generated-types.js.map +1 -0
  129. package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.d.ts +5 -0
  130. package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js +34 -0
  131. package/dist/destinations/salesforce-marketing-cloud/contactDataExtension/index.js.map +1 -0
  132. package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.d.ts +11 -0
  133. package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.js +3 -0
  134. package/dist/destinations/salesforce-marketing-cloud/dataExtension/generated-types.js.map +1 -0
  135. package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.d.ts +5 -0
  136. package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js +23 -0
  137. package/dist/destinations/salesforce-marketing-cloud/dataExtension/index.js.map +1 -0
  138. package/dist/destinations/salesforce-marketing-cloud/generated-types.d.ts +2 -0
  139. package/dist/destinations/salesforce-marketing-cloud/index.js +23 -4
  140. package/dist/destinations/salesforce-marketing-cloud/index.js.map +1 -1
  141. package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.d.ts +3 -0
  142. package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js +31 -0
  143. package/dist/destinations/salesforce-marketing-cloud/sfmc-operations.js.map +1 -0
  144. package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.d.ts +10 -0
  145. package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.js +59 -0
  146. package/dist/destinations/salesforce-marketing-cloud/sfmc-properties.js.map +1 -0
  147. package/dist/destinations/sendgrid/index.js +8 -0
  148. package/dist/destinations/sendgrid/index.js.map +1 -1
  149. package/dist/destinations/sendgrid/sendgrid-properties.d.ts +8 -5
  150. package/dist/destinations/sendgrid/sendgrid-properties.js +34 -3
  151. package/dist/destinations/sendgrid/sendgrid-properties.js.map +1 -1
  152. package/dist/destinations/sendgrid/updateUserProfile/index.js +6 -10
  153. package/dist/destinations/sendgrid/updateUserProfile/index.js.map +1 -1
  154. package/dist/destinations/tiktok-conversions/reportWebEvent/generated-types.d.ts +1 -0
  155. package/dist/destinations/tiktok-conversions/reportWebEvent/index.js +15 -2
  156. package/dist/destinations/tiktok-conversions/reportWebEvent/index.js.map +1 -1
  157. package/package.json +4 -4
  158. package/dist/destinations/google-enhanced-conversions/constants.d.ts +0 -1
  159. package/dist/destinations/google-enhanced-conversions/constants.js +0 -185
  160. package/dist/destinations/google-enhanced-conversions/constants.js.map +0 -1
  161. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/types.d.ts +0 -5
  162. package/dist/destinations/google-enhanced-conversions/uploadClickConversion/types.js.map +0 -1
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const properties_1 = require("../properties");
5
+ const action = {
6
+ title: 'Upsert Contact',
7
+ description: 'Create or update a contact in HubSpot.',
8
+ defaultSubscription: 'type = "identify"',
9
+ fields: {
10
+ email: {
11
+ label: 'Email',
12
+ type: 'string',
13
+ description: 'The contact’s email. Email is used to uniquely identify contact records in HubSpot. If an existing contact is found with this email, we will update the contact. If a contact is not found, we will create a new contact.',
14
+ required: true,
15
+ format: 'email',
16
+ default: {
17
+ '@path': '$.traits.email'
18
+ }
19
+ },
20
+ company: {
21
+ label: 'Company Name',
22
+ type: 'string',
23
+ description: 'The contact’s company.',
24
+ default: {
25
+ '@path': '$.traits.company'
26
+ }
27
+ },
28
+ firstname: {
29
+ label: 'First Name',
30
+ type: 'string',
31
+ description: 'The contact’s first name.',
32
+ default: {
33
+ '@if': {
34
+ exists: { '@path': '$.traits.first_name' },
35
+ then: { '@path': '$.traits.first_name' },
36
+ else: { '@path': '$.traits.firstName' }
37
+ }
38
+ }
39
+ },
40
+ lastname: {
41
+ label: 'Last Name',
42
+ type: 'string',
43
+ description: 'The contact’s last name.',
44
+ default: {
45
+ '@if': {
46
+ exists: { '@path': '$.traits.last_name' },
47
+ then: { '@path': '$.traits.last_name' },
48
+ else: { '@path': '$.traits.lastName' }
49
+ }
50
+ }
51
+ },
52
+ phone: {
53
+ label: 'Phone',
54
+ type: 'string',
55
+ description: 'The contact’s phone number.',
56
+ default: {
57
+ '@path': '$.traits.phone'
58
+ }
59
+ },
60
+ address: {
61
+ label: 'Street Address',
62
+ type: 'string',
63
+ description: "The contact's street address, including apartment or unit number.",
64
+ default: {
65
+ '@path': '$.traits.address.street'
66
+ }
67
+ },
68
+ city: {
69
+ label: 'City',
70
+ type: 'string',
71
+ description: "The contact's city of residence.",
72
+ default: {
73
+ '@path': '$.traits.address.city'
74
+ }
75
+ },
76
+ state: {
77
+ label: 'State',
78
+ type: 'string',
79
+ description: "The contact's state of residence.",
80
+ default: {
81
+ '@path': '$.traits.address.state'
82
+ }
83
+ },
84
+ country: {
85
+ label: 'Country',
86
+ type: 'string',
87
+ description: "The contact's country of residence.",
88
+ default: {
89
+ '@path': '$.traits.address.country'
90
+ }
91
+ },
92
+ zip: {
93
+ label: 'Postal Code',
94
+ type: 'string',
95
+ description: "The contact's zip code.",
96
+ default: {
97
+ '@if': {
98
+ exists: { '@path': '$.traits.address.postalCode' },
99
+ then: { '@path': '$.traits.address.postalCode' },
100
+ else: { '@path': '$.traits.address.postal_code' }
101
+ }
102
+ }
103
+ },
104
+ website: {
105
+ label: 'Website',
106
+ type: 'string',
107
+ description: 'The contact’s company/other website.',
108
+ default: {
109
+ '@path': '$.traits.website'
110
+ }
111
+ },
112
+ lifecyclestage: {
113
+ label: 'Lifecycle Stage',
114
+ type: 'string',
115
+ description: 'The contact’s stage within the marketing/sales process. See more information on default and custom stages in [HubSpot’s documentation](https://knowledge.hubspot.com/contacts/use-lifecycle-stages). Segment supports moving status forwards or backwards.'
116
+ },
117
+ properties: {
118
+ label: 'Other properties',
119
+ type: 'object',
120
+ description: 'Any other default or custom contact properties. Custom properties must be predefined in HubSpot. See more information in [HubSpot’s documentation](https://knowledge.hubspot.com/crm-setup/manage-your-properties#create-custom-properties).',
121
+ defaultObjectUI: 'keyvalue:only'
122
+ }
123
+ },
124
+ perform: async (request, { payload, transactionContext }) => {
125
+ const contactProperties = {
126
+ company: payload.company,
127
+ firstname: payload.firstname,
128
+ lastname: payload.lastname,
129
+ phone: payload.phone,
130
+ address: payload.address,
131
+ city: payload.city,
132
+ state: payload.state,
133
+ country: payload.country,
134
+ zip: payload.zip,
135
+ lifecyclestage: payload.lifecyclestage?.toLowerCase(),
136
+ ...payload.properties
137
+ };
138
+ try {
139
+ const response = await updateContact(request, payload.email, contactProperties);
140
+ transactionContext?.setTransaction('contact_id', response.data.id);
141
+ if (payload.lifecyclestage) {
142
+ const currentLCS = response.data.properties['lifecyclestage'];
143
+ const hasLCSChanged = currentLCS == payload.lifecyclestage.toLowerCase();
144
+ if (hasLCSChanged)
145
+ return response;
146
+ await updateContact(request, payload.email, { lifecylestage: '' });
147
+ return updateContact(request, payload.email, contactProperties);
148
+ }
149
+ return response;
150
+ }
151
+ catch (ex) {
152
+ if (!(ex instanceof actions_core_1.HTTPError))
153
+ throw ex;
154
+ const error = ex;
155
+ const statusCode = error.response.status;
156
+ if (statusCode == 404) {
157
+ const result = await createContact(request, { email: payload.email, ...contactProperties });
158
+ transactionContext?.setTransaction('contact_id', result.data.id);
159
+ return result;
160
+ }
161
+ throw error;
162
+ }
163
+ }
164
+ };
165
+ async function createContact(request, contactProperties) {
166
+ return request(`${properties_1.HubSpotBaseURL}/crm/v3/objects/contacts`, {
167
+ method: 'POST',
168
+ json: {
169
+ properties: {
170
+ ...contactProperties
171
+ }
172
+ }
173
+ });
174
+ }
175
+ async function updateContact(request, email, properties) {
176
+ return request(`${properties_1.HubSpotBaseURL}/crm/v3/objects/contacts/${email}?idProperty=email`, {
177
+ method: 'PATCH',
178
+ json: {
179
+ properties: {
180
+ ...properties
181
+ }
182
+ }
183
+ });
184
+ }
185
+ exports.default = action;
186
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/contact/index.ts"],"names":[],"mappings":";;AACA,wDAAiD;AAEjD,8CAA8C;AAQ9C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,wCAAwC;IACrD,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EACT,2NAA2N;YAC7N,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,OAAO;YACf,OAAO,EAAE;gBACP,OAAO,EAAE,gBAAgB;aAC1B;SACF;QACD,OAAO,EAAE;YACP,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wBAAwB;YACrC,OAAO,EAAE;gBACP,OAAO,EAAE,kBAAkB;aAC5B;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,Y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AAA;AAED,KAAK,UAAU,aAAa,CAAC,OAAsB,EAAE,iBAA6C;IAChG,OAAO,OAAO,CAAkB,GAAG,2BAAc,0BAA0B,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"}
@@ -0,0 +1,6 @@
1
+ export interface Payload {
2
+ objectType: string;
3
+ properties: {
4
+ [k: string]: unknown;
5
+ };
6
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/createCustomObjectRecord/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { 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,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const hubspotDefinedObjects = ['contacts', 'companies', 'deals', 'tickets'];
5
+ const customObjectExpression = new RegExp('^[a-zA-Z0-9]+_[a-zA-Z][a-zA-Z0-9_-]+$');
6
+ const action = {
7
+ title: 'Create Custom Object',
8
+ description: 'Create or Update a Custom Object in HubSpot',
9
+ fields: {
10
+ objectType: {
11
+ label: 'Object Type',
12
+ description: 'The CRM object schema to use for creating a record. This can be a standard object (i.e. tickets, deals) or ***fullyQualifiedName*** of a custom object. Custom objects and their schema must be predefined in HubSpot.',
13
+ type: 'string',
14
+ required: true
15
+ },
16
+ properties: {
17
+ label: 'Properties',
18
+ description: 'Properties to send to HubSpot. Please make sure to include the object’s required properties. Any custom properties must be predefined in HubSpot. More information in [HubSpot documentation](https://knowledge.hubspot.com/crm-setup/manage-your-properties#create-custom-properties).',
19
+ type: 'object',
20
+ required: true,
21
+ defaultObjectUI: 'keyvalue:only',
22
+ allowNull: false
23
+ }
24
+ },
25
+ perform: async (request, { payload }) => {
26
+ if (Object.keys(payload.properties).length === 0) {
27
+ throw new actions_core_1.IntegrationError('At-least one Custom Object property should be mapped', 'Object properties are not defined', 400);
28
+ }
29
+ if (!customObjectExpression.test(payload.objectType) && !hubspotDefinedObjects.includes(payload.objectType)) {
30
+ throw new actions_core_1.IntegrationError('Custom Object is not in valid format. Please make sure that you are using either a valid format of object’s fullyQualifiedName (eg: p11223344_myobject) or a supported HubSpot defined object (ie: deals, tickets, contacts and companies).', 'Custom Object is not in valid format', 400);
31
+ }
32
+ return request(`https://api.hubapi.com/crm/v3/objects/${payload.objectType}`, {
33
+ method: 'POST',
34
+ json: {
35
+ properties: { ...payload.properties }
36
+ }
37
+ });
38
+ }
39
+ };
40
+ exports.default = action;
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/createCustomObjectRecord/index.ts"],"names":[],"mappings":";;AACA,wDAAwD;AAKxD,MAAM,qBAAqB,GAAa,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,CAAA;AAKrF,MAAM,sBAAsB,GAAG,IAAI,MAAM,CAAC,uCAAuC,CAAC,CAAA;AAElF,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EAAE,6CAA6C;IAC1D,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,aAAa;YACpB,WAAW,EACT,wNAAwN;YAC1N,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf;QACD,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EACT,yRAAyR;YAC3R,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,eAAe,EAAE,eAAe;YAChC,SAAS,EAAE,KAAK;SACjB;KACF;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QAEtC,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;YAChD,MAAM,IAAI,+BAAgB,CACxB,sDAAsD,EACtD,mCAAmC,EACnC,GAAG,CACJ,CAAA;SACF;QAGD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE;YAC3G,MAAM,IAAI,+BAAgB,CACxB,6OAA6O,EAC7O,sCAAsC,EACtC,GAAG,CACJ,CAAA;SACF;QAED,OAAO,OAAO,CAAC,yCAAyC,OAAO,CAAC,UAAU,EAAE,EAAE;YAC5E,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE;aACtC;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ export interface Settings {
2
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import type { DestinationDefinition } from '@segment/actions-core';
2
+ import type { Settings } from './generated-types';
3
+ declare const destination: DestinationDefinition<Settings>;
4
+ export default destination;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const sendCustomBehavioralEvent_1 = __importDefault(require("./sendCustomBehavioralEvent"));
7
+ const contact_1 = __importDefault(require("./contact"));
8
+ const createCustomObjectRecord_1 = __importDefault(require("./createCustomObjectRecord"));
9
+ const destination = {
10
+ name: 'Hubspot Cloud Mode (Actions)',
11
+ slug: 'actions-hubspot-cloud',
12
+ mode: 'cloud',
13
+ authentication: {
14
+ scheme: 'oauth2',
15
+ fields: {},
16
+ testAuthentication: (request) => {
17
+ return request(`https://api.hubapi.com/crm/v3/objects/contacts?limit=1`);
18
+ },
19
+ refreshAccessToken: async (request, { auth }) => {
20
+ const res = await request('https://api.hubapi.com/oauth/v1/token', {
21
+ method: 'POST',
22
+ body: new URLSearchParams({
23
+ refresh_token: auth.refreshToken,
24
+ client_id: auth.clientId,
25
+ client_secret: auth.clientSecret,
26
+ grant_type: 'refresh_token'
27
+ })
28
+ });
29
+ return { accessToken: res.data.access_token };
30
+ }
31
+ },
32
+ extendRequest({ auth }) {
33
+ return {
34
+ headers: {
35
+ authorization: `Bearer ${auth?.accessToken}`
36
+ }
37
+ };
38
+ },
39
+ actions: {
40
+ sendCustomBehavioralEvent: sendCustomBehavioralEvent_1.default,
41
+ contact: contact_1.default,
42
+ createCustomObjectRecord: createCustomObjectRecord_1.default
43
+ }
44
+ };
45
+ exports.default = destination;
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/index.ts"],"names":[],"mappings":";;;;;AAGA,4FAAmE;AACnE,wDAA+B;AAC/B,0FAAiE;AAKjE,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,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAE9B,OAAO,OAAO,CAAC,wDAAwD,CAAC,CAAA;QAC1E,CAAC;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAE9C,MAAM,GAAG,GAAG,MAAM,OAAO,CAAuB,uCAAuC,EAAE;gBACvF,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,CAAC,YAAY,EAAE,CAAA;QAC/C,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,OAAO,EAAP,iBAAO;QACP,wBAAwB,EAAxB,kCAAwB;KACzB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -0,0 +1 @@
1
+ export declare const HubSpotBaseURL = "https://api.hubapi.com";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HubSpotBaseURL = void 0;
4
+ exports.HubSpotBaseURL = 'https://api.hubapi.com';
5
+ //# sourceMappingURL=properties.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"properties.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/properties.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,wBAAwB,CAAA"}
@@ -0,0 +1,10 @@
1
+ export interface Payload {
2
+ eventName: string;
3
+ occurredAt?: string | number;
4
+ email?: string;
5
+ utk?: string;
6
+ objectId?: string;
7
+ properties?: {
8
+ [k: string]: unknown;
9
+ };
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=generated-types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/sendCustomBehavioralEvent/generated-types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import type { 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,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const properties_1 = require("../properties");
4
+ const action = {
5
+ title: 'Send Custom Behavioral Event',
6
+ description: 'Send a custom behavioral event to HubSpot.',
7
+ defaultSubscription: 'type = "track"',
8
+ fields: {
9
+ eventName: {
10
+ label: 'Event Name',
11
+ description: 'The internal event name assigned by HubSpot. This can be found in your HubSpot account. Events must be predefined in HubSpot. Learn how to find the internal name in [HubSpot’s documentation](https://knowledge.hubspot.com/analytics-tools/create-custom-behavioral-events?_ga=2.219778269.578939721.1663963266-497800475.1660075188#define-the-api-call).',
12
+ type: 'string',
13
+ required: true
14
+ },
15
+ occurredAt: {
16
+ label: 'Event Timestamp',
17
+ description: "The time when this event occurred. If this isn't set, the current time will be used.",
18
+ type: 'datetime',
19
+ default: {
20
+ '@path': '$.timestamp'
21
+ }
22
+ },
23
+ email: {
24
+ label: 'Email Address',
25
+ description: 'The email of the contact associated with this event. This is required if no user token or object ID is provided.',
26
+ type: 'string',
27
+ format: 'email',
28
+ default: {
29
+ '@if': {
30
+ exists: { '@path': '$.properties.email' },
31
+ then: { '@path': '$.properties.email' },
32
+ else: { '@path': '$.context.traits.email' }
33
+ }
34
+ }
35
+ },
36
+ utk: {
37
+ label: 'User Token',
38
+ description: 'The user token (utk) of the contact associated with this event. This is required if no email or object ID is provided.',
39
+ type: 'string'
40
+ },
41
+ objectId: {
42
+ label: 'Object ID',
43
+ description: 'The ID of the object associated with this event. This can be the HubSpot contact ID, company ID, or ID of any other object. This is required if no email or user token is provided.',
44
+ type: 'string'
45
+ },
46
+ properties: {
47
+ label: 'Event Properties',
48
+ description: 'Default or custom properties that describe the event. See more information in [HubSpot’s documentation](https://knowledge.hubspot.com/analytics-tools/create-custom-behavioral-events#add-and-manage-event-properties).',
49
+ type: 'object',
50
+ defaultObjectUI: 'keyvalue:only'
51
+ }
52
+ },
53
+ perform: (request, { payload }) => {
54
+ const event = {
55
+ eventName: payload.eventName,
56
+ occurredAt: payload.occurredAt,
57
+ utk: payload.utk,
58
+ email: payload.email,
59
+ objectId: payload.objectId,
60
+ properties: payload.properties
61
+ };
62
+ return request(`${properties_1.HubSpotBaseURL}/events/v3/send`, {
63
+ method: 'post',
64
+ json: event
65
+ });
66
+ }
67
+ };
68
+ exports.default = action;
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,8VAA8V;YAChW,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M;YACd,IAAI,EAAE,KAAK;SACZ,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,7 @@
1
+ declare const generateValidHubSpotCustomObjectName: (seed: string) => {
2
+ objectType: string;
3
+ properties: {
4
+ testProperty: string;
5
+ };
6
+ };
7
+ export { generateValidHubSpotCustomObjectName };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateValidHubSpotCustomObjectName = void 0;
4
+ const generateHash = (seed) => {
5
+ let i, chr, hash;
6
+ hash = 0;
7
+ if (seed.length === 0)
8
+ return hash;
9
+ for (i = 0; i < seed.length; i++) {
10
+ chr = seed.charCodeAt(i);
11
+ hash = (hash << 5) - hash + chr;
12
+ hash |= 0;
13
+ }
14
+ return Math.abs(hash);
15
+ };
16
+ const generateValidHubSpotCustomObjectName = (seed) => {
17
+ const hash = generateHash(seed);
18
+ return {
19
+ objectType: `p${hash}_Obj${hash}`,
20
+ properties: { testProperty: `testValue-${hash}` }
21
+ };
22
+ };
23
+ exports.generateValidHubSpotCustomObjectName = generateValidHubSpotCustomObjectName;
24
+ //# sourceMappingURL=testHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testHelper.js","sourceRoot":"","sources":["../../../src/destinations/hubspot/testHelper.ts"],"names":[],"mappings":";;;AAAA,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;IACpC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAA;IAChB,IAAI,GAAG,CAAC,CAAA;IAER,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAClC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAChC,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QACxB,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,GAAG,CAAA;QAC/B,IAAI,IAAI,CAAC,CAAA;KACV;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,oCAAoC,GAAG,CAAC,IAAY,EAAE,EAAE;IAC5D,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;IAC/B,OAAO;QACL,UAAU,EAAE,IAAI,IAAI,OAAO,IAAI,EAAE;QACjC,UAAU,EAAE,EAAE,YAAY,EAAE,aAAa,IAAI,EAAE,EAAE;KAClD,CAAA;AACH,CAAC,CAAA;AACQ,oFAAoC"}
@@ -47,8 +47,8 @@ register('60ae8b97dcb6cc52d5d0d5ab', './google-enhanced-conversions');
47
47
  register('627ea052118e3cd530d28963', './google-sheets');
48
48
  register('62e184d538b54413fe754512', './heap');
49
49
  register('624dddd054ced46facfdb9c0', './launchdarkly');
50
- register('62f435d1d311567bd5bf0e8d', './linkedin-audiences');
51
50
  register('63360a5fe290ca3fdfad4a68', './loops');
51
+ register('62f435d1d311567bd5bf0e8d', './linkedin-audiences');
52
52
  register('615c7438d93d9b61b1e9e192', './mixpanel');
53
53
  register('61a8032ea5f157ee37a720be', './metronome');
54
54
  register('620feaa207e70f6c6a765ff7', './moengage');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/destinations/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,wDAAmD;AACnD,gDAAuB;AAWV,QAAA,YAAY,GAA0C,EAAE,CAAA;AACxD,QAAA,QAAQ,GAAsC,EAAE,CAAA;AAU7D,QAAQ,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAA;AAChD,QAAQ,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAA;AACtD,QAAQ,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAA;AACnD,QAAQ,CAAC,0BAA0B,EAAE,SAAS,CA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AACpE,CAAC;AAGD,KAAK,UAAU,kBAAkB,CAAC,IAAY;IAC5C,MAAM,WAAW,GAAG,MAAM,kDAAO,KAAK,IAAI,EAAE,IAAE,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IAGxE,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,OAAO,WAAW,EAAE,OAAO,KAAK,QAAQ,EAAE;QAClE,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,WAAW,CAAA;AACpB,CAAC;AAED,KAAK,UAAU,uBAAuB,CAAC,GAAW;IAChD,MAAM,WAAW,GAAG,oBAAY,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAA;IAExE,IAAI,CAAC,WAAW,EAAE;QAChB,OAAO,IAAI,CAAA;KACZ;IAGD,OAAO,IAAI,0BAAW,CAAC,WAAyC,CAAC,CAAA;AACnE,CAAC;AAED,SAAgB,kBAAkB,CAAC,EAAU;IAC3C,MAAM,WAAW,GAAG,gBAAQ,CAAC,EAAE,CAAC,CAAA;IAEhC,IAAI,CAAC,WAAW,EAAE,UAAU,EAAE;QAC5B,OAAO,IAAI,CAAA;KACZ;IAED,OAAO,IAAI,0BAAW,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC;AARD,gDAQC;AAEM,KAAK,UAAU,uBAAuB,CAAC,WAAmB;IAC/D,OAAO,kBAAkB,CAAC,WAAW,CAAC,IAAI,uBAAuB,CAAC,WAAW,CAAC,CAAA;AAChF,CAAC;AAFD,0DAEC"}
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const updateAudience_1 = __importDefault(require("./updateAudience"));
7
7
  const linkedin_properties_1 = require("./linkedin-properties");
8
+ const https_1 = __importDefault(require("https"));
8
9
  const destination = {
9
10
  name: 'Linkedin Audiences',
10
11
  slug: 'actions-linkedin-audiences',
@@ -19,13 +20,13 @@ const destination = {
19
20
  required: true
20
21
  }
21
22
  },
22
- testAuthentication: async (request, { auth, settings }) => {
23
- return request(`https://api.linkedin.com/rest/adAccountsV2/${settings.ad_account_id}`, {
24
- method: 'POST',
23
+ testAuthentication: async (request, { settings, auth }) => {
24
+ return await request(`https://api.linkedin.com/rest/adAccounts/${settings.ad_account_id}`, {
25
+ method: 'GET',
25
26
  headers: {
26
27
  'X-Restli-Protocol-Version': '2.0.0',
27
28
  'LinkedIn-Version': linkedin_properties_1.LINKEDIN_API_VERSION,
28
- authorization: auth.accessToken
29
+ authorization: `Bearer ${auth?.accessToken}`
29
30
  }
30
31
  });
31
32
  },
@@ -43,12 +44,13 @@ const destination = {
43
44
  }
44
45
  },
45
46
  extendRequest({ auth }) {
47
+ const agent = new https_1.default.Agent({ keepAlive: true });
46
48
  return {
47
49
  headers: {
48
50
  authorization: `Bearer ${auth?.accessToken}`,
49
- 'LinkedIn-Version': linkedin_properties_1.LINKEDIN_API_VERSION,
50
- 'Content-Type': 'application/json'
51
- }
51
+ 'LinkedIn-Version': linkedin_properties_1.LINKEDIN_API_VERSION
52
+ },
53
+ agent
52
54
  };
53
55
  },
54
56
  actions: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/index.ts"],"names":[],"mappings":";;;;;AAEA,sEAA6C;AAC7C,+DAA4D;AAS5D,MAAM,WAAW,GAAoC;IACnD,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;SACF;QACD,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE;YACxD,OAAO,OAAO,CAAC,8CAA8C,QAAQ,CAAC,aAAa,EAAE,EAAE;gBACrF,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,2BAA2B,EAAE,OAAO;oBACpC,kBAAkB,EAAE,0CAAoB;oBACxC,aAAa,EAAE,IAAI,CAAC,WAAW;iBAChC;aACF,CAAC,CAAA;QACJ,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;QACpB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,IAAI,EAAE,WAAW,EAAE;gBAC5C,kBAAkB,EAAE,0CAAoB;gBACxC,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-audiences/index.ts"],"names":[],"mappings":";;;;;AAEA,sEAA6C;AAC7C,+DAA4D;AAC5D,kDAAyB;AASzB,MAAM,WAAW,GAAoC;IAGnD,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,4BAA4B;IAClC,I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,EAAE,0CAAoB;aACzC;YACD,KAAK;SACN,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -85,15 +85,20 @@ async function processPayload(request, settings, payloads) {
85
85
  }
86
86
  const dmpSegmentId = await getDmpSegmentId(request, settings, payloads[0]);
87
87
  const elements = extractUsers(payloads);
88
- return request(`https://api.linkedin.com/rest/dmpSegments/${dmpSegmentId}/users`, {
88
+ const res = await request(`https://api.linkedin.com/rest/dmpSegments/${dmpSegmentId}/users`, {
89
89
  method: 'POST',
90
90
  headers: {
91
91
  'X-RestLi-Method': 'BATCH_CREATE'
92
92
  },
93
93
  json: {
94
94
  elements
95
- }
95
+ },
96
+ throwHttpErrors: false
96
97
  });
98
+ if (res.status !== 200) {
99
+ throw new actions_core_1.RetryableError('Error while attempting to update LinkedIn DMP Segment. This batch will be retried.');
100
+ }
101
+ return res;
97
102
  }
98
103
  async function getDmpSegmentId(request, settings, payload) {
99
104
  const res = await getDmpSegment(request, settings, payload);
@@ -104,10 +109,18 @@ async function getDmpSegmentId(request, settings, payload) {
104
109
  return createDmpSegment(request, settings, payload);
105
110
  }
106
111
  async function getDmpSegment(request, settings, payload) {
107
- return request(`https://api.linkedin.com/rest/dmpSegments?q=account&account=urn:li:sponsoredAccount:${settings.ad_account_id}&sourceSegmentId=${payload.source_segment_id}&sourcePlatform=SEGMENT`);
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
+ });
108
121
  }
109
122
  async function createDmpSegment(request, settings, payload) {
110
- await request('https://api.linkedin.com/rest/dmpSegments', {
123
+ const res = await request('https://api.linkedin.com/rest/dmpSegments', {
111
124
  method: 'POST',
112
125
  json: {
113
126
  name: payload.dmp_segment_name,
@@ -123,12 +136,8 @@ async function createDmpSegment(request, settings, payload) {
123
136
  ]
124
137
  }
125
138
  });
126
- const res = await getDmpSegment(request, settings, payload);
127
- const body = await res.json();
128
- if (body.elements?.length > 0) {
129
- return body.elements[0].id;
130
- }
131
- throw new actions_core_1.RetryableError('Failed to fetch or create a LinkedIn DMP Segment.');
139
+ const headers = res.headers.toJSON();
140
+ return headers['x-linkedin-id'];
132
141
  }
133
142
  function extractUsers(payloads) {
134
143
  const elements = [];