cryptique-sdk 1.1.1 → 1.1.4

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/lib/cjs/index.js CHANGED
@@ -3770,6 +3770,18 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
3770
3770
 
3771
3771
  // Save updated session
3772
3772
  StorageManager.saveSession(session);
3773
+
3774
+ // Fire page_view auto event on every navigation (single source of truth with session tracking)
3775
+ // This ensures SPAs get page_view on route changes without a separate history override
3776
+ if (typeof CONFIG !== 'undefined' && CONFIG.AUTO_EVENTS && CONFIG.AUTO_EVENTS.enabled && typeof shouldTrackAutoEvents === 'function' && shouldTrackAutoEvents()) {
3777
+ if (typeof AutoEventsTracker !== 'undefined') {
3778
+ if (!AutoEventsTracker.isSetup) {
3779
+ AutoEventsTracker.setup();
3780
+ } else {
3781
+ AutoEventsTracker.trackPageView();
3782
+ }
3783
+ }
3784
+ }
3773
3785
  } catch (error) {
3774
3786
  console.error("Error tracking page visit:", error);
3775
3787
  }
@@ -7805,51 +7817,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
7805
7817
  // Initialize SDK when DOM is ready
7806
7818
  // ============================================================================
7807
7819
 
7808
- /**
7809
- * Monitor path changes for Single Page Applications (SPAs)
7810
- * Re-checks auto events configuration when navigation occurs
7811
- */
7812
- function setupSPANavigationMonitoring() {
7813
- let lastPath = window.location.pathname;
7814
-
7815
- // Check path changes
7816
- function checkPathChange() {
7817
- const currentPath = window.location.pathname;
7818
- if (currentPath !== lastPath) {
7819
- lastPath = currentPath;
7820
-
7821
- // If auto events were disabled on previous page but enabled on new page, setup
7822
- if (CONFIG.AUTO_EVENTS.enabled && shouldTrackAutoEvents() && !AutoEventsTracker.isSetup) {
7823
- AutoEventsTracker.setup();
7824
- }
7825
- // Fire page_view on every SPA navigation when auto events are enabled
7826
- // (setup() only runs once, so trackPageView wouldn't fire on route changes otherwise)
7827
- if (CONFIG.AUTO_EVENTS.enabled && shouldTrackAutoEvents() && AutoEventsTracker.isSetup) {
7828
- AutoEventsTracker.trackPageView();
7829
- }
7830
- // Note: If auto events should be disabled on new page, trackAutoEvent will check
7831
- // shouldTrackAutoEvents() before tracking, so no need to remove listeners
7832
- }
7833
- }
7834
-
7835
- // Check on popstate (browser back/forward)
7836
- window.addEventListener('popstate', checkPathChange);
7837
-
7838
- // For SPAs using history.pushState/replaceState, monitor them
7839
- const originalPushState = history.pushState;
7840
- const originalReplaceState = history.replaceState;
7841
-
7842
- history.pushState = function(...args) {
7843
- originalPushState.apply(history, args);
7844
- setTimeout(checkPathChange, 0);
7845
- };
7846
-
7847
- history.replaceState = function(...args) {
7848
- originalReplaceState.apply(history, args);
7849
- setTimeout(checkPathChange, 0);
7850
- };
7851
- }
7852
-
7853
7820
  // Initialize SDK
7854
7821
  async function initializeSDK() {
7855
7822
  await Initializer.initialize();
@@ -7859,9 +7826,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
7859
7826
  setTimeout(() => {
7860
7827
  AutoEventsTracker.setup();
7861
7828
  }, 2000); // Wait 2 seconds for initial session to be saved
7862
-
7863
- // Setup SPA navigation monitoring for auto events
7864
- setupSPANavigationMonitoring();
7865
7829
  }
7866
7830
 
7867
7831
  if (document.readyState === 'loading') {
package/lib/esm/index.js CHANGED
@@ -3768,6 +3768,18 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
3768
3768
 
3769
3769
  // Save updated session
3770
3770
  StorageManager.saveSession(session);
3771
+
3772
+ // Fire page_view auto event on every navigation (single source of truth with session tracking)
3773
+ // This ensures SPAs get page_view on route changes without a separate history override
3774
+ if (typeof CONFIG !== 'undefined' && CONFIG.AUTO_EVENTS && CONFIG.AUTO_EVENTS.enabled && typeof shouldTrackAutoEvents === 'function' && shouldTrackAutoEvents()) {
3775
+ if (typeof AutoEventsTracker !== 'undefined') {
3776
+ if (!AutoEventsTracker.isSetup) {
3777
+ AutoEventsTracker.setup();
3778
+ } else {
3779
+ AutoEventsTracker.trackPageView();
3780
+ }
3781
+ }
3782
+ }
3771
3783
  } catch (error) {
3772
3784
  console.error("Error tracking page visit:", error);
3773
3785
  }
@@ -7803,51 +7815,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
7803
7815
  // Initialize SDK when DOM is ready
7804
7816
  // ============================================================================
7805
7817
 
7806
- /**
7807
- * Monitor path changes for Single Page Applications (SPAs)
7808
- * Re-checks auto events configuration when navigation occurs
7809
- */
7810
- function setupSPANavigationMonitoring() {
7811
- let lastPath = window.location.pathname;
7812
-
7813
- // Check path changes
7814
- function checkPathChange() {
7815
- const currentPath = window.location.pathname;
7816
- if (currentPath !== lastPath) {
7817
- lastPath = currentPath;
7818
-
7819
- // If auto events were disabled on previous page but enabled on new page, setup
7820
- if (CONFIG.AUTO_EVENTS.enabled && shouldTrackAutoEvents() && !AutoEventsTracker.isSetup) {
7821
- AutoEventsTracker.setup();
7822
- }
7823
- // Fire page_view on every SPA navigation when auto events are enabled
7824
- // (setup() only runs once, so trackPageView wouldn't fire on route changes otherwise)
7825
- if (CONFIG.AUTO_EVENTS.enabled && shouldTrackAutoEvents() && AutoEventsTracker.isSetup) {
7826
- AutoEventsTracker.trackPageView();
7827
- }
7828
- // Note: If auto events should be disabled on new page, trackAutoEvent will check
7829
- // shouldTrackAutoEvents() before tracking, so no need to remove listeners
7830
- }
7831
- }
7832
-
7833
- // Check on popstate (browser back/forward)
7834
- window.addEventListener('popstate', checkPathChange);
7835
-
7836
- // For SPAs using history.pushState/replaceState, monitor them
7837
- const originalPushState = history.pushState;
7838
- const originalReplaceState = history.replaceState;
7839
-
7840
- history.pushState = function(...args) {
7841
- originalPushState.apply(history, args);
7842
- setTimeout(checkPathChange, 0);
7843
- };
7844
-
7845
- history.replaceState = function(...args) {
7846
- originalReplaceState.apply(history, args);
7847
- setTimeout(checkPathChange, 0);
7848
- };
7849
- }
7850
-
7851
7818
  // Initialize SDK
7852
7819
  async function initializeSDK() {
7853
7820
  await Initializer.initialize();
@@ -7857,9 +7824,6 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
7857
7824
  setTimeout(() => {
7858
7825
  AutoEventsTracker.setup();
7859
7826
  }, 2000); // Wait 2 seconds for initial session to be saved
7860
-
7861
- // Setup SPA navigation monitoring for auto events
7862
- setupSPANavigationMonitoring();
7863
7827
  }
7864
7828
 
7865
7829
  if (document.readyState === 'loading') {
package/lib/umd/index.js CHANGED
@@ -3774,6 +3774,18 @@
3774
3774
 
3775
3775
  // Save updated session
3776
3776
  StorageManager.saveSession(session);
3777
+
3778
+ // Fire page_view auto event on every navigation (single source of truth with session tracking)
3779
+ // This ensures SPAs get page_view on route changes without a separate history override
3780
+ if (typeof CONFIG !== 'undefined' && CONFIG.AUTO_EVENTS && CONFIG.AUTO_EVENTS.enabled && typeof shouldTrackAutoEvents === 'function' && shouldTrackAutoEvents()) {
3781
+ if (typeof AutoEventsTracker !== 'undefined') {
3782
+ if (!AutoEventsTracker.isSetup) {
3783
+ AutoEventsTracker.setup();
3784
+ } else {
3785
+ AutoEventsTracker.trackPageView();
3786
+ }
3787
+ }
3788
+ }
3777
3789
  } catch (error) {
3778
3790
  console.error("Error tracking page visit:", error);
3779
3791
  }
@@ -7809,51 +7821,6 @@
7809
7821
  // Initialize SDK when DOM is ready
7810
7822
  // ============================================================================
7811
7823
 
7812
- /**
7813
- * Monitor path changes for Single Page Applications (SPAs)
7814
- * Re-checks auto events configuration when navigation occurs
7815
- */
7816
- function setupSPANavigationMonitoring() {
7817
- let lastPath = window.location.pathname;
7818
-
7819
- // Check path changes
7820
- function checkPathChange() {
7821
- const currentPath = window.location.pathname;
7822
- if (currentPath !== lastPath) {
7823
- lastPath = currentPath;
7824
-
7825
- // If auto events were disabled on previous page but enabled on new page, setup
7826
- if (CONFIG.AUTO_EVENTS.enabled && shouldTrackAutoEvents() && !AutoEventsTracker.isSetup) {
7827
- AutoEventsTracker.setup();
7828
- }
7829
- // Fire page_view on every SPA navigation when auto events are enabled
7830
- // (setup() only runs once, so trackPageView wouldn't fire on route changes otherwise)
7831
- if (CONFIG.AUTO_EVENTS.enabled && shouldTrackAutoEvents() && AutoEventsTracker.isSetup) {
7832
- AutoEventsTracker.trackPageView();
7833
- }
7834
- // Note: If auto events should be disabled on new page, trackAutoEvent will check
7835
- // shouldTrackAutoEvents() before tracking, so no need to remove listeners
7836
- }
7837
- }
7838
-
7839
- // Check on popstate (browser back/forward)
7840
- window.addEventListener('popstate', checkPathChange);
7841
-
7842
- // For SPAs using history.pushState/replaceState, monitor them
7843
- const originalPushState = history.pushState;
7844
- const originalReplaceState = history.replaceState;
7845
-
7846
- history.pushState = function(...args) {
7847
- originalPushState.apply(history, args);
7848
- setTimeout(checkPathChange, 0);
7849
- };
7850
-
7851
- history.replaceState = function(...args) {
7852
- originalReplaceState.apply(history, args);
7853
- setTimeout(checkPathChange, 0);
7854
- };
7855
- }
7856
-
7857
7824
  // Initialize SDK
7858
7825
  async function initializeSDK() {
7859
7826
  await Initializer.initialize();
@@ -7863,9 +7830,6 @@
7863
7830
  setTimeout(() => {
7864
7831
  AutoEventsTracker.setup();
7865
7832
  }, 2000); // Wait 2 seconds for initial session to be saved
7866
-
7867
- // Setup SPA navigation monitoring for auto events
7868
- setupSPANavigationMonitoring();
7869
7833
  }
7870
7834
 
7871
7835
  if (document.readyState === 'loading') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cryptique-sdk",
3
- "version": "1.1.1",
3
+ "version": "1.1.4",
4
4
  "type": "module",
5
5
  "description": "Cryptique Analytics SDK - Comprehensive web analytics and user tracking for modern web applications",
6
6
  "main": "lib/cjs/index.js",