@blotoutio/providers-facebook-sdk 1.55.0 → 1.55.2

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 (4) hide show
  1. package/index.cjs.js +100 -3
  2. package/index.js +100 -3
  3. package/index.mjs +100 -3
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -222,6 +222,27 @@ const FACEBOOK_STANDARD_EVENTS = new Set([
222
222
  'Subscribe',
223
223
  'ViewContent',
224
224
  ]);
225
+ const VALID_DELIVERY_CATEGORIES = new Set([
226
+ 'home_delivery',
227
+ 'curbside',
228
+ 'in_store',
229
+ ]);
230
+ const normalizeDeliveryCategory = (input) => {
231
+ if (!input)
232
+ return '';
233
+ const normalized = input.trim().toLowerCase();
234
+ return VALID_DELIVERY_CATEGORIES.has(normalized) ? normalized : '';
235
+ };
236
+ const META_IDENTITY_KEYS = new Set([
237
+ 'subscription_id',
238
+ 'fb_login_id',
239
+ 'lead_id',
240
+ 'page_id',
241
+ 'page_scoped_user_id',
242
+ 'ctwa_clid',
243
+ 'ig_account_id',
244
+ 'ig_sid',
245
+ ]);
225
246
 
226
247
  const getFbq = () => {
227
248
  if (!window || !window.fbq) {
@@ -337,6 +358,48 @@ const getProductIdFromMapping = (item, productIdMapping) => {
337
358
  };
338
359
 
339
360
  // eslint-disable-next-line @nx/enforce-module-boundaries
361
+ const FB_STANDARD_KEYS = new Set([
362
+ 'value',
363
+ 'currency',
364
+ 'name',
365
+ 'type',
366
+ 'category',
367
+ 'ids',
368
+ 'content_ids',
369
+ 'search',
370
+ 'status',
371
+ 'predicted_ltv',
372
+ 'orderId',
373
+ 'item_number',
374
+ 'contents',
375
+ 'num_items',
376
+ 'fbp',
377
+ ]);
378
+ const PII_KEYS = new Set([
379
+ 'email',
380
+ 'phone',
381
+ 'firstName',
382
+ 'first_name',
383
+ 'lastName',
384
+ 'last_name',
385
+ 'address',
386
+ 'address1',
387
+ 'address2',
388
+ 'city',
389
+ 'state',
390
+ 'zip',
391
+ 'zipCode',
392
+ 'postalCode',
393
+ 'postal_code',
394
+ 'country',
395
+ 'dob',
396
+ 'dateOfBirth',
397
+ 'date_of_birth',
398
+ 'gender',
399
+ 'ip',
400
+ 'ipAddress',
401
+ 'ip_address',
402
+ ]);
340
403
  const getProductMappingModel = (productIdMapping, useVariantId) => {
341
404
  const value = productIdMapping || useVariantId || '0';
342
405
  return (value && /^[012]$/.test(value) ? value : '0');
@@ -363,6 +426,9 @@ const prepareData = (data, productIdMapping) => {
363
426
  if (data['ids']) {
364
427
  payload['content_ids'] = data['ids'];
365
428
  }
429
+ if (!payload['content_ids'] && Array.isArray(data['content_ids'])) {
430
+ payload['content_ids'] = data['content_ids'];
431
+ }
366
432
  if (data['search']) {
367
433
  payload['search_string'] = data['search'];
368
434
  }
@@ -375,6 +441,9 @@ const prepareData = (data, productIdMapping) => {
375
441
  if (data['orderId']) {
376
442
  payload['order_id'] = data['orderId'];
377
443
  }
444
+ if (data['item_number']) {
445
+ payload['item_number'] = data['item_number'];
446
+ }
378
447
  if (data['contents'] && Array.isArray(data['contents'])) {
379
448
  payload['contents'] = data['contents'].map((item) => {
380
449
  const content = {};
@@ -394,23 +463,51 @@ const prepareData = (data, productIdMapping) => {
394
463
  if (item.title) {
395
464
  content['title'] = item.title;
396
465
  }
466
+ if (item.description) {
467
+ content['description'] = item.description;
468
+ }
469
+ if (item.brand) {
470
+ content['brand'] = item.brand;
471
+ }
472
+ if (item.delivery_category) {
473
+ const deliveryCategory = normalizeDeliveryCategory(item.delivery_category);
474
+ if (deliveryCategory) {
475
+ content['delivery_category'] = deliveryCategory;
476
+ }
477
+ }
397
478
  return content;
398
479
  });
399
480
  if (data['contents'] && data['contents'][0] && data['contents'][0].type) {
400
481
  payload['content_type'] = data['contents'][0].type;
401
482
  }
402
483
  }
403
- if (data['contents'] || data['ids']) {
404
- const contents = data['contents'] || data['ids'];
484
+ if (data['contents'] || data['ids'] || data['content_ids']) {
485
+ const contents = data['contents'] || data['ids'] || data['content_ids'];
405
486
  if (Array.isArray(contents)) {
406
487
  payload['num_items'] = contents.length;
407
488
  }
408
489
  }
490
+ if (!payload['content_ids'] && Array.isArray(payload['contents'])) {
491
+ const ids = payload['contents']
492
+ .map((c) => c['id'])
493
+ .filter(Boolean);
494
+ if (ids.length > 0) {
495
+ payload['content_ids'] = ids;
496
+ }
497
+ }
498
+ Object.entries(data).forEach(([key, val]) => {
499
+ if (!FB_STANDARD_KEYS.has(key) &&
500
+ !PII_KEYS.has(key) &&
501
+ !META_IDENTITY_KEYS.has(key) &&
502
+ !key.toLowerCase().startsWith('user')) {
503
+ payload[key] = val;
504
+ }
505
+ });
409
506
  return payload;
410
507
  };
411
508
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
412
509
  const payload = {
413
- sdkVersion: "1.55.0" ,
510
+ sdkVersion: "1.55.2" ,
414
511
  };
415
512
  if (window.fbq &&
416
513
  !!manifestVariables['pixelId'] &&
package/index.js CHANGED
@@ -223,6 +223,27 @@ var ProvidersFacebookSdk = (function () {
223
223
  'Subscribe',
224
224
  'ViewContent',
225
225
  ]);
226
+ const VALID_DELIVERY_CATEGORIES = new Set([
227
+ 'home_delivery',
228
+ 'curbside',
229
+ 'in_store',
230
+ ]);
231
+ const normalizeDeliveryCategory = (input) => {
232
+ if (!input)
233
+ return '';
234
+ const normalized = input.trim().toLowerCase();
235
+ return VALID_DELIVERY_CATEGORIES.has(normalized) ? normalized : '';
236
+ };
237
+ const META_IDENTITY_KEYS = new Set([
238
+ 'subscription_id',
239
+ 'fb_login_id',
240
+ 'lead_id',
241
+ 'page_id',
242
+ 'page_scoped_user_id',
243
+ 'ctwa_clid',
244
+ 'ig_account_id',
245
+ 'ig_sid',
246
+ ]);
226
247
 
227
248
  const getFbq = () => {
228
249
  if (!window || !window.fbq) {
@@ -338,6 +359,48 @@ var ProvidersFacebookSdk = (function () {
338
359
  };
339
360
 
340
361
  // eslint-disable-next-line @nx/enforce-module-boundaries
362
+ const FB_STANDARD_KEYS = new Set([
363
+ 'value',
364
+ 'currency',
365
+ 'name',
366
+ 'type',
367
+ 'category',
368
+ 'ids',
369
+ 'content_ids',
370
+ 'search',
371
+ 'status',
372
+ 'predicted_ltv',
373
+ 'orderId',
374
+ 'item_number',
375
+ 'contents',
376
+ 'num_items',
377
+ 'fbp',
378
+ ]);
379
+ const PII_KEYS = new Set([
380
+ 'email',
381
+ 'phone',
382
+ 'firstName',
383
+ 'first_name',
384
+ 'lastName',
385
+ 'last_name',
386
+ 'address',
387
+ 'address1',
388
+ 'address2',
389
+ 'city',
390
+ 'state',
391
+ 'zip',
392
+ 'zipCode',
393
+ 'postalCode',
394
+ 'postal_code',
395
+ 'country',
396
+ 'dob',
397
+ 'dateOfBirth',
398
+ 'date_of_birth',
399
+ 'gender',
400
+ 'ip',
401
+ 'ipAddress',
402
+ 'ip_address',
403
+ ]);
341
404
  const getProductMappingModel = (productIdMapping, useVariantId) => {
342
405
  const value = productIdMapping || useVariantId || '0';
343
406
  return (value && /^[012]$/.test(value) ? value : '0');
@@ -364,6 +427,9 @@ var ProvidersFacebookSdk = (function () {
364
427
  if (data['ids']) {
365
428
  payload['content_ids'] = data['ids'];
366
429
  }
430
+ if (!payload['content_ids'] && Array.isArray(data['content_ids'])) {
431
+ payload['content_ids'] = data['content_ids'];
432
+ }
367
433
  if (data['search']) {
368
434
  payload['search_string'] = data['search'];
369
435
  }
@@ -376,6 +442,9 @@ var ProvidersFacebookSdk = (function () {
376
442
  if (data['orderId']) {
377
443
  payload['order_id'] = data['orderId'];
378
444
  }
445
+ if (data['item_number']) {
446
+ payload['item_number'] = data['item_number'];
447
+ }
379
448
  if (data['contents'] && Array.isArray(data['contents'])) {
380
449
  payload['contents'] = data['contents'].map((item) => {
381
450
  const content = {};
@@ -395,23 +464,51 @@ var ProvidersFacebookSdk = (function () {
395
464
  if (item.title) {
396
465
  content['title'] = item.title;
397
466
  }
467
+ if (item.description) {
468
+ content['description'] = item.description;
469
+ }
470
+ if (item.brand) {
471
+ content['brand'] = item.brand;
472
+ }
473
+ if (item.delivery_category) {
474
+ const deliveryCategory = normalizeDeliveryCategory(item.delivery_category);
475
+ if (deliveryCategory) {
476
+ content['delivery_category'] = deliveryCategory;
477
+ }
478
+ }
398
479
  return content;
399
480
  });
400
481
  if (data['contents'] && data['contents'][0] && data['contents'][0].type) {
401
482
  payload['content_type'] = data['contents'][0].type;
402
483
  }
403
484
  }
404
- if (data['contents'] || data['ids']) {
405
- const contents = data['contents'] || data['ids'];
485
+ if (data['contents'] || data['ids'] || data['content_ids']) {
486
+ const contents = data['contents'] || data['ids'] || data['content_ids'];
406
487
  if (Array.isArray(contents)) {
407
488
  payload['num_items'] = contents.length;
408
489
  }
409
490
  }
491
+ if (!payload['content_ids'] && Array.isArray(payload['contents'])) {
492
+ const ids = payload['contents']
493
+ .map((c) => c['id'])
494
+ .filter(Boolean);
495
+ if (ids.length > 0) {
496
+ payload['content_ids'] = ids;
497
+ }
498
+ }
499
+ Object.entries(data).forEach(([key, val]) => {
500
+ if (!FB_STANDARD_KEYS.has(key) &&
501
+ !PII_KEYS.has(key) &&
502
+ !META_IDENTITY_KEYS.has(key) &&
503
+ !key.toLowerCase().startsWith('user')) {
504
+ payload[key] = val;
505
+ }
506
+ });
410
507
  return payload;
411
508
  };
412
509
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
413
510
  const payload = {
414
- sdkVersion: "1.55.0" ,
511
+ sdkVersion: "1.55.2" ,
415
512
  };
416
513
  if (window.fbq &&
417
514
  !!manifestVariables['pixelId'] &&
package/index.mjs CHANGED
@@ -220,6 +220,27 @@ const FACEBOOK_STANDARD_EVENTS = new Set([
220
220
  'Subscribe',
221
221
  'ViewContent',
222
222
  ]);
223
+ const VALID_DELIVERY_CATEGORIES = new Set([
224
+ 'home_delivery',
225
+ 'curbside',
226
+ 'in_store',
227
+ ]);
228
+ const normalizeDeliveryCategory = (input) => {
229
+ if (!input)
230
+ return '';
231
+ const normalized = input.trim().toLowerCase();
232
+ return VALID_DELIVERY_CATEGORIES.has(normalized) ? normalized : '';
233
+ };
234
+ const META_IDENTITY_KEYS = new Set([
235
+ 'subscription_id',
236
+ 'fb_login_id',
237
+ 'lead_id',
238
+ 'page_id',
239
+ 'page_scoped_user_id',
240
+ 'ctwa_clid',
241
+ 'ig_account_id',
242
+ 'ig_sid',
243
+ ]);
223
244
 
224
245
  const getFbq = () => {
225
246
  if (!window || !window.fbq) {
@@ -335,6 +356,48 @@ const getProductIdFromMapping = (item, productIdMapping) => {
335
356
  };
336
357
 
337
358
  // eslint-disable-next-line @nx/enforce-module-boundaries
359
+ const FB_STANDARD_KEYS = new Set([
360
+ 'value',
361
+ 'currency',
362
+ 'name',
363
+ 'type',
364
+ 'category',
365
+ 'ids',
366
+ 'content_ids',
367
+ 'search',
368
+ 'status',
369
+ 'predicted_ltv',
370
+ 'orderId',
371
+ 'item_number',
372
+ 'contents',
373
+ 'num_items',
374
+ 'fbp',
375
+ ]);
376
+ const PII_KEYS = new Set([
377
+ 'email',
378
+ 'phone',
379
+ 'firstName',
380
+ 'first_name',
381
+ 'lastName',
382
+ 'last_name',
383
+ 'address',
384
+ 'address1',
385
+ 'address2',
386
+ 'city',
387
+ 'state',
388
+ 'zip',
389
+ 'zipCode',
390
+ 'postalCode',
391
+ 'postal_code',
392
+ 'country',
393
+ 'dob',
394
+ 'dateOfBirth',
395
+ 'date_of_birth',
396
+ 'gender',
397
+ 'ip',
398
+ 'ipAddress',
399
+ 'ip_address',
400
+ ]);
338
401
  const getProductMappingModel = (productIdMapping, useVariantId) => {
339
402
  const value = productIdMapping || useVariantId || '0';
340
403
  return (value && /^[012]$/.test(value) ? value : '0');
@@ -361,6 +424,9 @@ const prepareData = (data, productIdMapping) => {
361
424
  if (data['ids']) {
362
425
  payload['content_ids'] = data['ids'];
363
426
  }
427
+ if (!payload['content_ids'] && Array.isArray(data['content_ids'])) {
428
+ payload['content_ids'] = data['content_ids'];
429
+ }
364
430
  if (data['search']) {
365
431
  payload['search_string'] = data['search'];
366
432
  }
@@ -373,6 +439,9 @@ const prepareData = (data, productIdMapping) => {
373
439
  if (data['orderId']) {
374
440
  payload['order_id'] = data['orderId'];
375
441
  }
442
+ if (data['item_number']) {
443
+ payload['item_number'] = data['item_number'];
444
+ }
376
445
  if (data['contents'] && Array.isArray(data['contents'])) {
377
446
  payload['contents'] = data['contents'].map((item) => {
378
447
  const content = {};
@@ -392,23 +461,51 @@ const prepareData = (data, productIdMapping) => {
392
461
  if (item.title) {
393
462
  content['title'] = item.title;
394
463
  }
464
+ if (item.description) {
465
+ content['description'] = item.description;
466
+ }
467
+ if (item.brand) {
468
+ content['brand'] = item.brand;
469
+ }
470
+ if (item.delivery_category) {
471
+ const deliveryCategory = normalizeDeliveryCategory(item.delivery_category);
472
+ if (deliveryCategory) {
473
+ content['delivery_category'] = deliveryCategory;
474
+ }
475
+ }
395
476
  return content;
396
477
  });
397
478
  if (data['contents'] && data['contents'][0] && data['contents'][0].type) {
398
479
  payload['content_type'] = data['contents'][0].type;
399
480
  }
400
481
  }
401
- if (data['contents'] || data['ids']) {
402
- const contents = data['contents'] || data['ids'];
482
+ if (data['contents'] || data['ids'] || data['content_ids']) {
483
+ const contents = data['contents'] || data['ids'] || data['content_ids'];
403
484
  if (Array.isArray(contents)) {
404
485
  payload['num_items'] = contents.length;
405
486
  }
406
487
  }
488
+ if (!payload['content_ids'] && Array.isArray(payload['contents'])) {
489
+ const ids = payload['contents']
490
+ .map((c) => c['id'])
491
+ .filter(Boolean);
492
+ if (ids.length > 0) {
493
+ payload['content_ids'] = ids;
494
+ }
495
+ }
496
+ Object.entries(data).forEach(([key, val]) => {
497
+ if (!FB_STANDARD_KEYS.has(key) &&
498
+ !PII_KEYS.has(key) &&
499
+ !META_IDENTITY_KEYS.has(key) &&
500
+ !key.toLowerCase().startsWith('user')) {
501
+ payload[key] = val;
502
+ }
503
+ });
407
504
  return payload;
408
505
  };
409
506
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
410
507
  const payload = {
411
- sdkVersion: "1.55.0" ,
508
+ sdkVersion: "1.55.2" ,
412
509
  };
413
510
  if (window.fbq &&
414
511
  !!manifestVariables['pixelId'] &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-facebook-sdk",
3
- "version": "1.55.0",
3
+ "version": "1.55.2",
4
4
  "description": "Facebook Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",