@segment/action-destinations 3.260.0 → 3.261.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/destinations/chartmogul/index.js +1 -1
- package/dist/destinations/chartmogul/index.js.map +1 -1
- package/dist/destinations/gameball/index.js +1 -1
- package/dist/destinations/gameball/index.js.map +1 -1
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js +2 -2
- package/dist/destinations/hubspot/upsertCustomObjectRecord/index.js.map +1 -1
- package/dist/destinations/index.js +1 -0
- package/dist/destinations/index.js.map +1 -1
- package/dist/destinations/inleads-ai/common-fields.d.ts +3 -0
- package/dist/destinations/inleads-ai/common-fields.js +238 -0
- package/dist/destinations/inleads-ai/common-fields.js.map +1 -0
- package/dist/destinations/inleads-ai/contants.d.ts +4 -0
- package/dist/destinations/inleads-ai/contants.js +8 -0
- package/dist/destinations/inleads-ai/contants.js.map +1 -0
- package/dist/destinations/inleads-ai/generated-types.d.ts +3 -0
- package/dist/destinations/inleads-ai/generated-types.js +3 -0
- package/dist/destinations/inleads-ai/generated-types.js.map +1 -0
- package/dist/destinations/inleads-ai/group/generated-types.d.ts +44 -0
- package/dist/destinations/inleads-ai/group/generated-types.js +3 -0
- package/dist/destinations/inleads-ai/group/generated-types.js.map +1 -0
- package/dist/destinations/inleads-ai/group/index.d.ts +5 -0
- package/dist/destinations/inleads-ai/group/index.js +76 -0
- package/dist/destinations/inleads-ai/group/index.js.map +1 -0
- package/dist/destinations/inleads-ai/identify/generated-types.d.ts +46 -0
- package/dist/destinations/inleads-ai/identify/generated-types.js +3 -0
- package/dist/destinations/inleads-ai/identify/generated-types.js.map +1 -0
- package/dist/destinations/inleads-ai/identify/index.d.ts +5 -0
- package/dist/destinations/inleads-ai/identify/index.js +120 -0
- package/dist/destinations/inleads-ai/identify/index.js.map +1 -0
- package/dist/destinations/inleads-ai/index.d.ts +4 -0
- package/dist/destinations/inleads-ai/index.js +66 -0
- package/dist/destinations/inleads-ai/index.js.map +1 -0
- package/dist/destinations/inleads-ai/track/generated-types.d.ts +45 -0
- package/dist/destinations/inleads-ai/track/generated-types.js +3 -0
- package/dist/destinations/inleads-ai/track/generated-types.js.map +1 -0
- package/dist/destinations/inleads-ai/track/index.d.ts +5 -0
- package/dist/destinations/inleads-ai/track/index.js +64 -0
- package/dist/destinations/inleads-ai/track/index.js.map +1 -0
- package/dist/destinations/kameleoon/group/generated-types.d.ts +1 -0
- package/dist/destinations/kameleoon/group/index.js +9 -0
- package/dist/destinations/kameleoon/group/index.js.map +1 -1
- package/dist/destinations/kameleoon/identify/generated-types.d.ts +1 -0
- package/dist/destinations/kameleoon/identify/index.js +9 -0
- package/dist/destinations/kameleoon/identify/index.js.map +1 -1
- package/dist/destinations/kameleoon/page/generated-types.d.ts +1 -0
- package/dist/destinations/kameleoon/page/index.js +9 -0
- package/dist/destinations/kameleoon/page/index.js.map +1 -1
- package/dist/destinations/klaviyo/index.js +3 -1
- package/dist/destinations/klaviyo/index.js.map +1 -1
- package/dist/destinations/klaviyo/orderCompleted/generated-types.d.ts +1 -4
- package/dist/destinations/klaviyo/orderCompleted/index.js +6 -15
- package/dist/destinations/klaviyo/orderCompleted/index.js.map +1 -1
- package/dist/destinations/klaviyo/removeProfile/generated-types.d.ts +6 -0
- package/dist/destinations/klaviyo/removeProfile/generated-types.js +3 -0
- package/dist/destinations/klaviyo/removeProfile/generated-types.js.map +1 -0
- package/dist/destinations/klaviyo/removeProfile/index.d.ts +5 -0
- package/dist/destinations/klaviyo/removeProfile/index.js +57 -0
- package/dist/destinations/klaviyo/removeProfile/index.js.map +1 -0
- package/dist/destinations/klaviyo/trackEvent/index.js +1 -0
- package/dist/destinations/klaviyo/trackEvent/index.js.map +1 -1
- package/dist/destinations/klaviyo/types.d.ts +3 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js +2 -2
- package/dist/destinations/liveramp-audiences/audienceEnteredS3/index.js.map +1 -1
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js +2 -2
- package/dist/destinations/liveramp-audiences/audienceEnteredSftp/index.js.map +1 -1
- package/dist/destinations/segment/segment-properties.d.ts +1 -0
- package/dist/destinations/segment/segment-properties.js +8 -1
- package/dist/destinations/segment/segment-properties.js.map +1 -1
- package/dist/destinations/segment/sendGroup/generated-types.d.ts +1 -0
- package/dist/destinations/segment/sendGroup/index.js +2 -0
- package/dist/destinations/segment/sendGroup/index.js.map +1 -1
- package/dist/destinations/segment/sendIdentify/generated-types.d.ts +1 -0
- package/dist/destinations/segment/sendIdentify/index.js +2 -0
- package/dist/destinations/segment/sendIdentify/index.js.map +1 -1
- package/dist/destinations/segment/sendPage/generated-types.d.ts +1 -0
- package/dist/destinations/segment/sendPage/index.js +2 -0
- package/dist/destinations/segment/sendPage/index.js.map +1 -1
- package/dist/destinations/segment/sendScreen/generated-types.d.ts +1 -0
- package/dist/destinations/segment/sendScreen/index.js +2 -0
- package/dist/destinations/segment/sendScreen/index.js.map +1 -1
- package/dist/destinations/segment/sendTrack/generated-types.d.ts +1 -0
- package/dist/destinations/segment/sendTrack/index.js +2 -0
- package/dist/destinations/segment/sendTrack/index.js.map +1 -1
- package/dist/destinations/segment-profiles/segment-properties.d.ts +1 -0
- package/dist/destinations/segment-profiles/segment-properties.js +8 -1
- package/dist/destinations/segment-profiles/segment-properties.js.map +1 -1
- package/dist/destinations/segment-profiles/sendGroup/generated-types.d.ts +1 -0
- package/dist/destinations/segment-profiles/sendGroup/index.js +3 -1
- package/dist/destinations/segment-profiles/sendGroup/index.js.map +1 -1
- package/dist/destinations/segment-profiles/sendIdentify/generated-types.d.ts +1 -0
- package/dist/destinations/segment-profiles/sendIdentify/index.js +3 -1
- package/dist/destinations/segment-profiles/sendIdentify/index.js.map +1 -1
- package/dist/destinations/segment-profiles/sendSubscription/generated-types.d.ts +1 -0
- package/dist/destinations/segment-profiles/sendSubscription/index.js +3 -1
- package/dist/destinations/segment-profiles/sendSubscription/index.js.map +1 -1
- package/dist/destinations/segment-profiles/sendSubscription/subscription-properties.d.ts +1 -0
- package/dist/destinations/segment-profiles/sendSubscription/subscription-properties.js +8 -1
- package/dist/destinations/segment-profiles/sendSubscription/subscription-properties.js.map +1 -1
- package/dist/destinations/segment-profiles/sendTrack/generated-types.d.ts +1 -0
- package/dist/destinations/segment-profiles/sendTrack/index.js +3 -1
- package/dist/destinations/segment-profiles/sendTrack/index.js.map +1 -1
- package/dist/destinations/tiktok-conversions/common_fields.d.ts +2 -0
- package/dist/destinations/tiktok-conversions/common_fields.js +244 -0
- package/dist/destinations/tiktok-conversions/common_fields.js.map +1 -0
- package/dist/destinations/tiktok-conversions/formatter.d.ts +3 -0
- package/dist/destinations/tiktok-conversions/formatter.js +43 -0
- package/dist/destinations/tiktok-conversions/formatter.js.map +1 -0
- package/dist/destinations/tiktok-conversions/index.js +163 -75
- package/dist/destinations/tiktok-conversions/index.js.map +1 -1
- package/dist/destinations/tiktok-conversions/reportWebEvent/generated-types.d.ts +12 -4
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.d.ts +1 -1
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.js +5 -233
- package/dist/destinations/tiktok-conversions/reportWebEvent/index.js.map +1 -1
- package/dist/destinations/tiktok-conversions/utils.d.ts +4 -0
- package/dist/destinations/tiktok-conversions/utils.js +65 -0
- package/dist/destinations/tiktok-conversions/utils.js.map +1 -0
- package/package.json +2 -2
- package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.d.ts +0 -3
- package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js +0 -34
- package/dist/destinations/tiktok-conversions/reportWebEvent/formatter.js.map +0 -1
|
@@ -2,11 +2,15 @@ export interface Payload {
|
|
|
2
2
|
event: string;
|
|
3
3
|
event_id?: string;
|
|
4
4
|
timestamp?: string;
|
|
5
|
-
phone_number?: string;
|
|
6
|
-
email?: string;
|
|
7
|
-
|
|
5
|
+
phone_number?: string[];
|
|
6
|
+
email?: string[];
|
|
7
|
+
order_id?: string;
|
|
8
|
+
shop_id?: string;
|
|
9
|
+
external_id?: string[];
|
|
8
10
|
ttclid?: string;
|
|
11
|
+
ttp?: string;
|
|
9
12
|
lead_id?: string;
|
|
13
|
+
locale?: string;
|
|
10
14
|
url?: string;
|
|
11
15
|
referrer?: string;
|
|
12
16
|
ip?: string;
|
|
@@ -14,12 +18,16 @@ export interface Payload {
|
|
|
14
18
|
contents?: {
|
|
15
19
|
price?: number;
|
|
16
20
|
quantity?: number;
|
|
17
|
-
|
|
21
|
+
content_category?: string;
|
|
18
22
|
content_id?: string;
|
|
23
|
+
content_name?: string;
|
|
24
|
+
brand?: string;
|
|
19
25
|
}[];
|
|
26
|
+
content_type?: string;
|
|
20
27
|
currency?: string;
|
|
21
28
|
value?: number;
|
|
22
29
|
description?: string;
|
|
23
30
|
query?: string;
|
|
31
|
+
limited_data_use?: boolean;
|
|
24
32
|
test_event_code?: string;
|
|
25
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ActionDefinition } from '@segment/actions-core';
|
|
2
2
|
import type { Settings } from '../generated-types';
|
|
3
3
|
import type { Payload } from './generated-types';
|
|
4
4
|
declare const action: ActionDefinition<Settings, Payload>;
|
|
@@ -1,243 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
3
|
+
const common_fields_1 = require("../common_fields");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
4
5
|
const action = {
|
|
5
6
|
title: 'Report Web Event',
|
|
6
|
-
description: 'Report events directly to TikTok. Data shared can power TikTok solutions like dynamic product ads, custom targeting, campaign optimization and attribution.',
|
|
7
|
+
description: 'Report Web events directly to TikTok. Data shared can power TikTok solutions like dynamic product ads, custom targeting, campaign optimization and attribution.',
|
|
7
8
|
fields: {
|
|
8
|
-
|
|
9
|
-
label: 'Event Name',
|
|
10
|
-
type: 'string',
|
|
11
|
-
required: true,
|
|
12
|
-
description: 'Conversion event name. Please refer to the "Supported Web Events" section on in TikTok’s [Events API documentation](https://ads.tiktok.com/marketing_api/docs?id=1701890979375106) for accepted event names.'
|
|
13
|
-
},
|
|
14
|
-
event_id: {
|
|
15
|
-
label: 'Event ID',
|
|
16
|
-
type: 'string',
|
|
17
|
-
description: 'Any hashed ID that can identify a unique user/session.',
|
|
18
|
-
default: {
|
|
19
|
-
'@path': '$.messageId'
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
timestamp: {
|
|
23
|
-
label: 'Event Timestamp',
|
|
24
|
-
type: 'string',
|
|
25
|
-
description: 'Timestamp that the event took place, in ISO 8601 format.',
|
|
26
|
-
default: {
|
|
27
|
-
'@path': '$.timestamp'
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
phone_number: {
|
|
31
|
-
label: 'Phone Number',
|
|
32
|
-
description: 'Phone number of the user who triggered the conversion event, in E.164 standard format, e.g. +14150000000. Segment will hash this value before sending to TikTok.',
|
|
33
|
-
type: 'string',
|
|
34
|
-
default: {
|
|
35
|
-
'@if': {
|
|
36
|
-
exists: { '@path': '$.properties.phone' },
|
|
37
|
-
then: { '@path': '$.properties.phone' },
|
|
38
|
-
else: { '@path': '$.traits.phone' }
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
email: {
|
|
43
|
-
label: 'Email',
|
|
44
|
-
description: 'Email address of the user who triggered the conversion event. Segment will hash this value before sending to TikTok.',
|
|
45
|
-
type: 'string',
|
|
46
|
-
format: 'email',
|
|
47
|
-
default: {
|
|
48
|
-
'@if': {
|
|
49
|
-
exists: { '@path': '$.properties.email' },
|
|
50
|
-
then: { '@path': '$.properties.email' },
|
|
51
|
-
else: { '@path': '$.traits.email' }
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
external_id: {
|
|
56
|
-
label: 'External ID',
|
|
57
|
-
description: 'Uniquely identifies the user who triggered the conversion event. Segment will hash this value before sending to TikTok.',
|
|
58
|
-
type: 'string',
|
|
59
|
-
default: {
|
|
60
|
-
'@if': {
|
|
61
|
-
exists: { '@path': '$.userId' },
|
|
62
|
-
then: { '@path': '$.userId' },
|
|
63
|
-
else: { '@path': '$.anonymousId' }
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
ttclid: {
|
|
68
|
-
label: 'TikTok Click ID',
|
|
69
|
-
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.',
|
|
70
|
-
type: 'string',
|
|
71
|
-
default: {
|
|
72
|
-
'@if': {
|
|
73
|
-
exists: { '@path': '$.properties.ttclid' },
|
|
74
|
-
then: { '@path': '$.properties.ttclid' },
|
|
75
|
-
else: { '@path': '$.traits.ttclid' }
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
lead_id: {
|
|
80
|
-
label: 'TikTok Lead ID',
|
|
81
|
-
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',
|
|
82
|
-
type: 'string',
|
|
83
|
-
default: {
|
|
84
|
-
'@if': {
|
|
85
|
-
exists: { '@path': '$.properties.lead_id' },
|
|
86
|
-
then: { '@path': '$.properties.lead_id' },
|
|
87
|
-
else: { '@path': '$.traits.lead_id' }
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
url: {
|
|
92
|
-
label: 'Page URL',
|
|
93
|
-
type: 'string',
|
|
94
|
-
description: 'The page URL where the conversion event took place.',
|
|
95
|
-
default: {
|
|
96
|
-
'@path': '$.context.page.url'
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
referrer: {
|
|
100
|
-
label: 'Page Referrer',
|
|
101
|
-
type: 'string',
|
|
102
|
-
description: 'The page referrer.',
|
|
103
|
-
default: {
|
|
104
|
-
'@path': '$.context.page.referrer'
|
|
105
|
-
}
|
|
106
|
-
},
|
|
107
|
-
ip: {
|
|
108
|
-
label: 'IP Address',
|
|
109
|
-
type: 'string',
|
|
110
|
-
description: 'IP address of the browser.',
|
|
111
|
-
default: {
|
|
112
|
-
'@path': '$.context.ip'
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
user_agent: {
|
|
116
|
-
label: 'User Agent',
|
|
117
|
-
type: 'string',
|
|
118
|
-
description: 'User agent from the user’s device.',
|
|
119
|
-
default: {
|
|
120
|
-
'@path': '$.context.userAgent'
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
contents: {
|
|
124
|
-
label: 'Contents',
|
|
125
|
-
type: 'object',
|
|
126
|
-
multiple: true,
|
|
127
|
-
description: 'Related items in a web event.',
|
|
128
|
-
properties: {
|
|
129
|
-
price: {
|
|
130
|
-
label: 'Price',
|
|
131
|
-
description: 'Price of the item.',
|
|
132
|
-
type: 'number'
|
|
133
|
-
},
|
|
134
|
-
quantity: {
|
|
135
|
-
label: 'Quantity',
|
|
136
|
-
description: 'Number of items.',
|
|
137
|
-
type: 'number'
|
|
138
|
-
},
|
|
139
|
-
content_type: {
|
|
140
|
-
label: 'Content Type',
|
|
141
|
-
description: 'Type of the product item.',
|
|
142
|
-
type: 'string'
|
|
143
|
-
},
|
|
144
|
-
content_id: {
|
|
145
|
-
label: 'Content ID',
|
|
146
|
-
description: 'ID of the product item.',
|
|
147
|
-
type: 'string'
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
currency: {
|
|
152
|
-
label: 'Currency',
|
|
153
|
-
type: 'string',
|
|
154
|
-
description: 'Currency for the value specified as ISO 4217 code.',
|
|
155
|
-
default: {
|
|
156
|
-
'@path': '$.properties.currency'
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
value: {
|
|
160
|
-
label: 'Value',
|
|
161
|
-
type: 'number',
|
|
162
|
-
description: 'Value of the order or items sold.',
|
|
163
|
-
default: {
|
|
164
|
-
'@if': {
|
|
165
|
-
exists: { '@path': '$.properties.value' },
|
|
166
|
-
then: { '@path': '$.properties.value' },
|
|
167
|
-
else: { '@path': '$.properties.revenue' }
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
description: {
|
|
172
|
-
label: 'Description',
|
|
173
|
-
type: 'string',
|
|
174
|
-
description: 'A string description of the web event.'
|
|
175
|
-
},
|
|
176
|
-
query: {
|
|
177
|
-
label: 'Query',
|
|
178
|
-
type: 'string',
|
|
179
|
-
description: 'The text string that was searched for.',
|
|
180
|
-
default: {
|
|
181
|
-
'@path': '$.properties.query'
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
test_event_code: {
|
|
185
|
-
label: 'Test Event Code',
|
|
186
|
-
type: 'string',
|
|
187
|
-
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.'
|
|
188
|
-
}
|
|
9
|
+
...common_fields_1.commonFields
|
|
189
10
|
},
|
|
190
11
|
perform: (request, { payload, settings }) => {
|
|
191
|
-
|
|
192
|
-
hashedExternalId: formatter_1.formatUserId(payload.external_id),
|
|
193
|
-
hashedEmail: formatter_1.formatEmail(payload.email),
|
|
194
|
-
hashedPhoneNumber: formatter_1.formatPhone(payload.phone_number)
|
|
195
|
-
};
|
|
196
|
-
let payloadUrl, urlTtclid;
|
|
197
|
-
if (payload.url) {
|
|
198
|
-
try {
|
|
199
|
-
payloadUrl = new URL(payload.url);
|
|
200
|
-
}
|
|
201
|
-
catch (error) {
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
if (payloadUrl)
|
|
205
|
-
urlTtclid = payloadUrl.searchParams.get('ttclid');
|
|
206
|
-
return request('https://business-api.tiktok.com/open_api/v1.3/pixel/track/', {
|
|
207
|
-
method: 'post',
|
|
208
|
-
json: {
|
|
209
|
-
pixel_code: settings.pixelCode,
|
|
210
|
-
event: payload.event,
|
|
211
|
-
event_id: payload.event_id ? `${payload.event_id}` : undefined,
|
|
212
|
-
timestamp: payload.timestamp,
|
|
213
|
-
test_event_code: payload.test_event_code,
|
|
214
|
-
context: {
|
|
215
|
-
user: {
|
|
216
|
-
external_id: userData.hashedExternalId,
|
|
217
|
-
phone_number: userData.hashedPhoneNumber,
|
|
218
|
-
email: userData.hashedEmail,
|
|
219
|
-
lead_id: payload.lead_id
|
|
220
|
-
},
|
|
221
|
-
ad: {
|
|
222
|
-
callback: payload.ttclid ? payload.ttclid : urlTtclid ? urlTtclid : undefined
|
|
223
|
-
},
|
|
224
|
-
page: {
|
|
225
|
-
url: payload.url,
|
|
226
|
-
referrer: payload.referrer
|
|
227
|
-
},
|
|
228
|
-
ip: payload.ip,
|
|
229
|
-
user_agent: payload.user_agent
|
|
230
|
-
},
|
|
231
|
-
properties: {
|
|
232
|
-
contents: payload.contents,
|
|
233
|
-
currency: payload.currency,
|
|
234
|
-
value: payload.value,
|
|
235
|
-
description: payload.description,
|
|
236
|
-
query: payload.query
|
|
237
|
-
},
|
|
238
|
-
partner_name: 'Segment'
|
|
239
|
-
}
|
|
240
|
-
});
|
|
12
|
+
return utils_1.performWebEvent(request, settings, payload);
|
|
241
13
|
}
|
|
242
14
|
};
|
|
243
15
|
exports.default = action;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/tiktok-conversions/reportWebEvent/index.ts"],"names":[],"mappings":";;AAGA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/destinations/tiktok-conversions/reportWebEvent/index.ts"],"names":[],"mappings":";;AAGA,oDAA+C;AAC/C,oCAA0C;AAE1C,MAAM,MAAM,GAAwC;IAClD,KAAK,EAAE,kBAAkB;IACzB,WAAW,EACT,iKAAiK;IACnK,MAAM,EAAE;QACN,GAAG,4BAAY;KAChB;IACD,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,OAAO,uBAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IACpD,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RequestClient } from '@segment/actions-core';
|
|
2
|
+
import { Settings } from './generated-types';
|
|
3
|
+
import { Payload } from './reportWebEvent/generated-types';
|
|
4
|
+
export declare function performWebEvent(request: RequestClient, settings: Settings, payload: Payload): Promise<import("@segment/actions-core").ModifiedResponse<unknown>>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.performWebEvent = void 0;
|
|
4
|
+
const formatter_1 = require("./formatter");
|
|
5
|
+
function performWebEvent(request, settings, payload) {
|
|
6
|
+
const phone_numbers = formatter_1.formatPhones(payload.phone_number);
|
|
7
|
+
const emails = formatter_1.formatEmails(payload.email);
|
|
8
|
+
const userIds = formatter_1.formatUserIds(payload.external_id);
|
|
9
|
+
let payloadUrl, urlTtclid;
|
|
10
|
+
if (payload.url) {
|
|
11
|
+
try {
|
|
12
|
+
payloadUrl = new URL(payload.url);
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (payloadUrl)
|
|
18
|
+
urlTtclid = payloadUrl.searchParams.get('ttclid');
|
|
19
|
+
return request('https://business-api.tiktok.com/open_api/v1.3/event/track/', {
|
|
20
|
+
method: 'post',
|
|
21
|
+
json: {
|
|
22
|
+
event_source: 'web',
|
|
23
|
+
event_source_id: settings.pixelCode,
|
|
24
|
+
partner_name: 'Segment',
|
|
25
|
+
data: [
|
|
26
|
+
{
|
|
27
|
+
event: payload.event,
|
|
28
|
+
event_time: payload.timestamp
|
|
29
|
+
? Math.floor(new Date(payload.timestamp).getTime() / 1000)
|
|
30
|
+
: Math.floor(new Date().getTime() / 1000),
|
|
31
|
+
event_id: payload.event_id ? `${payload.event_id}` : undefined,
|
|
32
|
+
user: {
|
|
33
|
+
ttclid: payload.ttclid ? payload.ttclid : urlTtclid ? urlTtclid : undefined,
|
|
34
|
+
external_id: userIds,
|
|
35
|
+
phone: phone_numbers,
|
|
36
|
+
email: emails,
|
|
37
|
+
lead_id: payload.lead_id ? payload.lead_id : undefined,
|
|
38
|
+
ttp: payload.ttp ? payload.ttp : undefined,
|
|
39
|
+
ip: payload.ip ? payload.ip : undefined,
|
|
40
|
+
user_agent: payload.user_agent ? payload.user_agent : undefined,
|
|
41
|
+
locale: payload.locale ? payload.locale : undefined
|
|
42
|
+
},
|
|
43
|
+
properties: {
|
|
44
|
+
contents: payload.contents ? payload.contents : [],
|
|
45
|
+
content_type: payload.content_type ? payload.content_type : undefined,
|
|
46
|
+
currency: payload.currency ? payload.currency : undefined,
|
|
47
|
+
value: payload.value ? payload.value : undefined,
|
|
48
|
+
query: payload.query ? payload.query : undefined,
|
|
49
|
+
description: payload.description ? payload.description : undefined,
|
|
50
|
+
order_id: payload.order_id ? payload.order_id : undefined,
|
|
51
|
+
shop_id: payload.shop_id ? payload.shop_id : undefined
|
|
52
|
+
},
|
|
53
|
+
page: {
|
|
54
|
+
url: payload.url ? payload.url : undefined,
|
|
55
|
+
referrer: payload.referrer ? payload.referrer : undefined
|
|
56
|
+
},
|
|
57
|
+
limited_data_use: payload.limited_data_use ? payload.limited_data_use : false,
|
|
58
|
+
test_event_code: payload.test_event_code ? payload.test_event_code : undefined
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
exports.performWebEvent = performWebEvent;
|
|
65
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/destinations/tiktok-conversions/utils.ts"],"names":[],"mappings":";;;AAGA,2CAA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C,WAAW,CAAC,CAAC,CAAC,SAAS;wBAClE,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;AA5DD,0CA4DC"}
|
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.
|
|
4
|
+
"version": "3.261.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/segmentio/action-destinations",
|
|
@@ -86,5 +86,5 @@
|
|
|
86
86
|
"__tests__/__helpers__/"
|
|
87
87
|
]
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "959c7a6bf59896ee7000dfcca8b1d0e3c6b2c93f"
|
|
90
90
|
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatPhone = exports.formatUserId = exports.formatEmail = void 0;
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
|
-
function formatEmail(email) {
|
|
6
|
-
if (email) {
|
|
7
|
-
return hashAndEncode(email.toLowerCase());
|
|
8
|
-
}
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
11
|
-
exports.formatEmail = formatEmail;
|
|
12
|
-
function formatUserId(userId) {
|
|
13
|
-
if (userId) {
|
|
14
|
-
return hashAndEncode(userId.toLowerCase().trim());
|
|
15
|
-
}
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
exports.formatUserId = formatUserId;
|
|
19
|
-
function formatPhone(phone) {
|
|
20
|
-
if (!phone)
|
|
21
|
-
return undefined;
|
|
22
|
-
const validatedPhone = phone.match(/[0-9]{0,14}/g);
|
|
23
|
-
if (validatedPhone === null) {
|
|
24
|
-
throw new Error(`${phone} is not a valid E.164 phone number.`);
|
|
25
|
-
}
|
|
26
|
-
let formattedPhone = `+${phone.replace(/[^0-9]/g, '')}`;
|
|
27
|
-
formattedPhone = formattedPhone.substring(0, 15);
|
|
28
|
-
return hashAndEncode(formattedPhone);
|
|
29
|
-
}
|
|
30
|
-
exports.formatPhone = formatPhone;
|
|
31
|
-
function hashAndEncode(property) {
|
|
32
|
-
return crypto_1.createHash('sha256').update(property).digest('hex');
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../../../src/destinations/tiktok-conversions/reportWebEvent/formatter.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAKnC,SAAgB,WAAW,CAAC,KAAyB;IACnD,IAAI,KAAK,EAAE;QACT,OAAO,aAAa,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;KAC1C;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AALD,kCAKC;AAOD,SAAgB,YAAY,CAAC,MAA0B;IACrD,IAAI,MAAM,EAAE;QACV,OAAO,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;KAClD;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AALD,oCAKC;AAOD,SAAgB,WAAW,CAAC,KAAyB;IACnD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAE5B,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,CAAA;IAClD,IAAI,cAAc,KAAK,IAAI,EAAE;QAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,qCAAqC,CAAC,CAAA;KAC/D;IAED,IAAI,cAAc,GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAA;IAEvD,cAAc,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAChD,OAAO,aAAa,CAAC,cAAc,CAAC,CAAA;AACtC,CAAC;AAZD,kCAYC;AAED,SAAS,aAAa,CAAC,QAAgB;IACrC,OAAO,mBAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC5D,CAAC"}
|