@umituz/react-native-subscription 2.33.6 → 2.33.7

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.33.6",
3
+ "version": "2.33.7",
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",
@@ -6,6 +6,8 @@ import { executeFeatureAction } from "./featureGateActions";
6
6
 
7
7
  export type { UseFeatureGateParams, UseFeatureGateResult } from "./useFeatureGate.types";
8
8
 
9
+ declare const __DEV__: boolean;
10
+
9
11
  export function useFeatureGate(params: UseFeatureGateParams): UseFeatureGateResult {
10
12
  const {
11
13
  isAuthenticated,
@@ -25,14 +27,34 @@ export function useFeatureGate(params: UseFeatureGateParams): UseFeatureGateResu
25
27
  const { creditBalanceRef, hasSubscriptionRef, onShowPaywallRef, requiredCreditsRef, isCreditsLoadedRef } = useSyncedRefs(creditBalance, hasSubscription, onShowPaywall, requiredCredits, isCreditsLoaded);
26
28
 
27
29
  useEffect(() => {
28
- if (shouldExecuteAuthAction(
30
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
31
+ console.log("[FeatureGate] Auth completion useEffect triggered:", {
32
+ isWaitingForAuthCredits: isWaitingForAuthCreditsRef.current,
33
+ isCreditsLoaded,
34
+ hasPendingAction: !!pendingActionRef.current,
35
+ hasSubscription,
36
+ creditBalance,
37
+ requiredCredits,
38
+ });
39
+ }
40
+
41
+ const shouldExecute = shouldExecuteAuthAction(
29
42
  isWaitingForAuthCreditsRef.current,
30
43
  isCreditsLoaded,
31
44
  !!pendingActionRef.current,
32
45
  hasSubscription,
33
46
  creditBalance,
34
47
  requiredCredits
35
- )) {
48
+ );
49
+
50
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
51
+ console.log("[FeatureGate] shouldExecuteAuthAction:", shouldExecute);
52
+ }
53
+
54
+ if (shouldExecute) {
55
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
56
+ console.log("[FeatureGate] ✅ EXECUTING PENDING ACTION after auth!");
57
+ }
36
58
  isWaitingForAuthCreditsRef.current = false;
37
59
  const action = pendingActionRef.current!;
38
60
  pendingActionRef.current = null;
@@ -41,6 +63,9 @@ export function useFeatureGate(params: UseFeatureGateParams): UseFeatureGateResu
41
63
  }
42
64
 
43
65
  if (isWaitingForAuthCreditsRef.current && isCreditsLoaded && pendingActionRef.current) {
66
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
67
+ console.log("[FeatureGate] Auth credits loaded but insufficient, showing paywall");
68
+ }
44
69
  isWaitingForAuthCreditsRef.current = false;
45
70
  isWaitingForPurchaseRef.current = true;
46
71
  onShowPaywall(requiredCredits);
@@ -48,14 +73,34 @@ export function useFeatureGate(params: UseFeatureGateParams): UseFeatureGateResu
48
73
  }, [isCreditsLoaded, creditBalance, hasSubscription, requiredCredits, onShowPaywall]);
49
74
 
50
75
  useEffect(() => {
51
- if (shouldExecutePurchaseAction(
76
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
77
+ console.log("[FeatureGate] Purchase completion useEffect triggered:", {
78
+ creditBalance,
79
+ prevCreditBalance: prevCreditBalanceRef.current,
80
+ hasSubscription,
81
+ prevHasSubscription: hasSubscriptionRef.current,
82
+ isWaitingForPurchase: isWaitingForPurchaseRef.current,
83
+ hasPendingAction: !!pendingActionRef.current,
84
+ });
85
+ }
86
+
87
+ const shouldExecute = shouldExecutePurchaseAction(
52
88
  isWaitingForPurchaseRef.current,
53
89
  creditBalance,
54
90
  prevCreditBalanceRef.current ?? 0,
55
91
  hasSubscription,
56
92
  hasSubscriptionRef.current,
57
93
  !!pendingActionRef.current
58
- )) {
94
+ );
95
+
96
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
97
+ console.log("[FeatureGate] shouldExecutePurchaseAction:", shouldExecute);
98
+ }
99
+
100
+ if (shouldExecute) {
101
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
102
+ console.log("[FeatureGate] ✅ EXECUTING PENDING ACTION after purchase!");
103
+ }
59
104
  const action = pendingActionRef.current!;
60
105
  pendingActionRef.current = null;
61
106
  isWaitingForPurchaseRef.current = false;