getu-attribution-v2-sdk 0.1.0 → 0.1.1

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/index.js CHANGED
@@ -39,7 +39,7 @@ __webpack_require__.d(__webpack_exports__, {
39
39
  "default": () => (/* binding */ src)
40
40
  });
41
41
 
42
- // UNUSED EXPORTS: AttributionSDK, Currency, EventType, addUTMToURL, destroy, flush, getAttributionData, getCurrentUTMParams, getSDK, getStatus, init, trackEvent, trackFormSubmit, trackLogin, trackPageView, trackPurchase, trackSignup, waitForSDK
42
+ // UNUSED EXPORTS: AttributionSDK, Currency, EventType, addUTMToURL, destroy, flush, getAttributionData, getCurrentUTMParams, getSDK, getStatus, init, trackAddToCart, trackEmailVerification, trackEvent, trackFormSubmit, trackLogin, trackPageView, trackProductView, trackPurchase, trackSignup, trackVideoPlay, waitForSDK
43
43
 
44
44
  ;// ./src/types/index.ts
45
45
  // Event types matching server-side enum exactly
@@ -743,7 +743,7 @@ class AttributionStorageManager {
743
743
 
744
744
 
745
745
  class EventQueueManager {
746
- constructor(logger, apiKey, apiEndpoint, batchSize = 100, batchInterval = 5000, maxRetries = 3, retryDelay = 1000, sendEvents) {
746
+ constructor(logger, apiKey, apiEndpoint, batchSize = 100, batchInterval = 2000, maxRetries = 3, retryDelay = 1000, sendEvents) {
747
747
  this.queue = [];
748
748
  this.processing = false;
749
749
  this.batchTimer = null;
@@ -976,7 +976,7 @@ class AttributionSDK {
976
976
  this.config = {
977
977
  apiEndpoint: defaultEndpoint,
978
978
  batchSize: 100,
979
- batchInterval: 5000,
979
+ batchInterval: 2000,
980
980
  maxRetries: 3,
981
981
  retryDelay: 1000,
982
982
  enableDebug: false,
@@ -1174,6 +1174,22 @@ class AttributionSDK {
1174
1174
  async trackFormSubmit(tracking_user_id, formData) {
1175
1175
  await this.trackEvent(EventType.FORM_SUBMIT, formData, tracking_user_id);
1176
1176
  }
1177
+ // Track video play
1178
+ async trackVideoPlay(tracking_user_id, videoData) {
1179
+ await this.trackEvent(EventType.VIDEO_PLAY, videoData, tracking_user_id);
1180
+ }
1181
+ // Track email verification
1182
+ async trackEmailVerification(tracking_user_id, verificationData) {
1183
+ await this.trackEvent(EventType.EMAIL_VERIFICATION, verificationData, tracking_user_id);
1184
+ }
1185
+ // Track product view
1186
+ async trackProductView(tracking_user_id, productData) {
1187
+ await this.trackEvent(EventType.PRODUCT_VIEW, productData, tracking_user_id);
1188
+ }
1189
+ // Track add to cart
1190
+ async trackAddToCart(tracking_user_id, cartData) {
1191
+ await this.trackEvent(EventType.ADD_TO_CART, cartData, tracking_user_id);
1192
+ }
1177
1193
  // Get attribution data
1178
1194
  getAttributionData() {
1179
1195
  return this.storage.getUTMData();
@@ -1698,7 +1714,7 @@ function autoInit() {
1698
1714
  autoTrackPageView: script.getAttribute("data-auto-track-page-view") === "true",
1699
1715
  autoCleanUTM: script.getAttribute("data-auto-clean-utm") !== "false",
1700
1716
  batchSize: parseInt(script.getAttribute("data-batch-size") || "100"),
1701
- batchInterval: parseInt(script.getAttribute("data-batch-interval") || "5000"),
1717
+ batchInterval: parseInt(script.getAttribute("data-batch-interval") || "2000"),
1702
1718
  };
1703
1719
  // Initialize SDK
1704
1720
  init(config);
@@ -1824,6 +1840,42 @@ async function trackFormSubmit(tracking_user_id, formData) {
1824
1840
  }
1825
1841
  await sdk.trackFormSubmit(tracking_user_id, formData);
1826
1842
  }
1843
+ // Track video play
1844
+ async function trackVideoPlay(tracking_user_id, videoData) {
1845
+ const sdk = getSDK();
1846
+ if (!sdk) {
1847
+ console.warn("GetuAI SDK: Not initialized. Call init() first.");
1848
+ return;
1849
+ }
1850
+ await sdk.trackVideoPlay(tracking_user_id, videoData);
1851
+ }
1852
+ // Track email verification
1853
+ async function trackEmailVerification(tracking_user_id, verificationData) {
1854
+ const sdk = getSDK();
1855
+ if (!sdk) {
1856
+ console.warn("GetuAI SDK: Not initialized. Call init() first.");
1857
+ return;
1858
+ }
1859
+ await sdk.trackEmailVerification(tracking_user_id, verificationData);
1860
+ }
1861
+ // Track product view
1862
+ async function trackProductView(tracking_user_id, productData) {
1863
+ const sdk = getSDK();
1864
+ if (!sdk) {
1865
+ console.warn("GetuAI SDK: Not initialized. Call init() first.");
1866
+ return;
1867
+ }
1868
+ await sdk.trackProductView(tracking_user_id, productData);
1869
+ }
1870
+ // Track add to cart
1871
+ async function trackAddToCart(tracking_user_id, cartData) {
1872
+ const sdk = getSDK();
1873
+ if (!sdk) {
1874
+ console.warn("GetuAI SDK: Not initialized. Call init() first.");
1875
+ return;
1876
+ }
1877
+ await sdk.trackAddToCart(tracking_user_id, cartData);
1878
+ }
1827
1879
  // Get attribution data
1828
1880
  function getAttributionData() {
1829
1881
  const sdk = getSDK();
@@ -1904,6 +1956,22 @@ class AttributionSDKStatic extends AttributionSDK {
1904
1956
  static async trackFormSubmit(tracking_user_id, formData) {
1905
1957
  return await trackFormSubmit(tracking_user_id, formData);
1906
1958
  }
1959
+ // Static method to track video play
1960
+ static async trackVideoPlay(tracking_user_id, videoData) {
1961
+ return await trackVideoPlay(tracking_user_id, videoData);
1962
+ }
1963
+ // Static method to track email verification
1964
+ static async trackEmailVerification(tracking_user_id, verificationData) {
1965
+ return await trackEmailVerification(tracking_user_id, verificationData);
1966
+ }
1967
+ // Static method to track product view
1968
+ static async trackProductView(tracking_user_id, productData) {
1969
+ return await trackProductView(tracking_user_id, productData);
1970
+ }
1971
+ // Static method to track add to cart
1972
+ static async trackAddToCart(tracking_user_id, cartData) {
1973
+ return await trackAddToCart(tracking_user_id, cartData);
1974
+ }
1907
1975
  // Static method to get attribution data
1908
1976
  static getAttributionData() {
1909
1977
  return getAttributionData();
@@ -1961,6 +2029,10 @@ if (typeof window !== "undefined") {
1961
2029
  trackLogin,
1962
2030
  trackSignup,
1963
2031
  trackFormSubmit,
2032
+ trackVideoPlay,
2033
+ trackEmailVerification,
2034
+ trackProductView,
2035
+ trackAddToCart,
1964
2036
  getAttributionData,
1965
2037
  flush,
1966
2038
  getStatus,
@@ -1980,6 +2052,10 @@ if (typeof window !== "undefined") {
1980
2052
  window.trackLogin = trackLogin;
1981
2053
  window.trackSignup = trackSignup;
1982
2054
  window.trackFormSubmit = trackFormSubmit;
2055
+ window.trackVideoPlay = trackVideoPlay;
2056
+ window.trackEmailVerification = trackEmailVerification;
2057
+ window.trackProductView = trackProductView;
2058
+ window.trackAddToCart = trackAddToCart;
1983
2059
  window.getAttributionData = getAttributionData;
1984
2060
  window.flush = flush;
1985
2061
  window.getStatus = getStatus;
@@ -1999,6 +2075,10 @@ if (typeof window !== "undefined") {
1999
2075
  trackLogin,
2000
2076
  trackSignup,
2001
2077
  trackFormSubmit,
2078
+ trackVideoPlay,
2079
+ trackEmailVerification,
2080
+ trackProductView,
2081
+ trackAddToCart,
2002
2082
  getAttributionData,
2003
2083
  flush,
2004
2084
  getStatus,
@@ -1,7 +1,7 @@
1
1
  import { IMMEDIATE_EVENTS, } from "../types";
2
2
  import { retry, debounce, getTimestamp } from "../utils";
3
3
  export class EventQueueManager {
4
- constructor(logger, apiKey, apiEndpoint, batchSize = 100, batchInterval = 5000, maxRetries = 3, retryDelay = 1000, sendEvents) {
4
+ constructor(logger, apiKey, apiEndpoint, batchSize = 100, batchInterval = 2000, maxRetries = 3, retryDelay = 1000, sendEvents) {
5
5
  this.queue = [];
6
6
  this.processing = false;
7
7
  this.batchTimer = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getu-attribution-v2-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "GetuAI Attribution SDK for client-side tracking",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",