@umituz/react-native-subscription 2.37.7 → 2.37.9
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 +1 -1
- package/src/domains/credits/infrastructure/operations/CreditsInitializer.ts +1 -1
- package/src/domains/revenuecat/infrastructure/services/RevenueCatInitializer.ts +2 -2
- package/src/domains/revenuecat/infrastructure/services/UserSwitchMutex.ts +1 -1
- package/src/domains/subscription/application/initializer/BackgroundInitializer.ts +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-subscription",
|
|
3
|
-
"version": "2.37.
|
|
3
|
+
"version": "2.37.9",
|
|
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",
|
|
@@ -77,7 +77,7 @@ export async function initializeCreditsWithRetry(params: InitializeCreditsParams
|
|
|
77
77
|
const exponentialDelay = baseDelay * Math.pow(2, attempt);
|
|
78
78
|
const jitter = Math.random() * baseDelay;
|
|
79
79
|
const delay = Math.min(exponentialDelay + jitter, maxDelay);
|
|
80
|
-
await new Promise(resolve => setTimeout(resolve, delay));
|
|
80
|
+
await new Promise<void>(resolve => setTimeout(() => resolve(), delay));
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
83
|
break;
|
|
@@ -29,7 +29,7 @@ export async function initializeSDK(
|
|
|
29
29
|
if (configState.configurationPromise) {
|
|
30
30
|
await configState.configurationPromise;
|
|
31
31
|
} else {
|
|
32
|
-
await new Promise(resolve => setTimeout(resolve, CONFIGURATION_RETRY_DELAY_MS));
|
|
32
|
+
await new Promise<void>(resolve => setTimeout(() => resolve(), CONFIGURATION_RETRY_DELAY_MS));
|
|
33
33
|
}
|
|
34
34
|
retryCount++;
|
|
35
35
|
}
|
|
@@ -65,7 +65,7 @@ export async function initializeSDK(
|
|
|
65
65
|
retryCount: configStartRetryCount,
|
|
66
66
|
error
|
|
67
67
|
});
|
|
68
|
-
await new Promise(resolve => setTimeout(resolve, CONFIGURATION_RETRY_DELAY_MS));
|
|
68
|
+
await new Promise<void>(resolve => setTimeout(() => resolve(), CONFIGURATION_RETRY_DELAY_MS));
|
|
69
69
|
return initializeSDK(deps, userId, apiKey, configStartRetryCount + 1);
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -41,7 +41,7 @@ class UserSwitchMutexImpl {
|
|
|
41
41
|
if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
42
42
|
console.log(`[UserSwitchMutex] Rate limiting: waiting ${delayNeeded}ms`);
|
|
43
43
|
}
|
|
44
|
-
await new Promise(resolve => setTimeout(resolve, delayNeeded));
|
|
44
|
+
await new Promise<void>(resolve => setTimeout(() => resolve(), delayNeeded));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -5,7 +5,7 @@ import type { SubscriptionInitConfig } from "../SubscriptionInitializerTypes";
|
|
|
5
5
|
const AUTH_STATE_DEBOUNCE_MS = 500; // Wait 500ms before processing auth state changes
|
|
6
6
|
|
|
7
7
|
export async function startBackgroundInitialization(config: SubscriptionInitConfig): Promise<() => void> {
|
|
8
|
-
let debounceTimer:
|
|
8
|
+
let debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
9
9
|
let lastUserId: string | undefined = undefined;
|
|
10
10
|
|
|
11
11
|
const initializeInBackground = async (revenueCatUserId?: string): Promise<void> => {
|
|
@@ -58,7 +58,14 @@ export async function startBackgroundInitialization(config: SubscriptionInitConf
|
|
|
58
58
|
console.log('[BackgroundInitializer] Initial RevenueCat userId:', initialRevenueCatUserId || '(undefined - anonymous)');
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
// Only initialize immediately if we have a real (non-anonymous) user ID.
|
|
62
|
+
// If anonymous, skip and wait for auth listener to provide the real user ID.
|
|
63
|
+
// This prevents a Firestore permission-denied error from querying with an anonymous ID.
|
|
64
|
+
if (initialRevenueCatUserId) {
|
|
65
|
+
await initializeInBackground(initialRevenueCatUserId);
|
|
66
|
+
} else if (typeof __DEV__ !== 'undefined' && __DEV__) {
|
|
67
|
+
console.log('[BackgroundInitializer] Skipping anonymous init, waiting for auth state');
|
|
68
|
+
}
|
|
62
69
|
|
|
63
70
|
const unsubscribe = setupAuthStateListener(() => auth, debouncedInitialize);
|
|
64
71
|
|