spotny-sdk 1.0.20 → 1.0.21

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.
@@ -97,6 +97,8 @@ public class SpotnyBeaconScanner: NSObject {
97
97
  private var campaignFetchInProgress: [String: Bool] = [:]
98
98
  private var campaignFetched: [String: Bool] = [:]
99
99
  private var campaignFetchCooldown: [String: Date] = [:] // backoff after failed fetch
100
+ // 410 from /track means backend session expired — stop sending heartbeats until next NEARBY
101
+ private var impressionDisabled: [String: Bool] = [:]
100
102
 
101
103
  // MARK: - Init
102
104
 
@@ -663,6 +665,9 @@ public class SpotnyBeaconScanner: NSObject {
663
665
  if 200...299 ~= status {
664
666
  print("✅ SpotnySDK: \(eventType) — \(String(format: "%.2f", distance))m")
665
667
  self.logToFile("\(eventType) beacon \(key) @ \(String(format: "%.2f", distance))m")
668
+ } else if status == 410 && isImpression {
669
+ self.impressionDisabled[key] = true
670
+ print("⚠️ SpotnySDK: IMPRESSION_HEARTBEAT session expired (410) — stopping heartbeats for \(key)")
666
671
  } else if status == 429 {
667
672
  let penalty = Date().addingTimeInterval(10)
668
673
  if isImpression { self.lastImpressionEventSent[key] = penalty }
@@ -751,6 +756,7 @@ public class SpotnyBeaconScanner: NSObject {
751
756
  campaignFetchInProgress.removeValue(forKey: key)
752
757
  campaignFetched.removeValue(forKey: key)
753
758
  campaignFetchCooldown.removeValue(forKey: key)
759
+ impressionDisabled.removeValue(forKey: key)
754
760
  print("🧹 SpotnySDK: Cleaned up \(key)")
755
761
  }
756
762
 
@@ -857,6 +863,7 @@ extension SpotnyBeaconScanner: KTKBeaconManagerDelegate {
857
863
  if let campaign = activeCampaigns[key],
858
864
  campaign.campaignId != nil,
859
865
  !campaign.inQueue,
866
+ impressionDisabled[key] != true,
860
867
  distance <= impressionDistance {
861
868
  let lastImp = lastImpressionEventSent[key] ?? .distantPast
862
869
  if now.timeIntervalSince(lastImp) >= impressionEventInterval {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spotny-sdk",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Beacon Scanner",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",