@umituz/react-native-subscription 2.12.34 → 2.12.36

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.12.34",
3
+ "version": "2.12.36",
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",
@@ -50,6 +50,10 @@ export interface UsePremiumResult {
50
50
  * ```
51
51
  */
52
52
  export const usePremium = (userId?: string): UsePremiumResult => {
53
+ if (__DEV__) {
54
+ console.log('[DEBUG usePremium] Hook called', { userId: userId || 'ANONYMOUS' });
55
+ }
56
+
53
57
  // Fetch user credits (server state)
54
58
  const { credits, isLoading: creditsLoading } = useCredits({
55
59
  userId,
@@ -60,6 +64,16 @@ export const usePremium = (userId?: string): UsePremiumResult => {
60
64
  const { data: packages = [], isLoading: packagesLoading } =
61
65
  useSubscriptionPackages(userId);
62
66
 
67
+ if (__DEV__) {
68
+ console.log('[DEBUG usePremium] State', {
69
+ userId: userId || 'ANONYMOUS',
70
+ packagesCount: packages?.length || 0,
71
+ packagesLoading,
72
+ creditsLoading,
73
+ isPremium: credits !== null,
74
+ });
75
+ }
76
+
63
77
  // Purchase and restore mutations
64
78
  const purchaseMutation = usePurchasePackage(userId);
65
79
  const restoreMutation = useRestorePurchase(userId);
@@ -108,11 +108,27 @@ class SubscriptionManagerImpl {
108
108
 
109
109
  async getPackages(): Promise<PurchasesPackage[]> {
110
110
  this.ensureConfigured();
111
+ if (__DEV__) {
112
+ console.log('[DEBUG SubscriptionManager] getPackages called', {
113
+ hasServiceInstance: !!this.serviceInstance,
114
+ hasPackageHandler: !!this.packageHandler,
115
+ });
116
+ }
111
117
  if (!this.serviceInstance) {
118
+ if (__DEV__) {
119
+ console.log('[DEBUG SubscriptionManager] Creating service instance...');
120
+ }
112
121
  this.serviceInstance = getRevenueCatService();
113
122
  this.packageHandler!.setService(this.serviceInstance);
114
123
  }
115
- return this.packageHandler!.fetchPackages();
124
+ const packages = await this.packageHandler!.fetchPackages();
125
+ if (__DEV__) {
126
+ console.log('[DEBUG SubscriptionManager] fetchPackages returned', {
127
+ count: packages.length,
128
+ packages: packages.map(p => ({ id: p.identifier, type: p.packageType })),
129
+ });
130
+ }
131
+ return packages;
116
132
  }
117
133
 
118
134
  async purchasePackage(pkg: PurchasesPackage): Promise<boolean> {
@@ -17,9 +17,17 @@ import {
17
17
  * Works for both authenticated and anonymous users
18
18
  */
19
19
  export const useSubscriptionPackages = (userId: string | undefined) => {
20
+ if (__DEV__) {
21
+ console.log('[DEBUG useSubscriptionPackages] Hook called', { userId: userId || 'ANONYMOUS' });
22
+ }
23
+
20
24
  return useQuery({
21
25
  queryKey: [...SUBSCRIPTION_QUERY_KEYS.packages, userId ?? "anonymous"] as const,
22
26
  queryFn: async () => {
27
+ if (__DEV__) {
28
+ console.log('[DEBUG useSubscriptionPackages] QueryFn executing...', { userId: userId || 'ANONYMOUS' });
29
+ }
30
+
23
31
  addPackageBreadcrumb("subscription", "Fetch packages query started", {
24
32
  userId: userId ?? "ANONYMOUS",
25
33
  });
@@ -27,16 +35,44 @@ export const useSubscriptionPackages = (userId: string | undefined) => {
27
35
  // Initialize if needed (works for both authenticated and anonymous users)
28
36
  if (userId) {
29
37
  if (!SubscriptionManager.isInitializedForUser(userId)) {
38
+ if (__DEV__) {
39
+ console.log('[DEBUG useSubscriptionPackages] Initializing for user:', userId);
40
+ }
30
41
  await SubscriptionManager.initialize(userId);
42
+ } else {
43
+ if (__DEV__) {
44
+ console.log('[DEBUG useSubscriptionPackages] Already initialized for user:', userId);
45
+ }
31
46
  }
32
47
  } else {
33
48
  if (!SubscriptionManager.isInitialized()) {
49
+ if (__DEV__) {
50
+ console.log('[DEBUG useSubscriptionPackages] Initializing for ANONYMOUS user');
51
+ }
34
52
  await SubscriptionManager.initialize(undefined);
53
+ } else {
54
+ if (__DEV__) {
55
+ console.log('[DEBUG useSubscriptionPackages] Already initialized for ANONYMOUS');
56
+ }
35
57
  }
36
58
  }
37
59
 
60
+ if (__DEV__) {
61
+ console.log('[DEBUG useSubscriptionPackages] Calling getPackages...');
62
+ }
63
+
38
64
  const packages = await SubscriptionManager.getPackages();
39
65
 
66
+ if (__DEV__) {
67
+ console.log('[DEBUG useSubscriptionPackages] Got packages', {
68
+ count: packages.length,
69
+ packages: packages.map(p => ({
70
+ id: p.identifier,
71
+ type: p.packageType,
72
+ })),
73
+ });
74
+ }
75
+
40
76
  addPackageBreadcrumb("subscription", "Fetch packages query success", {
41
77
  userId: userId ?? "ANONYMOUS",
42
78
  count: packages.length,