@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.
- package/dist/cjs/constants.d.ts +2 -0
- package/dist/cjs/constants.js +6 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/fields/common_fields.d.ts +2 -0
- package/dist/cjs/{common_fields.js → fields/common_fields.js} +2 -113
- package/dist/cjs/fields/common_fields.js.map +1 -0
- package/dist/cjs/identify/generated-types.d.ts +0 -17
- package/dist/cjs/identify/index.js +10 -20
- package/dist/cjs/identify/index.js.map +1 -1
- package/dist/cjs/reportWebEvent/fields.d.ts +2 -0
- package/dist/cjs/reportWebEvent/fields.js +161 -0
- package/dist/cjs/reportWebEvent/fields.js.map +1 -0
- package/dist/cjs/reportWebEvent/generated-types.d.ts +62 -11
- package/dist/cjs/reportWebEvent/index.js +12 -24
- package/dist/cjs/reportWebEvent/index.js.map +1 -1
- package/dist/cjs/reportWebEvent/travel_fields.d.ts +2 -0
- package/dist/cjs/reportWebEvent/travel_fields.js +210 -0
- package/dist/cjs/reportWebEvent/travel_fields.js.map +1 -0
- package/dist/cjs/reportWebEvent/utils.d.ts +3 -0
- package/dist/cjs/reportWebEvent/utils.js +101 -0
- package/dist/cjs/reportWebEvent/utils.js.map +1 -0
- package/dist/cjs/reportWebEvent/vehicle_fields.d.ts +2 -0
- package/dist/cjs/reportWebEvent/vehicle_fields.js +255 -0
- package/dist/cjs/reportWebEvent/vehicle_fields.js.map +1 -0
- package/dist/cjs/types.d.ts +85 -29
- package/dist/cjs/utils.d.ts +4 -0
- package/dist/cjs/utils.js +18 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/constants.d.ts +2 -0
- package/dist/esm/constants.js +3 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/fields/common_fields.d.ts +2 -0
- package/dist/esm/{common_fields.js → fields/common_fields.js} +1 -112
- package/dist/esm/fields/common_fields.js.map +1 -0
- package/dist/esm/identify/generated-types.d.ts +0 -17
- package/dist/esm/identify/index.js +10 -20
- package/dist/esm/identify/index.js.map +1 -1
- package/dist/esm/reportWebEvent/fields.d.ts +2 -0
- package/dist/esm/reportWebEvent/fields.js +158 -0
- package/dist/esm/reportWebEvent/fields.js.map +1 -0
- package/dist/esm/reportWebEvent/generated-types.d.ts +62 -11
- package/dist/esm/reportWebEvent/index.js +12 -24
- package/dist/esm/reportWebEvent/index.js.map +1 -1
- package/dist/esm/reportWebEvent/travel_fields.d.ts +2 -0
- package/dist/esm/reportWebEvent/travel_fields.js +207 -0
- package/dist/esm/reportWebEvent/travel_fields.js.map +1 -0
- package/dist/esm/reportWebEvent/utils.d.ts +3 -0
- package/dist/esm/reportWebEvent/utils.js +98 -0
- package/dist/esm/reportWebEvent/utils.js.map +1 -0
- package/dist/esm/reportWebEvent/vehicle_fields.d.ts +2 -0
- package/dist/esm/reportWebEvent/vehicle_fields.js +252 -0
- package/dist/esm/reportWebEvent/vehicle_fields.js.map +1 -0
- package/dist/esm/types.d.ts +85 -29
- package/dist/esm/utils.d.ts +4 -0
- package/dist/esm/utils.js +15 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/constants.ts +2 -0
- package/src/{common_fields.ts → fields/common_fields.ts} +1 -114
- package/src/identify/generated-types.ts +0 -65
- package/src/identify/index.ts +10 -20
- package/src/reportWebEvent/__tests__/index.test.ts +521 -23
- package/src/reportWebEvent/fields.ts +162 -0
- package/src/reportWebEvent/generated-types.ts +239 -41
- package/src/reportWebEvent/index.ts +14 -26
- package/src/reportWebEvent/travel_fields.ts +216 -0
- package/src/reportWebEvent/utils.ts +167 -0
- package/src/reportWebEvent/vehicle_fields.ts +255 -0
- package/src/types.ts +89 -54
- package/src/utils.ts +18 -0
- package/dist/cjs/common_fields.d.ts +0 -2
- package/dist/cjs/common_fields.js.map +0 -1
- package/dist/esm/common_fields.d.ts +0 -2
- package/dist/esm/common_fields.js.map +0 -1
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { InputField } from '@segment/actions-core'
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
event: {
|
|
5
|
-
label: 'Event Name',
|
|
6
|
-
type: 'string',
|
|
7
|
-
required: true,
|
|
8
|
-
description:
|
|
9
|
-
'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.'
|
|
10
|
-
},
|
|
11
|
-
event_id: {
|
|
12
|
-
label: 'Event ID',
|
|
13
|
-
type: 'string',
|
|
14
|
-
description: 'Any hashed ID that can identify a unique user/session.',
|
|
15
|
-
default: {
|
|
16
|
-
'@path': '$.messageId'
|
|
17
|
-
}
|
|
18
|
-
},
|
|
3
|
+
export const common_fields: Record<string, InputField> = {
|
|
19
4
|
phone_number: {
|
|
20
5
|
label: 'Phone Number',
|
|
21
6
|
description:
|
|
@@ -127,22 +112,6 @@ export const commonFields: Record<string, InputField> = {
|
|
|
127
112
|
}
|
|
128
113
|
}
|
|
129
114
|
},
|
|
130
|
-
order_id: {
|
|
131
|
-
label: 'Order ID',
|
|
132
|
-
type: 'string',
|
|
133
|
-
description: 'Order ID of the transaction.',
|
|
134
|
-
default: {
|
|
135
|
-
'@path': '$.properties.order_id'
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
shop_id: {
|
|
139
|
-
label: 'Shop ID',
|
|
140
|
-
type: 'string',
|
|
141
|
-
description: 'Shop ID of the transaction.',
|
|
142
|
-
default: {
|
|
143
|
-
'@path': '$.properties.shop_id'
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
115
|
external_id: {
|
|
147
116
|
label: 'External ID',
|
|
148
117
|
description:
|
|
@@ -156,87 +125,5 @@ export const commonFields: Record<string, InputField> = {
|
|
|
156
125
|
else: { '@path': '$.anonymousId' }
|
|
157
126
|
}
|
|
158
127
|
}
|
|
159
|
-
},
|
|
160
|
-
contents: {
|
|
161
|
-
label: 'Contents',
|
|
162
|
-
type: 'object',
|
|
163
|
-
multiple: true,
|
|
164
|
-
description: 'Related item details for the event.',
|
|
165
|
-
properties: {
|
|
166
|
-
price: {
|
|
167
|
-
label: 'Price',
|
|
168
|
-
description: 'Price of the item.',
|
|
169
|
-
type: 'number'
|
|
170
|
-
},
|
|
171
|
-
quantity: {
|
|
172
|
-
label: 'Quantity',
|
|
173
|
-
description: 'Number of items.',
|
|
174
|
-
type: 'number'
|
|
175
|
-
},
|
|
176
|
-
content_category: {
|
|
177
|
-
label: 'Content Category',
|
|
178
|
-
description: 'Category of the product item.',
|
|
179
|
-
type: 'string'
|
|
180
|
-
},
|
|
181
|
-
content_id: {
|
|
182
|
-
label: 'Content ID',
|
|
183
|
-
description: 'ID of the product item.',
|
|
184
|
-
type: 'string'
|
|
185
|
-
},
|
|
186
|
-
content_name: {
|
|
187
|
-
label: 'Content Name',
|
|
188
|
-
description: 'Name of the product item.',
|
|
189
|
-
type: 'string'
|
|
190
|
-
},
|
|
191
|
-
brand: {
|
|
192
|
-
label: 'Brand',
|
|
193
|
-
description: 'Brand name of the product item.',
|
|
194
|
-
type: 'string'
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
},
|
|
198
|
-
content_type: {
|
|
199
|
-
label: 'Content Type',
|
|
200
|
-
description:
|
|
201
|
-
'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`.',
|
|
202
|
-
type: 'string',
|
|
203
|
-
choices: [
|
|
204
|
-
{ label: 'product', value: 'product' },
|
|
205
|
-
{ label: 'product_group', value: 'product_group' }
|
|
206
|
-
],
|
|
207
|
-
default: 'product'
|
|
208
|
-
},
|
|
209
|
-
currency: {
|
|
210
|
-
label: 'Currency',
|
|
211
|
-
type: 'string',
|
|
212
|
-
description: 'Currency for the value specified as ISO 4217 code.',
|
|
213
|
-
default: {
|
|
214
|
-
'@path': '$.properties.currency'
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
value: {
|
|
218
|
-
label: 'Value',
|
|
219
|
-
type: 'number',
|
|
220
|
-
description: 'Value of the order or items sold.',
|
|
221
|
-
default: {
|
|
222
|
-
'@if': {
|
|
223
|
-
exists: { '@path': '$.properties.value' },
|
|
224
|
-
then: { '@path': '$.properties.value' },
|
|
225
|
-
else: { '@path': '$.properties.revenue' }
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
},
|
|
229
|
-
description: {
|
|
230
|
-
label: 'Description',
|
|
231
|
-
type: 'string',
|
|
232
|
-
description: 'A string description of the web event.'
|
|
233
|
-
},
|
|
234
|
-
query: {
|
|
235
|
-
label: 'Query',
|
|
236
|
-
type: 'string',
|
|
237
|
-
description: 'The text string that was searched for.',
|
|
238
|
-
default: {
|
|
239
|
-
'@path': '$.properties.query'
|
|
240
|
-
}
|
|
241
128
|
}
|
|
242
129
|
}
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
// Generated file. DO NOT MODIFY IT BY HAND.
|
|
2
2
|
|
|
3
3
|
export interface Payload {
|
|
4
|
-
/**
|
|
5
|
-
* 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.
|
|
6
|
-
*/
|
|
7
|
-
event: string
|
|
8
|
-
/**
|
|
9
|
-
* Any hashed ID that can identify a unique user/session.
|
|
10
|
-
*/
|
|
11
|
-
event_id?: string
|
|
12
4
|
/**
|
|
13
5
|
* 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.
|
|
14
6
|
*/
|
|
@@ -46,65 +38,8 @@ export interface Payload {
|
|
|
46
38
|
*/
|
|
47
39
|
state?: string
|
|
48
40
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Order ID of the transaction.
|
|
51
|
-
*/
|
|
52
|
-
order_id?: string
|
|
53
|
-
/**
|
|
54
|
-
* Shop ID of the transaction.
|
|
55
|
-
*/
|
|
56
|
-
shop_id?: string
|
|
57
41
|
/**
|
|
58
42
|
* Uniquely identifies the user who triggered the conversion event. TikTok Pixel will hash this value before sending to TikTok.
|
|
59
43
|
*/
|
|
60
44
|
external_id?: string[]
|
|
61
|
-
/**
|
|
62
|
-
* Related item details for the event.
|
|
63
|
-
*/
|
|
64
|
-
contents?: {
|
|
65
|
-
/**
|
|
66
|
-
* Price of the item.
|
|
67
|
-
*/
|
|
68
|
-
price?: number
|
|
69
|
-
/**
|
|
70
|
-
* Number of items.
|
|
71
|
-
*/
|
|
72
|
-
quantity?: number
|
|
73
|
-
/**
|
|
74
|
-
* Category of the product item.
|
|
75
|
-
*/
|
|
76
|
-
content_category?: string
|
|
77
|
-
/**
|
|
78
|
-
* ID of the product item.
|
|
79
|
-
*/
|
|
80
|
-
content_id?: string
|
|
81
|
-
/**
|
|
82
|
-
* Name of the product item.
|
|
83
|
-
*/
|
|
84
|
-
content_name?: string
|
|
85
|
-
/**
|
|
86
|
-
* Brand name of the product item.
|
|
87
|
-
*/
|
|
88
|
-
brand?: string
|
|
89
|
-
}[]
|
|
90
|
-
/**
|
|
91
|
-
* 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`.
|
|
92
|
-
*/
|
|
93
|
-
content_type?: string
|
|
94
|
-
/**
|
|
95
|
-
* Currency for the value specified as ISO 4217 code.
|
|
96
|
-
*/
|
|
97
|
-
currency?: string
|
|
98
|
-
/**
|
|
99
|
-
* Value of the order or items sold.
|
|
100
|
-
*/
|
|
101
|
-
value?: number
|
|
102
|
-
/**
|
|
103
|
-
* A string description of the web event.
|
|
104
|
-
*/
|
|
105
|
-
description?: string
|
|
106
|
-
/**
|
|
107
|
-
* The text string that was searched for.
|
|
108
|
-
*/
|
|
109
|
-
query?: string
|
|
110
45
|
}
|
package/src/identify/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types'
|
|
2
2
|
import type { Settings } from '../generated-types'
|
|
3
3
|
import type { Payload } from './generated-types'
|
|
4
|
-
import {
|
|
4
|
+
import { getUser } from '../utils'
|
|
5
5
|
import { TikTokPixel } from '../types'
|
|
6
|
-
import {
|
|
6
|
+
import { common_fields } from '../fields/common_fields'
|
|
7
7
|
|
|
8
8
|
// Change from unknown to the partner SDK types
|
|
9
9
|
const action: BrowserActionDefinition<Settings, TikTokPixel, Payload> = {
|
|
@@ -13,25 +13,25 @@ const action: BrowserActionDefinition<Settings, TikTokPixel, Payload> = {
|
|
|
13
13
|
defaultSubscription: 'type = "identify"',
|
|
14
14
|
platform: 'web',
|
|
15
15
|
fields: {
|
|
16
|
-
...
|
|
16
|
+
...common_fields,
|
|
17
17
|
phone_number: {
|
|
18
|
-
...
|
|
18
|
+
...common_fields.phone_number,
|
|
19
19
|
default: { '@path': '$.traits.phone' }
|
|
20
20
|
},
|
|
21
21
|
email: {
|
|
22
|
-
...
|
|
22
|
+
...common_fields.email,
|
|
23
23
|
default: { '@path': '$.traits.email' }
|
|
24
24
|
},
|
|
25
25
|
first_name: {
|
|
26
|
-
...
|
|
26
|
+
...common_fields.first_name,
|
|
27
27
|
default: { '@path': '$.traits.first_name' }
|
|
28
28
|
},
|
|
29
29
|
last_name: {
|
|
30
|
-
...
|
|
30
|
+
...common_fields.last_name,
|
|
31
31
|
default: { '@path': '$.traits.last_name' }
|
|
32
32
|
},
|
|
33
33
|
address: {
|
|
34
|
-
...
|
|
34
|
+
...common_fields.address,
|
|
35
35
|
default: {
|
|
36
36
|
city: { '@path': '$.traits.address.city' },
|
|
37
37
|
country: { '@path': '$.traits.address.country' },
|
|
@@ -40,19 +40,9 @@ const action: BrowserActionDefinition<Settings, TikTokPixel, Payload> = {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
|
-
perform: (ttq, { payload }) => {
|
|
43
|
+
perform: (ttq, { payload, settings }) => {
|
|
44
44
|
if (payload.email || payload.phone_number || payload.external_id) {
|
|
45
|
-
ttq.identify(
|
|
46
|
-
email: handleArrayInput(payload.email),
|
|
47
|
-
phone_number: formatPhone(handleArrayInput(payload.phone_number)),
|
|
48
|
-
external_id: handleArrayInput(payload.external_id),
|
|
49
|
-
first_name: formatString(payload.first_name),
|
|
50
|
-
last_name: formatString(payload.last_name),
|
|
51
|
-
city: formatAddress(payload.address?.city),
|
|
52
|
-
state: formatAddress(payload.address?.state),
|
|
53
|
-
country: formatAddress(payload.address?.country),
|
|
54
|
-
zip_code: formatString(payload.address?.zip_code)
|
|
55
|
-
})
|
|
45
|
+
ttq.instance(settings.pixelCode).identify(getUser(payload))
|
|
56
46
|
}
|
|
57
47
|
}
|
|
58
48
|
}
|