@umituz/react-native-subscription 2.37.106 → 2.37.107

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.37.106",
3
+ "version": "2.37.107",
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",
@@ -1,12 +1,10 @@
1
1
  import Purchases, { type CustomerInfo, type PurchasesOfferings } from "react-native-purchases";
2
- import { doc, setDoc } from "firebase/firestore";
3
2
  import type { InitializeResult } from "../../../../shared/application/ports/IRevenueCatService";
4
3
  import type { InitializerDeps } from "./RevenueCatInitializer.types";
5
4
  import { FAILED_INITIALIZATION_RESULT } from "./initializerConstants";
6
5
  import { UserSwitchMutex } from "./UserSwitchMutex";
7
6
  import { getPremiumEntitlement } from "../../core/types";
8
7
  import { ANONYMOUS_CACHE_KEY, type PeriodType } from "../../../subscription/core/SubscriptionConstants";
9
- import { requireFirestore } from "../../../../shared/infrastructure/firestore";
10
8
 
11
9
  declare const __DEV__: boolean;
12
10
 
@@ -39,17 +37,6 @@ function isAnonymousId(userId: string): boolean {
39
37
  return userId.startsWith('$RCAnonymous') || userId.startsWith('device_');
40
38
  }
41
39
 
42
- async function syncRevenueCatIdToProfile(firebaseUserId: string, revenueCatUserId: string): Promise<void> {
43
- try {
44
- const db = requireFirestore();
45
- const userRef = doc(db, "users", firebaseUserId);
46
- await setDoc(userRef, { revenueCatUserId }, { merge: true });
47
- } catch (error) {
48
- // Non-fatal: profile update failure should not block SDK initialization
49
- console.warn('[UserSwitchHandler] Failed to sync RevenueCat ID to profile:', error instanceof Error ? error.message : String(error));
50
- }
51
- }
52
-
53
40
  export async function handleUserSwitch(
54
41
  deps: InitializerDeps,
55
42
  userId: string
@@ -119,11 +106,6 @@ async function performUserSwitch(
119
106
  deps.setCurrentUserId(normalizedUserId || undefined);
120
107
  const offerings = await fetchOfferingsSafe();
121
108
 
122
- if (normalizedUserId) {
123
- const rcId = await Purchases.getAppUserID();
124
- void syncRevenueCatIdToProfile(normalizedUserId, rcId);
125
- }
126
-
127
109
  if (typeof __DEV__ !== 'undefined' && __DEV__) {
128
110
  console.log('[UserSwitchHandler] User switch completed successfully');
129
111
  }
@@ -184,13 +166,8 @@ export async function handleInitialConfiguration(
184
166
  fetchOfferingsSafe(),
185
167
  ]);
186
168
 
187
- const currentUserId = await Purchases.getAppUserID();
188
-
189
- if (normalizedUserId) {
190
- void syncRevenueCatIdToProfile(normalizedUserId, currentUserId);
191
- }
192
-
193
169
  if (typeof __DEV__ !== 'undefined' && __DEV__) {
170
+ const currentUserId = await Purchases.getAppUserID();
194
171
  console.log('[UserSwitchHandler] Initial configuration completed:', {
195
172
  revenueCatUserId: currentUserId,
196
173
  activeEntitlements: Object.keys(customerInfo.entitlements.active),
@@ -39,6 +39,10 @@ export const extractRevenueCatData = (customerInfo: CustomerInfo, entitlementId:
39
39
  return {
40
40
  expirationDate: entitlement.expirationDate ?? null,
41
41
  willRenew: entitlement.willRenew ?? null,
42
+ // Maps SDK's `storeTransactionId` (current transaction ID from Apple/Google)
43
+ // to our domain's `originalTransactionId`. Used as dedup key in processedTransactions.
44
+ // Note: The SDK does not expose `original_store_transaction_id` (the first purchase's
45
+ // ID that stays constant across renewals) — only available via server-side webhooks.
42
46
  originalTransactionId: subscription?.storeTransactionId ?? null,
43
47
  periodType: validatePeriodType(entitlement.periodType),
44
48
  packageType: null,