saasco-sdk 0.1.37 → 0.1.38

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/index.cjs.js CHANGED
@@ -7,7 +7,7 @@ var psl = require('psl');
7
7
  var uuid$1 = require('@lukeed/uuid');
8
8
  var zod = require('zod');
9
9
 
10
- var version = "0.1.37";
10
+ var version = "0.1.38";
11
11
 
12
12
  const timezones = {
13
13
  'Asia/Barnaul': 'RU',
@@ -604,6 +604,13 @@ function createFacebookPixelIntegration(config) {
604
604
  s = b.getElementsByTagName(e)[0];
605
605
  s.parentNode.insertBefore(t, s);
606
606
  })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
607
+ // Prevent automatic PageView tracking
608
+ window.fbq.disablePushState = true;
609
+ // Allow duplicate PageView events
610
+ window.fbq.allowDuplicatePageViews = true;
611
+ if (config.automaticConfiguration === false) {
612
+ window.fbq('set', 'autoConfig', false, config.pixelId);
613
+ }
607
614
  // Initialize pixel
608
615
  window.fbq('init', config.pixelId);
609
616
  // If script loads synchronously, mark as ready
@@ -680,15 +687,15 @@ function trackFacebookEvent(eventName, properties, eventMapping) {
680
687
  if (isServer$1 || !window.fbq) return;
681
688
  const fbEventName = getFacebookEventName(eventName, eventMapping);
682
689
  const eventsWithParams = ['Purchase', 'StartTrial', 'Subscribe'];
690
+ const isStandardEvent = standardFacebookEvents.includes(fbEventName);
691
+ const trackType = isStandardEvent ? 'track' : 'trackCustom';
683
692
  if (eventsWithParams.includes(fbEventName) && properties) {
684
693
  const fbParams = {};
685
694
  if (properties['value'] !== undefined) fbParams['value'] = properties['value'];
686
695
  if (properties['currency'] !== undefined) fbParams['currency'] = properties['currency'];
687
696
  if (properties['predicted_ltv'] !== undefined) fbParams['predicted_ltv'] = properties['predicted_ltv'];
688
- window.fbq('track', fbEventName, fbParams);
697
+ window.fbq(trackType, fbEventName, fbParams);
689
698
  } else {
690
- const isStandardEvent = standardFacebookEvents.includes(fbEventName);
691
- const trackType = isStandardEvent ? 'track' : 'trackCustom';
692
699
  window.fbq(trackType, fbEventName);
693
700
  }
694
701
  }
package/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import { isValid, parse } from 'psl';
3
3
  import { v4 } from '@lukeed/uuid';
4
4
  import { z } from 'zod';
5
5
 
6
- var version = "0.1.37";
6
+ var version = "0.1.38";
7
7
 
8
8
  const timezones = {
9
9
  'Asia/Barnaul': 'RU',
@@ -600,6 +600,13 @@ function createFacebookPixelIntegration(config) {
600
600
  s = b.getElementsByTagName(e)[0];
601
601
  s.parentNode.insertBefore(t, s);
602
602
  })(window, document, 'script', 'https://connect.facebook.net/en_US/fbevents.js');
603
+ // Prevent automatic PageView tracking
604
+ window.fbq.disablePushState = true;
605
+ // Allow duplicate PageView events
606
+ window.fbq.allowDuplicatePageViews = true;
607
+ if (config.automaticConfiguration === false) {
608
+ window.fbq('set', 'autoConfig', false, config.pixelId);
609
+ }
603
610
  // Initialize pixel
604
611
  window.fbq('init', config.pixelId);
605
612
  // If script loads synchronously, mark as ready
@@ -676,15 +683,15 @@ function trackFacebookEvent(eventName, properties, eventMapping) {
676
683
  if (isServer$1 || !window.fbq) return;
677
684
  const fbEventName = getFacebookEventName(eventName, eventMapping);
678
685
  const eventsWithParams = ['Purchase', 'StartTrial', 'Subscribe'];
686
+ const isStandardEvent = standardFacebookEvents.includes(fbEventName);
687
+ const trackType = isStandardEvent ? 'track' : 'trackCustom';
679
688
  if (eventsWithParams.includes(fbEventName) && properties) {
680
689
  const fbParams = {};
681
690
  if (properties['value'] !== undefined) fbParams['value'] = properties['value'];
682
691
  if (properties['currency'] !== undefined) fbParams['currency'] = properties['currency'];
683
692
  if (properties['predicted_ltv'] !== undefined) fbParams['predicted_ltv'] = properties['predicted_ltv'];
684
- window.fbq('track', fbEventName, fbParams);
693
+ window.fbq(trackType, fbEventName, fbParams);
685
694
  } else {
686
- const isStandardEvent = standardFacebookEvents.includes(fbEventName);
687
- const trackType = isStandardEvent ? 'track' : 'trackCustom';
688
695
  window.fbq(trackType, fbEventName);
689
696
  }
690
697
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasco-sdk",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "@lukeed/uuid": "^2.0.1",
@@ -11,6 +11,7 @@ declare global {
11
11
  loaded?: boolean;
12
12
  version?: string;
13
13
  disablePushState?: boolean;
14
+ allowDuplicatePageViews?: boolean;
14
15
  }
15
16
  }
16
17
  export type FacebookEventMapping = {
@@ -23,6 +24,7 @@ export type FacebookPixelIntegrationConfig = IntegrationConfigBase & {
23
24
  export type FacebookPixelConfig = {
24
25
  pixelId: string;
25
26
  eventMapping?: FacebookEventMapping;
27
+ automaticConfiguration?: boolean;
26
28
  };
27
29
  export declare const standardFacebookEvents: readonly ["AddPaymentInfo", "AddToCart", "AddToWishlist", "CompleteRegistration", "Contact", "CustomizeProduct", "Donate", "FindLocation", "InitiateCheckout", "Lead", "Purchase", "Schedule", "Search", "StartTrial", "SubmitApplication", "Subscribe", "ViewContent", "PageView"];
28
30
  export type StandardFacebookEvent = (typeof standardFacebookEvents)[number];