cryptique-sdk 1.2.3 → 1.2.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
@@ -2880,14 +2880,34 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
2880
2880
  });
2881
2881
 
2882
2882
  // Automatic wallet address matching - only call once per address per session
2883
- // Prevents repeated calls to /api/sdk/wallet-address on every interval tick
2883
+ // Prevents repeated calls to /api/sdk/wallet-address on every interval tick.
2884
+ // Also guards against the race condition where the wallet is detected before the
2885
+ // initial session POST has completed on the backend (which would return 404).
2886
+ // We wait until isInitialized is true (meaning sendInitialSessionData has run)
2887
+ // plus an extra 1 s buffer to ensure the backend has persisted the session.
2884
2888
  if (walletAddress !== runtimeState.reportedWalletAddress) {
2885
2889
  runtimeState.reportedWalletAddress = walletAddress;
2886
- IdentityManager.walletAddress(walletAddress).catch((error) => {
2887
- console.warn('Error in automatic wallet address matching:', error);
2888
- // Reset so it retries next time wallet info is updated
2889
- runtimeState.reportedWalletAddress = null;
2890
- });
2890
+ const _sendWalletAddress = () => {
2891
+ IdentityManager.walletAddress(walletAddress).catch((error) => {
2892
+ console.warn('Error in automatic wallet address matching:', error);
2893
+ // Reset so it retries next time wallet info is updated
2894
+ runtimeState.reportedWalletAddress = null;
2895
+ });
2896
+ };
2897
+ if (runtimeState.isInitialized) {
2898
+ // SDK already fully initialised - still give backend 1 s to persist session
2899
+ setTimeout(_sendWalletAddress, 1000);
2900
+ } else {
2901
+ // SDK still starting up - poll until initialised then add 1 s buffer
2902
+ const _waitAndSend = () => {
2903
+ if (runtimeState.isInitialized) {
2904
+ setTimeout(_sendWalletAddress, 1000);
2905
+ } else {
2906
+ setTimeout(_waitAndSend, 200);
2907
+ }
2908
+ };
2909
+ setTimeout(_waitAndSend, 200);
2910
+ }
2891
2911
  }
2892
2912
  }
2893
2913
 
package/lib/esm/index.js CHANGED
@@ -2878,14 +2878,34 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
2878
2878
  });
2879
2879
 
2880
2880
  // Automatic wallet address matching - only call once per address per session
2881
- // Prevents repeated calls to /api/sdk/wallet-address on every interval tick
2881
+ // Prevents repeated calls to /api/sdk/wallet-address on every interval tick.
2882
+ // Also guards against the race condition where the wallet is detected before the
2883
+ // initial session POST has completed on the backend (which would return 404).
2884
+ // We wait until isInitialized is true (meaning sendInitialSessionData has run)
2885
+ // plus an extra 1 s buffer to ensure the backend has persisted the session.
2882
2886
  if (walletAddress !== runtimeState.reportedWalletAddress) {
2883
2887
  runtimeState.reportedWalletAddress = walletAddress;
2884
- IdentityManager.walletAddress(walletAddress).catch((error) => {
2885
- console.warn('Error in automatic wallet address matching:', error);
2886
- // Reset so it retries next time wallet info is updated
2887
- runtimeState.reportedWalletAddress = null;
2888
- });
2888
+ const _sendWalletAddress = () => {
2889
+ IdentityManager.walletAddress(walletAddress).catch((error) => {
2890
+ console.warn('Error in automatic wallet address matching:', error);
2891
+ // Reset so it retries next time wallet info is updated
2892
+ runtimeState.reportedWalletAddress = null;
2893
+ });
2894
+ };
2895
+ if (runtimeState.isInitialized) {
2896
+ // SDK already fully initialised - still give backend 1 s to persist session
2897
+ setTimeout(_sendWalletAddress, 1000);
2898
+ } else {
2899
+ // SDK still starting up - poll until initialised then add 1 s buffer
2900
+ const _waitAndSend = () => {
2901
+ if (runtimeState.isInitialized) {
2902
+ setTimeout(_sendWalletAddress, 1000);
2903
+ } else {
2904
+ setTimeout(_waitAndSend, 200);
2905
+ }
2906
+ };
2907
+ setTimeout(_waitAndSend, 200);
2908
+ }
2889
2909
  }
2890
2910
  }
2891
2911
 
package/lib/umd/index.js CHANGED
@@ -2884,14 +2884,34 @@
2884
2884
  });
2885
2885
 
2886
2886
  // Automatic wallet address matching - only call once per address per session
2887
- // Prevents repeated calls to /api/sdk/wallet-address on every interval tick
2887
+ // Prevents repeated calls to /api/sdk/wallet-address on every interval tick.
2888
+ // Also guards against the race condition where the wallet is detected before the
2889
+ // initial session POST has completed on the backend (which would return 404).
2890
+ // We wait until isInitialized is true (meaning sendInitialSessionData has run)
2891
+ // plus an extra 1 s buffer to ensure the backend has persisted the session.
2888
2892
  if (walletAddress !== runtimeState.reportedWalletAddress) {
2889
2893
  runtimeState.reportedWalletAddress = walletAddress;
2890
- IdentityManager.walletAddress(walletAddress).catch((error) => {
2891
- console.warn('Error in automatic wallet address matching:', error);
2892
- // Reset so it retries next time wallet info is updated
2893
- runtimeState.reportedWalletAddress = null;
2894
- });
2894
+ const _sendWalletAddress = () => {
2895
+ IdentityManager.walletAddress(walletAddress).catch((error) => {
2896
+ console.warn('Error in automatic wallet address matching:', error);
2897
+ // Reset so it retries next time wallet info is updated
2898
+ runtimeState.reportedWalletAddress = null;
2899
+ });
2900
+ };
2901
+ if (runtimeState.isInitialized) {
2902
+ // SDK already fully initialised - still give backend 1 s to persist session
2903
+ setTimeout(_sendWalletAddress, 1000);
2904
+ } else {
2905
+ // SDK still starting up - poll until initialised then add 1 s buffer
2906
+ const _waitAndSend = () => {
2907
+ if (runtimeState.isInitialized) {
2908
+ setTimeout(_sendWalletAddress, 1000);
2909
+ } else {
2910
+ setTimeout(_waitAndSend, 200);
2911
+ }
2912
+ };
2913
+ setTimeout(_waitAndSend, 200);
2914
+ }
2895
2915
  }
2896
2916
  }
2897
2917
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cryptique-sdk",
3
- "version": "1.2.3",
3
+ "version": "1.2.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",