@umituz/react-native-subscription 2.19.3 → 2.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-subscription",
3
- "version": "2.19.3",
3
+ "version": "2.19.4",
4
4
  "description": "Complete subscription management with RevenueCat, paywall UI, and credits system for React Native apps",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -113,22 +113,35 @@ export async function initializeCreditsTransaction(
113
113
  ? [...(existing?.purchaseHistory || []), purchaseMetadata].slice(-10)
114
114
  : existing?.purchaseHistory;
115
115
 
116
- const creditsData = {
116
+ // Build credits data, excluding undefined values (Firestore doesn't accept undefined)
117
+ const creditsData: Record<string, unknown> = {
117
118
  credits: newCredits,
118
- packageType: packageType !== "unknown" ? packageType : undefined,
119
119
  creditLimit,
120
- productId: productId || undefined,
121
- purchaseSource: metadata?.source,
122
- purchaseType: metadata?.type ? purchaseType : undefined,
123
- platform: productId ? platform : undefined,
124
- appVersion: productId ? appVersion : undefined,
125
120
  purchasedAt,
126
121
  lastUpdatedAt: now,
127
122
  lastPurchaseAt: now,
128
123
  processedPurchases,
129
- purchaseHistory,
130
124
  };
131
125
 
126
+ // Only add optional fields if they have values
127
+ if (packageType && packageType !== "unknown") {
128
+ creditsData.packageType = packageType;
129
+ }
130
+ if (productId) {
131
+ creditsData.productId = productId;
132
+ creditsData.platform = platform;
133
+ creditsData.appVersion = appVersion;
134
+ }
135
+ if (metadata?.source) {
136
+ creditsData.purchaseSource = metadata.source;
137
+ }
138
+ if (metadata?.type) {
139
+ creditsData.purchaseType = purchaseType;
140
+ }
141
+ if (purchaseHistory && purchaseHistory.length > 0) {
142
+ creditsData.purchaseHistory = purchaseHistory;
143
+ }
144
+
132
145
  transaction.set(creditsRef, creditsData, { merge: true });
133
146
 
134
147
  return { credits: newCredits };