cryptique-sdk 1.0.8 → 1.0.9

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
@@ -4148,9 +4148,11 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
4148
4148
  }
4149
4149
 
4150
4150
  // Use fetch for regular sends or as fallback
4151
+ const controller = new AbortController();
4152
+ let timeoutId = null;
4153
+
4151
4154
  try {
4152
- const controller = new AbortController();
4153
- const timeoutId = setTimeout(() => controller.abort(), timeout);
4155
+ timeoutId = setTimeout(() => controller.abort(), timeout);
4154
4156
 
4155
4157
  const fetchOptions = {
4156
4158
  method: method,
@@ -4167,6 +4169,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
4167
4169
  const response = await fetch(endpoint, fetchOptions);
4168
4170
 
4169
4171
  clearTimeout(timeoutId);
4172
+ timeoutId = null;
4170
4173
 
4171
4174
  // Read response body (can only read once)
4172
4175
  const responseText = await response.text();
@@ -4214,9 +4217,21 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
4214
4217
 
4215
4218
  return responseData;
4216
4219
  } catch (error) {
4220
+ // Always clear timeout in case of error
4221
+ if (timeoutId !== null) {
4222
+ clearTimeout(timeoutId);
4223
+ }
4224
+
4225
+ // Handle AbortError gracefully (timeout or page unload)
4226
+ if (error.name === 'AbortError' || error.message?.includes('aborted') || error.message?.includes('signal is aborted')) {
4227
+ // Don't log as error - this is expected behavior for timeouts or page unloads
4228
+ // Don't retry aborted requests - they were intentionally cancelled
4229
+ return; // Silently return, don't throw
4230
+ }
4231
+
4217
4232
  console.error('❌ Error sending data:', error);
4218
4233
 
4219
- // Retry if retries > 0
4234
+ // Retry if retries > 0 (but not for abort errors)
4220
4235
  if (retries > 0) {
4221
4236
  await new Promise(resolve => setTimeout(resolve, 1000)); // Wait 1s before retry
4222
4237
  return this.send(endpoint, data, { ...options, retries: retries - 1 });
package/lib/esm/index.js CHANGED
@@ -4146,9 +4146,11 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
4146
4146
  }
4147
4147
 
4148
4148
  // Use fetch for regular sends or as fallback
4149
+ const controller = new AbortController();
4150
+ let timeoutId = null;
4151
+
4149
4152
  try {
4150
- const controller = new AbortController();
4151
- const timeoutId = setTimeout(() => controller.abort(), timeout);
4153
+ timeoutId = setTimeout(() => controller.abort(), timeout);
4152
4154
 
4153
4155
  const fetchOptions = {
4154
4156
  method: method,
@@ -4165,6 +4167,7 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
4165
4167
  const response = await fetch(endpoint, fetchOptions);
4166
4168
 
4167
4169
  clearTimeout(timeoutId);
4170
+ timeoutId = null;
4168
4171
 
4169
4172
  // Read response body (can only read once)
4170
4173
  const responseText = await response.text();
@@ -4212,9 +4215,21 @@ if (window.Cryptique && window.Cryptique.initialized) ; else {
4212
4215
 
4213
4216
  return responseData;
4214
4217
  } catch (error) {
4218
+ // Always clear timeout in case of error
4219
+ if (timeoutId !== null) {
4220
+ clearTimeout(timeoutId);
4221
+ }
4222
+
4223
+ // Handle AbortError gracefully (timeout or page unload)
4224
+ if (error.name === 'AbortError' || error.message?.includes('aborted') || error.message?.includes('signal is aborted')) {
4225
+ // Don't log as error - this is expected behavior for timeouts or page unloads
4226
+ // Don't retry aborted requests - they were intentionally cancelled
4227
+ return; // Silently return, don't throw
4228
+ }
4229
+
4215
4230
  console.error('❌ Error sending data:', error);
4216
4231
 
4217
- // Retry if retries > 0
4232
+ // Retry if retries > 0 (but not for abort errors)
4218
4233
  if (retries > 0) {
4219
4234
  await new Promise(resolve => setTimeout(resolve, 1000)); // Wait 1s before retry
4220
4235
  return this.send(endpoint, data, { ...options, retries: retries - 1 });
package/lib/umd/index.js CHANGED
@@ -4152,9 +4152,11 @@
4152
4152
  }
4153
4153
 
4154
4154
  // Use fetch for regular sends or as fallback
4155
+ const controller = new AbortController();
4156
+ let timeoutId = null;
4157
+
4155
4158
  try {
4156
- const controller = new AbortController();
4157
- const timeoutId = setTimeout(() => controller.abort(), timeout);
4159
+ timeoutId = setTimeout(() => controller.abort(), timeout);
4158
4160
 
4159
4161
  const fetchOptions = {
4160
4162
  method: method,
@@ -4171,6 +4173,7 @@
4171
4173
  const response = await fetch(endpoint, fetchOptions);
4172
4174
 
4173
4175
  clearTimeout(timeoutId);
4176
+ timeoutId = null;
4174
4177
 
4175
4178
  // Read response body (can only read once)
4176
4179
  const responseText = await response.text();
@@ -4218,9 +4221,21 @@
4218
4221
 
4219
4222
  return responseData;
4220
4223
  } catch (error) {
4224
+ // Always clear timeout in case of error
4225
+ if (timeoutId !== null) {
4226
+ clearTimeout(timeoutId);
4227
+ }
4228
+
4229
+ // Handle AbortError gracefully (timeout or page unload)
4230
+ if (error.name === 'AbortError' || error.message?.includes('aborted') || error.message?.includes('signal is aborted')) {
4231
+ // Don't log as error - this is expected behavior for timeouts or page unloads
4232
+ // Don't retry aborted requests - they were intentionally cancelled
4233
+ return; // Silently return, don't throw
4234
+ }
4235
+
4221
4236
  console.error('❌ Error sending data:', error);
4222
4237
 
4223
- // Retry if retries > 0
4238
+ // Retry if retries > 0 (but not for abort errors)
4224
4239
  if (retries > 0) {
4225
4240
  await new Promise(resolve => setTimeout(resolve, 1000)); // Wait 1s before retry
4226
4241
  return this.send(endpoint, data, { ...options, retries: retries - 1 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cryptique-sdk",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
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",