@segment/analytics-browser-actions-tiktok-pixel 1.94.1-staging-108b283de.0 → 1.95.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 (75) hide show
  1. package/dist/cjs/constants.d.ts +2 -0
  2. package/dist/cjs/constants.js +6 -0
  3. package/dist/cjs/constants.js.map +1 -0
  4. package/dist/cjs/fields/common_fields.d.ts +2 -0
  5. package/dist/cjs/{common_fields.js → fields/common_fields.js} +2 -113
  6. package/dist/cjs/fields/common_fields.js.map +1 -0
  7. package/dist/cjs/identify/generated-types.d.ts +0 -17
  8. package/dist/cjs/identify/index.js +10 -20
  9. package/dist/cjs/identify/index.js.map +1 -1
  10. package/dist/cjs/reportWebEvent/fields.d.ts +2 -0
  11. package/dist/cjs/reportWebEvent/fields.js +161 -0
  12. package/dist/cjs/reportWebEvent/fields.js.map +1 -0
  13. package/dist/cjs/reportWebEvent/generated-types.d.ts +62 -11
  14. package/dist/cjs/reportWebEvent/index.js +12 -24
  15. package/dist/cjs/reportWebEvent/index.js.map +1 -1
  16. package/dist/cjs/reportWebEvent/travel_fields.d.ts +2 -0
  17. package/dist/cjs/reportWebEvent/travel_fields.js +210 -0
  18. package/dist/cjs/reportWebEvent/travel_fields.js.map +1 -0
  19. package/dist/cjs/reportWebEvent/utils.d.ts +3 -0
  20. package/dist/cjs/reportWebEvent/utils.js +101 -0
  21. package/dist/cjs/reportWebEvent/utils.js.map +1 -0
  22. package/dist/cjs/reportWebEvent/vehicle_fields.d.ts +2 -0
  23. package/dist/cjs/reportWebEvent/vehicle_fields.js +255 -0
  24. package/dist/cjs/reportWebEvent/vehicle_fields.js.map +1 -0
  25. package/dist/cjs/types.d.ts +85 -29
  26. package/dist/cjs/utils.d.ts +4 -0
  27. package/dist/cjs/utils.js +18 -0
  28. package/dist/cjs/utils.js.map +1 -0
  29. package/dist/esm/constants.d.ts +2 -0
  30. package/dist/esm/constants.js +3 -0
  31. package/dist/esm/constants.js.map +1 -0
  32. package/dist/esm/fields/common_fields.d.ts +2 -0
  33. package/dist/esm/{common_fields.js → fields/common_fields.js} +1 -112
  34. package/dist/esm/fields/common_fields.js.map +1 -0
  35. package/dist/esm/identify/generated-types.d.ts +0 -17
  36. package/dist/esm/identify/index.js +10 -20
  37. package/dist/esm/identify/index.js.map +1 -1
  38. package/dist/esm/reportWebEvent/fields.d.ts +2 -0
  39. package/dist/esm/reportWebEvent/fields.js +158 -0
  40. package/dist/esm/reportWebEvent/fields.js.map +1 -0
  41. package/dist/esm/reportWebEvent/generated-types.d.ts +62 -11
  42. package/dist/esm/reportWebEvent/index.js +12 -24
  43. package/dist/esm/reportWebEvent/index.js.map +1 -1
  44. package/dist/esm/reportWebEvent/travel_fields.d.ts +2 -0
  45. package/dist/esm/reportWebEvent/travel_fields.js +207 -0
  46. package/dist/esm/reportWebEvent/travel_fields.js.map +1 -0
  47. package/dist/esm/reportWebEvent/utils.d.ts +3 -0
  48. package/dist/esm/reportWebEvent/utils.js +98 -0
  49. package/dist/esm/reportWebEvent/utils.js.map +1 -0
  50. package/dist/esm/reportWebEvent/vehicle_fields.d.ts +2 -0
  51. package/dist/esm/reportWebEvent/vehicle_fields.js +252 -0
  52. package/dist/esm/reportWebEvent/vehicle_fields.js.map +1 -0
  53. package/dist/esm/types.d.ts +85 -29
  54. package/dist/esm/utils.d.ts +4 -0
  55. package/dist/esm/utils.js +15 -0
  56. package/dist/esm/utils.js.map +1 -0
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/package.json +4 -4
  59. package/src/constants.ts +2 -0
  60. package/src/{common_fields.ts → fields/common_fields.ts} +1 -114
  61. package/src/identify/generated-types.ts +0 -65
  62. package/src/identify/index.ts +10 -20
  63. package/src/reportWebEvent/__tests__/index.test.ts +521 -23
  64. package/src/reportWebEvent/fields.ts +162 -0
  65. package/src/reportWebEvent/generated-types.ts +239 -41
  66. package/src/reportWebEvent/index.ts +14 -26
  67. package/src/reportWebEvent/travel_fields.ts +216 -0
  68. package/src/reportWebEvent/utils.ts +167 -0
  69. package/src/reportWebEvent/vehicle_fields.ts +255 -0
  70. package/src/types.ts +89 -54
  71. package/src/utils.ts +18 -0
  72. package/dist/cjs/common_fields.d.ts +0 -2
  73. package/dist/cjs/common_fields.js.map +0 -1
  74. package/dist/esm/common_fields.d.ts +0 -2
  75. package/dist/esm/common_fields.js.map +0 -1
@@ -1,34 +1,90 @@
1
1
  export interface TikTokPixel {
2
2
  page: () => void;
3
3
  instance: (pixel_code: string) => TikTokPixel;
4
- identify: ({ email, phone_number, external_id, first_name, last_name, city, state, country, zip_code }: {
5
- email: string | undefined;
6
- phone_number: string | undefined;
7
- external_id: string | undefined;
8
- first_name: string | undefined;
9
- last_name: string | undefined;
10
- city: string | undefined;
11
- state: string | undefined;
12
- country: string | undefined;
13
- zip_code: string | undefined;
14
- }) => void;
15
- track: (event: string, { contents, content_type, currency, value, description, query, order_id, shop_id }: {
16
- contents: {
17
- price?: number | undefined;
18
- quantity?: number | undefined;
19
- content_category?: string | undefined;
20
- content_id?: string | undefined;
21
- content_name?: string | undefined;
22
- brand?: string | undefined;
23
- }[] | [];
24
- content_type: string | undefined;
25
- currency: string | undefined;
26
- value: number | undefined;
27
- description: string | undefined;
28
- query: string | undefined;
29
- order_id: string | undefined;
30
- shop_id: string | undefined;
31
- }, { event_id }: {
32
- event_id: string | undefined;
4
+ identify: (user: TTUser) => void;
5
+ track: (event: string, { ...props }: TTBaseProps & TTTravelProps & TTAutoProps, { event_id }: {
6
+ event_id?: string;
33
7
  }) => void;
34
8
  }
9
+ export interface TTUser {
10
+ external_id: string;
11
+ phone_number: string | undefined;
12
+ email: string;
13
+ locale?: string;
14
+ first_name?: string;
15
+ last_name?: string;
16
+ city?: string;
17
+ state?: string;
18
+ country?: string;
19
+ zip_code?: string;
20
+ }
21
+ export interface TTBaseProps {
22
+ contents: TTContentItem[];
23
+ content_type?: string;
24
+ currency?: string;
25
+ value?: number;
26
+ query?: string;
27
+ description?: string;
28
+ order_id?: string;
29
+ shop_id?: string;
30
+ content_ids?: string[];
31
+ num_items?: number;
32
+ search_string?: string;
33
+ }
34
+ export interface TTTravelProps {
35
+ city?: string;
36
+ region?: string;
37
+ country?: string;
38
+ checkin_date?: string;
39
+ checkout_date?: string;
40
+ num_adults?: number;
41
+ num_children?: number;
42
+ num_infants?: number;
43
+ suggested_hotels?: string[];
44
+ departing_departure_date?: string;
45
+ returning_departure_date?: string;
46
+ origin_airport?: string;
47
+ destination_airiport?: string;
48
+ destination_ids?: string[];
49
+ departing_arrival_date?: string;
50
+ returning_arrival_date?: string;
51
+ travel_class?: string;
52
+ user_score?: number;
53
+ preferred_num_stops?: number;
54
+ travel_start?: string;
55
+ travel_end?: string;
56
+ suggested_destinations?: string[];
57
+ }
58
+ export interface TTAutoProps {
59
+ postal_code?: string;
60
+ make?: string;
61
+ model?: string;
62
+ year?: number;
63
+ state_of_vehicle?: string;
64
+ mileage?: {
65
+ value?: number;
66
+ unit?: string;
67
+ };
68
+ exterior_color?: string;
69
+ transmission?: string;
70
+ body_style?: string;
71
+ fuel_type?: string;
72
+ drivetrain?: string;
73
+ preferred_price_range?: number[];
74
+ trim?: string;
75
+ vin?: string;
76
+ interior_color?: string;
77
+ condition_of_vehicle?: string;
78
+ viewcontent_type?: string;
79
+ search_type?: string;
80
+ registration_type?: string;
81
+ }
82
+ interface TTContentItem {
83
+ price?: number;
84
+ quantity?: number;
85
+ content_category?: string;
86
+ content_id?: string;
87
+ content_name?: string;
88
+ brand?: string;
89
+ }
90
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Payload as IdentifyPayload } from './identify/generated-types';
2
+ import { Payload as TrackPayload } from './reportWebEvent/generated-types';
3
+ import { TTUser } from './types';
4
+ export declare function getUser(payload: IdentifyPayload | TrackPayload): TTUser;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUser = getUser;
4
+ const formatter_1 = require("./formatter");
5
+ function getUser(payload) {
6
+ return {
7
+ email: (0, formatter_1.handleArrayInput)(payload.email),
8
+ phone_number: (0, formatter_1.formatPhone)((0, formatter_1.handleArrayInput)(payload.phone_number)),
9
+ external_id: (0, formatter_1.handleArrayInput)(payload.external_id),
10
+ first_name: (0, formatter_1.formatString)(payload.first_name),
11
+ last_name: (0, formatter_1.formatString)(payload.last_name),
12
+ city: (0, formatter_1.formatAddress)(payload.address?.city),
13
+ state: (0, formatter_1.formatAddress)(payload.address?.state),
14
+ country: (0, formatter_1.formatAddress)(payload.address?.country),
15
+ zip_code: (0, formatter_1.formatString)(payload.address?.zip_code)
16
+ };
17
+ }
18
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;AAKA,0BAYC;AAfD,2CAAwF;AAGxF,SAAgB,OAAO,CAAC,OAAuC;IAC7D,OAAO;QACL,KAAK,EAAE,IAAA,4BAAgB,EAAC,OAAO,CAAC,KAAK,CAAC;QACtC,YAAY,EAAE,IAAA,uBAAW,EAAC,IAAA,4BAAgB,EAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACjE,WAAW,EAAE,IAAA,4BAAgB,EAAC,OAAO,CAAC,WAAW,CAAC;QAClD,UAAU,EAAE,IAAA,wBAAY,EAAC,OAAO,CAAC,UAAU,CAAC;QAC5C,SAAS,EAAE,IAAA,wBAAY,EAAC,OAAO,CAAC,SAAS,CAAC;QAC1C,IAAI,EAAE,IAAA,yBAAa,EAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;QAC1C,KAAK,EAAE,IAAA,yBAAa,EAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC;QAC5C,OAAO,EAAE,IAAA,yBAAa,EAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC;QAChD,QAAQ,EAAE,IAAA,wBAAY,EAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;KAClD,CAAA;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const VEHICLE_FIELDS = "vehicle_fields";
2
+ export declare const TRAVEL_FIELDS = "travel_fields";
@@ -0,0 +1,3 @@
1
+ export const VEHICLE_FIELDS = 'vehicle_fields';
2
+ export const TRAVEL_FIELDS = 'travel_fields';
3
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAA;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { InputField } from '@segment/actions-core';
2
+ export declare const common_fields: Record<string, InputField>;
@@ -1,18 +1,4 @@
1
- export const commonFields = {
2
- event: {
3
- label: 'Event Name',
4
- type: 'string',
5
- required: true,
6
- description: 'Conversion event name. Please refer to the "Supported Web Events" section on in TikTok’s [Pixel SDK documentation](https://business-api.tiktok.com/portal/docs?id=1739585696931842) for accepted event names.'
7
- },
8
- event_id: {
9
- label: 'Event ID',
10
- type: 'string',
11
- description: 'Any hashed ID that can identify a unique user/session.',
12
- default: {
13
- '@path': '$.messageId'
14
- }
15
- },
1
+ export const common_fields = {
16
2
  phone_number: {
17
3
  label: 'Phone Number',
18
4
  description: 'A single phone number in E.164 standard format. TikTok Pixel will hash this value before sending to TikTok. e.g. +14150000000. Segment will hash this value before sending to TikTok.',
@@ -121,22 +107,6 @@ export const commonFields = {
121
107
  }
122
108
  }
123
109
  },
124
- order_id: {
125
- label: 'Order ID',
126
- type: 'string',
127
- description: 'Order ID of the transaction.',
128
- default: {
129
- '@path': '$.properties.order_id'
130
- }
131
- },
132
- shop_id: {
133
- label: 'Shop ID',
134
- type: 'string',
135
- description: 'Shop ID of the transaction.',
136
- default: {
137
- '@path': '$.properties.shop_id'
138
- }
139
- },
140
110
  external_id: {
141
111
  label: 'External ID',
142
112
  description: 'Uniquely identifies the user who triggered the conversion event. TikTok Pixel will hash this value before sending to TikTok.',
@@ -149,87 +119,6 @@ export const commonFields = {
149
119
  else: { '@path': '$.anonymousId' }
150
120
  }
151
121
  }
152
- },
153
- contents: {
154
- label: 'Contents',
155
- type: 'object',
156
- multiple: true,
157
- description: 'Related item details for the event.',
158
- properties: {
159
- price: {
160
- label: 'Price',
161
- description: 'Price of the item.',
162
- type: 'number'
163
- },
164
- quantity: {
165
- label: 'Quantity',
166
- description: 'Number of items.',
167
- type: 'number'
168
- },
169
- content_category: {
170
- label: 'Content Category',
171
- description: 'Category of the product item.',
172
- type: 'string'
173
- },
174
- content_id: {
175
- label: 'Content ID',
176
- description: 'ID of the product item.',
177
- type: 'string'
178
- },
179
- content_name: {
180
- label: 'Content Name',
181
- description: 'Name of the product item.',
182
- type: 'string'
183
- },
184
- brand: {
185
- label: 'Brand',
186
- description: 'Brand name of the product item.',
187
- type: 'string'
188
- }
189
- }
190
- },
191
- content_type: {
192
- label: 'Content Type',
193
- description: 'Type of the product item. When the `content_id` in the `Contents` field is specified as a `sku_id`, set this field to `product`. When the `content_id` in the `Contents` field is specified as an `item_group_id`, set this field to `product_group`.',
194
- type: 'string',
195
- choices: [
196
- { label: 'product', value: 'product' },
197
- { label: 'product_group', value: 'product_group' }
198
- ],
199
- default: 'product'
200
- },
201
- currency: {
202
- label: 'Currency',
203
- type: 'string',
204
- description: 'Currency for the value specified as ISO 4217 code.',
205
- default: {
206
- '@path': '$.properties.currency'
207
- }
208
- },
209
- value: {
210
- label: 'Value',
211
- type: 'number',
212
- description: 'Value of the order or items sold.',
213
- default: {
214
- '@if': {
215
- exists: { '@path': '$.properties.value' },
216
- then: { '@path': '$.properties.value' },
217
- else: { '@path': '$.properties.revenue' }
218
- }
219
- }
220
- },
221
- description: {
222
- label: 'Description',
223
- type: 'string',
224
- description: 'A string description of the web event.'
225
- },
226
- query: {
227
- label: 'Query',
228
- type: 'string',
229
- description: 'The text string that was searched for.',
230
- default: {
231
- '@path': '$.properties.query'
232
- }
233
122
  }
234
123
  };
235
124
  //# sourceMappingURL=common_fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common_fields.js","sourceRoot":"","sources":["../../../src/fields/common_fields.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAA+B;IACvD,YAAY,EAAE;QACZ,KAAK,EAAE,cAAc;QACrB,WAAW,EACT,uLAAuL;QACzL,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACzC,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACvC,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;aAC5C;SACF;KACF;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,wFAAwF;QACrG,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACzC,IAAI,EAAE,EAAE,OAAO,EAAE,oBAAoB,EAAE;gBACvC,IAAI,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;aAC5C;SACF;KACF;IACD,UAAU,EAAE;QACV,KAAK,EAAE,YAAY;QACnB,WAAW,EACT,0HAA0H;QAC5H,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE;gBAC9C,IAAI,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE;gBAC5C,IAAI,EAAE,EAAE,OAAO,EAAE,6BAA6B,EAAE;aACjD;SACF;KACF;IACD,SAAS,EAAE;QACT,KAAK,EAAE,WAAW;QAClB,WAAW,EACT,yHAAyH;QAC3H,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;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EAAE;oBACvD,IAAI,EAAE,EAAE,OAAO,EAAE,kCAAkC,EAAE;oBACrD,IAAI,EAAE,EAAE,OAAO,EAAE,sCAAsC,EAAE;iBAC1D;aACF;YACD,KAAK,EAAE;gBACL,KAAK,EAAE;oBACL,MAAM,EAAE,EAAE,OAAO,EAAE,4BAA4B,EAAE;oBACjD,IAAI,EAAE,EAAE,OAAO,EAAE,4BAA4B,EAAE;oBAC/C,IAAI,EAAE,EAAE,OAAO,EAAE,gCAAgC,EAAE;iBACpD;aACF;SACF;KACF;IACD,WAAW,EAAE;QACX,KAAK,EAAE,aAAa;QACpB,WAAW,EACT,8HAA8H;QAChI,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;gBAC/B,IAAI,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE;gBAC7B,IAAI,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE;aACnC;SACF;KACF;CACF,CAAA"}
@@ -1,6 +1,4 @@
1
1
  export interface Payload {
2
- event: string;
3
- event_id?: string;
4
2
  phone_number?: string[];
5
3
  email?: string[];
6
4
  first_name?: string;
@@ -11,20 +9,5 @@ export interface Payload {
11
9
  zip_code?: string;
12
10
  state?: string;
13
11
  };
14
- order_id?: string;
15
- shop_id?: string;
16
12
  external_id?: string[];
17
- contents?: {
18
- price?: number;
19
- quantity?: number;
20
- content_category?: string;
21
- content_id?: string;
22
- content_name?: string;
23
- brand?: string;
24
- }[];
25
- content_type?: string;
26
- currency?: string;
27
- value?: number;
28
- description?: string;
29
- query?: string;
30
13
  }
@@ -1,30 +1,30 @@
1
- import { formatPhone, handleArrayInput, formatString, formatAddress } from '../formatter';
2
- import { commonFields } from '../common_fields';
1
+ import { getUser } from '../utils';
2
+ import { common_fields } from '../fields/common_fields';
3
3
  const action = {
4
4
  title: 'Identify',
5
5
  description: 'Use a Segment identify() call to sent PII data to TikTok Pixel. Note that the PII information will be sent with the next track() call.',
6
6
  defaultSubscription: 'type = "identify"',
7
7
  platform: 'web',
8
8
  fields: {
9
- ...commonFields,
9
+ ...common_fields,
10
10
  phone_number: {
11
- ...commonFields.phone_number,
11
+ ...common_fields.phone_number,
12
12
  default: { '@path': '$.traits.phone' }
13
13
  },
14
14
  email: {
15
- ...commonFields.email,
15
+ ...common_fields.email,
16
16
  default: { '@path': '$.traits.email' }
17
17
  },
18
18
  first_name: {
19
- ...commonFields.first_name,
19
+ ...common_fields.first_name,
20
20
  default: { '@path': '$.traits.first_name' }
21
21
  },
22
22
  last_name: {
23
- ...commonFields.last_name,
23
+ ...common_fields.last_name,
24
24
  default: { '@path': '$.traits.last_name' }
25
25
  },
26
26
  address: {
27
- ...commonFields.address,
27
+ ...common_fields.address,
28
28
  default: {
29
29
  city: { '@path': '$.traits.address.city' },
30
30
  country: { '@path': '$.traits.address.country' },
@@ -33,19 +33,9 @@ const action = {
33
33
  }
34
34
  }
35
35
  },
36
- perform: (ttq, { payload }) => {
36
+ perform: (ttq, { payload, settings }) => {
37
37
  if (payload.email || payload.phone_number || payload.external_id) {
38
- ttq.identify({
39
- email: handleArrayInput(payload.email),
40
- phone_number: formatPhone(handleArrayInput(payload.phone_number)),
41
- external_id: handleArrayInput(payload.external_id),
42
- first_name: formatString(payload.first_name),
43
- last_name: formatString(payload.last_name),
44
- city: formatAddress(payload.address?.city),
45
- state: formatAddress(payload.address?.state),
46
- country: formatAddress(payload.address?.country),
47
- zip_code: formatString(payload.address?.zip_code)
48
- });
38
+ ttq.instance(settings.pixelCode).identify(getUser(payload));
49
39
  }
50
40
  }
51
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/identify/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEzF,OAAO,EAAE,YAAY,EAAE,MAA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AAE;SAC3C;QACD,OAAO,EAAE;YACP,GAAG,aAAa,CAAC,OAAO;YACxB,OAAO,EAAE;gBACP,IAAI,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE;gBAC1C,OAAO,EAAE,EAAE,OAAO,EAAE,0BAA0B,EAAE;gBAChD,QAAQ,EAAE,EAAE,OAAO,EAAE,8BAA8B,EAAE;gBACrD,KAAK,EAAE,EAAE,OAAO,EAAE,wBAAwB,EAAE;aAC7C;SACF;KACF;IACD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QACtC,IAAI,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACjE,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;CACF,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -0,0 +1,2 @@
1
+ import { InputField } from '@segment/actions-core';
2
+ export declare const track_fields: Record<string, InputField>;
@@ -0,0 +1,158 @@
1
+ import { VEHICLE_FIELDS, TRAVEL_FIELDS } from '../constants';
2
+ export const track_fields = {
3
+ event_spec_type: {
4
+ label: 'Additional Fields',
5
+ type: 'string',
6
+ description: 'Include fields for travel or vehicle events.',
7
+ choices: [
8
+ { value: TRAVEL_FIELDS, label: 'Travel Fields' },
9
+ { value: VEHICLE_FIELDS, label: 'Vehicle Fields' }
10
+ ]
11
+ },
12
+ event: {
13
+ label: 'Event Name',
14
+ type: 'string',
15
+ required: true,
16
+ description: 'Conversion event name. Please refer to the "Supported Web Events" section on in TikTok’s [Pixel SDK documentation](https://business-api.tiktok.com/portal/docs?id=1739585696931842) for accepted event names.'
17
+ },
18
+ event_id: {
19
+ label: 'Event ID',
20
+ type: 'string',
21
+ description: 'Any hashed ID that can identify a unique user/session.',
22
+ default: {
23
+ '@path': '$.messageId'
24
+ }
25
+ },
26
+ order_id: {
27
+ label: 'Order ID',
28
+ type: 'string',
29
+ description: 'Order ID of the transaction.',
30
+ default: {
31
+ '@path': '$.properties.order_id'
32
+ }
33
+ },
34
+ shop_id: {
35
+ label: 'Shop ID',
36
+ type: 'string',
37
+ description: 'Shop ID of the transaction.',
38
+ default: {
39
+ '@path': '$.properties.shop_id'
40
+ }
41
+ },
42
+ contents: {
43
+ label: 'Contents',
44
+ type: 'object',
45
+ multiple: true,
46
+ description: 'Related item details for the event.',
47
+ properties: {
48
+ price: {
49
+ label: 'Price',
50
+ description: 'Price of the item.',
51
+ type: 'number'
52
+ },
53
+ quantity: {
54
+ label: 'Quantity',
55
+ description: 'Number of items.',
56
+ type: 'number'
57
+ },
58
+ content_category: {
59
+ label: 'Content Category',
60
+ description: 'Category of the product item.',
61
+ type: 'string'
62
+ },
63
+ content_id: {
64
+ label: 'Content ID',
65
+ description: 'ID of the product item.',
66
+ type: 'string'
67
+ },
68
+ content_name: {
69
+ label: 'Content Name',
70
+ description: 'Name of the product item.',
71
+ type: 'string'
72
+ },
73
+ brand: {
74
+ label: 'Brand',
75
+ description: 'Brand name of the product item.',
76
+ type: 'string'
77
+ }
78
+ }
79
+ },
80
+ content_ids: {
81
+ label: 'Content IDs',
82
+ description: "Product IDs associated with the event, such as SKUs. Do not populate this field if the 'Contents' field is populated. This field accepts a single string value or an array of string values.",
83
+ type: 'string',
84
+ multiple: true,
85
+ default: {
86
+ '@path': '$.properties.content_ids'
87
+ }
88
+ },
89
+ num_items: {
90
+ label: 'Number of Items',
91
+ type: 'number',
92
+ description: 'Number of items when checkout was initiated. Used with the InitiateCheckout event.',
93
+ default: {
94
+ '@path': '$.properties.num_items'
95
+ }
96
+ },
97
+ content_type: {
98
+ label: 'Content Type',
99
+ description: 'Type of the product item. When the `content_id` in the `Contents` field is specified as a `sku_id`, set this field to `product`. When the `content_id` in the `Contents` field is specified as an `item_group_id`, set this field to `product_group`.',
100
+ type: 'string',
101
+ choices: [
102
+ { label: 'product', value: 'product' },
103
+ { label: 'product_group', value: 'product_group' }
104
+ ],
105
+ default: 'product'
106
+ },
107
+ currency: {
108
+ label: 'Currency',
109
+ type: 'string',
110
+ description: 'Currency for the value specified as ISO 4217 code.',
111
+ default: {
112
+ '@path': '$.properties.currency'
113
+ }
114
+ },
115
+ value: {
116
+ label: 'Value',
117
+ type: 'number',
118
+ description: 'Value of the order or items sold.',
119
+ default: {
120
+ '@if': {
121
+ exists: { '@path': '$.properties.value' },
122
+ then: { '@path': '$.properties.value' },
123
+ else: { '@path': '$.properties.revenue' }
124
+ }
125
+ }
126
+ },
127
+ description: {
128
+ label: 'Description',
129
+ type: 'string',
130
+ description: 'A string description of the web event.'
131
+ },
132
+ query: {
133
+ label: 'Query',
134
+ type: 'string',
135
+ description: 'The text string that was searched for.',
136
+ default: {
137
+ '@path': '$.properties.query'
138
+ }
139
+ },
140
+ search_string: {
141
+ label: 'Search String',
142
+ type: 'string',
143
+ description: 'The text string entered by the user for the search. Optionally used with the Search event.',
144
+ default: {
145
+ '@path': '$.properties.search_string'
146
+ },
147
+ depends_on: {
148
+ conditions: [
149
+ {
150
+ fieldKey: 'event',
151
+ operator: 'is',
152
+ value: 'Search'
153
+ }
154
+ ]
155
+ }
156
+ }
157
+ };
158
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../../../src/reportWebEvent/fields.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5D,MAAM,CAAC,MAAM,YAAY,GAA+B;IACpD,eAAe,EAAE;QACb,KAAK,EAAE,mBAAmB;QAC1B,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,8CAA8C;QAC3D,OAAO,EAAE;YACT,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,eAAe,EAAE;YAChD,EAAE,KAAK,EAAE,cAAc,E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AE,wCAAwC;KACxD;IACD,KAAK,EAAE;QACH,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,wCAAwC;QACrD,OAAO,EAAE;YACT,OAAO,EAAE,oBAAoB;SAC5B;KACJ;IACD,aAAa,EAAE;QACX,KAAK,EAAE,eAAe;QACtB,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,4FAA4F;QACzG,OAAO,EAAE;YACT,OAAO,EAAE,4BAA4B;SACpC;QACD,UAAU,EAAE;YACZ,UAAU,EAAE;gBACR;oBACA,QAAQ,EAAE,OAAO;oBACjB,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,QAAQ;iBACd;aACJ;SACA;KACJ;CACJ,CAAA"}
@@ -1,19 +1,9 @@
1
1
  export interface Payload {
2
+ event_spec_type?: string;
2
3
  event: string;
3
4
  event_id?: string;
4
- phone_number?: string[];
5
- email?: string[];
6
- first_name?: string;
7
- last_name?: string;
8
- address?: {
9
- city?: string;
10
- country?: string;
11
- zip_code?: string;
12
- state?: string;
13
- };
14
5
  order_id?: string;
15
6
  shop_id?: string;
16
- external_id?: string[];
17
7
  contents?: {
18
8
  price?: number;
19
9
  quantity?: number;
@@ -22,9 +12,70 @@ export interface Payload {
22
12
  content_name?: string;
23
13
  brand?: string;
24
14
  }[];
15
+ content_ids?: string[];
16
+ num_items?: number;
25
17
  content_type?: string;
26
18
  currency?: string;
27
19
  value?: number;
28
20
  description?: string;
29
21
  query?: string;
22
+ search_string?: string;
23
+ phone_number?: string[];
24
+ email?: string[];
25
+ first_name?: string;
26
+ last_name?: string;
27
+ address?: {
28
+ city?: string;
29
+ country?: string;
30
+ zip_code?: string;
31
+ state?: string;
32
+ };
33
+ external_id?: string[];
34
+ vehicle_fields?: {
35
+ postal_code?: string;
36
+ make?: string;
37
+ model?: string;
38
+ year?: number;
39
+ state_of_vehicle?: string;
40
+ mileage_value?: number;
41
+ mileage_unit?: string;
42
+ exterior_color?: string;
43
+ transmission?: string;
44
+ body_style?: string;
45
+ fuel_type?: string;
46
+ drivetrain?: string;
47
+ preferred_price_range_min?: number;
48
+ preferred_price_range_max?: number;
49
+ trim?: string;
50
+ vin?: string;
51
+ interior_color?: string;
52
+ condition_of_vehicle?: string;
53
+ viewcontent_type?: string;
54
+ search_type?: string;
55
+ registration_type?: string;
56
+ };
57
+ travel_fields?: {
58
+ city?: string;
59
+ region?: string;
60
+ country?: string;
61
+ checkin_date?: string;
62
+ checkout_date?: string;
63
+ num_adults?: number;
64
+ num_children?: number;
65
+ num_infants?: number;
66
+ suggested_hotels?: string[];
67
+ departing_departure_date?: string;
68
+ returning_departure_date?: string;
69
+ origin_airport?: string;
70
+ destination_airport?: string;
71
+ destination_ids?: string[];
72
+ departing_arrival_date?: string;
73
+ returning_arrival_date?: string;
74
+ travel_class?: string;
75
+ user_score?: number;
76
+ preferred_num_stops?: number;
77
+ travel_start?: string;
78
+ travel_end?: string;
79
+ suggested_destinations?: string[];
80
+ };
30
81
  }