@segment/action-destinations 3.244.0-staging-52cf421f0 → 3.244.0-staging-554d8726a

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 (94) hide show
  1. package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/generated-types.d.ts +3 -3
  2. package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/index.js +4 -305
  3. package/dist/destinations/tiktok-offline-conversions/reportOfflineEvent/index.js.map +1 -1
  4. package/dist/destinations/tiktok-offline-conversions/utils.d.ts +8 -0
  5. package/dist/destinations/tiktok-offline-conversions/utils.js +67 -0
  6. package/dist/destinations/tiktok-offline-conversions/utils.js.map +1 -0
  7. package/package.json +2 -2
  8. package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.d.ts +0 -1
  9. package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js +0 -184
  10. package/dist/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.js.map +0 -1
  11. package/dist/destinations/engage/sendgrid/Profile.d.ts +0 -6
  12. package/dist/destinations/engage/sendgrid/Profile.js +0 -3
  13. package/dist/destinations/engage/sendgrid/Profile.js.map +0 -1
  14. package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.d.ts +0 -21
  15. package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js +0 -174
  16. package/dist/destinations/engage/sendgrid/previewApiLookup/api-lookups.js.map +0 -1
  17. package/dist/destinations/klaviyo/removeProfileToList/generated-types.d.ts +0 -4
  18. package/dist/destinations/klaviyo/removeProfileToList/generated-types.js +0 -3
  19. package/dist/destinations/klaviyo/removeProfileToList/generated-types.js.map +0 -1
  20. package/dist/destinations/klaviyo/removeProfileToList/index.d.ts +0 -5
  21. package/dist/destinations/klaviyo/removeProfileToList/index.js +0 -43
  22. package/dist/destinations/klaviyo/removeProfileToList/index.js.map +0 -1
  23. package/dist/destinations/mixpanel/utils.d.ts +0 -13
  24. package/dist/destinations/mixpanel/utils.js +0 -117
  25. package/dist/destinations/mixpanel/utils.js.map +0 -1
  26. package/dist/destinations/movable-ink/categoryView/generated-types.d.ts +0 -22
  27. package/dist/destinations/movable-ink/categoryView/generated-types.js +0 -3
  28. package/dist/destinations/movable-ink/categoryView/generated-types.js.map +0 -1
  29. package/dist/destinations/movable-ink/categoryView/index.d.ts +0 -5
  30. package/dist/destinations/movable-ink/categoryView/index.js +0 -43
  31. package/dist/destinations/movable-ink/categoryView/index.js.map +0 -1
  32. package/dist/destinations/movable-ink/conversion/generated-types.d.ts +0 -20
  33. package/dist/destinations/movable-ink/conversion/generated-types.js +0 -3
  34. package/dist/destinations/movable-ink/conversion/generated-types.js.map +0 -1
  35. package/dist/destinations/movable-ink/conversion/index.d.ts +0 -5
  36. package/dist/destinations/movable-ink/conversion/index.js +0 -45
  37. package/dist/destinations/movable-ink/conversion/index.js.map +0 -1
  38. package/dist/destinations/movable-ink/fields.d.ts +0 -21
  39. package/dist/destinations/movable-ink/fields.js +0 -236
  40. package/dist/destinations/movable-ink/fields.js.map +0 -1
  41. package/dist/destinations/movable-ink/identify/generated-types.d.ts +0 -7
  42. package/dist/destinations/movable-ink/identify/generated-types.js +0 -3
  43. package/dist/destinations/movable-ink/identify/generated-types.js.map +0 -1
  44. package/dist/destinations/movable-ink/identify/index.d.ts +0 -5
  45. package/dist/destinations/movable-ink/identify/index.js +0 -32
  46. package/dist/destinations/movable-ink/identify/index.js.map +0 -1
  47. package/dist/destinations/movable-ink/productAdded/generated-types.d.ts +0 -22
  48. package/dist/destinations/movable-ink/productAdded/generated-types.js +0 -3
  49. package/dist/destinations/movable-ink/productAdded/generated-types.js.map +0 -1
  50. package/dist/destinations/movable-ink/productAdded/index.d.ts +0 -5
  51. package/dist/destinations/movable-ink/productAdded/index.js +0 -43
  52. package/dist/destinations/movable-ink/productAdded/index.js.map +0 -1
  53. package/dist/destinations/movable-ink/productViewed/generated-types.d.ts +0 -21
  54. package/dist/destinations/movable-ink/productViewed/generated-types.js +0 -3
  55. package/dist/destinations/movable-ink/productViewed/generated-types.js.map +0 -1
  56. package/dist/destinations/movable-ink/productViewed/index.d.ts +0 -5
  57. package/dist/destinations/movable-ink/productViewed/index.js +0 -43
  58. package/dist/destinations/movable-ink/productViewed/index.js.map +0 -1
  59. package/dist/destinations/movable-ink/search/generated-types.d.ts +0 -12
  60. package/dist/destinations/movable-ink/search/generated-types.js +0 -3
  61. package/dist/destinations/movable-ink/search/generated-types.js.map +0 -1
  62. package/dist/destinations/movable-ink/search/index.d.ts +0 -5
  63. package/dist/destinations/movable-ink/search/index.js +0 -43
  64. package/dist/destinations/movable-ink/search/index.js.map +0 -1
  65. package/dist/destinations/movable-ink/sendCustomEvent/generated-types.d.ts +0 -25
  66. package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js +0 -3
  67. package/dist/destinations/movable-ink/sendCustomEvent/generated-types.js.map +0 -1
  68. package/dist/destinations/movable-ink/sendCustomEvent/index.d.ts +0 -5
  69. package/dist/destinations/movable-ink/sendCustomEvent/index.js +0 -48
  70. package/dist/destinations/movable-ink/sendCustomEvent/index.js.map +0 -1
  71. package/dist/destinations/trackey/group.types.d.ts +0 -11
  72. package/dist/destinations/trackey/group.types.js +0 -3
  73. package/dist/destinations/trackey/group.types.js.map +0 -1
  74. package/dist/destinations/trackey/identify.types.d.ts +0 -11
  75. package/dist/destinations/trackey/identify.types.js +0 -3
  76. package/dist/destinations/trackey/identify.types.js.map +0 -1
  77. package/dist/destinations/trackey/track.types.d.ts +0 -12
  78. package/dist/destinations/trackey/track.types.js +0 -3
  79. package/dist/destinations/trackey/track.types.js.map +0 -1
  80. package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.d.ts +0 -4
  81. package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js +0 -3
  82. package/dist/destinations/yahoo-audiences/createCustomerNode/generated-types.js.map +0 -1
  83. package/dist/destinations/yahoo-audiences/createCustomerNode/index.d.ts +0 -5
  84. package/dist/destinations/yahoo-audiences/createCustomerNode/index.js +0 -33
  85. package/dist/destinations/yahoo-audiences/createCustomerNode/index.js.map +0 -1
  86. package/dist/destinations/yahoo-audiences/createSegment/generated-types.d.ts +0 -6
  87. package/dist/destinations/yahoo-audiences/createSegment/generated-types.js +0 -3
  88. package/dist/destinations/yahoo-audiences/createSegment/generated-types.js.map +0 -1
  89. package/dist/destinations/yahoo-audiences/createSegment/index.d.ts +0 -5
  90. package/dist/destinations/yahoo-audiences/createSegment/index.js +0 -45
  91. package/dist/destinations/yahoo-audiences/createSegment/index.js.map +0 -1
  92. package/dist/destinations/yahoo-audiences/utils.d.ts +0 -4
  93. package/dist/destinations/yahoo-audiences/utils.js +0 -30
  94. package/dist/destinations/yahoo-audiences/utils.js.map +0 -1
@@ -3,7 +3,9 @@ export interface Payload {
3
3
  event_id?: string;
4
4
  timestamp?: string;
5
5
  phone_numbers?: string[];
6
- emails?: string[];
6
+ email_addresses?: string[];
7
+ order_id?: string;
8
+ shop_id?: string;
7
9
  external_ids?: string[];
8
10
  ttclid?: string;
9
11
  ttp?: string;
@@ -26,8 +28,6 @@ export interface Payload {
26
28
  value?: number;
27
29
  description?: string;
28
30
  query?: string;
29
- order_id?: string;
30
- shop_id?: string;
31
31
  limited_data_use?: boolean;
32
32
  test_event_code?: string;
33
33
  }
@@ -1,316 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const actions_core_1 = require("@segment/actions-core");
4
- const formatter_1 = require("./formatter");
3
+ const common_fields_1 = require("../common_fields");
4
+ const utils_1 = require("../utils");
5
5
  const action = {
6
6
  title: 'Track Payment Offline Conversion',
7
7
  description: 'Send details of an in-store purchase or console purchase to the Tiktok Offline Events API',
8
8
  fields: {
9
- event: {
10
- label: 'Event Name',
11
- type: 'string',
12
- required: true,
13
- description: 'Conversion event name. Please refer to the "Offline Standard Events" section on in TikTok’s [Events API 2.0 documentation](https://business-api.tiktok.com/portal/docs?id=1771101186666498) for accepted event names.'
14
- },
15
- event_id: {
16
- label: 'Event ID',
17
- type: 'string',
18
- description: 'Any hashed ID that can identify a unique user/session.',
19
- default: {
20
- '@path': '$.messageId'
21
- }
22
- },
23
- timestamp: {
24
- label: 'Event Timestamp',
25
- type: 'string',
26
- description: 'Timestamp that the event took place, in ISO 8601 format.',
27
- default: {
28
- '@path': '$.timestamp'
29
- }
30
- },
31
- phone_numbers: {
32
- label: 'Phone Numbers',
33
- description: 'A single phone number or array of phone numbers in E.164 standard format. Segment will hash this value before sending to TikTok. At least one phone number is required if no value is provided in the Emails field.',
34
- type: 'string',
35
- multiple: true,
36
- default: {
37
- '@if': {
38
- exists: { '@path': '$.properties.phone' },
39
- then: { '@path': '$.properties.phone' },
40
- else: { '@path': '$.traits.phone' }
41
- }
42
- }
43
- },
44
- emails: {
45
- label: 'Emails',
46
- description: 'A single email address or an array of email addresses. Segment will hash this value before sending to TikTok. At least one email is required if no value is provided in the Phone Numbers field.',
47
- type: 'string',
48
- multiple: true,
49
- default: {
50
- '@if': {
51
- exists: { '@path': '$.properties.email' },
52
- then: { '@path': '$.properties.email' },
53
- else: { '@path': '$.traits.email' }
54
- }
55
- }
56
- },
57
- external_ids: {
58
- label: 'External ID',
59
- description: 'Uniquely identifies the user who triggered the conversion event. Segment will hash this value before sending to TikTok.',
60
- type: 'string',
61
- multiple: true,
62
- default: {
63
- '@if': {
64
- exists: { '@path': '$.userId' },
65
- then: { '@path': '$.userId' },
66
- else: { '@path': '$.anonymousId' }
67
- }
68
- }
69
- },
70
- ttclid: {
71
- label: 'TikTok Click ID',
72
- description: 'The value of the ttclid used to match website visitor events with TikTok ads. The ttclid is valid for 7 days. See [Set up ttclid](https://ads.tiktok.com/marketing_api/docs?rid=4eezrhr6lg4&id=1681728034437121) for details.',
73
- type: 'string',
74
- default: {
75
- '@if': {
76
- exists: { '@path': '$.properties.ttclid' },
77
- then: { '@path': '$.properties.ttclid' },
78
- else: { '@path': '$.traits.ttclid' }
79
- }
80
- }
81
- },
82
- ttp: {
83
- label: 'TikTok Cookie ID',
84
- description: 'TikTok Cookie ID. If you also use Pixel SDK and have enabled cookies, Pixel SDK automatically saves a unique identifier in the `_ttp` cookie. The value of `_ttp` is used to match website visitor events with TikTok ads. You can extract the value of `_ttp` and attach the value here. To learn more about the `ttp` parameter, refer to [Events API 2.0 - Send TikTok Cookie](https://ads.tiktok.com/marketing_api/docs?id=%201771100936446977) (`_ttp`).',
85
- type: 'string',
86
- default: {
87
- '@if': {
88
- exists: { '@path': '$.properties.ttp' },
89
- then: { '@path': '$.properties.ttp' },
90
- else: { '@path': '$.integrations.TikTok Pixel.ttp' }
91
- }
92
- }
93
- },
94
- lead_id: {
95
- label: 'TikTok Lead ID',
96
- description: 'ID of TikTok leads. Every lead will have its own lead_id when exported from TikTok. This feature is in Beta. Please contact your TikTok representative to inquire regarding availability',
97
- type: 'string',
98
- default: {
99
- '@if': {
100
- exists: { '@path': '$.properties.lead_id' },
101
- then: { '@path': '$.properties.lead_id' },
102
- else: { '@path': '$.traits.lead_id' }
103
- }
104
- }
105
- },
106
- locale: {
107
- label: 'Locale',
108
- description: 'The BCP 47 language identifier. For reference, refer to the [IETF BCP 47 standardized code](https://www.rfc-editor.org/rfc/bcp/bcp47.txt).',
109
- type: 'string',
110
- default: {
111
- '@path': '$.context.locale'
112
- }
113
- },
114
- url: {
115
- label: 'Page URL',
116
- type: 'string',
117
- description: 'The page URL where the conversion event took place.',
118
- default: {
119
- '@path': '$.context.page.url'
120
- }
121
- },
122
- referrer: {
123
- label: 'Page Referrer',
124
- type: 'string',
125
- description: 'The page referrer.',
126
- default: {
127
- '@path': '$.context.page.referrer'
128
- }
129
- },
130
- ip: {
131
- label: 'IP Address',
132
- type: 'string',
133
- description: 'IP address of the browser.',
134
- default: {
135
- '@path': '$.context.ip'
136
- }
137
- },
138
- user_agent: {
139
- label: 'User Agent',
140
- type: 'string',
141
- description: 'User agent from the user’s device.',
142
- default: {
143
- '@path': '$.context.userAgent'
144
- }
145
- },
146
- contents: {
147
- label: 'Contents',
148
- type: 'object',
149
- multiple: true,
150
- description: 'Related items in a web event.',
151
- properties: {
152
- price: {
153
- label: 'Price',
154
- description: 'Price of the item.',
155
- type: 'number'
156
- },
157
- quantity: {
158
- label: 'Quantity',
159
- description: 'Number of items.',
160
- type: 'number'
161
- },
162
- content_category: {
163
- label: 'Content Category',
164
- description: 'Category of the product item.',
165
- type: 'string'
166
- },
167
- content_id: {
168
- label: 'Content ID',
169
- description: 'ID of the product item.',
170
- type: 'string'
171
- },
172
- content_name: {
173
- label: 'Content Name',
174
- description: 'Name of the product item.',
175
- type: 'string'
176
- },
177
- brand: {
178
- label: 'Brand',
179
- description: 'Brand name of the product item.',
180
- type: 'string'
181
- }
182
- }
183
- },
184
- content_type: {
185
- label: 'Content Type',
186
- description: 'Type of the product item. When the `content_id` in the `contents` parameter is specified as `sku_id`, set this field to `product`. When the `content_id` in the `contents` parameter is specified as `item_group_id`, set this field to `product_group`.',
187
- type: 'string',
188
- choices: ['product', 'product_group'],
189
- default: 'product'
190
- },
191
- currency: {
192
- label: 'Currency',
193
- type: 'string',
194
- description: 'Currency for the value specified as ISO 4217 code.',
195
- default: {
196
- '@path': '$.properties.currency'
197
- }
198
- },
199
- value: {
200
- label: 'Value',
201
- type: 'number',
202
- description: 'Value of the order or items sold.',
203
- default: {
204
- '@if': {
205
- exists: { '@path': '$.properties.value' },
206
- then: { '@path': '$.properties.value' },
207
- else: { '@path': '$.properties.revenue' }
208
- }
209
- }
210
- },
211
- description: {
212
- label: 'Description',
213
- type: 'string',
214
- description: 'A string description of the web event.'
215
- },
216
- query: {
217
- label: 'Query',
218
- type: 'string',
219
- description: 'The text string that was searched for.',
220
- default: {
221
- '@path': '$.properties.query'
222
- }
223
- },
224
- order_id: {
225
- label: 'Order ID',
226
- type: 'string',
227
- description: 'Order ID of the transaction.',
228
- default: {
229
- '@path': '$.properties.order_id'
230
- }
231
- },
232
- shop_id: {
233
- label: 'Shop ID',
234
- type: 'string',
235
- description: 'Shop ID of the transaction.',
236
- default: {
237
- '@path': '$.properties.shop_id'
238
- }
239
- },
240
- limited_data_use: {
241
- label: 'Limited Data Use',
242
- type: 'boolean',
243
- description: 'Use this field to flag an event for limited data processing. TikTok will recognize this parameter as a request for limited data processing, and will limit its processing activities accordingly if the event shared occurred in an eligible location. To learn more about the Limited Data Use feature, refer to [Events API 2.0 - Limited Data Use](https://ads.tiktok.com/marketing_api/docs?id=1771101204435970).',
244
- default: {
245
- '@path': '$.properties.limited_data_use'
246
- }
247
- },
248
- test_event_code: {
249
- label: 'Test Event Code',
250
- type: 'string',
251
- description: 'Use this field to specify that events should be test events rather than actual traffic. You can find your Test Event Code in your TikTok Events Manager under the "Test Event" tab. You\'ll want to remove your Test Event Code when sending real traffic through this integration.'
252
- }
9
+ ...common_fields_1.commonFields
253
10
  },
254
11
  perform: (request, { payload, settings }) => {
255
- const phone_numbers = formatter_1.formatPhones(payload.phone_numbers);
256
- const emails = formatter_1.formatEmails(payload.emails);
257
- const userIds = formatter_1.formatUserIds(payload.external_ids);
258
- if (phone_numbers.length < 1 && emails.length < 1 && userIds.length < 1)
259
- throw new actions_core_1.PayloadValidationError('TikTok Offline Conversions API requires an email address and/or phone number');
260
- let payloadUrl, urlTtclid;
261
- if (payload.url) {
262
- try {
263
- payloadUrl = new URL(payload.url);
264
- }
265
- catch (error) {
266
- }
267
- }
268
- if (payloadUrl)
269
- urlTtclid = payloadUrl.searchParams.get('ttclid');
270
- return request('https://business-api.tiktok.com/open_api/v1.3/event/track/', {
271
- method: 'post',
272
- json: {
273
- event_source: 'offline',
274
- event_source_id: settings.eventSetID,
275
- partner_name: 'Segment',
276
- data: [
277
- {
278
- event: payload.event,
279
- event_time: payload.timestamp
280
- ? Math.floor(new Date(payload.timestamp).getTime() / 1000)
281
- : Math.floor(new Date().getTime() / 1000),
282
- event_id: payload.event_id ? `${payload.event_id}` : undefined,
283
- user: {
284
- ttclid: payload.ttclid ? payload.ttclid : urlTtclid ? urlTtclid : undefined,
285
- external_id: userIds,
286
- phone_number: phone_numbers,
287
- email: emails,
288
- lead_id: payload.lead_id ? payload.lead_id : undefined,
289
- ttp: payload.ttp ? payload.ttp : undefined,
290
- ip: payload.ip ? payload.ip : undefined,
291
- user_agent: payload.user_agent ? payload.user_agent : undefined,
292
- locale: payload.locale ? payload.locale : undefined
293
- },
294
- properties: {
295
- contents: payload.contents ? payload.contents : [],
296
- content_type: payload.content_type ? payload.content_type : undefined,
297
- currency: payload.currency ? payload.currency : undefined,
298
- value: payload.value ? payload.value : undefined,
299
- query: payload.query ? payload.query : undefined,
300
- description: payload.description ? payload.description : undefined,
301
- order_id: payload.order_id ? payload.order_id : undefined,
302
- shop_id: payload.shop_id ? payload.shop_id : undefined
303
- },
304
- page: {
305
- url: payload.url ? payload.url : undefined,
306
- referrer: payload.referrer ? payload.referrer : undefined
307
- },
308
- limited_data_use: payload.limited_data_use ? payload.limited_data_use : false,
309
- test_event_code: payload.test_event_code ? payload.test_event_code : undefined
310
- }
311
- ]
312
- }
313
- });
12
+ return utils_1.performOfflineEvent(request, settings, payload);
314
13
  }
315
14
  };
316
15
  exports.default = action;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/tiktok-offline-conversions/reportOfflineEvent/index.ts"],"names":[],"mappings":";;AAAA,wDAAgF;AAGhF,2CAAuE;AAEvE,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,kCAAkC;IACzC,WAAW,EAAE,2FAA2F;IACxG,MAAM,EAAE;QACN,KAAK,EAAE;YACL,KAAK,EAAE,YAAY;YACnB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,WAAW,EACT,uNAAuN;SAC1N;QACD,QAAQ,EAAE;YACR,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wDAAwD;YACrE,OAAO,EAAE;gBACP,OAAO,EAAE,aAAa;aACvB;SACF;QACD,SAAS,EAAE;YACT,KAAK,EAAE,iBAAiB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CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;4BAChD,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;4BAClE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;4BACzD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;yBACvD;wBACD,IAAI,EAAE;4BACJ,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;4BAC1C,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;yBAC1D;wBACD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK;wBAC7E,eAAe,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;qBAC/E;iBACF;aACF;SACF,CAAC,CAAA;IACJ,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/tiktok-offline-conversions/reportOfflineEvent/index.ts"],"names":[],"mappings":";;AAGA,oDAA+C;AAC/C,oCAA8C;AAE9C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,kCAAkC;IACzC,WAAW,EAAE,2FAA2F;IACxG,MAAM,EAAE;QACN,GAAG,4BAAY;KAChB;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,OAAO,2BAAmB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { RequestClient } from '@segment/actions-core';
2
+ import { Settings } from './generated-types';
3
+ import { Payload as ReportOfflineEventPayload } from './reportOfflineEvent/generated-types';
4
+ import { Payload as TrackNonPaymentOfflineConversionPayload } from './trackNonPaymentOfflineConversion/generated-types';
5
+ import { Payload as TrackPaymentOfflineConversionPayload } from './trackPaymentOfflineConversion/generated-types';
6
+ declare type OfflineEventPayload = ReportOfflineEventPayload | TrackNonPaymentOfflineConversionPayload | TrackPaymentOfflineConversionPayload;
7
+ export declare function performOfflineEvent(request: RequestClient, settings: Settings, payload: OfflineEventPayload): Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
8
+ export {};
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.performOfflineEvent = void 0;
4
+ const actions_core_1 = require("@segment/actions-core");
5
+ const formatter_1 = require("./formatter");
6
+ function performOfflineEvent(request, settings, payload) {
7
+ const phone_numbers = formatter_1.formatPhones(payload.phone_numbers);
8
+ const emails = formatter_1.formatEmails(payload.email_addresses);
9
+ const userIds = formatter_1.formatUserIds(payload.external_ids);
10
+ if (phone_numbers.length < 1 && emails.length < 1 && userIds.length < 1)
11
+ throw new actions_core_1.PayloadValidationError('TikTok Offline Conversions API requires an email address and/or phone number and or a userId');
12
+ const urlTtclid = payload.url
13
+ ? (() => {
14
+ try {
15
+ return new URL(payload.url).searchParams.get('ttclid');
16
+ }
17
+ catch (error) {
18
+ }
19
+ })()
20
+ : undefined;
21
+ return request('https://business-api.tiktok.com/open_api/v1.3/event/track/', {
22
+ method: 'post',
23
+ json: {
24
+ event_source: 'offline',
25
+ event_source_id: settings.eventSetID,
26
+ partner_name: 'Segment',
27
+ data: [
28
+ {
29
+ event: payload.event,
30
+ event_time: payload.timestamp
31
+ ? Math.floor(new Date(payload.timestamp).getTime() / 1000)
32
+ : Math.floor(new Date().getTime() / 1000),
33
+ event_id: payload.event_id ? `${payload.event_id}` : undefined,
34
+ user: {
35
+ ttclid: payload.ttclid ? payload.ttclid : urlTtclid ? urlTtclid : undefined,
36
+ external_id: userIds,
37
+ phone: phone_numbers,
38
+ email: emails,
39
+ lead_id: payload.lead_id ? payload.lead_id : undefined,
40
+ ttp: payload.ttp ? payload.ttp : undefined,
41
+ ip: payload.ip ? payload.ip : undefined,
42
+ user_agent: payload.user_agent ? payload.user_agent : undefined,
43
+ locale: payload.locale ? payload.locale : undefined
44
+ },
45
+ properties: {
46
+ contents: payload.contents ? payload.contents : [],
47
+ content_type: payload.content_type ? payload.content_type : undefined,
48
+ currency: payload.currency ? payload.currency : undefined,
49
+ value: payload.value ? payload.value : undefined,
50
+ query: payload.query ? payload.query : undefined,
51
+ description: payload.description ? payload.description : undefined,
52
+ order_id: payload.order_id ? payload.order_id : undefined,
53
+ shop_id: payload.shop_id ? payload.shop_id : undefined
54
+ },
55
+ page: {
56
+ url: payload.url ? payload.url : undefined,
57
+ referrer: payload.referrer ? payload.referrer : undefined
58
+ },
59
+ limited_data_use: payload.limited_data_use ? payload.limited_data_use : false,
60
+ test_event_code: payload.test_event_code ? payload.test_event_code : undefined
61
+ }
62
+ ]
63
+ }
64
+ });
65
+ }
66
+ exports.performOfflineEvent = performOfflineEvent;
67
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/destinations/tiktok-offline-conversions/utils.ts"],"names":[],"mappings":";;;AAAA,wDAA6E;AAK7E,2CAAuE;AAOvE,SAAgB,mBAAmB,CAAC,OAAsB,EAAE,QAAkB,EAAE,OAA4B;IAC1G,MAAM,aAAa,GAAG,wBAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;IACzD,MAAM,MAAM,GAAG,wBAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IACpD,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BAClE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;wBACzD,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;qBACvD;oBACD,IAAI,EAAE;wBACJ,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS;wBAC1C,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;qBAC1D;oBACD,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,KAAK;oBAC7E,eAAe,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;iBAC/E;aACF;SACF;KACF,CAAC,CAAA;AACJ,CAAC;AAhED,kDAgEC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@segment/action-destinations",
3
3
  "description": "Destination Actions engine and definitions.",
4
- "version": "3.244.0-staging-52cf421f0",
4
+ "version": "3.244.0-staging-554d8726a",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/segmentio/action-destinations",
@@ -43,7 +43,7 @@
43
43
  "@bufbuild/protobuf": "^1.4.2",
44
44
  "@bufbuild/protoc-gen-es": "^1.4.2",
45
45
  "@segment/a1-notation": "^2.1.4",
46
- "@segment/actions-core": "3.97.0-staging-52cf421f0",
46
+ "@segment/actions-core": "3.97.0-staging-f0c32a21d",
47
47
  "@segment/actions-shared": "^1.78.0",
48
48
  "@types/node": "^18.11.15",
49
49
  "ajv-formats": "^2.1.1",
@@ -1,184 +0,0 @@
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 actions_core_1 = require("@segment/actions-core");
7
- const test_data_1 = require("../../../../lib/test-data");
8
- const index_1 = __importDefault(require("../../index"));
9
- const nock_1 = __importDefault(require("nock"));
10
- const testDestination = actions_core_1.createTestIntegration(index_1.default);
11
- const actionSlug = 'updateUserProfile';
12
- const destinationSlug = 'Braze';
13
- const seedName = `${destinationSlug}#${actionSlug}`;
14
- const receivedAt = '2021-08-03T17:40:04.055Z';
15
- const settings = {
16
- app_id: 'my-app-id',
17
- api_key: 'my-api-key',
18
- endpoint: 'https://rest.iad-01.braze.com'
19
- };
20
- describe(`Testing snapshot for ${destinationSlug}'s ${actionSlug} destination action:`, () => {
21
- it('required fields', async () => {
22
- const action = index_1.default.actions[actionSlug];
23
- const [eventData, settingsData] = test_data_1.generateTestData(seedName, index_1.default, action, true);
24
- nock_1.default(/.*/).persist().get(/.*/).reply(200);
25
- nock_1.default(/.*/).persist().post(/.*/).reply(200);
26
- nock_1.default(/.*/).persist().put(/.*/).reply(200);
27
- const event = actions_core_1.createTestEvent({
28
- properties: eventData
29
- });
30
- const responses = await testDestination.testAction(actionSlug, {
31
- event: event,
32
- mapping: event.properties,
33
- settings: settingsData,
34
- auth: undefined
35
- });
36
- const request = responses[0].request;
37
- const rawBody = await request.text();
38
- try {
39
- const json = JSON.parse(rawBody);
40
- expect(json).toMatchSnapshot();
41
- return;
42
- }
43
- catch (err) {
44
- expect(rawBody).toMatchSnapshot();
45
- }
46
- expect(request.headers).toMatchSnapshot();
47
- });
48
- it('all fields', async () => {
49
- const action = index_1.default.actions[actionSlug];
50
- const [eventData, settingsData] = test_data_1.generateTestData(seedName, index_1.default, action, false);
51
- nock_1.default(/.*/).persist().get(/.*/).reply(200);
52
- nock_1.default(/.*/).persist().post(/.*/).reply(200);
53
- nock_1.default(/.*/).persist().put(/.*/).reply(200);
54
- const event = actions_core_1.createTestEvent({
55
- properties: eventData
56
- });
57
- const responses = await testDestination.testAction(actionSlug, {
58
- event: event,
59
- mapping: event.properties,
60
- settings: settingsData,
61
- auth: undefined
62
- });
63
- const request = responses[0].request;
64
- const rawBody = await request.text();
65
- try {
66
- const json = JSON.parse(rawBody);
67
- expect(json).toMatchSnapshot();
68
- return;
69
- }
70
- catch (err) {
71
- expect(rawBody).toMatchSnapshot();
72
- }
73
- });
74
- it('it should work with batched events', async () => {
75
- nock_1.default('https://rest.iad-01.braze.com').post('/users/track').reply(200, {});
76
- const events = [
77
- actions_core_1.createTestEvent({
78
- event: 'Test Event 1',
79
- type: 'track',
80
- receivedAt,
81
- properties: {}
82
- }),
83
- actions_core_1.createTestEvent({
84
- event: 'Test Event 2',
85
- type: 'track',
86
- receivedAt,
87
- properties: {}
88
- })
89
- ];
90
- const responses = await testDestination.testBatchAction(actionSlug, {
91
- events,
92
- useDefaultMappings: true,
93
- mapping: {
94
- external_id: {
95
- '@path': '$.userId'
96
- },
97
- user_alias: {},
98
- braze_id: {
99
- '@path': '$.properties.braze_id'
100
- },
101
- name: {
102
- '@path': '$.event'
103
- },
104
- time: {
105
- '@path': '$.receivedAt'
106
- },
107
- properties: {
108
- '@path': '$.properties'
109
- },
110
- products: {
111
- '@path': '$.properties.products'
112
- },
113
- enable_batching: true,
114
- _update_existing_only: true
115
- },
116
- settings: {
117
- ...settings
118
- }
119
- });
120
- expect(responses.length).toBe(1);
121
- expect(responses[0].status).toBe(200);
122
- expect(responses[0].options.headers).toMatchSnapshot();
123
- expect(responses[0].options.json).toMatchSnapshot();
124
- });
125
- it('it should work with a single batched events', async () => {
126
- nock_1.default('https://rest.iad-01.braze.com').post('/users/track').reply(200, {});
127
- const events = [
128
- actions_core_1.createTestEvent({
129
- event: 'Test Event 1',
130
- type: 'track',
131
- receivedAt,
132
- properties: {
133
- products: [
134
- {
135
- quantity: 1,
136
- product_id: 'Bowflex Treadmill 10',
137
- price: 100
138
- },
139
- {
140
- quantity: 2,
141
- product_id: 'Bowflex Treadmill 20',
142
- price: 200
143
- }
144
- ]
145
- }
146
- })
147
- ];
148
- const responses = await testDestination.testBatchAction(actionSlug, {
149
- events,
150
- useDefaultMappings: true,
151
- mapping: {
152
- external_id: {
153
- '@path': '$.userId'
154
- },
155
- user_alias: {},
156
- braze_id: {
157
- '@path': '$.properties.braze_id'
158
- },
159
- name: {
160
- '@path': '$.event'
161
- },
162
- time: {
163
- '@path': '$.receivedAt'
164
- },
165
- properties: {
166
- '@path': '$.properties'
167
- },
168
- products: {
169
- '@path': '$.properties.products'
170
- },
171
- enable_batching: true,
172
- _update_existing_only: true
173
- },
174
- settings: {
175
- ...settings
176
- }
177
- });
178
- expect(responses.length).toBe(1);
179
- expect(responses[0].status).toBe(200);
180
- expect(responses[0].options.headers).toMatchSnapshot();
181
- expect(responses[0].options.json).toMatchSnapshot();
182
- });
183
- });
184
- //# sourceMappingURL=snapshot.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"snapshot.test.js","sourceRoot":"","sources":["../../../../../src/destinations/braze/updateUserProfile/__snapshots__/snapshot.test.ts"],"names":[],"mappings":";;;;;AAAA,wDAA4F;AAC5F,yDAA4D;AAC5D,wDAAqC;AACrC,gDAAuB;AAEvB,MAAM,eAAe,GAAG,oCAAqB,CAAC,eAAW,CAAC,CAAA;AAC1D,MAAM,UAAU,GAAG,mBAAmB,CAAA;AACtC,MAAM,eAAe,GAAG,OAAO,CAAA;AAC/B,MAAM,QAAQ,GAAG,GAAG,eAAe,IAAI,UAAU,EAAE,CAAA;AACnD,MAAM,UAAU,GAAG,0BAA0B,CAAA;AAC7C,MAAM,QAAQ,GAAG;IACf,MAAM,EAAE,WAAW;IACnB,OAAO,EAAE,YAAY;IACrB,QAAQ,EAAE,+BAAwC;CACnD,CAAA;AAED,QAAQ,CAAC,wBAAwB,eAAe,MAAM,UAAU,sBAAsB,EAAE,GAAG,EAAE;IAC3F,EAAE,CAAC,iBAAiB,EAAE,KAAK,IAAI,E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