saasco-sdk 0.1.34 → 0.1.35

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.34";
10
+ var version = "0.1.35";
11
11
 
12
12
  const timezones = {
13
13
  'Asia/Barnaul': 'RU',
@@ -556,6 +556,7 @@ function getBrowserContext() {
556
556
 
557
557
  const isBrowser$1 = typeof window !== 'undefined';
558
558
  const isServer$1 = !isBrowser$1;
559
+ const standardFacebookEvents = ['AddPaymentInfo', 'AddToCart', 'AddToWishlist', 'CompleteRegistration', 'Contact', 'CustomizeProduct', 'Donate', 'FindLocation', 'InitiateCheckout', 'Lead', 'Purchase', 'Schedule', 'Search', 'StartTrial', 'SubmitApplication', 'Subscribe', 'ViewContent'];
559
560
  /**
560
561
  * Create a Facebook Pixel integration instance
561
562
  */
@@ -689,7 +690,9 @@ function trackFacebookEvent(eventName, properties, eventMapping) {
689
690
  if (properties['predicted_ltv'] !== undefined) fbParams['predicted_ltv'] = properties['predicted_ltv'];
690
691
  window.fbq('track', fbEventName, fbParams);
691
692
  } else {
692
- window.fbq('track', fbEventName);
693
+ const isStandardEvent = standardFacebookEvents.includes(fbEventName);
694
+ const trackType = isStandardEvent ? 'track' : 'trackCustom';
695
+ window.fbq(trackType, fbEventName);
693
696
  }
694
697
  }
695
698
  function coerceMetaConversionsAmValues(properties) {
@@ -950,10 +953,9 @@ class IntegrationManager {
950
953
  if (integration.init) {
951
954
  try {
952
955
  state.status = 'loading';
953
- this.logger.log(`init ${integration.name}`);
954
956
  yield integration.init();
955
957
  state.status = 'ready';
956
- this.logger.log(`ready ${integration.name}`);
958
+ this.logger.log(`${integration.name} integration ready`);
957
959
  this.flush();
958
960
  } catch (e) {
959
961
  state.status = 'error';
@@ -1060,11 +1062,9 @@ class IntegrationManager {
1060
1062
  if (this.config.flushInterval <= 0) return;
1061
1063
  this.flushTimer = setInterval(() => {
1062
1064
  if (this.globalQueue.length > 0) {
1063
- this.logger.log('periodic flush triggered');
1064
1065
  this.flush();
1065
1066
  }
1066
1067
  }, this.config.flushInterval);
1067
- this.logger.log(`periodic flushing enabled: ${this.config.flushInterval}ms`);
1068
1068
  }
1069
1069
  /**
1070
1070
  * Setup page unload handler for client environment
@@ -1080,7 +1080,6 @@ class IntegrationManager {
1080
1080
  // Use both beforeunload and pagehide for better coverage
1081
1081
  window.addEventListener('beforeunload', this.unloadHandler);
1082
1082
  window.addEventListener('pagehide', this.unloadHandler);
1083
- this.logger.log('page unload handlers registered');
1084
1083
  }
1085
1084
  /** Debug helpers */
1086
1085
  getStats() {
@@ -1631,5 +1630,6 @@ exports.browserContextSchema = browserContextSchema;
1631
1630
  exports.createFacebookPixelIntegration = createFacebookPixelIntegration;
1632
1631
  exports.getBrowserContext = getBrowserContext;
1633
1632
  exports.initializeFacebookPixel = initializeFacebookPixel;
1633
+ exports.standardFacebookEvents = standardFacebookEvents;
1634
1634
  exports.timezones = timezones;
1635
1635
  exports.trackFacebookEvent = trackFacebookEvent;
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.34";
6
+ var version = "0.1.35";
7
7
 
8
8
  const timezones = {
9
9
  'Asia/Barnaul': 'RU',
@@ -552,6 +552,7 @@ function getBrowserContext() {
552
552
 
553
553
  const isBrowser$1 = typeof window !== 'undefined';
554
554
  const isServer$1 = !isBrowser$1;
555
+ const standardFacebookEvents = ['AddPaymentInfo', 'AddToCart', 'AddToWishlist', 'CompleteRegistration', 'Contact', 'CustomizeProduct', 'Donate', 'FindLocation', 'InitiateCheckout', 'Lead', 'Purchase', 'Schedule', 'Search', 'StartTrial', 'SubmitApplication', 'Subscribe', 'ViewContent'];
555
556
  /**
556
557
  * Create a Facebook Pixel integration instance
557
558
  */
@@ -685,7 +686,9 @@ function trackFacebookEvent(eventName, properties, eventMapping) {
685
686
  if (properties['predicted_ltv'] !== undefined) fbParams['predicted_ltv'] = properties['predicted_ltv'];
686
687
  window.fbq('track', fbEventName, fbParams);
687
688
  } else {
688
- window.fbq('track', fbEventName);
689
+ const isStandardEvent = standardFacebookEvents.includes(fbEventName);
690
+ const trackType = isStandardEvent ? 'track' : 'trackCustom';
691
+ window.fbq(trackType, fbEventName);
689
692
  }
690
693
  }
691
694
  function coerceMetaConversionsAmValues(properties) {
@@ -946,10 +949,9 @@ class IntegrationManager {
946
949
  if (integration.init) {
947
950
  try {
948
951
  state.status = 'loading';
949
- this.logger.log(`init ${integration.name}`);
950
952
  yield integration.init();
951
953
  state.status = 'ready';
952
- this.logger.log(`ready ${integration.name}`);
954
+ this.logger.log(`${integration.name} integration ready`);
953
955
  this.flush();
954
956
  } catch (e) {
955
957
  state.status = 'error';
@@ -1056,11 +1058,9 @@ class IntegrationManager {
1056
1058
  if (this.config.flushInterval <= 0) return;
1057
1059
  this.flushTimer = setInterval(() => {
1058
1060
  if (this.globalQueue.length > 0) {
1059
- this.logger.log('periodic flush triggered');
1060
1061
  this.flush();
1061
1062
  }
1062
1063
  }, this.config.flushInterval);
1063
- this.logger.log(`periodic flushing enabled: ${this.config.flushInterval}ms`);
1064
1064
  }
1065
1065
  /**
1066
1066
  * Setup page unload handler for client environment
@@ -1076,7 +1076,6 @@ class IntegrationManager {
1076
1076
  // Use both beforeunload and pagehide for better coverage
1077
1077
  window.addEventListener('beforeunload', this.unloadHandler);
1078
1078
  window.addEventListener('pagehide', this.unloadHandler);
1079
- this.logger.log('page unload handlers registered');
1080
1079
  }
1081
1080
  /** Debug helpers */
1082
1081
  getStats() {
@@ -1620,4 +1619,4 @@ const browserContextSchema = z.object({
1620
1619
  $utmAdId: z.string().nullable()
1621
1620
  });
1622
1621
 
1623
- export { IntegrationManager, Logger, Saasco, browserContextSchema, createFacebookPixelIntegration, getBrowserContext, initializeFacebookPixel, timezones, trackFacebookEvent };
1622
+ export { IntegrationManager, Logger, Saasco, browserContextSchema, createFacebookPixelIntegration, getBrowserContext, initializeFacebookPixel, standardFacebookEvents, timezones, trackFacebookEvent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasco-sdk",
3
- "version": "0.1.34",
3
+ "version": "0.1.35",
4
4
  "dependencies": {
5
5
  "tslib": "^2.3.0",
6
6
  "@lukeed/uuid": "^2.0.1",
@@ -17,7 +17,8 @@ export type FacebookPixelConfig = {
17
17
  pixelId: string;
18
18
  eventMapping?: FacebookEventMapping;
19
19
  };
20
- export type StandardFacebookEvent = 'AddPaymentInfo' | 'AddToCart' | 'AddToWishlist' | 'CompleteRegistration' | 'Contact' | 'CustomizeProduct' | 'Donate' | 'FindLocation' | 'InitiateCheckout' | 'Lead' | 'Purchase' | 'Schedule' | 'Search' | 'StartTrial' | 'SubmitApplication' | 'Subscribe' | 'ViewContent';
20
+ export declare const standardFacebookEvents: readonly ["AddPaymentInfo", "AddToCart", "AddToWishlist", "CompleteRegistration", "Contact", "CustomizeProduct", "Donate", "FindLocation", "InitiateCheckout", "Lead", "Purchase", "Schedule", "Search", "StartTrial", "SubmitApplication", "Subscribe", "ViewContent"];
21
+ export type StandardFacebookEvent = (typeof standardFacebookEvents)[number];
21
22
  /**
22
23
  * Create a Facebook Pixel integration instance
23
24
  */