@segment/action-destinations 3.229.1-test-action-cli-72ee8aca.7 → 3.330.1-staging.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 (133) hide show
  1. package/dist/destinations/blackbaud-raisers-edge-nxt/utils/index.d.ts +1 -1
  2. package/dist/destinations/criteo-audiences/addUserToAudience/index.js +8 -8
  3. package/dist/destinations/criteo-audiences/addUserToAudience/index.js.map +1 -1
  4. package/dist/destinations/criteo-audiences/criteo-audiences.d.ts +5 -6
  5. package/dist/destinations/criteo-audiences/criteo-audiences.js +66 -53
  6. package/dist/destinations/criteo-audiences/criteo-audiences.js.map +1 -1
  7. package/dist/destinations/criteo-audiences/removeUserFromAudience/index.js +8 -8
  8. package/dist/destinations/criteo-audiences/removeUserFromAudience/index.js.map +1 -1
  9. package/dist/destinations/engage/sendgrid/sendEmail/actionDefinition.js +9 -0
  10. package/dist/destinations/engage/sendgrid/sendEmail/actionDefinition.js.map +1 -1
  11. package/dist/destinations/engage/twilio/sendMobilePush/actionDefinition.js +9 -0
  12. package/dist/destinations/engage/twilio/sendMobilePush/actionDefinition.js.map +1 -1
  13. package/dist/destinations/engage/twilio/sendSms/actionDefinition.js +9 -0
  14. package/dist/destinations/engage/twilio/sendSms/actionDefinition.js.map +1 -1
  15. package/dist/destinations/engage/twilio/sendWhatsApp/actionDefinition.js +9 -0
  16. package/dist/destinations/engage/twilio/sendWhatsApp/actionDefinition.js.map +1 -1
  17. package/dist/destinations/engage/utils/EngageActionPerformer.d.ts +1 -1
  18. package/dist/destinations/engage/utils/EngageStats.js +5 -1
  19. package/dist/destinations/engage/utils/EngageStats.js.map +1 -1
  20. package/dist/destinations/klaviyo/functions.d.ts +8 -0
  21. package/dist/destinations/klaviyo/functions.js +34 -1
  22. package/dist/destinations/klaviyo/functions.js.map +1 -1
  23. package/dist/destinations/klaviyo/index.js +1 -1
  24. package/dist/destinations/klaviyo/index.js.map +1 -1
  25. package/dist/destinations/klaviyo/types.d.ts +42 -0
  26. package/dist/destinations/klaviyo/upsertProfile/generated-types.d.ts +1 -0
  27. package/dist/destinations/klaviyo/upsertProfile/index.js +32 -1
  28. package/dist/destinations/klaviyo/upsertProfile/index.js.map +1 -1
  29. package/dist/destinations/linkedin-conversions/api/index.d.ts +9 -2
  30. package/dist/destinations/linkedin-conversions/api/index.js +140 -1
  31. package/dist/destinations/linkedin-conversions/api/index.js.map +1 -1
  32. package/dist/destinations/linkedin-conversions/constants.d.ts +1 -0
  33. package/dist/destinations/linkedin-conversions/constants.js +7 -1
  34. package/dist/destinations/linkedin-conversions/constants.js.map +1 -1
  35. package/dist/destinations/linkedin-conversions/index.js +2 -1
  36. package/dist/destinations/linkedin-conversions/index.js.map +1 -1
  37. package/dist/destinations/linkedin-conversions/streamConversion/generated-types.d.ts +18 -0
  38. package/dist/destinations/linkedin-conversions/streamConversion/index.js +161 -15
  39. package/dist/destinations/linkedin-conversions/streamConversion/index.js.map +1 -1
  40. package/dist/destinations/linkedin-conversions/types.d.ts +50 -0
  41. package/dist/destinations/tiktok-audiences/addToAudience/generated-types.d.ts +2 -0
  42. package/dist/destinations/tiktok-audiences/addToAudience/index.js +2 -0
  43. package/dist/destinations/tiktok-audiences/addToAudience/index.js.map +1 -1
  44. package/dist/destinations/tiktok-audiences/addUser/generated-types.d.ts +2 -0
  45. package/dist/destinations/tiktok-audiences/addUser/index.js +2 -0
  46. package/dist/destinations/tiktok-audiences/addUser/index.js.map +1 -1
  47. package/dist/destinations/tiktok-audiences/functions.js +17 -2
  48. package/dist/destinations/tiktok-audiences/functions.js.map +1 -1
  49. package/dist/destinations/tiktok-audiences/properties.d.ts +2 -0
  50. package/dist/destinations/tiktok-audiences/properties.js +28 -7
  51. package/dist/destinations/tiktok-audiences/properties.js.map +1 -1
  52. package/dist/destinations/tiktok-audiences/removeFromAudience/generated-types.d.ts +2 -0
  53. package/dist/destinations/tiktok-audiences/removeFromAudience/index.js +2 -0
  54. package/dist/destinations/tiktok-audiences/removeFromAudience/index.js.map +1 -1
  55. package/dist/destinations/tiktok-audiences/removeUser/generated-types.d.ts +2 -0
  56. package/dist/destinations/tiktok-audiences/removeUser/index.js +2 -0
  57. package/dist/destinations/tiktok-audiences/removeUser/index.js.map +1 -1
  58. package/package.json +3 -3
  59. package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.d.ts +0 -1
  60. package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js +0 -184
  61. package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js.map +0 -1
  62. package/dist/destinations/klaviyo/addProfileToList/generated-types.d.ts +0 -4
  63. package/dist/destinations/klaviyo/addProfileToList/generated-types.js +0 -3
  64. package/dist/destinations/klaviyo/addProfileToList/generated-types.js.map +0 -1
  65. package/dist/destinations/klaviyo/addProfileToList/index.d.ts +0 -5
  66. package/dist/destinations/klaviyo/addProfileToList/index.js +0 -48
  67. package/dist/destinations/klaviyo/addProfileToList/index.js.map +0 -1
  68. package/dist/destinations/klaviyo/properties.d.ts +0 -3
  69. package/dist/destinations/klaviyo/properties.js +0 -21
  70. package/dist/destinations/klaviyo/properties.js.map +0 -1
  71. package/dist/destinations/klaviyo/removeProfileToList/generated-types.d.ts +0 -4
  72. package/dist/destinations/klaviyo/removeProfileToList/generated-types.js +0 -3
  73. package/dist/destinations/klaviyo/removeProfileToList/generated-types.js.map +0 -1
  74. package/dist/destinations/klaviyo/removeProfileToList/index.d.ts +0 -5
  75. package/dist/destinations/klaviyo/removeProfileToList/index.js +0 -43
  76. package/dist/destinations/klaviyo/removeProfileToList/index.js.map +0 -1
  77. package/dist/destinations/mixpanel/utils.d.ts +0 -13
  78. package/dist/destinations/mixpanel/utils.js +0 -117
  79. package/dist/destinations/mixpanel/utils.js.map +0 -1
  80. package/dist/destinations/movable-ink/categoryView/generated-types.d.ts +0 -22
  81. package/dist/destinations/movable-ink/categoryView/generated-types.js +0 -3
  82. package/dist/destinations/movable-ink/categoryView/generated-types.js.map +0 -1
  83. package/dist/destinations/movable-ink/categoryView/index.d.ts +0 -5
  84. package/dist/destinations/movable-ink/categoryView/index.js +0 -43
  85. package/dist/destinations/movable-ink/categoryView/index.js.map +0 -1
  86. package/dist/destinations/movable-ink/conversion/generated-types.d.ts +0 -20
  87. package/dist/destinations/movable-ink/conversion/generated-types.js +0 -3
  88. package/dist/destinations/movable-ink/conversion/generated-types.js.map +0 -1
  89. package/dist/destinations/movable-ink/conversion/index.d.ts +0 -5
  90. package/dist/destinations/movable-ink/conversion/index.js +0 -45
  91. package/dist/destinations/movable-ink/conversion/index.js.map +0 -1
  92. package/dist/destinations/movable-ink/fields.d.ts +0 -21
  93. package/dist/destinations/movable-ink/fields.js +0 -236
  94. package/dist/destinations/movable-ink/fields.js.map +0 -1
  95. package/dist/destinations/movable-ink/identify/generated-types.d.ts +0 -7
  96. package/dist/destinations/movable-ink/identify/generated-types.js +0 -3
  97. package/dist/destinations/movable-ink/identify/generated-types.js.map +0 -1
  98. package/dist/destinations/movable-ink/identify/index.d.ts +0 -5
  99. package/dist/destinations/movable-ink/identify/index.js +0 -32
  100. package/dist/destinations/movable-ink/identify/index.js.map +0 -1
  101. package/dist/destinations/movable-ink/productAdded/generated-types.d.ts +0 -22
  102. package/dist/destinations/movable-ink/productAdded/generated-types.js +0 -3
  103. package/dist/destinations/movable-ink/productAdded/generated-types.js.map +0 -1
  104. package/dist/destinations/movable-ink/productAdded/index.d.ts +0 -5
  105. package/dist/destinations/movable-ink/productAdded/index.js +0 -43
  106. package/dist/destinations/movable-ink/productAdded/index.js.map +0 -1
  107. package/dist/destinations/movable-ink/productViewed/generated-types.d.ts +0 -21
  108. package/dist/destinations/movable-ink/productViewed/generated-types.js +0 -3
  109. package/dist/destinations/movable-ink/productViewed/generated-types.js.map +0 -1
  110. package/dist/destinations/movable-ink/productViewed/index.d.ts +0 -5
  111. package/dist/destinations/movable-ink/productViewed/index.js +0 -43
  112. package/dist/destinations/movable-ink/productViewed/index.js.map +0 -1
  113. package/dist/destinations/movable-ink/search/generated-types.d.ts +0 -12
  114. package/dist/destinations/movable-ink/search/generated-types.js +0 -3
  115. package/dist/destinations/movable-ink/search/generated-types.js.map +0 -1
  116. package/dist/destinations/movable-ink/search/index.d.ts +0 -5
  117. package/dist/destinations/movable-ink/search/index.js +0 -43
  118. package/dist/destinations/movable-ink/search/index.js.map +0 -1
  119. package/dist/destinations/movable-ink/sendCustomEvent/generated-types.d.ts +0 -25
  120. package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js +0 -3
  121. package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js.map +0 -1
  122. package/dist/destinations/movable-ink/sendCustomEvent/index.d.ts +0 -5
  123. package/dist/destinations/movable-ink/sendCustomEvent/index.js +0 -48
  124. package/dist/destinations/movable-ink/sendCustomEvent/index.js.map +0 -1
  125. package/dist/destinations/trackey/group.types.d.ts +0 -11
  126. package/dist/destinations/trackey/group.types.js +0 -3
  127. package/dist/destinations/trackey/group.types.js.map +0 -1
  128. package/dist/destinations/trackey/identify.types.d.ts +0 -11
  129. package/dist/destinations/trackey/identify.types.js +0 -3
  130. package/dist/destinations/trackey/identify.types.js.map +0 -1
  131. package/dist/destinations/trackey/track.types.d.ts +0 -12
  132. package/dist/destinations/trackey/track.types.js +0 -3
  133. package/dist/destinations/trackey/track.types.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addProfileToList = exports.getListIdDynamicData = void 0;
3
+ exports.sendImportJobRequest = exports.createImportJobPayload = exports.addProfileToList = exports.getListIdDynamicData = void 0;
4
4
  const config_1 = require("./config");
5
5
  async function getListIdDynamicData(request, settings) {
6
6
  try {
@@ -48,4 +48,37 @@ async function addProfileToList(request, profileId, listId) {
48
48
  });
49
49
  }
50
50
  exports.addProfileToList = addProfileToList;
51
+ const createImportJobPayload = (profiles, listId) => ({
52
+ data: {
53
+ type: 'profile-bulk-import-job',
54
+ attributes: {
55
+ profiles: {
56
+ data: profiles.map(({ list_id, enable_batching, ...attributes }) => ({
57
+ type: 'profile',
58
+ attributes
59
+ }))
60
+ }
61
+ },
62
+ ...(listId
63
+ ? {
64
+ relationships: {
65
+ lists: {
66
+ data: [{ type: 'list', id: listId }]
67
+ }
68
+ }
69
+ }
70
+ : {})
71
+ }
72
+ });
73
+ exports.createImportJobPayload = createImportJobPayload;
74
+ const sendImportJobRequest = async (request, importJobPayload) => {
75
+ return await request(`${config_1.API_URL}/profile-bulk-import-jobs/`, {
76
+ method: 'POST',
77
+ headers: {
78
+ revision: '2023-10-15.pre'
79
+ },
80
+ json: importJobPayload
81
+ });
82
+ };
83
+ exports.sendImportJobRequest = sendImportJobRequest;
51
84
  //# sourceMappingURL=functions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/functions.ts"],"names":[],"mappings":";;;AACA,qCAAiD;AAI1C,KAAK,UAAU,oBAAoB,CAAC,OAAsB,EAAE,QAAkB;IACnF,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,gBAAO,SAAS,EAAE;YAChD,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,aAAa,EAAE,mBAAmB,QAAQ,CAAC,OAAO,EAAE;gBACpD,MAAM,EAAE,kBAAkB;gBAC1B,QAAQ,EAAE,sBAAa;aACxB;YACD,mBAAmB,EAAE,IAAI;SAC1B,CAAC,CAAA;QACF,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAyB,CAAA;QACxE,MAAM,OAAO,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAkD,EAAE,EAAE;YAC5F,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;QACxD,CAAC,CAAC,CAAA;QACF,OAAO;YACL,OAAO;SACR,CA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E,CAAC;qBACrC;iBACF;aACF;YACH,CAAC,CAAC,EAAE,CAAC;KACR;CACF,CAAC,CAAA;AArBW,QAAA,sBAAsB,0BAqBjC;AAEK,MAAM,oBAAoB,GAAG,KAAK,EAAE,OAAsB,EAAE,gBAA4C,EAAE,EAAE;IACjH,OAAO,MAAM,OAAO,CAAC,GAAG,gBAAO,4BAA4B,EAAE;QAC3D,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,QAAQ,EAAE,gBAAgB;SAC3B;QACD,IAAI,EAAE,gBAAgB;KACvB,CAAC,CAAA;AACJ,CAAC,CAAA;AARY,QAAA,oBAAoB,wBAQhC"}
@@ -15,7 +15,7 @@ const destination = {
15
15
  scheme: 'custom',
16
16
  fields: {
17
17
  api_key: {
18
- type: 'string',
18
+ type: 'password',
19
19
  label: 'API Key',
20
20
  description: `You can find this by going to Klaviyo's UI and clicking Account > Settings > API Keys > Create API Key`,
21
21
  required: true
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/index.ts"],"names":[],"mappings":";;;;;AAGA,oEAA2C;AAC3C,qCAAiD;AAEjD,8DAAqC;AAErC,sEAA6C;AAE7C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,wGAAwG;gBACrH,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,GAAG,gBAAO,YAAY,EAAE;gBACrC,MAAM,EAAE,KAAK;aACd,CAAC,CAAA;QACJ,CAAC;KACF;IAED,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,OAAO,OAAO,CAAC,GAAG,gBAAO,8BAA8B,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE;oBACJ,IAAI,EAAE,2BAA2B;oBACjC,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;gCACf,EAAE,EAAE,OAAO,CAAC,MAAM;6BACnB;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAA;IACJ,CAAC;IAED,aAAa,CAAC,EAAE,QAAQ,EAAE;QACxB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,mBAAmB,QAAQ,CAAC,OAAO,EAAE;gBACpD,MAAM,EAAE,kBAAkB;gBAC1B,QAAQ,EAAE,sBAAa;aACxB;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,aAAa,EAAb,uBAAa;QACb,UAAU,EAAV,oBAAU;QACV,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/klaviyo/index.ts"],"names":[],"mappings":";;;;;AAGA,oEAA2C;AAC3C,qCAAiD;AAEjD,8DAAqC;AAErC,sEAA6C;AAE7C,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,mBAAmB;IACzB,IAAI,EAAE,iBAAiB;IACvB,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,SAAS;gBAChB,WAAW,EAAE,wGAAwG;gBACrH,QAAQ,EAAE,IAAI;aACf;SACF;QACD,kBAAkB,EAAE,CAAC,OAAO,EAAE,EAAE;YAC9B,OAAO,OAAO,CAAC,GAAG,gBAAO,YAAY,EAAE;gBACrC,MAAM,EAAE,KAAK;aACd,CAAC,CAAA;QACJ,CAAC;KACF;IAED,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACvC,OAAO,OAAO,CAAC,GAAG,gBAAO,8BAA8B,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,IAAI,EAAE;oBACJ,IAAI,EAAE,2BAA2B;oBACjC,UAAU,EAAE;wBACV,OAAO,EAAE;4BACP,IAAI,EAAE;gCACJ,IAAI,EAAE,SAAS;gCACf,EAAE,EAAE,OAAO,CAAC,MAAM;6BACnB;yBACF;qBACF;iBACF;aACF;SACF,CAAC,CAAA;IACJ,CAAC;IAED,aAAa,CAAC,EAAE,QAAQ,EAAE;QACxB,OAAO;YACL,OAAO,EAAE;gBACP,aAAa,EAAE,mBAAmB,QAAQ,CAAC,OAAO,EAAE;gBACpD,MAAM,EAAE,kBAAkB;gBAC1B,QAAQ,EAAE,sBAAa;aACxB;SACF,CAAA;IACH,CAAC;IAED,OAAO,EAAE;QACP,aAAa,EAAb,uBAAa;QACb,UAAU,EAAV,oBAAU;QACV,cAAc,EAAd,wBAAc;KACf;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -67,3 +67,45 @@ export interface GetListResultContent {
67
67
  };
68
68
  }[];
69
69
  }
70
+ export interface Location {
71
+ address1?: string | null;
72
+ address2?: string | null;
73
+ city?: string | null;
74
+ region?: string | null;
75
+ zip?: string | null;
76
+ latitude?: string | null;
77
+ longitude?: string | null;
78
+ country?: string | null;
79
+ }
80
+ export interface ProfileAttributes {
81
+ email?: string;
82
+ phone_number?: string;
83
+ external_id?: string;
84
+ first_name?: string;
85
+ last_name?: string;
86
+ organization?: string;
87
+ title?: string;
88
+ image?: string;
89
+ location?: Location | null;
90
+ properties?: Record<string, any>;
91
+ list_id?: string;
92
+ }
93
+ export interface ImportJobPayload {
94
+ type: string;
95
+ attributes: {
96
+ profiles: {
97
+ data: {
98
+ type: string;
99
+ attributes: ProfileAttributes;
100
+ }[];
101
+ };
102
+ };
103
+ relationships?: {
104
+ lists: {
105
+ data: {
106
+ type: string;
107
+ id: string;
108
+ }[];
109
+ };
110
+ };
111
+ }
@@ -1,5 +1,6 @@
1
1
  export interface Payload {
2
2
  email?: string;
3
+ enable_batching?: boolean;
3
4
  phone_number?: string;
4
5
  external_id?: string;
5
6
  first_name?: string;
@@ -15,6 +15,11 @@ const action = {
15
15
  format: 'email',
16
16
  default: { '@path': '$.traits.email' }
17
17
  },
18
+ enable_batching: {
19
+ type: 'boolean',
20
+ label: 'Batch Data to Klaviyo',
21
+ description: 'When enabled, the action will use the klaviyo batch API.'
22
+ },
18
23
  phone_number: {
19
24
  label: 'Phone Number',
20
25
  description: `Individual's phone number in E.164 format. If SMS is not enabled and if you use Phone Number as identifier, then you have to provide one of Email or External ID.`,
@@ -131,7 +136,7 @@ const action = {
131
136
  }
132
137
  },
133
138
  perform: async (request, { payload }) => {
134
- const { email, external_id, phone_number, list_id, ...otherAttributes } = payload;
139
+ const { email, external_id, phone_number, list_id, enable_batching, ...otherAttributes } = payload;
135
140
  if (!email && !phone_number && !external_id) {
136
141
  throw new actions_core_1.PayloadValidationError('One of External ID, Phone Number and Email is required.');
137
142
  }
@@ -177,6 +182,32 @@ const action = {
177
182
  }
178
183
  throw new actions_core_1.APIError('An error occurred while processing the request', 400);
179
184
  }
185
+ },
186
+ performBatch: async (request, { payload }) => {
187
+ payload = payload.filter((profile) => profile.email || profile.external_id || profile.phone_number);
188
+ const profilesWithList = payload.filter((profile) => profile.list_id);
189
+ const profilesWithoutList = payload.filter((profile) => !profile.list_id);
190
+ let importResponseWithList;
191
+ let importResponseWithoutList;
192
+ try {
193
+ if (profilesWithList.length > 0) {
194
+ const listId = profilesWithList[0].list_id;
195
+ const importJobPayload = functions_1.createImportJobPayload(profilesWithList, listId);
196
+ importResponseWithList = await functions_1.sendImportJobRequest(request, importJobPayload);
197
+ }
198
+ if (profilesWithoutList.length > 0) {
199
+ const importJobPayload = functions_1.createImportJobPayload(profilesWithoutList);
200
+ importResponseWithoutList = await functions_1.sendImportJobRequest(request, importJobPayload);
201
+ }
202
+ }
203
+ catch (error) {
204
+ console.error('Error processing batch:', error);
205
+ throw new Error('An error occurred while processing the request');
206
+ }
207
+ return {
208
+ withList: importResponseWithList,
209
+ withoutList: importResponseWithoutList
210
+ };
180
211
  }
181
212
  };
182
213
  exports.default = action;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/upsertProfile/index.ts"],"names":[],"mappings":";;AAIA,sCAAmC;AACnC,wDAAwE;AAExE,4CAAqE;AAErE,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,sBAAsB;IACnC,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,kFAAkF;YAC/F,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE;SACvC;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,mKAAmK;YAChL,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;SAC/C;QACD,WAAW,EAAE;YACX,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,+JAA+J;YAC5K,IAAI,EAAE,QAAQ;SACf;QACD,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,0BAA0B;YACvC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;SAC3C;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,yBAAyB;YACtC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;SAC1C;QACD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H,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/klaviyo/upsertProfile/index.ts"],"names":[],"mappings":";;AAIA,sCAAmC;AACnC,wDAAwE;AAExE,4CAAmH;AAEnH,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAAE,sBAAsB;IACnC,mBAAmB,EAAE,mBAAmB;IACxC,MAAM,EAAE;QACN,KAAK,EAAE;YACL,KAAK,EAAE,OAAO;YACd,WAAW,EAAE,kFAAkF;YAC/F,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,OAAO,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE;SACvC;QACD,eAAe,EAAE;YACf,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EAAE,0DAA0D;SACxE;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,mKAAmK;YAChL,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;SAC/C;QACD,WAAW,EAAE;YACX,KAAK,EAAE,aAAa;YACpB,WAAW,EAAE,+JAA+J;YAC5K,IAAI,EAAE,QAAQ;SACf;QACD,UAAU,EAAE;YACV,KAAK,EAAE,YAAY;YACnB,WAAW,EAAE,0BAA0B;YACvC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;SAC3C;QACD,SAAS,EAAE;YACT,KAAK,EAAE,WAAW;YAClB,WAAW,EAAE,yBAAyB;YACtC,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE;SAC1C;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,cAAc;YACrB,WAAW,EAAE,uFAAuF;YACpG,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,EAAE,OAA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RequestClient, ModifiedResponse, DynamicFieldResponse } from '@segment/actions-core';
2
2
  import type { ProfileAPIResponse } from '../types';
3
+ import type { Payload } from '../streamConversion/generated-types';
3
4
  export declare class LinkedInConversions {
4
5
  request: RequestClient;
5
- constructor(request: RequestClient);
6
+ conversionRuleId?: string;
7
+ constructor(request: RequestClient, conversionRuleId?: string);
6
8
  getProfile(): Promise<ModifiedResponse<ProfileAPIResponse>>;
9
+ getAdAccounts: () => Promise<DynamicFieldResponse>;
10
+ getConversionRulesList: (adAccountId: string) => Promise<DynamicFieldResponse>;
11
+ getCampaignsList: (adAccountUrn: string) => Promise<DynamicFieldResponse>;
12
+ streamConversionEvent(payload: Payload): Promise<ModifiedResponse>;
13
+ associateCampignToConversion(payload: Payload): Promise<ModifiedResponse>;
7
14
  }
@@ -3,14 +3,153 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LinkedInConversions = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  class LinkedInConversions {
6
- constructor(request) {
6
+ constructor(request, conversionRuleId) {
7
+ this.getAdAccounts = async () => {
8
+ try {
9
+ const response = [];
10
+ const result = await this.request(`${constants_1.BASE_URL}/adAccountUsers`, {
11
+ method: 'GET',
12
+ searchParams: {
13
+ q: 'authenticatedUser'
14
+ }
15
+ });
16
+ result.data.elements.forEach((item) => {
17
+ response.push(item);
18
+ });
19
+ const choices = response?.map((item) => {
20
+ return {
21
+ label: item.user,
22
+ value: item.account
23
+ };
24
+ });
25
+ return {
26
+ choices
27
+ };
28
+ }
29
+ catch (err) {
30
+ return {
31
+ choices: [],
32
+ error: {
33
+ message: err.response?.data?.message ?? 'An error occurred while fetching ad accounts.',
34
+ code: err.response?.data?.code?.toString() ?? 'FETCH_AD_ACCOUNTS_ERROR'
35
+ }
36
+ };
37
+ }
38
+ };
39
+ this.getConversionRulesList = async (adAccountId) => {
40
+ if (!adAccountId || !adAccountId.length) {
41
+ return {
42
+ choices: [],
43
+ error: {
44
+ message: 'Please select Ad Account first to get list of Conversion Rules.',
45
+ code: 'FIELD_NOT_SELECTED'
46
+ }
47
+ };
48
+ }
49
+ try {
50
+ const response = [];
51
+ const result = await this.request(`${constants_1.BASE_URL}/conversions`, {
52
+ method: 'GET',
53
+ searchParams: {
54
+ q: 'account',
55
+ account: adAccountId
56
+ }
57
+ });
58
+ result.data.elements.forEach((item) => {
59
+ response.push(item);
60
+ });
61
+ const choices = response?.map((item) => {
62
+ return {
63
+ label: item.name,
64
+ value: item.id
65
+ };
66
+ });
67
+ return {
68
+ choices
69
+ };
70
+ }
71
+ catch (err) {
72
+ return {
73
+ choices: [],
74
+ error: {
75
+ message: err.response?.data?.message ?? 'An error occurred while fetching conversion rules.',
76
+ code: err.response?.data?.code?.toString() ?? 'FETCH_CONVERSIONS_ERROR'
77
+ }
78
+ };
79
+ }
80
+ };
81
+ this.getCampaignsList = async (adAccountUrn) => {
82
+ const parts = adAccountUrn.split(':');
83
+ const adAccountId = parts.pop();
84
+ if (!adAccountId || !adAccountId.length) {
85
+ return {
86
+ choices: [],
87
+ error: {
88
+ message: 'Please select Ad Account first to get list of Conversion Rules.',
89
+ code: 'FIELD_NOT_SELECTED'
90
+ }
91
+ };
92
+ }
93
+ try {
94
+ const response = [];
95
+ const result = await this.request(`${constants_1.BASE_URL}/adAccounts/${adAccountId}/adCampaigns?q=search&search=(status:(values:List(ACTIVE)))`, {
96
+ method: 'GET'
97
+ });
98
+ result.data.elements.forEach((item) => {
99
+ response.push(item);
100
+ });
101
+ const choices = response?.map((item) => {
102
+ return {
103
+ label: item.name,
104
+ value: item.id
105
+ };
106
+ });
107
+ return {
108
+ choices
109
+ };
110
+ }
111
+ catch (err) {
112
+ return {
113
+ choices: [],
114
+ error: {
115
+ message: err.response?.data?.message ?? 'An error occurred while fetching conversion rules.',
116
+ code: err.response?.data?.code?.toString() ?? 'FETCH_CONVERSIONS_ERROR'
117
+ }
118
+ };
119
+ }
120
+ };
7
121
  this.request = request;
122
+ this.conversionRuleId = conversionRuleId;
8
123
  }
9
124
  async getProfile() {
10
125
  return this.request(`${constants_1.BASE_URL}/me`, {
11
126
  method: 'GET'
12
127
  });
13
128
  }
129
+ async streamConversionEvent(payload) {
130
+ return this.request(`${constants_1.BASE_URL}/conversionEvents`, {
131
+ method: 'POST',
132
+ json: {
133
+ conversion: `urn:lla:llaPartnerConversion:${this.conversionRuleId}`,
134
+ conversionHappenedAt: payload.conversionHappenedAt,
135
+ conversionValue: payload.conversionValue,
136
+ eventId: payload.eventId,
137
+ user: {
138
+ userIds: payload.userIds,
139
+ userInfo: payload.userInfo
140
+ }
141
+ }
142
+ });
143
+ }
144
+ async associateCampignToConversion(payload) {
145
+ return this.request(`${constants_1.BASE_URL}/campaignConversions/(campaign:urn%3Ali%3AsponsoredCampaign%3A${payload.campaignId},conversion:urn%3Alla%3AllaPartnerConversion%3A${this.conversionRuleId})`, {
146
+ method: 'PUT',
147
+ body: JSON.stringify({
148
+ campaign: `urn:li:sponsoredCampaign:${payload.campaignId}`,
149
+ conversion: `urn:lla:llaPartnerConversion:${this.conversionRuleId}`
150
+ })
151
+ });
152
+ }
14
153
  }
15
154
  exports.LinkedInConversions = LinkedInConversions;
16
155
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/api/index.ts"],"names":[],"mappings":";;;AACA,4CAAuC;AAGvC,MAAa,mBAAmB;IAG9B,YAAY,OAAsB;QAChC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,oBAAQ,KAAK,EAAE;YACpC,MAAM,EAAE,KAAK;SACd,CAAC,CAAA;IACJ,CAAC;CACF;AAZD,kDAYC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/linkedin-conversions/api/index.ts"],"names":[],"mappings":";;;AACA,4CAAuC;AAYvC,MAAa,mBAAmB;I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AC,qBAAqB,CAAC,OAAgB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,oBAAQ,mBAAmB,EAAE;YAClD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE;gBACJ,UAAU,EAAE,gCAAgC,IAAI,CAAC,gBAAgB,EAAE;gBACnE,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;gBAClD,eAAe,EAAE,OAAO,CAAC,eAAe;gBACxC,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,IAAI,EAAE;oBACJ,OAAO,EAAE,OAAO,CAAC,OAAO;oBACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;iBAC3B;aACF;SACF,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,4BAA4B,CAAC,OAAgB;QACjD,OAAO,IAAI,CAAC,OAAO,CACjB,GAAG,oBAAQ,iEAAiE,OAAO,CAAC,UAAU,kDAAkD,IAAI,CAAC,gBAAgB,GAAG,EACxK;YACE,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;gBACnB,QAAQ,EAAE,4BAA4B,OAAO,CAAC,UAAU,EAAE;gBAC1D,UAAU,EAAE,gCAAgC,IAAI,CAAC,gBAAgB,EAAE;aACpE,CAAC;SACH,CACF,CAAA;IACH,CAAC;CACF;AA/KD,kDA+KC"}
@@ -1,3 +1,4 @@
1
1
  export declare const LINKEDIN_API_VERSION = "202309";
2
2
  export declare const BASE_URL = "https://api.linkedin.com/rest";
3
3
  export declare const LINKEDIN_SOURCE_PLATFORM = "SEGMENT";
4
+ export declare const SUPPORTED_ID_TYPE: string[];
@@ -1,7 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LINKEDIN_SOURCE_PLATFORM = exports.BASE_URL = exports.LINKEDIN_API_VERSION = void 0;
3
+ exports.SUPPORTED_ID_TYPE = exports.LINKEDIN_SOURCE_PLATFORM = exports.BASE_URL = exports.LINKEDIN_API_VERSION = void 0;
4
4
  exports.LINKEDIN_API_VERSION = '202309';
5
5
  exports.BASE_URL = 'https://api.linkedin.com/rest';
6
6
  exports.LINKEDIN_SOURCE_PLATFORM = 'SEGMENT';
7
+ exports.SUPPORTED_ID_TYPE = [
8
+ 'SHA256_EMAIL',
9
+ 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID',
10
+ 'ACXIOM_ID',
11
+ 'ORACLE_MOAT_ID'
12
+ ];
7
13
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-conversions/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAC/B,QAAA,QAAQ,GAAG,+BAA+B,CAAA;AAC1C,QAAA,wBAAwB,GAAG,SAAS,CAAA"}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-conversions/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,oBAAoB,GAAG,QAAQ,CAAA;AAC/B,QAAA,QAAQ,GAAG,+BAA+B,CAAA;AAC1C,QAAA,wBAAwB,GAAG,SAAS,CAAA;AAEpC,QAAA,iBAAiB,GAAG;IAC/B,cAAc;IACd,wCAAwC;IACxC,WAAW;IACX,gBAAgB;CACjB,CAAA"}
@@ -57,7 +57,8 @@ const destination = {
57
57
  return {
58
58
  headers: {
59
59
  authorization: `Bearer ${auth?.accessToken}`,
60
- 'LinkedIn-Version': constants_1.LINKEDIN_API_VERSION
60
+ 'LinkedIn-Version': constants_1.LINKEDIN_API_VERSION,
61
+ 'X-Restli-Protocol-Version': `2.0.0`
61
62
  }
62
63
  };
63
64
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-conversions/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAgG;AAEhG,+BAA2C;AAE3C,2CAAkD;AAElD,0EAAiD;AAEjD,MAAM,WAAW,GA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B,CACxB,wHAAwH,EACxH,yBAAU,CAAC,qBAAqB,EAChC,GAAG,CACJ,CAAA;iBACF;gBAED,MAAM,IAAI,+BAAgB,CACxB,+CAA+C,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,EAC5E,yBAAU,CAAC,oBAAoB,EAC/B,GAAG,CACJ,CAAA;aACF;YAED,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,gCAAoB;aACzC;SACF,CAAA;IACH,CAAC;IACD,OAAO,EAAE;QACP,gBAAgB,EAAhB,0BAAgB;KACjB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/destinations/linkedin-conversions/index.ts"],"names":[],"mappings":";;;;;AACA,wDAAgG;AAEhG,+BAA2C;AAE3C,2CAAkD;AAElD,0EAAiD;AAEjD,MAAM,WAAW,GAAoC;IACnD,IAAI,EAAE,0BAA0B;IAChC,IAAI,EAAE,8BAA8B;IACpC,IAAI,EAAE,OAAO;IAEb,cAAc,EAAE;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,EAAE;QACV,kBAAkB,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAC9C,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE;gBACtB,MAAM,IAAI,yCAA0B,CAAC,gEAAgE,CAAC,CAAA;aACvG;YAED,MAAM,iBAAiB,GAAwB,IAAI,yBAAmB,CAAC,OAAO,CAAC,CAAA;YAE/E,IAAI;gBAGF,OAAO,MAAM,iBAAiB,CAAC,UAAU,EAAE,CAAA;aAC5C;YAAC,OAAO,CAAM,EAAE;gBACf,MAA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AA;IACH,CAAC;IACD,OAAO,EAAE;QACP,gBAAgB,EAAhB,0BAAgB;KACjB;CACF,CAAA;AAED,kBAAe,WAAW,CAAA"}
@@ -1,5 +1,23 @@
1
1
  export interface Payload {
2
2
  adAccountId: string;
3
+ conversionHappenedAt: number;
4
+ conversionValue?: {
5
+ currencyCode: string;
6
+ amount: string;
7
+ };
8
+ eventId?: string;
9
+ userIds?: {
10
+ idType: string;
11
+ idValue: string;
12
+ }[];
13
+ userInfo?: {
14
+ firstName?: string;
15
+ lastName?: string;
16
+ companyName?: string;
17
+ title?: string;
18
+ countryCode?: string;
19
+ };
20
+ campaignId: string;
3
21
  }
4
22
  export interface HookBundle {
5
23
  onMappingSave: {
@@ -1,17 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const actions_core_1 = require("@segment/actions-core");
4
+ const api_1 = require("../api");
5
+ const constants_1 = require("../constants");
3
6
  const action = {
4
7
  title: 'Stream Conversion Event',
5
8
  description: 'Directly streams conversion events to a specific conversion rule.',
6
- fields: {
7
- adAccountId: {
8
- label: 'Ad Account',
9
- description: 'A dynamic field dropdown which fetches all adAccounts.',
10
- type: 'string',
11
- required: true,
12
- dynamic: true
13
- }
14
- },
9
+ defaultSubscription: 'type = "track"',
15
10
  hooks: {
16
11
  onMappingSave: {
17
12
  label: 'Create a Conversion Rule',
@@ -117,14 +112,165 @@ const action = {
117
112
  }
118
113
  }
119
114
  },
120
- perform: (request, data) => {
121
- return request('https://example.com', {
122
- method: 'post',
123
- json: {
124
- conversion: data.hookOutputs?.onMappingSave?.id
115
+ fields: {
116
+ adAccountId: {
117
+ label: 'Ad Account',
118
+ description: 'A dynamic field dropdown which fetches all adAccounts.',
119
+ type: 'string',
120
+ required: true,
121
+ dynamic: true
122
+ },
123
+ conversionHappenedAt: {
124
+ label: 'Timestamp',
125
+ description: 'Epoch timestamp in milliseconds at which the conversion event happened. If your source records conversion timestamps in second, insert 000 at the end to transform it to milliseconds.',
126
+ type: 'integer',
127
+ required: true,
128
+ default: {
129
+ '@path': '$.timestamp'
125
130
  }
126
- });
131
+ },
132
+ conversionValue: {
133
+ label: 'Conversion Value',
134
+ description: 'The monetary value for this conversion. Example: {“currencyCode”: “USD”, “amount”: “50.0”}.',
135
+ type: 'object',
136
+ required: false,
137
+ properties: {
138
+ currencyCode: {
139
+ label: 'Currency Code',
140
+ type: 'string',
141
+ required: true,
142
+ description: 'ISO format'
143
+ },
144
+ amount: {
145
+ label: 'Amount',
146
+ type: 'string',
147
+ required: true,
148
+ description: 'Value of the conversion in decimal string. Can be dynamically set up or have a fixed value.'
149
+ }
150
+ }
151
+ },
152
+ eventId: {
153
+ label: 'Event ID',
154
+ description: 'Will be used for deduplication in future.',
155
+ type: 'string',
156
+ required: false,
157
+ default: {
158
+ '@path': '$.messageId'
159
+ }
160
+ },
161
+ userIds: {
162
+ label: 'User Ids',
163
+ description: 'Either userIds or userInfo is required. List of one or more identifiers to match the conversion user with objects containing "idType" and "idValue".',
164
+ type: 'object',
165
+ multiple: true,
166
+ properties: {
167
+ idType: {
168
+ label: 'ID Type',
169
+ description: `Valid values are: ${constants_1.SUPPORTED_ID_TYPE.join(', ')}`,
170
+ type: 'string',
171
+ required: true
172
+ },
173
+ idValue: {
174
+ label: 'ID Value',
175
+ description: 'The value of the identifier.',
176
+ type: 'string',
177
+ required: true
178
+ }
179
+ }
180
+ },
181
+ userInfo: {
182
+ label: 'User Info',
183
+ description: 'Object containing additional fields for user matching.',
184
+ type: 'object',
185
+ required: false,
186
+ properties: {
187
+ firstName: {
188
+ label: 'First Name',
189
+ type: 'string',
190
+ required: false
191
+ },
192
+ lastName: {
193
+ label: 'Last Name',
194
+ type: 'string',
195
+ required: false
196
+ },
197
+ companyName: {
198
+ label: 'Company Name',
199
+ type: 'string',
200
+ required: false
201
+ },
202
+ title: {
203
+ label: 'Title',
204
+ type: 'string',
205
+ required: false
206
+ },
207
+ countryCode: {
208
+ label: 'Country Code',
209
+ type: 'string',
210
+ required: false
211
+ }
212
+ }
213
+ },
214
+ campaignId: {
215
+ label: 'Campaign',
216
+ type: 'string',
217
+ required: true,
218
+ dynamic: true,
219
+ description: 'A dynamic field dropdown which fetches all active campaigns.'
220
+ }
221
+ },
222
+ dynamicFields: {
223
+ adAccountId: async (request) => {
224
+ const linkedIn = new api_1.LinkedInConversions(request);
225
+ return linkedIn.getAdAccounts();
226
+ },
227
+ campaignId: async (request, { payload }) => {
228
+ const linkedIn = new api_1.LinkedInConversions(request);
229
+ return linkedIn.getCampaignsList(payload.adAccountId);
230
+ }
231
+ },
232
+ perform: async (request, { payload, hookOutputs }) => {
233
+ validate(payload);
234
+ let conversionRuleId = '';
235
+ if (hookOutputs?.onMappingSave?.outputs?.id) {
236
+ conversionRuleId = hookOutputs?.onMappingSave.outputs?.id;
237
+ }
238
+ if (!conversionRuleId) {
239
+ throw new actions_core_1.PayloadValidationError('Conversion Rule ID is required.');
240
+ }
241
+ const linkedinApiClient = new api_1.LinkedInConversions(request, conversionRuleId);
242
+ try {
243
+ await linkedinApiClient.associateCampignToConversion(payload);
244
+ return linkedinApiClient.streamConversionEvent(payload);
245
+ }
246
+ catch (error) {
247
+ return error;
248
+ }
127
249
  }
128
250
  };
251
+ function validate(payload) {
252
+ const dateFromTimestamp = new Date(payload.conversionHappenedAt);
253
+ if (isNaN(dateFromTimestamp.getTime())) {
254
+ throw new actions_core_1.PayloadValidationError('Timestamp field should be valid timestamp.');
255
+ }
256
+ const ninetyDaysAgo = Date.now() - 90 * 24 * 60 * 60 * 1000;
257
+ if (payload.conversionHappenedAt < ninetyDaysAgo) {
258
+ throw new actions_core_1.PayloadValidationError('Timestamp should be within the past 90 days.');
259
+ }
260
+ if (payload.userIds &&
261
+ Array.isArray(payload.userIds) &&
262
+ payload.userIds?.length === 0 &&
263
+ (!payload.userInfo || !(payload.userInfo.firstName && payload.userInfo.lastName))) {
264
+ throw new actions_core_1.PayloadValidationError('Either userIds array or userInfo with firstName and lastName should be present.');
265
+ }
266
+ else if (payload.userIds && payload.userIds.length !== 0) {
267
+ const isValidUserIds = payload.userIds.every((obj) => {
268
+ return constants_1.SUPPORTED_ID_TYPE.includes(obj.idType);
269
+ });
270
+ if (!isValidUserIds) {
271
+ throw new actions_core_1.PayloadValidationError(`Invalid idType in userIds field. Allowed idType will be: ${constants_1.SUPPORTED_ID_TYPE}`);
272
+ }
273
+ }
274
+ }
129
275
  exports.default = action;
130
276
  //# sourceMappingURL=index.js.map