@segment/analytics-browser-actions-facebook-conversions-api-web 1.9.0 → 1.9.1-staging-c01044061.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.
@@ -3,353 +3,361 @@ import { getDependenciesFor } from './depends-on'
3
3
  import { CURRENCY_ISO_CODES } from '../constants'
4
4
 
5
5
  export const event_config: InputField = {
6
- label: 'Event Configuration',
7
- description: 'Specify the type of Facebook Conversions API event to send.',
8
- type: 'object',
9
- required: true,
10
- additionalProperties: false,
11
- defaultObjectUI: 'keyvalue',
12
- properties: {
13
- event_name: {
14
- label: 'Event Name',
15
- description: "Facebook Conversions API Event Name to send. Select 'Custom Event' to send a non standard event.",
16
- type: 'string',
17
- required: true,
18
- choices: [
19
- { label: 'Custom Event', value: 'CustomEvent' },
20
- { label: 'Page View', value: 'PageView' },
21
- { label: 'Add Payment Info', value: 'AddPaymentInfo' },
22
- { label: 'Add To Cart', value: 'AddToCart' },
23
- { label: 'Add To Wishlist', value: 'AddToWishlist' },
24
- { label: 'Complete Registration', value: 'CompleteRegistration' },
25
- { label: 'Contact', value: 'Contact' },
26
- { label: 'Customize Product', value: 'CustomizeProduct' },
27
- { label: 'Donate', value: 'Donate' },
28
- { label: 'Find Location', value: 'FindLocation' },
29
- { label: 'Initiate Checkout', value: 'InitiateCheckout' },
30
- { label: 'Lead', value: 'Lead' },
31
- { label: 'Purchase', value: 'Purchase' },
32
- { label: 'Schedule', value: 'Schedule' },
33
- { label: 'Search', value: 'Search' },
34
- { label: 'Start Trial', value: 'StartTrial' },
35
- { label: 'Submit Application', value: 'SubmitApplication' },
36
- { label: 'Subscribe', value: 'Subscribe' },
37
- { label: 'View Content', value: 'ViewContent' }
38
- ]
39
- },
40
- custom_event_name:{
41
- label: 'Custom Event Name',
42
- description: 'Custom event name to send to Facebook',
43
- type: 'string',
44
- depends_on: getDependenciesFor('custom_event_name')
45
- },
46
- show_fields: {
47
- label: 'Show all fields',
48
- description: 'Show all fields, even those which are not relevant to the selected Event Name.',
49
- type: 'boolean',
50
- default: false
51
- }
6
+ label: 'Event Configuration',
7
+ description: 'Specify the type of Facebook Conversions API event to send.',
8
+ type: 'object',
9
+ required: true,
10
+ additionalProperties: false,
11
+ defaultObjectUI: 'keyvalue',
12
+ properties: {
13
+ event_name: {
14
+ label: 'Event Name',
15
+ description: "Facebook Conversions API Event Name to send. Select 'Custom Event' to send a non standard event.",
16
+ type: 'string',
17
+ required: true,
18
+ choices: [
19
+ { label: 'Custom Event', value: 'CustomEvent' },
20
+ { label: 'Page View', value: 'PageView' },
21
+ { label: 'Add Payment Info', value: 'AddPaymentInfo' },
22
+ { label: 'Add To Cart', value: 'AddToCart' },
23
+ { label: 'Add To Wishlist', value: 'AddToWishlist' },
24
+ { label: 'Complete Registration', value: 'CompleteRegistration' },
25
+ { label: 'Contact', value: 'Contact' },
26
+ { label: 'Customize Product', value: 'CustomizeProduct' },
27
+ { label: 'Donate', value: 'Donate' },
28
+ { label: 'Find Location', value: 'FindLocation' },
29
+ { label: 'Initiate Checkout', value: 'InitiateCheckout' },
30
+ { label: 'Lead', value: 'Lead' },
31
+ { label: 'Purchase', value: 'Purchase' },
32
+ { label: 'Schedule', value: 'Schedule' },
33
+ { label: 'Search', value: 'Search' },
34
+ { label: 'Start Trial', value: 'StartTrial' },
35
+ { label: 'Submit Application', value: 'SubmitApplication' },
36
+ { label: 'Subscribe', value: 'Subscribe' },
37
+ { label: 'View Content', value: 'ViewContent' }
38
+ ]
52
39
  },
53
- default: {
54
- event_name: 'CustomEvent',
55
- custom_event_name: {'@path': '$.event'},
56
- show_fields: false
40
+ custom_event_name: {
41
+ label: 'Custom Event Name',
42
+ description: 'Custom event name to send to Facebook',
43
+ type: 'string',
44
+ depends_on: getDependenciesFor('custom_event_name')
45
+ },
46
+ show_fields: {
47
+ label: 'Show all fields',
48
+ description: 'Show all fields, even those which are not relevant to the selected Event Name.',
49
+ type: 'boolean',
50
+ default: false
57
51
  }
52
+ },
53
+ default: {
54
+ event_name: 'CustomEvent',
55
+ custom_event_name: { '@path': '$.event' },
56
+ show_fields: false
57
+ }
58
58
  }
59
59
 
60
60
  export const content_category: InputField = {
61
- label: 'Content Category',
62
- description: 'The category of the content associated with the event.',
63
- type: 'string',
64
- default: { '@path': '$.properties.category' },
65
- depends_on: getDependenciesFor('content_category')
61
+ label: 'Content Category',
62
+ description: 'The category of the content associated with the event.',
63
+ type: 'string',
64
+ default: { '@path': '$.properties.category' },
65
+ depends_on: getDependenciesFor('content_category')
66
66
  }
67
67
 
68
68
  export const content_name: InputField = {
69
- label: 'Content Name',
70
- description: 'The name of the page or product associated with the event.',
71
- type: 'string',
72
- default: { '@path': '$.properties.name' },
73
- depends_on: getDependenciesFor('content_name')
69
+ label: 'Content Name',
70
+ description: 'The name of the page or product associated with the event.',
71
+ type: 'string',
72
+ default: { '@path': '$.properties.name' },
73
+ depends_on: getDependenciesFor('content_name')
74
74
  }
75
75
 
76
76
  export const content_type: InputField = {
77
- label: 'Content Type',
78
- description:
79
- 'If the IDs being passed in content_ids or contents parameter are IDs of products, then the value should be product. If product group IDs are being passed, then the value should be product_group. If no content_type is provided, Meta will match the event to every item that has the same ID, independent of its type.',
80
- type: 'string',
81
- choices: [
82
- { value: 'product', label: 'Product' },
83
- { value: 'product_group', label: 'Product Group' }
84
- ],
85
- default: 'product',
86
- depends_on: getDependenciesFor('content_type')
77
+ label: 'Content Type',
78
+ description:
79
+ 'If the IDs being passed in content_ids or contents parameter are IDs of products, then the value should be product. If product group IDs are being passed, then the value should be product_group. If no content_type is provided, Meta will match the event to every item that has the same ID, independent of its type.',
80
+ type: 'string',
81
+ choices: [
82
+ { value: 'product', label: 'Product' },
83
+ { value: 'product_group', label: 'Product Group' }
84
+ ],
85
+ default: 'product',
86
+ depends_on: getDependenciesFor('content_type')
87
87
  }
88
88
 
89
89
  export const content_ids: InputField = {
90
- label: 'Content IDs',
91
- description: "Product IDs associated with the event, such as SKUs (e.g. ['ABC123', 'XYZ789']). Accepts a single string value or array of strings.",
92
- type: 'string',
93
- multiple: true,
94
- default: { "@liquid": "{{ properties.products | map: 'product_id' }}"}
95
- ,
96
- depends_on: getDependenciesFor('content_ids')
90
+ label: 'Content IDs',
91
+ description:
92
+ "Product IDs associated with the event, such as SKUs (e.g. ['ABC123', 'XYZ789']). Accepts a single string value or array of strings.",
93
+ type: 'string',
94
+ multiple: true,
95
+ default: { '@liquid': "{{ properties.products | map: 'product_id' }}" },
96
+ depends_on: getDependenciesFor('content_ids')
97
97
  }
98
98
 
99
99
  export const contents: InputField = {
100
- label: 'Contents',
101
- description: 'A list of JSON objects that contain the product IDs associated with the event plus information about the products. ID and quantity are required fields.',
102
- type: 'object',
103
- multiple: true,
104
- additionalProperties: true,
105
- defaultObjectUI: 'keyvalue',
106
- properties: {
107
- id: {
108
- label: 'ID',
109
- description: 'The product ID of the purchased item.',
110
- type: 'string',
111
- required: true
112
- },
113
- quantity: {
114
- label: 'Quantity',
115
- description: 'The number of items purchased.',
116
- type: 'integer',
117
- required: true
118
- },
119
- item_price: {
120
- label: 'Item Price',
121
- description: 'The price of the item.',
122
- type: 'number'
123
- }
100
+ label: 'Contents',
101
+ description:
102
+ 'A list of JSON objects that contain the product IDs associated with the event plus information about the products. ID and quantity are required fields.',
103
+ type: 'object',
104
+ multiple: true,
105
+ additionalProperties: true,
106
+ defaultObjectUI: 'keyvalue',
107
+ properties: {
108
+ id: {
109
+ label: 'ID',
110
+ description: 'The product ID of the purchased item.',
111
+ type: 'string',
112
+ required: true
124
113
  },
125
- default: {
126
- '@arrayPath': [
127
- '$.properties.products',
128
- {
129
- id: { '@path': '$.product_id' },
130
- quantity: { '@path': '$.quantity' },
131
- item_price: { '@path': '$.price' }
132
- }
133
- ]
114
+ quantity: {
115
+ label: 'Quantity',
116
+ description: 'The number of items purchased.',
117
+ type: 'integer',
118
+ required: true
134
119
  },
135
- depends_on: getDependenciesFor('contents')
136
- }
120
+ item_price: {
121
+ label: 'Item Price',
122
+ description: 'The price of the item.',
123
+ type: 'number'
124
+ }
125
+ },
126
+ default: {
127
+ '@arrayPath': [
128
+ '$.properties.products',
129
+ {
130
+ id: { '@path': '$.product_id' },
131
+ quantity: { '@path': '$.quantity' },
132
+ item_price: { '@path': '$.price' }
133
+ }
134
+ ]
135
+ },
136
+ depends_on: getDependenciesFor('contents')
137
+ }
137
138
 
138
139
  export const currency: InputField = {
139
- label: 'Currency',
140
- description: 'The currency for the value specified. Currency must be a valid ISO 4217 three-digit currency code.',
141
- type: 'string',
142
- default: { '@path': '$.properties.currency' },
143
- depends_on: getDependenciesFor('currency'),
144
- choices:(() => {
145
- return [...CURRENCY_ISO_CODES].map(code => ({
146
- value: code,
147
- label: code
148
- }))
149
- })(),
150
- required: {
151
- match: 'all',
152
- conditions: [
153
- {
154
- fieldKey: 'event_config.event_name',
155
- operator: 'is',
156
- value: 'Purchase'
157
- }
158
- ]
159
- }
140
+ label: 'Currency',
141
+ description: 'The currency for the value specified. Currency must be a valid ISO 4217 three-digit currency code.',
142
+ type: 'string',
143
+ default: { '@path': '$.properties.currency' },
144
+ depends_on: getDependenciesFor('currency'),
145
+ choices: (() => {
146
+ return [...CURRENCY_ISO_CODES].map((code) => ({
147
+ value: code,
148
+ label: code
149
+ }))
150
+ })(),
151
+ required: {
152
+ match: 'all',
153
+ conditions: [
154
+ {
155
+ fieldKey: 'event_config.event_name',
156
+ operator: 'is',
157
+ value: 'Purchase'
158
+ }
159
+ ]
160
+ }
160
161
  }
161
162
 
162
163
  export const delivery_category: InputField = {
163
- label: 'Delivery Category',
164
- description: 'Category of the delivery',
165
- type: 'string',
166
- choices: [
167
- { value: 'in_store', label: 'In Store' },
168
- { value: 'curbside', label: 'Curbside' },
169
- { value: 'home_delivery', label: 'Home Delivery' }
170
- ],
171
- depends_on: getDependenciesFor('delivery_category')
164
+ label: 'Delivery Category',
165
+ description: 'Category of the delivery',
166
+ type: 'string',
167
+ choices: [
168
+ { value: 'in_store', label: 'In Store' },
169
+ { value: 'curbside', label: 'Curbside' },
170
+ { value: 'home_delivery', label: 'Home Delivery' }
171
+ ],
172
+ depends_on: getDependenciesFor('delivery_category')
172
173
  }
173
174
 
174
175
  export const num_items: InputField = {
175
- label: 'Number of Items',
176
- description: 'The number of items when checkout was initiated.',
177
- type: 'integer',
178
- default: { '@path': '$.properties.num_items' },
179
- depends_on: getDependenciesFor('num_items')
176
+ label: 'Number of Items',
177
+ description: 'The number of items when checkout was initiated.',
178
+ type: 'integer',
179
+ default: { '@path': '$.properties.num_items' },
180
+ depends_on: getDependenciesFor('num_items')
180
181
  }
181
182
 
182
183
  export const predicted_ltv: InputField = {
183
- label: 'Predicted LTV',
184
- description: 'Predicted lifetime value of a subscriber as defined by the advertiser and expressed as an exact value.',
185
- type: 'number',
186
- depends_on: getDependenciesFor('predicted_ltv')
184
+ label: 'Predicted LTV',
185
+ description: 'Predicted lifetime value of a subscriber as defined by the advertiser and expressed as an exact value.',
186
+ type: 'number',
187
+ depends_on: getDependenciesFor('predicted_ltv')
187
188
  }
188
189
 
189
190
  export const net_revenue: InputField = {
190
- label: 'Net Revenue',
191
- description: 'The net revenue associated with the purchase.',
192
- type: 'number',
193
- default: { '@path': '$.properties.net_revenue' },
194
- depends_on: getDependenciesFor('net_revenue')
191
+ label: 'Net Revenue',
192
+ description: 'The net revenue associated with the purchase.',
193
+ type: 'number',
194
+ default: { '@path': '$.properties.net_revenue' },
195
+ depends_on: getDependenciesFor('net_revenue')
195
196
  }
196
197
 
197
198
  export const search_string: InputField = {
198
- label: 'Search String',
199
- description: 'The string entered by the user for the search.',
200
- type: 'string',
201
- default: { '@path': '$.properties.query' },
202
- depends_on: getDependenciesFor('search_string')
199
+ label: 'Search String',
200
+ description: 'The string entered by the user for the search.',
201
+ type: 'string',
202
+ default: { '@path': '$.properties.query' },
203
+ depends_on: getDependenciesFor('search_string')
203
204
  }
204
205
 
205
206
  export const status: InputField = {
206
- label: 'Registration Status',
207
- description: 'The status of the registration. true for completed registrations, false otherwise.',
208
- type: 'boolean',
209
- depends_on: getDependenciesFor('status')
207
+ label: 'Registration Status',
208
+ description: 'The status of the registration. true for completed registrations, false otherwise.',
209
+ type: 'boolean',
210
+ depends_on: getDependenciesFor('status')
210
211
  }
211
212
 
212
213
  export const value: InputField = {
213
- label: 'Value',
214
- description: 'A numeric value associated with this event. This could be a monetary value or a value in some other metric.',
215
- type: 'number',
216
- default: { '@path': '$.properties.value' },
217
- depends_on: getDependenciesFor('value'),
218
- required: {
219
- match: 'all',
220
- conditions: [
221
- {
222
- fieldKey: 'event_config.event_name',
223
- operator: 'is',
224
- value: 'Purchase'
225
- }
226
- ]
227
- }
214
+ label: 'Value',
215
+ description:
216
+ 'A numeric value associated with this event. This could be a monetary value or a value in some other metric.',
217
+ type: 'number',
218
+ default: { '@path': '$.properties.value' },
219
+ depends_on: getDependenciesFor('value'),
220
+ required: {
221
+ match: 'all',
222
+ conditions: [
223
+ {
224
+ fieldKey: 'event_config.event_name',
225
+ operator: 'is',
226
+ value: 'Purchase'
227
+ }
228
+ ]
229
+ }
228
230
  }
229
231
 
230
232
  export const custom_data: InputField = {
231
- label: 'Custom Data',
232
- description: 'The custom data object can be used to pass custom properties.',
233
- type: 'object',
234
- additionalProperties: true,
235
- defaultObjectUI: 'keyvalue'
233
+ label: 'Custom Data',
234
+ description: 'The custom data object can be used to pass custom properties.',
235
+ type: 'object',
236
+ additionalProperties: true,
237
+ defaultObjectUI: 'keyvalue'
236
238
  }
237
239
 
238
240
  export const eventID: InputField = {
239
- label: 'Event ID',
240
- description: 'This ID can be any unique string. Event ID is used to deduplicate events sent both the server side Conversions API and the browser Pixel.',
241
- type: 'string',
242
- default: { '@path': '$.messageId' }
241
+ label: 'Event ID',
242
+ description:
243
+ 'This ID can be any unique string. Event ID is used to deduplicate events sent both the server side Conversions API and the browser Pixel.',
244
+ type: 'string',
245
+ default: { '@path': '$.messageId' }
243
246
  }
244
247
 
245
248
  export const eventSourceUrl: InputField = {
246
- label: 'Event Source URL',
247
- description: 'The URL of the page where the event occurred. Can be used to override the default URL taken from the current page.',
248
- type: 'string',
249
- default: { '@path': '$.context.page.url' }
249
+ label: 'Event Source URL',
250
+ description:
251
+ 'The URL of the page where the event occurred. Can be used to override the default URL taken from the current page.',
252
+ type: 'string',
253
+ default: { '@path': '$.context.page.url' }
250
254
  }
251
255
 
252
256
  export const userData: InputField = {
253
- label: 'User Data',
254
- description: 'User data to be sent with the event. This can include hashed identifiers like email, phone number, etc.',
255
- type: 'object',
256
- additionalProperties: false,
257
- defaultObjectUI: 'keyvalue',
258
- properties: {
259
- external_id: {
260
- label: 'External ID',
261
- description: 'A unique identifier for the user from your system',
262
- type: 'string'
263
- },
264
- em: {
265
- label: 'Email',
266
- description: 'Email address of the user',
267
- type: 'string',
268
- format: 'email'
269
- },
270
- ph: {
271
- label: 'Phone Number',
272
- description: 'Phone number of the user. Make sure to include the country code. For example, "15551234567" for a US number.',
273
- type: 'string'
274
- },
275
- fn: {
276
- label: 'First Name',
277
- description: 'First name of the user',
278
- type: 'string'
279
- },
280
- ln: {
281
- label: 'Last Name',
282
- description: 'Last name of the user',
283
- type: 'string'
284
- },
285
- ge: {
286
- label: 'Gender',
287
- description: 'Gender of the user. If unknown leave blank.',
288
- type: 'string',
289
- choices: [
290
- { label: 'Male', value: 'm' },
291
- { label: 'Female', value: 'f' }
292
- ]
293
- },
294
- db: {
295
- label: 'Date of Birth',
296
- description: 'Date of birth of the user',
297
- type: 'string',
298
- format: 'date'
299
- },
300
- ct: {
301
- label: 'City',
302
- description: 'City of the user',
303
- type: 'string'
304
- },
305
- st: {
306
- label: 'State',
307
- description: 'State of the user. Facebook expects the 2-letter abbreviation for US states. For example, "CA" for California, or "NY" for New York.',
308
- type: 'string'
309
- },
310
- zp: {
311
- label: 'ZIP/Postal Code',
312
- description: 'ZIP or postal code of the user. For example, U.S zip code: 94035, Australia zip code: 1987, France zip code: 75018, UK zip code: m11ae.',
313
- type: 'string'
314
- },
315
- country: {
316
- label: 'Country',
317
- description: 'The country of the user. Facebook expects the 2-letter ISO 3166-1 alpha-2 country code. For example, "US" for the United States, or "GB" for the United Kingdom.',
318
- type: 'string'
319
- }
257
+ label: 'User Data',
258
+ description:
259
+ 'User data to be sent with the event. This can include hashed identifiers like email, phone number, etc.',
260
+ type: 'object',
261
+ additionalProperties: false,
262
+ defaultObjectUI: 'keyvalue',
263
+ properties: {
264
+ external_id: {
265
+ label: 'External ID',
266
+ description: 'A unique identifier for the user from your system',
267
+ type: 'string'
268
+ },
269
+ em: {
270
+ label: 'Email',
271
+ description: 'Email address of the user',
272
+ type: 'string',
273
+ format: 'email'
274
+ },
275
+ ph: {
276
+ label: 'Phone Number',
277
+ description: 'Phone number of the user',
278
+ type: 'string'
279
+ },
280
+ fn: {
281
+ label: 'First Name',
282
+ description: 'First name of the user',
283
+ type: 'string'
320
284
  },
321
- default: {
322
- external_id: { '@path': '$.userId' },
323
- em: { '@path': '$.context.traits.email' },
324
- ph: { '@path': '$.context.traits.phone' },
325
- fn: { '@path': '$.context.traits.first_name' },
326
- ln: { '@path': '$.context.traits.last_name' },
327
- ge: { '@path': '$.context.traits.gender' },
328
- db: { '@path': '$.context.traits.birthday' },
329
- ct: { '@path': '$.context.traits.address.city' },
330
- st: { '@path': '$.context.traits.address.state' },
331
- zp: { '@path': '$.context.traits.address.postal_code' },
332
- country: { '@path': '$.context.traits.address.country' }
285
+ ln: {
286
+ label: 'Last Name',
287
+ description: 'Last name of the user',
288
+ type: 'string'
289
+ },
290
+ ge: {
291
+ label: 'Gender',
292
+ description: 'Gender of the user. If unknown leave blank.',
293
+ type: 'string',
294
+ choices: [
295
+ { label: 'Male', value: 'm' },
296
+ { label: 'Female', value: 'f' }
297
+ ]
298
+ },
299
+ db: {
300
+ label: 'Date of Birth',
301
+ description: 'Date of birth of the user',
302
+ type: 'string',
303
+ format: 'date'
304
+ },
305
+ ct: {
306
+ label: 'City',
307
+ description: 'City of the user',
308
+ type: 'string'
309
+ },
310
+ st: {
311
+ label: 'State',
312
+ description:
313
+ 'State of the user. Facebook expects the 2-letter abbreviation for US states. For example, "CA" for California, or "NY" for New York.',
314
+ type: 'string'
315
+ },
316
+ zp: {
317
+ label: 'ZIP/Postal Code',
318
+ description:
319
+ 'ZIP or postal code of the user. For example, "94025" for Menlo Park, CA, or "10001" for New York City.',
320
+ type: 'string'
321
+ },
322
+ country: {
323
+ label: 'Country',
324
+ description:
325
+ 'The country of the user. Facebook expects the 2-letter ISO 3166-1 alpha-2 country code. For example, "US" for the United States, or "GB" for the United Kingdom.',
326
+ type: 'string'
333
327
  }
328
+ },
329
+ default: {
330
+ external_id: { '@path': '$.userId' },
331
+ em: { '@path': '$.context.traits.email' },
332
+ ph: { '@path': '$.context.traits.phone' },
333
+ fn: { '@path': '$.context.traits.first_name' },
334
+ ln: { '@path': '$.context.traits.last_name' },
335
+ ge: { '@path': '$.context.traits.gender' },
336
+ db: { '@path': '$.context.traits.birthday' },
337
+ ct: { '@path': '$.context.traits.address.city' },
338
+ st: { '@path': '$.context.traits.address.state' },
339
+ zp: { '@path': '$.context.traits.address.postal_code' },
340
+ country: { '@path': '$.context.traits.address.country' }
341
+ }
334
342
  }
335
343
 
336
344
  export const AllFields = {
337
- event_config,
338
- content_category,
339
- content_ids,
340
- content_name,
341
- content_type,
342
- contents,
343
- currency,
344
- delivery_category,
345
- num_items,
346
- predicted_ltv,
347
- net_revenue,
348
- search_string,
349
- status,
350
- value,
351
- custom_data,
352
- eventID,
353
- eventSourceUrl,
354
- userData
355
- }
345
+ event_config,
346
+ content_category,
347
+ content_ids,
348
+ content_name,
349
+ content_type,
350
+ contents,
351
+ currency,
352
+ delivery_category,
353
+ num_items,
354
+ predicted_ltv,
355
+ net_revenue,
356
+ search_string,
357
+ status,
358
+ value,
359
+ custom_data,
360
+ eventID,
361
+ eventSourceUrl,
362
+ userData
363
+ }