@segment/action-destinations 3.309.1-staging-4ad52f673.0 → 3.311.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 (120) hide show
  1. package/dist/destinations/actions-pardot/prospects/index.js +2 -1
  2. package/dist/destinations/actions-pardot/prospects/index.js.map +1 -1
  3. package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.js +29 -49
  4. package/dist/destinations/amazon-amc/syncAudiencesToDSP/index.js.map +1 -1
  5. package/dist/destinations/angler-ai/fields/addressFields.js +1 -85
  6. package/dist/destinations/angler-ai/fields/addressFields.js.map +1 -1
  7. package/dist/destinations/angler-ai/fields/checkoutFields.js +15 -0
  8. package/dist/destinations/angler-ai/fields/checkoutFields.js.map +1 -1
  9. package/dist/destinations/angler-ai/presets.js +8 -0
  10. package/dist/destinations/angler-ai/presets.js.map +1 -1
  11. package/dist/destinations/angler-ai/routes.js +1 -1
  12. package/dist/destinations/angler-ai/routes.js.map +1 -1
  13. package/dist/destinations/angler-ai/saveCheckoutEvent/generated-types.d.ts +26 -0
  14. package/dist/destinations/angler-ai/saveCheckoutEvent/transform-payload.d.ts +28 -0
  15. package/dist/destinations/angler-ai/saveCustomEvent/generated-types.d.ts +26 -0
  16. package/dist/destinations/angler-ai/saveCustomEvent/transform-payload.d.ts +28 -0
  17. package/dist/destinations/angler-ai/saveOrder/generated-types.d.ts +13 -28
  18. package/dist/destinations/angler-ai/saveOrder/index.js +47 -12
  19. package/dist/destinations/angler-ai/saveOrder/index.js.map +1 -1
  20. package/dist/destinations/angler-ai/saveUser/generated-types.d.ts +0 -28
  21. package/dist/destinations/angler-ai/transformFields/transformCheckout.d.ts +28 -0
  22. package/dist/destinations/angler-ai/transformFields/transformCheckout.js +28 -0
  23. package/dist/destinations/angler-ai/transformFields/transformCheckout.js.map +1 -1
  24. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.d.ts +3 -3
  25. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js +9 -9
  26. package/dist/destinations/engage-messaging-sendgrid/previewApiLookup/apiLookups.js.map +1 -1
  27. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.d.ts +1 -2
  28. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js +3 -11
  29. package/dist/destinations/engage-messaging-sendgrid/sendEmail/SendEmailPerformer.js.map +1 -1
  30. package/dist/destinations/facebook-conversions-api/fb-capi-user-data.js +1 -1
  31. package/dist/destinations/facebook-conversions-api/fb-capi-user-data.js.map +1 -1
  32. package/dist/destinations/google-sheets/constants.d.ts +0 -1
  33. package/dist/destinations/google-sheets/constants.js +1 -2
  34. package/dist/destinations/google-sheets/constants.js.map +1 -1
  35. package/dist/destinations/google-sheets/googleapis/index.js +0 -3
  36. package/dist/destinations/google-sheets/googleapis/index.js.map +1 -1
  37. package/dist/destinations/google-sheets/postSheet/generated-types.d.ts +0 -1
  38. package/dist/destinations/google-sheets/postSheet/index.js +9 -25
  39. package/dist/destinations/google-sheets/postSheet/index.js.map +1 -1
  40. package/dist/destinations/google-sheets/postSheet/operations.d.ts +1 -3
  41. package/dist/destinations/google-sheets/postSheet/operations.js +4 -5
  42. package/dist/destinations/google-sheets/postSheet/operations.js.map +1 -1
  43. package/dist/destinations/google-sheets/postSheet2/index.js +4 -20
  44. package/dist/destinations/google-sheets/postSheet2/index.js.map +1 -1
  45. package/dist/destinations/google-sheets/postSheet2/operations2.d.ts +1 -3
  46. package/dist/destinations/google-sheets/postSheet2/operations2.js +5 -6
  47. package/dist/destinations/google-sheets/postSheet2/operations2.js.map +1 -1
  48. package/dist/destinations/hubspot/customEvent/client.d.ts +10 -0
  49. package/dist/destinations/hubspot/customEvent/client.js +38 -0
  50. package/dist/destinations/hubspot/customEvent/client.js.map +1 -0
  51. package/dist/destinations/hubspot/customEvent/common-fields.js +7 -3
  52. package/dist/destinations/hubspot/customEvent/common-fields.js.map +1 -1
  53. package/dist/destinations/hubspot/customEvent/constants.d.ts +4 -0
  54. package/dist/destinations/hubspot/customEvent/constants.js +141 -1
  55. package/dist/destinations/hubspot/customEvent/constants.js.map +1 -1
  56. package/dist/destinations/hubspot/customEvent/dynamic-fields.js +11 -5
  57. package/dist/destinations/hubspot/customEvent/dynamic-fields.js.map +1 -1
  58. package/dist/destinations/hubspot/customEvent/index.d.ts +1 -1
  59. package/dist/destinations/hubspot/customEvent/index.js +54 -16
  60. package/dist/destinations/hubspot/customEvent/index.js.map +1 -1
  61. package/dist/destinations/hubspot/customEvent/types.d.ts +93 -0
  62. package/dist/destinations/hubspot/customEvent/types.js +10 -0
  63. package/dist/destinations/hubspot/customEvent/types.js.map +1 -0
  64. package/dist/destinations/hubspot/customEvent/utils.d.ts +12 -0
  65. package/dist/destinations/hubspot/customEvent/utils.js +278 -0
  66. package/dist/destinations/hubspot/customEvent/utils.js.map +1 -0
  67. package/dist/destinations/hubspot/upsertObject/client.d.ts +11 -0
  68. package/dist/destinations/hubspot/upsertObject/client.js +39 -0
  69. package/dist/destinations/hubspot/upsertObject/client.js.map +1 -0
  70. package/dist/destinations/hubspot/upsertObject/common-fields.js +14 -7
  71. package/dist/destinations/hubspot/upsertObject/common-fields.js.map +1 -1
  72. package/dist/destinations/hubspot/upsertObject/constants.d.ts +1 -0
  73. package/dist/destinations/hubspot/upsertObject/constants.js +3 -7
  74. package/dist/destinations/hubspot/upsertObject/constants.js.map +1 -1
  75. package/dist/destinations/hubspot/upsertObject/dynamic-fields.js +3 -4
  76. package/dist/destinations/hubspot/upsertObject/dynamic-fields.js.map +1 -1
  77. package/dist/destinations/hubspot/upsertObject/index.js +36 -35
  78. package/dist/destinations/hubspot/upsertObject/index.js.map +1 -1
  79. package/dist/destinations/hubspot/upsertObject/types.d.ts +192 -0
  80. package/dist/destinations/hubspot/upsertObject/types.js +56 -0
  81. package/dist/destinations/hubspot/upsertObject/types.js.map +1 -0
  82. package/dist/destinations/hubspot/upsertObject/utils.d.ts +13 -0
  83. package/dist/destinations/hubspot/upsertObject/utils.js +548 -0
  84. package/dist/destinations/hubspot/upsertObject/utils.js.map +1 -0
  85. package/dist/destinations/linkedin-conversions/index.js +0 -9
  86. package/dist/destinations/linkedin-conversions/index.js.map +1 -1
  87. package/dist/destinations/loops/createOrUpdateContact/generated-types.d.ts +4 -0
  88. package/dist/destinations/loops/createOrUpdateContact/index.js +48 -2
  89. package/dist/destinations/loops/createOrUpdateContact/index.js.map +1 -1
  90. package/dist/destinations/salesforce/index.js +1 -3
  91. package/dist/destinations/salesforce/index.js.map +1 -1
  92. package/dist/destinations/salesforce/sf-operations.d.ts +0 -1
  93. package/dist/destinations/salesforce/sf-operations.js +0 -20
  94. package/dist/destinations/salesforce/sf-operations.js.map +1 -1
  95. package/dist/destinations/salesforce/sf-properties.d.ts +0 -1
  96. package/dist/destinations/salesforce/sf-properties.js +6 -40
  97. package/dist/destinations/salesforce/sf-properties.js.map +1 -1
  98. package/dist/destinations/webhook/send/index.js +1 -3
  99. package/dist/destinations/webhook/send/index.js.map +1 -1
  100. package/dist/destinations/webhook-extensible/generated-types.d.ts +0 -4
  101. package/dist/destinations/webhook-extensible/index.js +4 -49
  102. package/dist/destinations/webhook-extensible/index.js.map +1 -1
  103. package/dist/destinations/webhook-extensible/send/index.js +2 -2
  104. package/dist/destinations/webhook-extensible/send/index.js.map +1 -1
  105. package/package.json +4 -4
  106. package/dist/destinations/hubspot/customEvent/hubspot-api.d.ts +0 -62
  107. package/dist/destinations/hubspot/customEvent/hubspot-api.js +0 -305
  108. package/dist/destinations/hubspot/customEvent/hubspot-api.js.map +0 -1
  109. package/dist/destinations/hubspot/upsertObject/hubspot-api.d.ts +0 -219
  110. package/dist/destinations/hubspot/upsertObject/hubspot-api.js +0 -609
  111. package/dist/destinations/hubspot/upsertObject/hubspot-api.js.map +0 -1
  112. package/dist/destinations/salesforce/lead2/generated-types.d.ts +0 -25
  113. package/dist/destinations/salesforce/lead2/generated-types.js +0 -3
  114. package/dist/destinations/salesforce/lead2/generated-types.js.map +0 -1
  115. package/dist/destinations/salesforce/lead2/index.d.ts +0 -5
  116. package/dist/destinations/salesforce/lead2/index.js +0 -200
  117. package/dist/destinations/salesforce/lead2/index.js.map +0 -1
  118. package/dist/destinations/webhook-extensible/types.d.ts +0 -6
  119. package/dist/destinations/webhook-extensible/types.js +0 -3
  120. package/dist/destinations/webhook-extensible/types.js.map +0 -1
@@ -1,10 +1,150 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SUPPORTED_HUBSPOT_OBJECT_TYPES = void 0;
3
+ exports.DEFAULT_CUSTOM_EVENT_PROPERTIES = exports.DEPENDS_ON_OBJECT_TYPE_CONTACT = exports.SUPPORTED_HUBSPOT_OBJECT_TYPES = void 0;
4
4
  exports.SUPPORTED_HUBSPOT_OBJECT_TYPES = [
5
5
  { label: 'Contact', value: 'contact' },
6
6
  { label: 'Company', value: 'company' },
7
7
  { label: 'Deal', value: 'deal' },
8
8
  { label: 'Ticket', value: 'ticket' }
9
9
  ];
10
+ exports.DEPENDS_ON_OBJECT_TYPE_CONTACT = {
11
+ match: 'all',
12
+ conditions: [
13
+ {
14
+ fieldKey: 'object_type',
15
+ operator: 'is',
16
+ value: 'contact'
17
+ }
18
+ ]
19
+ };
20
+ exports.DEFAULT_CUSTOM_EVENT_PROPERTIES = [
21
+ {
22
+ label: `Asset description - string`,
23
+ value: 'hs_asset_description'
24
+ },
25
+ {
26
+ label: `Asset type - string`,
27
+ value: 'hs_asset_type'
28
+ },
29
+ {
30
+ label: `Browser - string`,
31
+ value: 'hs_browser'
32
+ },
33
+ {
34
+ label: `Campaign ID - string`,
35
+ value: 'hs_campaign_id'
36
+ },
37
+ {
38
+ label: `City - string`,
39
+ value: 'hs_city'
40
+ },
41
+ {
42
+ label: `Country - string`,
43
+ value: 'hs_country'
44
+ },
45
+ {
46
+ label: `Device name - string`,
47
+ value: 'hs_device_name'
48
+ },
49
+ {
50
+ label: `Device type - string`,
51
+ value: 'hs_device_type'
52
+ },
53
+ {
54
+ label: `Element class - string`,
55
+ value: 'hs_element_class'
56
+ },
57
+ {
58
+ label: `Element ID - string`,
59
+ value: 'hs_element_id'
60
+ },
61
+ {
62
+ label: `Element text - string`,
63
+ value: 'hs_element_text'
64
+ },
65
+ {
66
+ label: `Language - enumeration`,
67
+ value: 'hs_language'
68
+ },
69
+ {
70
+ label: `Link href - string`,
71
+ value: 'hs_link_href'
72
+ },
73
+ {
74
+ label: `Operating system - string`,
75
+ value: 'hs_operating_system'
76
+ },
77
+ {
78
+ label: `Operating version - string`,
79
+ value: 'hs_operating_version'
80
+ },
81
+ {
82
+ label: `Page content type - enumeration`,
83
+ value: 'hs_page_content_type'
84
+ },
85
+ {
86
+ label: `Page ID - string`,
87
+ value: 'hs_page_id'
88
+ },
89
+ {
90
+ label: `Page title - string`,
91
+ value: 'hs_page_title'
92
+ },
93
+ {
94
+ label: `Page URL - string`,
95
+ value: 'hs_page_url'
96
+ },
97
+ {
98
+ label: `Parent module ID - string`,
99
+ value: 'hs_parent_module_id'
100
+ },
101
+ {
102
+ label: `Referrer - string`,
103
+ value: 'hs_referrer'
104
+ },
105
+ {
106
+ label: `Region - string`,
107
+ value: 'hs_region'
108
+ },
109
+ {
110
+ label: `Screen height - number`,
111
+ value: 'hs_screen_height'
112
+ },
113
+ {
114
+ label: `Screen width - number`,
115
+ value: 'hs_screen_width'
116
+ },
117
+ {
118
+ label: `Touchpoint source - string`,
119
+ value: 'hs_touchpoint_source'
120
+ },
121
+ {
122
+ label: `Tracking name - string`,
123
+ value: 'hs_tracking_name'
124
+ },
125
+ {
126
+ label: `User agent - string`,
127
+ value: 'hs_user_agent'
128
+ },
129
+ {
130
+ label: `UTM Campaign - string`,
131
+ value: 'hs_utm_campaign'
132
+ },
133
+ {
134
+ label: `UTM Content - string`,
135
+ value: 'hs_utm_content'
136
+ },
137
+ {
138
+ label: `UTM Medium - string`,
139
+ value: 'hs_utm_medium'
140
+ },
141
+ {
142
+ label: `UTM Source - string`,
143
+ value: 'hs_utm_source'
144
+ },
145
+ {
146
+ label: `UTM Term - string`,
147
+ value: 'hs_utm_term'
148
+ }
149
+ ];
10
150
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,8BAA8B,GAAG;IAC5C,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;CACrC,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,8BAA8B,GAAG;IAC5C,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACtC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAChC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE;CACrC,CAAA;AAEY,QAAA,8BAA8B,GAAwB;IACjE,KAAK,EAAE,KAAK;IACZ,UAAU,EAAE;QACV;YACE,QAAQ,EAAE,aAAa;YACvB,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,SAAS;SACjB;KACF;CACF,CAAA;AAEY,QAAA,+BAA+B,GAA4B;IACtE;QACE,KAAK,EAAE,4BAA4B;QACnC,KAAK,EAAE,sBAAsB;KAC9B;IACD;QACE,KAAK,EAAE,qBAAqB;QAC5B,KAAK,EAAE,eAAe;KACvB;IACD;QACE,KAAK,EAAE,kBA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EAAE,wBAAwB;QAC/B,KAAK,EAAE,kBAAkB;KAC1B;IACD;QACE,KAAK,EAAE,uBAAuB;QAC9B,KAAK,EAAE,iBAAiB;KACzB;IACD;QACE,KAAK,EAAE,4BAA4B;QACnC,KAAK,EAAE,sBAAsB;KAC9B;IACD;QACE,KAAK,EAAE,wBAAwB;QAC/B,KAAK,EAAE,kBAAkB;KAC1B;IACD;QACE,KAAK,EAAE,qBAAqB;QAC5B,KAAK,EAAE,eAAe;KACvB;IACD;QACE,KAAK,EAAE,uBAAuB;QAC9B,KAAK,EAAE,iBAAiB;KACzB;IACD;QACE,KAAK,EAAE,sBAAsB;QAC7B,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,KAAK,EAAE,qBAAqB;QAC5B,KAAK,EAAE,eAAe;KACvB;IACD;QACE,KAAK,EAAE,qBAAqB;QAC5B,KAAK,EAAE,eAAe;KACvB;IACD;QACE,KAAK,EAAE,mBAAmB;QAC1B,KAAK,EAAE,aAAa;KACrB;CACF,CAAA"}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dynamicReadProperties = exports.dynamicReadObjectTypes = exports.dynamicReadEventNames = void 0;
4
4
  const properties_1 = require("../properties");
5
5
  const constants_1 = require("./constants");
6
+ const utils_1 = require("./utils");
6
7
  async function dynamicReadEventNames(request) {
7
8
  try {
8
9
  const response = await request(`${properties_1.HUBSPOT_BASE_URL}/events/v3/event-definitions/?includeProperties=false`, {
@@ -66,10 +67,11 @@ async function dynamicReadProperties(request, eventName) {
66
67
  method: 'GET',
67
68
  skipResponseCloning: true
68
69
  });
70
+ const cleanedEventName = utils_1.cleanEventName(eventName);
69
71
  return {
70
- choices: [
71
- ...response.data.results
72
- .filter((event) => event.fullyQualifiedName === eventName && !event.archived)
72
+ choices: (() => {
73
+ const choices = response.data.results
74
+ .filter((event) => (event.fullyQualifiedName === cleanedEventName || event.name === cleanedEventName) && !event.archived)
73
75
  .map((event) => {
74
76
  if (!event.properties || event.properties.length === 0) {
75
77
  return {
@@ -87,8 +89,12 @@ async function dynamicReadProperties(request, eventName) {
87
89
  };
88
90
  });
89
91
  })
90
- .flat()
91
- ]
92
+ .flat();
93
+ if (choices.length === 0) {
94
+ return constants_1.DEFAULT_CUSTOM_EVENT_PROPERTIES;
95
+ }
96
+ return choices;
97
+ })()
92
98
  };
93
99
  }
94
100
  catch (err) {
@@ -1 +1 @@
1
- {"version":3,"file":"dynamic-fields.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/dynamic-fields.ts"],"names":[],"mappings":";;;AAEA,8CAAgD;AAChD,2CAA4D;AAIrD,KAAK,UAAU,qBAAqB,CAAC,OAAsB;IAgBhE,IAAI;QACF,MAAM,QAAQ,GAAiB,MAAM,OAAO,CAC1C,GAAG,6BAAgB,uDAAuD,EAC1E;YACE,MAAM,EAAE,KAAK;YACb,mBAAmB,EAAE,IAAI;SAC1B,CACF,CAAA;QAED,OAAO;YACL,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,OAAO;iBAC3B,MAAM,CAAC,CAAC,KAAiB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;iBAClG,GAAG,CAAC,CAAC,KAAiB,EAAE,EAAE;gBACzB,OAAO;oBACL,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,QAAQ,IAAI,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,EAAE;oBAC3D,KAAK,EAAE,KAAK,CAAC,kBAAkB;iBAChC,CAAA;YACH,CAAC,CAAC;iBACD,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9E,CAAA;KACF;IAAC,OAAO,GAAG,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,iCAAiC,SAAS,EAAE;4BACnD,KAAK,EAAE,EAAE;yBACV,CAAA;qBACF;oBACD,OAAO,KAAK,CAAC,UAAU;yBACpB,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;yBACxC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;yBAC1E,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;wBAChB,OAAO;4BACL,KAAK,EAAE,GAAG,QAAQ,CAAC,KAAK,MAAM,QAAQ,CAAC,IAAI,EAAE;4BAC7C,KAAK,EAAE,QAAQ,CAAC,IAAI;yBACrB,CAAA;oBACH,CAAC,CAAC,CAAA;gBACN,CAAC,CAAC;qBACD,IAAI,EAAE,CAAA;gBAET,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;oBACxB,OAAO,2CAA+B,CAAA;iBACvC;gBAED,OAAO,OAAO,CAAA;YAChB,CAAC,CAAC,EAAE;SACL,CAAA;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAI,GAAY,GAAoB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAE,GAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QAEpH,OAAO;YACL,OAAO,EAAE,EAAE;YACX,KAAK,EAAE;gBACL,OAAO,EAAG,GAAoB,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,IAAI,sCAAsC;gBACjG,IAAI,EAAE,IAAI;aACX;SACF,CAAA;KACF;AACH,CAAC;AAhFD,sDAgFC"}
@@ -1,5 +1,5 @@
1
- import { ActionDefinition } from '@segment/actions-core';
2
1
  import type { Settings } from '../generated-types';
3
2
  import type { Payload } from './generated-types';
3
+ import { ActionDefinition } from '@segment/actions-core';
4
4
  declare const action: ActionDefinition<Settings, Payload>;
5
5
  export default action;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const actions_core_1 = require("@segment/actions-core");
4
- const hubspot_api_1 = require("./hubspot-api");
5
3
  const common_fields_1 = require("./common-fields");
4
+ const client_1 = require("./client");
5
+ const actions_core_1 = require("@segment/actions-core");
6
6
  const dynamic_fields_1 = require("./dynamic-fields");
7
+ const types_1 = require("./types");
8
+ const utils_1 = require("./utils");
7
9
  const action = {
8
10
  title: 'Custom Event',
9
11
  description: 'Send Custom Events to HubSpot',
@@ -12,9 +14,9 @@ const action = {
12
14
  label: 'Sync Mode',
13
15
  default: 'update',
14
16
  choices: [
15
- { label: 'Create new event schemas, and update existing event schemas', value: 'upsert' },
16
- { label: 'Create new event schemas, but do not update existing event schemas', value: 'add' },
17
- { label: 'Update existing event schemas, but do not create new event schemas', value: 'update' }
17
+ { label: 'Create new and update existing custom event definitions', value: 'upsert' },
18
+ { label: 'Create new, but do not update existing custom event definitions', value: 'add' },
19
+ { label: 'Update existing, but do ot create new custom event definitions', value: 'update' }
18
20
  ]
19
21
  },
20
22
  fields: {
@@ -40,20 +42,56 @@ const action = {
40
42
  }
41
43
  },
42
44
  perform: async (request, { payload, syncMode }) => {
43
- if (!payload.record_details.object_id && !payload.record_details.email && !payload.record_details.utk) {
44
- throw new actions_core_1.PayloadValidationError('At least one of object_id, email or utk is required');
45
- }
46
- if (payload.record_details.object_id && typeof payload.record_details.object_id !== 'number') {
47
- throw new actions_core_1.PayloadValidationError('Object ID must be numeric');
45
+ return await send(request, payload, syncMode);
46
+ }
47
+ };
48
+ const send = async (request, payload, syncMode) => {
49
+ const client = new client_1.Client(request);
50
+ const validPayload = utils_1.validate(payload);
51
+ const schema = utils_1.eventSchema(validPayload);
52
+ const cacheSchemaDiff = await utils_1.compareToCache(schema);
53
+ switch (cacheSchemaDiff.match) {
54
+ case types_1.SchemaMatch.FullMatch: {
55
+ return await utils_1.sendEvent(client, cacheSchemaDiff?.fullyQualifiedName, validPayload);
48
56
  }
49
- if (payload.record_details.email && payload.record_details.object_type !== 'contact') {
50
- throw new actions_core_1.PayloadValidationError('Email can only be used to associate an event with a Contacts object');
57
+ case types_1.SchemaMatch.Mismatch: {
58
+ throw new actions_core_1.IntegrationError('Cache schema mismatch.', 'CACHE_SCHEMA_MISMATCH', 400);
51
59
  }
52
- if (payload.record_details.utk && payload.record_details.object_type !== 'contact') {
53
- throw new actions_core_1.PayloadValidationError('User Token can only be used to associate an event with a Contacts object');
60
+ case types_1.SchemaMatch.NoMatch:
61
+ case types_1.SchemaMatch.PropertiesMissing: {
62
+ const hubspotSchemaDiff = await utils_1.compareToHubspot(client, schema);
63
+ switch (hubspotSchemaDiff.match) {
64
+ case types_1.SchemaMatch.FullMatch: {
65
+ const fullyQualifiedName = hubspotSchemaDiff?.fullyQualifiedName;
66
+ const name = hubspotSchemaDiff?.name;
67
+ await utils_1.saveSchemaToCache(fullyQualifiedName, name, schema);
68
+ return await utils_1.sendEvent(client, fullyQualifiedName, validPayload);
69
+ }
70
+ case types_1.SchemaMatch.Mismatch: {
71
+ throw new actions_core_1.IntegrationError('Hubspot schema mismatch.', 'HUBSPOT_SCHEMA_MISMATCH', 400);
72
+ }
73
+ case types_1.SchemaMatch.NoMatch: {
74
+ if (syncMode === 'update') {
75
+ throw new actions_core_1.IntegrationError(`The 'Sync Mode' setting is set to 'update' which is stopping Segment from creating a new Custom Event Schema in the HubSpot`, 'HUBSPOT_SCHEMA_MISSING', 400);
76
+ }
77
+ const schemaDiff = await utils_1.createHubspotEventSchema(client, schema);
78
+ const fullyQualifiedName = schemaDiff?.fullyQualifiedName;
79
+ const name = schemaDiff?.name;
80
+ await utils_1.saveSchemaToCache(fullyQualifiedName, name, schema);
81
+ return await utils_1.sendEvent(client, fullyQualifiedName, validPayload);
82
+ }
83
+ case types_1.SchemaMatch.PropertiesMissing: {
84
+ if (syncMode === 'add') {
85
+ throw new actions_core_1.IntegrationError(`The 'Sync Mode' setting is set to 'add' which is stopping Segment from creating a new properties on the Event Schema in the HubSpot`, 'HUBSPOT_SCHEMA_PROPERTIES_MISSING', 400);
86
+ }
87
+ const fullyQualifiedName = hubspotSchemaDiff?.fullyQualifiedName;
88
+ const name = hubspotSchemaDiff?.name;
89
+ await utils_1.updateHubspotSchema(client, fullyQualifiedName, hubspotSchemaDiff);
90
+ await utils_1.saveSchemaToCache(fullyQualifiedName, name, schema);
91
+ return await utils_1.sendEvent(client, fullyQualifiedName, validPayload);
92
+ }
93
+ }
54
94
  }
55
- const hubspotClient = new hubspot_api_1.HubspotClient(request, syncMode);
56
- return await hubspotClient.send(payload);
57
95
  }
58
96
  };
59
97
  exports.default = action;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAGhF,+CAAuD;AACvD,mDAA8C;AAE9C,qDAAuG;AAEvG,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,+BAA+B;IAC5C,QAAQ,EAAE;QACR,WAAW,EAAE,4DAA4D;QACzE,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,6DAA6D,EAAE,KAAK,EAAE,QAAQ,EAAE;YACzF,EAAE,KAAK,EAAE,oEAAoE,EAAE,KAAK,EAAE,KAAK,EAAE;YAC7F,EAAE,KAAK,EAAE,oEAAoE,EAAE,KAAK,EAAE,QAAQ,EAAE;SACjG;KACF;IACD,MAAM,EAAE;QACN,GAAG,4BAAY;KAChB;IACD,aAAa,EAAE;QACb,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC5B,OAAO,MAAM,sCAAqB,CAAC,OAAO,CAAC,CAAA;QAC7C,CAAC;QACD,cAAc,EAAE;YACd,WAAW,EAAE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AC,CAAA;QACtE,OAAO,MAAM,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC1C,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/index.ts"],"names":[],"mappings":";;AAEA,mDAA8C;AAC9C,qCAAiC;AACjC,wDAAyF;AACzF,qDAAuG;AACvG,mCAA+C;AAC/C,mCASgB;AAEhB,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,+BAA+B;IAC5C,QAAQ,EAAE;QACR,WAAW,EAAE,4DAA4D;QACzE,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,QAAQ;QACjB,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,yDAAyD,EAAE,KAAK,EAAE,QAAQ,EAAE;YACrF,EAAE,KAAK,EAAE,iEAAiE,EAAE,KAAK,EAAE,KAAK,EAAE;YAC1F,EAAE,KAAK,EAAE,gEAAgE,EAAE,KAAK,EAAE,QAAQ,EAAE;SAC7F;KACF;IACD,MAAM,EAAE;QACN,GAAG,4BAAY;KAChB;IACD,aAAa,EAAE;QACb,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;YAC5B,OAAO,MAAM,sCAAqB,CAAC,OAAO,CAAC,CAAA;QAC7C,CAAC;QACD,cAAc,EAAE;YACd,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBAC7B,OAAO,MAAM,uCAAsB,CAAC,OAAO,CAAC,CAAA;YAC9C,CAAC;SACF;QACD,UAAU,EAAE;YACV,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;gBACvC,MAAM,SAAS,GAAG,OAAO,EAAE,UAAU,CAAA;gBACrC,IAAI,CAAC,SAAS,EAAE;oBACd,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;iBAClD;gBACD,OAAO,MAAM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MAAM,iBAAS,CAAC,MAAM,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAA;iBACjE;aACF;SACF;KACF;AACH,CAAC,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,93 @@
1
+ export declare type SyncMode = 'upsert' | 'add' | 'update';
2
+ export declare type StringFormat = 'date' | 'datetime' | 'string';
3
+ export declare type SegmentPropertyType = 'number' | 'object' | 'boolean' | 'string';
4
+ export interface SegmentProperty {
5
+ type: SegmentPropertyType;
6
+ stringFormat?: StringFormat;
7
+ }
8
+ export declare const SchemaMatch: {
9
+ readonly FullMatch: "full_match";
10
+ readonly PropertiesMissing: "properties_missing";
11
+ readonly NoMatch: "no_match";
12
+ readonly Mismatch: "mismatch";
13
+ };
14
+ export declare type SchemaMatch = typeof SchemaMatch[keyof typeof SchemaMatch];
15
+ export interface SchemaDiff {
16
+ match: SchemaMatch;
17
+ fullyQualifiedName?: string;
18
+ name?: string;
19
+ missingProperties: {
20
+ [key: string]: SegmentProperty;
21
+ };
22
+ }
23
+ export interface Schema {
24
+ eventName: string;
25
+ properties: {
26
+ [key: string]: SegmentProperty;
27
+ };
28
+ primaryObject: string;
29
+ }
30
+ export declare type HubspotPropertyType = 'string' | 'number' | 'enumeration' | 'datetime';
31
+ export interface GetEventDefinitionResp {
32
+ archived: boolean;
33
+ fullyQualifiedName: string;
34
+ name: string;
35
+ properties: Array<{
36
+ archived: boolean;
37
+ name: string;
38
+ type: HubspotPropertyType;
39
+ }>;
40
+ }
41
+ export interface CreateEventDefinitionResp {
42
+ fullyQualifiedName: string;
43
+ name: string;
44
+ }
45
+ export interface CreatePropertyDefintionReq {
46
+ name: string;
47
+ label: string;
48
+ type: HubspotPropertyType;
49
+ description: string;
50
+ options?: Array<{
51
+ label: string;
52
+ value: boolean;
53
+ description: string;
54
+ hidden: boolean;
55
+ displayOrder: number;
56
+ }>;
57
+ }
58
+ export interface CreateEventDefinitionReq {
59
+ label: string;
60
+ name: string;
61
+ description: string;
62
+ primaryObject: string;
63
+ propertyDefinitions: Array<CreatePropertyDefintionReq>;
64
+ }
65
+ export interface CreateEventDefinitionRespErr {
66
+ response: {
67
+ data: {
68
+ message: string;
69
+ status: string;
70
+ category: string;
71
+ };
72
+ };
73
+ }
74
+ export interface CreatePropertyRegectedResp {
75
+ data: {
76
+ status: string;
77
+ message?: string;
78
+ propertiesErrorCode?: string;
79
+ };
80
+ }
81
+ export interface ErrorResponse {
82
+ code: string;
83
+ }
84
+ export interface EventCompletionReq {
85
+ eventName: string;
86
+ objectId?: number | undefined;
87
+ email?: string | undefined;
88
+ utk?: string | undefined;
89
+ occurredAt: string | number | undefined;
90
+ properties?: {
91
+ [k: string]: unknown;
92
+ } | undefined;
93
+ }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaMatch = void 0;
4
+ exports.SchemaMatch = {
5
+ FullMatch: 'full_match',
6
+ PropertiesMissing: 'properties_missing',
7
+ NoMatch: 'no_match',
8
+ Mismatch: 'mismatch'
9
+ };
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/destinations/hubspot/customEvent/types.ts"],"names":[],"mappings":";;;AAUa,QAAA,WAAW,GAAG;IACzB,SAAS,EAAE,YAAY;IACvB,iBAAiB,EAAE,oBAAoB;IACvC,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,UAAU;CACZ,CAAA"}
@@ -0,0 +1,12 @@
1
+ import type { Payload } from './generated-types';
2
+ import { Schema, SchemaDiff } from './types';
3
+ import { Client } from './client';
4
+ export declare function validate(payload: Payload): Payload;
5
+ export declare function cleanEventName(str: string): string;
6
+ export declare function eventSchema(payload: Payload): Schema;
7
+ export declare function compareToCache(_schema: Schema): Promise<SchemaDiff>;
8
+ export declare function compareToHubspot(client: Client, schema: Schema): Promise<SchemaDiff>;
9
+ export declare function saveSchemaToCache(_fullyQualifiedName: string, _name: string, _schema: Schema): Promise<void>;
10
+ export declare function sendEvent(client: Client, fullyQualifiedName: string, payload: Payload): Promise<import("@segment/actions-core/src").ModifiedResponse<unknown>>;
11
+ export declare function createHubspotEventSchema(client: Client, schema: Schema): Promise<SchemaDiff>;
12
+ export declare function updateHubspotSchema(client: Client, fullyQualifiedName: string, schemaDiff: SchemaDiff): Promise<void>;