@umituz/react-native-subscription 2.0.0 → 2.1.0

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.0.0",
3
+ "version": "2.1.0",
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",
@@ -28,6 +28,8 @@
28
28
  import { useCallback } from "react";
29
29
  import { useCredits } from "./useCredits";
30
30
 
31
+ declare const __DEV__: boolean;
32
+
31
33
  export interface UseFeatureGateParams {
32
34
  /** User ID for credits check */
33
35
  userId: string | undefined;
@@ -66,12 +68,39 @@ export function useFeatureGate(
66
68
  // User is premium if they have credits
67
69
  const isPremium = credits !== null;
68
70
 
71
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
72
+ // eslint-disable-next-line no-console
73
+ console.log("[useFeatureGate] Hook state", {
74
+ userId,
75
+ isAuthenticated,
76
+ isPremium,
77
+ hasCredits: credits !== null,
78
+ isLoading,
79
+ });
80
+ }
81
+
69
82
  const requireFeature = useCallback(
70
83
  (action: () => void | Promise<void>) => {
84
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
85
+ // eslint-disable-next-line no-console
86
+ console.log("[useFeatureGate] requireFeature() called", {
87
+ isAuthenticated,
88
+ isPremium,
89
+ });
90
+ }
91
+
71
92
  // Step 1: Check authentication
72
93
  if (!isAuthenticated) {
94
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
95
+ // eslint-disable-next-line no-console
96
+ console.log("[useFeatureGate] NOT authenticated → showing auth modal");
97
+ }
73
98
  // After auth, re-check premium before executing
74
99
  onShowAuthModal(() => {
100
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
101
+ // eslint-disable-next-line no-console
102
+ console.log("[useFeatureGate] Auth modal callback → executing action");
103
+ }
75
104
  // This callback runs after successful auth
76
105
  // The component will re-render with new auth state
77
106
  // and user can try the action again
@@ -82,11 +111,19 @@ export function useFeatureGate(
82
111
 
83
112
  // Step 2: Check premium (has credits from TanStack Query)
84
113
  if (!isPremium) {
114
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
115
+ // eslint-disable-next-line no-console
116
+ console.log("[useFeatureGate] NOT premium → showing paywall");
117
+ }
85
118
  onShowPaywall();
86
119
  return;
87
120
  }
88
121
 
89
122
  // Step 3: User is authenticated and premium - execute action
123
+ if (typeof __DEV__ !== "undefined" && __DEV__) {
124
+ // eslint-disable-next-line no-console
125
+ console.log("[useFeatureGate] PREMIUM user → executing action");
126
+ }
90
127
  action();
91
128
  },
92
129
  [isAuthenticated, isPremium, onShowAuthModal, onShowPaywall]