rampkit-expo-dev 0.0.73 → 0.0.74

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.
@@ -483,18 +483,23 @@ public class RampKitModule: Module {
483
483
  return result
484
484
  }
485
485
 
486
- /// Check all current entitlements and track any we haven't seen before
487
- /// This catches purchases made by Superwall/RevenueCat before our observer started
486
+ /// Check ALL transactions (not just current entitlements) and track any we haven't seen before
487
+ /// This catches ALL purchases including expired/superseded ones made by Superwall/RevenueCat
488
488
  /// Returns a dictionary with the results for JavaScript logging
489
489
  ///
490
490
  /// IMPORTANT: "Already sent" means we previously sent this transaction to the backend
491
- /// and received a successful HTTP 2xx response. The originalTransactionId is stored
491
+ /// and received a successful HTTP 2xx response. The transactionId is stored
492
492
  /// in UserDefaults ONLY after a successful send.
493
+ ///
494
+ /// NOTE: We use Transaction.all instead of Transaction.currentEntitlements because
495
+ /// currentEntitlements only returns ACTIVE entitlements. If a user purchases a subscription
496
+ /// and it expires, or if they upgrade (superseding the old transaction), currentEntitlements
497
+ /// will NOT include the original purchase. Transaction.all returns the complete history.
493
498
  @available(iOS 15.0, *)
494
499
  private func checkAndTrackCurrentEntitlements() async -> [String: Any] {
495
500
  print("[RampKit] ")
496
501
  print("[RampKit] ════════════════════════════════════════════════════════════")
497
- print("[RampKit] 🔍 CHECKING ENTITLEMENTS FOR UNSENT PURCHASES")
502
+ print("[RampKit] 🔍 CHECKING ALL TRANSACTIONS FOR UNSENT PURCHASES")
498
503
  print("[RampKit] ════════════════════════════════════════════════════════════")
499
504
  print("[RampKit] ")
500
505
  print("[RampKit] 📚 Tracked transaction IDs in storage: \(trackedTransactionIds.count)")
@@ -518,11 +523,11 @@ public class RampKitModule: Module {
518
523
  var skippedReasons: [[String: Any]] = []
519
524
  var alreadyTrackedDetails: [[String: Any]] = [] // NEW: Details of already-tracked transactions
520
525
 
521
- for await result in Transaction.currentEntitlements {
526
+ for await result in Transaction.all {
522
527
  foundCount += 1
523
528
 
524
529
  guard case .verified(let transaction) = result else {
525
- print("[RampKit] ⚠️ Unverified entitlement skipped")
530
+ print("[RampKit] ⚠️ Unverified transaction skipped")
526
531
  skippedReasons.append(["productId": "unknown", "reason": "unverified"])
527
532
  continue
528
533
  }
@@ -545,7 +550,7 @@ public class RampKitModule: Module {
545
550
  txDetails["environment"] = transaction.environment.rawValue
546
551
  }
547
552
 
548
- print("[RampKit] 📦 Found entitlement:")
553
+ print("[RampKit] 📦 Found transaction:")
549
554
  print("[RampKit] - productId: \(transaction.productID)")
550
555
  print("[RampKit] - transactionId: \(transactionId)")
551
556
  print("[RampKit] - originalTransactionId: \(originalId)")
@@ -604,9 +609,9 @@ public class RampKitModule: Module {
604
609
 
605
610
  print("[RampKit] ")
606
611
  print("[RampKit] ════════════════════════════════════════════════════════════")
607
- print("[RampKit] 📊 ENTITLEMENT CHECK SUMMARY")
612
+ print("[RampKit] 📊 TRANSACTION CHECK SUMMARY")
608
613
  print("[RampKit] ════════════════════════════════════════════════════════════")
609
- print("[RampKit] Total entitlements found: \(foundCount)")
614
+ print("[RampKit] Total transactions found: \(foundCount)")
610
615
  print("[RampKit] Already sent (HTTP 2xx): \(trackedCount) (no action needed)")
611
616
  print("[RampKit] Skipped (renewal/revoked): \(skippedReasons.count) (backend gets via S2S)")
612
617
  print("[RampKit] NEW events sent this session: \(newCount)")
@@ -1140,10 +1145,10 @@ public class RampKitModule: Module {
1140
1145
  private func trackPurchaseFromProductId(productId: String) async {
1141
1146
  print("[RampKit] 🔍 Looking up transaction for product: \(productId)")
1142
1147
 
1143
- // Try to find the latest transaction for this product
1148
+ // Try to find the latest transaction for this product (check all transactions, not just current entitlements)
1144
1149
  var latestTransaction: Transaction?
1145
1150
 
1146
- for await result in Transaction.currentEntitlements {
1151
+ for await result in Transaction.all {
1147
1152
  if case .verified(let transaction) = result {
1148
1153
  if transaction.productID == productId {
1149
1154
  if latestTransaction == nil || transaction.purchaseDate > latestTransaction!.purchaseDate {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rampkit-expo-dev",
3
- "version": "0.0.73",
3
+ "version": "0.0.74",
4
4
  "description": "The Expo SDK for RampKit. Build, test, and personalize app onboardings with instant updates.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",