@zaplier/sdk 1.1.3 → 1.1.5

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.cjs CHANGED
@@ -5694,11 +5694,22 @@ async function collectFingerprint(options = {}) {
5694
5694
  timezone: browser?.timezone || "unknown",
5695
5695
  // PRIORITY 3: Primary language only (most stable language preference)
5696
5696
  // Remove secondary languages as they can change more frequently
5697
- primaryLanguage: Array.isArray(browser?.languages) &&
5698
- browser.languages.length > 0 &&
5699
- browser.languages[0]
5700
- ? browser.languages[0].toLowerCase().split("-")[0] // Only language code (en, pt, fr), not region
5701
- : "unknown",
5697
+ primaryLanguage: (() => {
5698
+ try {
5699
+ const languages = browser?.languages;
5700
+ if (Array.isArray(languages) && languages.length > 0 && languages[0]) {
5701
+ return languages[0].toLowerCase().split("-")[0]; // Only language code (en, pt, fr), not region
5702
+ }
5703
+ // Fallback to navigator.language if browser.languages is not available
5704
+ if (typeof navigator !== 'undefined' && navigator.language) {
5705
+ return navigator.language.toLowerCase().split("-")[0];
5706
+ }
5707
+ return "unknown";
5708
+ }
5709
+ catch {
5710
+ return "unknown";
5711
+ }
5712
+ })(),
5702
5713
  // PRIORITY 4: Platform (ultra-stable - OS doesn't change)
5703
5714
  platform: (browser?.platform || "unknown").toLowerCase(),
5704
5715
  // PRIORITY 5: Device type (critical for differentiation, ultra-stable)
@@ -7587,15 +7598,15 @@ class ZaplierSDK {
7587
7598
  */
7588
7599
  getBrowserFingerprint() {
7589
7600
  const components = [
7590
- navigator.userAgent || '',
7591
- navigator.platform || '',
7601
+ navigator.userAgent || "",
7602
+ navigator.platform || "",
7592
7603
  screen.width || 0,
7593
7604
  screen.height || 0,
7594
7605
  new Date(2024, 0, 1).getTimezoneOffset(),
7595
- navigator.language || '',
7596
- navigator.hardwareConcurrency || 0
7606
+ navigator.language || "",
7607
+ navigator.hardwareConcurrency || 0,
7597
7608
  ];
7598
- const combined = components.join('|');
7609
+ const combined = components.join("|");
7599
7610
  let hash = 0;
7600
7611
  for (let i = 0; i < combined.length; i++) {
7601
7612
  const char = combined.charCodeAt(i);
@@ -7685,8 +7696,8 @@ class ZaplierSDK {
7685
7696
  // Use page load time (stable during session) instead of current time
7686
7697
  performance.timeOrigin || 0,
7687
7698
  // Deterministic entropy from browser characteristics
7688
- (navigator.plugins ? navigator.plugins.length : 0),
7689
- (navigator.mimeTypes ? navigator.mimeTypes.length : 0),
7699
+ navigator.plugins ? navigator.plugins.length : 0,
7700
+ navigator.mimeTypes ? navigator.mimeTypes.length : 0,
7690
7701
  // Memory usage pattern (if available, use rounded values for stability)
7691
7702
  Math.floor((performance.memory?.usedJSHeapSize || 0) / 1000000),
7692
7703
  Math.floor((performance.memory?.totalJSHeapSize || 0) / 1000000),
@@ -7698,14 +7709,18 @@ class ZaplierSDK {
7698
7709
  window.outerWidth || 0,
7699
7710
  Math.floor((window.devicePixelRatio || 1) * 100) / 100, // Round to 2 decimals
7700
7711
  // Canvas support (deterministic)
7701
- typeof document.createElement('canvas').getContext === 'function' ? 1 : 0,
7712
+ typeof document.createElement("canvas").getContext === "function"
7713
+ ? 1
7714
+ : 0,
7702
7715
  ];
7703
7716
  // Create deterministic entropy string
7704
7717
  const entropyString = entropyComponents.join("|");
7705
7718
  // Add deterministic checksum instead of random values
7706
7719
  let checksum = 0;
7707
7720
  for (let i = 0; i < entropyString.length; i++) {
7708
- checksum = ((checksum << 5) - checksum + entropyString.charCodeAt(i)) & 0xffffffff;
7721
+ checksum =
7722
+ ((checksum << 5) - checksum + entropyString.charCodeAt(i)) &
7723
+ 0xffffffff;
7709
7724
  }
7710
7725
  const deterministic = Math.abs(checksum).toString(36);
7711
7726
  // Advanced hash function with better distribution
@@ -7847,14 +7862,7 @@ class ZaplierSDK {
7847
7862
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
7848
7863
  }
7849
7864
  const jsonResponse = await response.json();
7850
- // If anti-adblock is enabled, also send via anti-adblock as a backup
7851
- // (but don't wait for it or use its response)
7852
- if (this.antiAdblockManager && method === "POST") {
7853
- // Send in parallel without blocking
7854
- this.antiAdblockManager.send(data, endpoint).catch(() => {
7855
- // Silently fail - we already got the response from standard fetch
7856
- });
7857
- }
7865
+ // Return immediately - anti-adblock is only used as fallback when fetch fails
7858
7866
  return jsonResponse;
7859
7867
  }
7860
7868
  catch (error) {