@umituz/react-native-subscription 2.14.99 → 2.14.101
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/README.md +211 -394
- package/package.json +3 -3
- package/src/application/README.md +46 -225
- package/src/application/ports/README.md +42 -97
- package/src/domain/README.md +36 -384
- package/src/domain/constants/README.md +0 -56
- package/src/domain/entities/README.md +43 -169
- package/src/domain/entities/SubscriptionStatus.ts +1 -1
- package/src/domain/errors/README.md +33 -287
- package/src/domain/value-objects/README.md +43 -179
- package/src/domains/README.md +50 -238
- package/src/domains/README.md.bak +274 -0
- package/src/domains/config/README.md +93 -383
- package/src/domains/config/domain/README.md +23 -376
- package/src/domains/config/domain/entities/README.md +34 -343
- package/src/domains/paywall/README.md +99 -369
- package/src/domains/paywall/components/README.md +34 -178
- package/src/domains/paywall/entities/README.md +34 -193
- package/src/domains/paywall/hooks/README.md +34 -122
- package/src/domains/wallet/README.md +34 -275
- package/src/domains/wallet/README.md.bak +209 -0
- package/src/domains/wallet/domain/README.md +34 -101
- package/src/domains/wallet/domain/entities/README.md +34 -115
- package/src/domains/wallet/domain/errors/README.md +34 -151
- package/src/domains/wallet/infrastructure/README.md +34 -89
- package/src/domains/wallet/presentation/components/README.md +34 -224
- package/src/domains/wallet/presentation/components/TransactionItem.tsx +1 -1
- package/src/domains/wallet/presentation/hooks/README.md +34 -248
- package/src/infrastructure/README.md +37 -496
- package/src/infrastructure/mappers/README.md +0 -13
- package/src/infrastructure/repositories/README.md +74 -360
- package/src/infrastructure/services/ActivationHandler.ts +1 -1
- package/src/infrastructure/services/README.md +95 -370
- package/src/infrastructure/services/SubscriptionService.ts +1 -1
- package/src/presentation/README.md +123 -408
- package/src/presentation/README.md.bak +172 -0
- package/src/presentation/components/README.md +151 -179
- package/src/presentation/components/README.md.bak +217 -0
- package/src/presentation/components/details/CreditRow.md +65 -310
- package/src/presentation/components/details/DetailRow.md +63 -255
- package/src/presentation/components/details/PremiumDetailsCard.md +65 -238
- package/src/presentation/components/details/PremiumStatusBadge.md +64 -239
- package/src/presentation/components/details/README.md +97 -447
- package/src/presentation/components/feedback/PaywallFeedbackModal.md +63 -287
- package/src/presentation/components/feedback/README.md +97 -445
- package/src/presentation/components/paywall/PaywallModal.md +66 -416
- package/src/presentation/components/paywall/README.md +50 -186
- package/src/presentation/components/sections/README.md +97 -466
- package/src/presentation/components/sections/SubscriptionSection.md +92 -244
- package/src/presentation/hooks/README.md +154 -741
- package/src/presentation/hooks/useAuthAwarePurchase.md +58 -325
- package/src/presentation/hooks/useAuthGate.md +61 -375
- package/src/presentation/hooks/useAuthSubscriptionSync.md +66 -370
- package/src/presentation/hooks/useCreditChecker.md +73 -378
- package/src/presentation/hooks/useCredits.md +74 -313
- package/src/presentation/hooks/useCredits.md.bak +231 -0
- package/src/presentation/hooks/useCreditsGate.md +66 -318
- package/src/presentation/hooks/useDeductCredit.md +0 -76
- package/src/presentation/hooks/useDeductCredit.ts +1 -1
- package/src/presentation/hooks/useDevTestCallbacks.md +63 -394
- package/src/presentation/hooks/useFeatureGate.md +105 -150
- package/src/presentation/hooks/useFeatureGate.md.bak +284 -0
- package/src/presentation/hooks/useInitializeCredits.md +64 -430
- package/src/presentation/hooks/usePaywall.md +61 -306
- package/src/presentation/hooks/usePaywallOperations.md +64 -458
- package/src/presentation/hooks/usePaywallVisibility.md +67 -316
- package/src/presentation/hooks/usePremium.md +84 -226
- package/src/presentation/hooks/usePremiumGate.md +60 -395
- package/src/presentation/hooks/usePremiumWithCredits.md +64 -401
- package/src/presentation/hooks/useSubscription.md +66 -422
- package/src/presentation/hooks/useSubscriptionDetails.md +65 -410
- package/src/presentation/hooks/useSubscriptionGate.md +80 -164
- package/src/presentation/hooks/useSubscriptionSettingsConfig.md +66 -346
- package/src/presentation/hooks/useSubscriptionStatus.md +66 -396
- package/src/presentation/hooks/useUserTier.md +63 -328
- package/src/presentation/hooks/useUserTierWithRepository.md +64 -424
- package/src/presentation/screens/README.md +48 -190
- package/src/presentation/types/README.md +0 -16
- package/src/presentation/utils/README.md +0 -21
- package/src/presentation/utils/subscriptionDateUtils.ts +1 -1
- package/src/revenuecat/README.md +99 -518
- package/src/revenuecat/application/README.md +35 -150
- package/src/revenuecat/application/ports/README.md +34 -162
- package/src/revenuecat/domain/README.md +42 -141
- package/src/revenuecat/domain/constants/README.md +34 -176
- package/src/revenuecat/domain/entities/README.md +34 -374
- package/src/revenuecat/domain/errors/README.md +47 -191
- package/src/revenuecat/domain/types/README.md +34 -366
- package/src/revenuecat/domain/value-objects/README.md +34 -434
- package/src/revenuecat/infrastructure/README.md +34 -43
- package/src/revenuecat/infrastructure/config/README.md +32 -23
- package/src/revenuecat/infrastructure/handlers/README.md +34 -211
- package/src/revenuecat/infrastructure/managers/README.md +34 -42
- package/src/revenuecat/infrastructure/services/README.md +35 -318
- package/src/revenuecat/infrastructure/utils/README.md +34 -375
- package/src/revenuecat/presentation/README.md +34 -176
- package/src/revenuecat/presentation/hooks/README.md +29 -35
- package/src/utils/README.md +38 -525
|
@@ -2,333 +2,88 @@
|
|
|
2
2
|
|
|
3
3
|
Hook for controlling paywall visibility and state.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Location
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
import { usePaywall } from '@umituz/react-native-subscription';
|
|
9
|
-
```
|
|
7
|
+
**Import Path**: `@umituz/react-native-subscription`
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
**File**: `src/presentation/hooks/usePaywall.ts`
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
function usePaywall(): {
|
|
15
|
-
showPaywall: (params?: PaywallTrigger) => void;
|
|
16
|
-
hidePaywall: () => void;
|
|
17
|
-
isPaywallVisible: boolean;
|
|
18
|
-
paywallConfig: PaywallConfig | null;
|
|
19
|
-
}
|
|
20
|
-
```
|
|
11
|
+
**Type**: Hook
|
|
21
12
|
|
|
22
|
-
##
|
|
13
|
+
## Strategy
|
|
23
14
|
|
|
24
|
-
|
|
25
|
-
|----------|------|-------------|
|
|
26
|
-
| `showPaywall` | `(params?: PaywallTrigger) => void` | Show paywall with optional context |
|
|
27
|
-
| `hidePaywall` | `() => void` | Hide paywall |
|
|
28
|
-
| `isPaywallVisible` | `boolean` | Whether paywall is currently visible |
|
|
29
|
-
| `paywallConfig` | `PaywallConfig \| null` | Current paywall configuration |
|
|
15
|
+
### Paywall State Management
|
|
30
16
|
|
|
31
|
-
|
|
17
|
+
1. **Visibility Control**: Show/hide paywall on demand
|
|
18
|
+
2. **Trigger Tracking**: Record what triggered paywall display
|
|
19
|
+
3. **Context Management**: Store paywall context and metadata
|
|
20
|
+
4. **Dynamic Configuration**: Support custom paywall configs per trigger
|
|
21
|
+
5. **State Persistence**: Maintain paywall state across component renders
|
|
22
|
+
6. **Event Tracking**: Enable analytics for paywall interactions
|
|
32
23
|
|
|
33
|
-
|
|
34
|
-
function UpgradeButton() {
|
|
35
|
-
const { showPaywall, hidePaywall, isPaywallVisible } = usePaywall();
|
|
24
|
+
### Integration Points
|
|
36
25
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
title="Upgrade to Premium"
|
|
42
|
-
/>
|
|
26
|
+
- **Paywall Context**: Global paywall state management
|
|
27
|
+
- **Paywall Domain**: `src/domains/paywall/README.md`
|
|
28
|
+
- **Analytics**: For tracking paywall impressions and conversions
|
|
29
|
+
- **Navigation**: For paywall screen routing
|
|
43
30
|
|
|
44
|
-
|
|
45
|
-
isVisible={isPaywallVisible}
|
|
46
|
-
onClose={hidePaywall}
|
|
47
|
-
/>
|
|
48
|
-
</>
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
```
|
|
31
|
+
## Restrictions
|
|
52
32
|
|
|
53
|
-
|
|
33
|
+
### REQUIRED
|
|
54
34
|
|
|
55
|
-
|
|
35
|
+
- **State Management**: MUST use showPaywall/hidePaywall functions
|
|
36
|
+
- **Trigger Tracking**: SHOULD include trigger information for analytics
|
|
37
|
+
- **Context**: SHOULD provide relevant context for paywall display
|
|
56
38
|
|
|
57
|
-
|
|
58
|
-
function TrackedPaywall() {
|
|
59
|
-
const { showPaywall, hidePaywall, isPaywallVisible } = usePaywall();
|
|
39
|
+
### PROHIBITED
|
|
60
40
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
featureId: 'advanced_features',
|
|
65
|
-
source,
|
|
66
|
-
metadata: {
|
|
67
|
-
screen: 'home',
|
|
68
|
-
buttonLocation: 'header',
|
|
69
|
-
},
|
|
70
|
-
});
|
|
41
|
+
- **NEVER** manage paywall state locally (use this hook instead)
|
|
42
|
+
- **NEVER** show paywall without user action or clear trigger
|
|
43
|
+
- **DO NOT** show paywall too frequently (respect user experience)
|
|
71
44
|
|
|
72
|
-
|
|
73
|
-
analytics.track('upgrade_button_clicked', { source });
|
|
74
|
-
};
|
|
45
|
+
### CRITICAL SAFETY
|
|
75
46
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
47
|
+
- **ALWAYS** hide paywall on successful purchase
|
|
48
|
+
- **NEVER** trap users in paywall (provide clear exit)
|
|
49
|
+
- **MUST** track paywall triggers for analytics
|
|
50
|
+
- **ALWAYS** provide close/dismiss option
|
|
80
51
|
|
|
81
|
-
|
|
82
|
-
};
|
|
52
|
+
## AI Agent Guidelines
|
|
83
53
|
|
|
84
|
-
|
|
85
|
-
<>
|
|
86
|
-
<Button onPress={() => handleUpgradeClick('header')} title="Upgrade" />
|
|
54
|
+
### When Implementing Paywall Triggers
|
|
87
55
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
```
|
|
56
|
+
1. **Always** include trigger source/context
|
|
57
|
+
2. **Always** track paywall impressions
|
|
58
|
+
3. **Always** provide clear close button
|
|
59
|
+
4. **Never** show paywall without clear reason
|
|
60
|
+
5. **Always** hide paywall after successful purchase
|
|
96
61
|
|
|
97
|
-
###
|
|
62
|
+
### Integration Checklist
|
|
98
63
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
64
|
+
- [ ] Import from correct path: `@umituz/react-native-subscription`
|
|
65
|
+
- [ ] Use showPaywall with trigger information
|
|
66
|
+
- [ ] Implement hidePaywall callback
|
|
67
|
+
- [ ] Track paywall impressions in analytics
|
|
68
|
+
- [ ] Track paywall dismissals
|
|
69
|
+
- [ ] Provide clear close button
|
|
70
|
+
- [ ] Test manual trigger
|
|
71
|
+
- [ ] Test automatic trigger (usage limit, etc.)
|
|
72
|
+
- [ ] Test purchase flow completion
|
|
73
|
+
- [ ] Verify paywall hides after purchase
|
|
103
74
|
|
|
104
|
-
|
|
105
|
-
showPaywall({
|
|
106
|
-
trigger: 'custom',
|
|
107
|
-
config: {
|
|
108
|
-
title: tier === 'free'
|
|
109
|
-
? 'Unlock Premium Features'
|
|
110
|
-
: 'Upgrade Your Plan',
|
|
111
|
-
features: tier === 'free'
|
|
112
|
-
? [
|
|
113
|
-
{ icon: '⭐', text: 'Unlimited Access' },
|
|
114
|
-
{ icon: '🚀', text: 'AI-Powered Tools' },
|
|
115
|
-
]
|
|
116
|
-
: [
|
|
117
|
-
{ icon: '💎', text: 'Exclusive Features' },
|
|
118
|
-
{ icon: '👑', text: 'VIP Support' },
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
};
|
|
75
|
+
### Common Patterns
|
|
123
76
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
77
|
+
1. **Manual Trigger**: User clicks upgrade button
|
|
78
|
+
2. **Usage Limit**: Show after N free uses
|
|
79
|
+
3. **Feature Gate**: Show when accessing premium feature
|
|
80
|
+
4. **Time-based**: Show after certain time/usage
|
|
81
|
+
5. **Event-driven**: Show on specific app events
|
|
128
82
|
|
|
129
|
-
|
|
130
|
-
isVisible={isPaywallVisible}
|
|
131
|
-
onClose={hidePaywall}
|
|
132
|
-
config={paywallConfig || undefined}
|
|
133
|
-
/>
|
|
134
|
-
</View>
|
|
135
|
-
);
|
|
136
|
-
}
|
|
137
|
-
```
|
|
83
|
+
## Related Documentation
|
|
138
84
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const { userTier } = useUserTier();
|
|
145
|
-
const { usageCount } = useFeatureUsage();
|
|
146
|
-
|
|
147
|
-
const shouldShowPaywall = useMemo(() => {
|
|
148
|
-
// Show paywall after 5 free uses
|
|
149
|
-
return userTier === 'free' && usageCount >= 5;
|
|
150
|
-
}, [userTier, usageCount]);
|
|
151
|
-
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (shouldShowPaywall && !isPaywallVisible) {
|
|
154
|
-
showPaywall({
|
|
155
|
-
trigger: 'usage_limit',
|
|
156
|
-
featureId: 'advanced_filters',
|
|
157
|
-
context: {
|
|
158
|
-
usageCount,
|
|
159
|
-
limit: 5,
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}, [shouldShowPaywall]);
|
|
164
|
-
|
|
165
|
-
return (
|
|
166
|
-
<PaywallModal
|
|
167
|
-
isVisible={isPaywallVisible}
|
|
168
|
-
onClose={hidePaywall}
|
|
169
|
-
config={{
|
|
170
|
-
title: 'Free Limit Reached',
|
|
171
|
-
description: `You've used this feature ${usageCount} times`,
|
|
172
|
-
features: [
|
|
173
|
-
{ icon: '∞', text: 'Unlimited Access' },
|
|
174
|
-
{ icon: '⚡', text: 'Faster Processing' },
|
|
175
|
-
],
|
|
176
|
-
}}
|
|
177
|
-
/>
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
## PaywallTrigger Type
|
|
183
|
-
|
|
184
|
-
```typescript
|
|
185
|
-
interface PaywallTrigger {
|
|
186
|
-
trigger: string; // What triggered the paywall
|
|
187
|
-
featureId?: string; // Which feature triggered it
|
|
188
|
-
source?: string; // Where it was triggered from
|
|
189
|
-
metadata?: Record<string, any>; // Additional context
|
|
190
|
-
config?: PaywallConfig; // Custom paywall config
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Examples
|
|
195
|
-
|
|
196
|
-
### Feature-Based Paywall
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
function FeatureButton({ featureId, requiredTier }) {
|
|
200
|
-
const { userTier } = useUserTier();
|
|
201
|
-
const { showPaywall } = usePaywall();
|
|
202
|
-
|
|
203
|
-
const handlePress = () => {
|
|
204
|
-
if (userTier !== requiredTier) {
|
|
205
|
-
showPaywall({
|
|
206
|
-
trigger: 'feature_access_denied',
|
|
207
|
-
featureId,
|
|
208
|
-
requiredTier,
|
|
209
|
-
});
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
executeFeature();
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
return <Button onPress={handlePress} title={featureId} />;
|
|
217
|
-
}
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
### Time-Based Paywall
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
function TimedPaywall() {
|
|
224
|
-
const { showPaywall, isPaywallVisible } = usePaywall();
|
|
225
|
-
const [sessionTime, setSessionTime] = useState(0);
|
|
226
|
-
|
|
227
|
-
useEffect(() => {
|
|
228
|
-
const timer = setInterval(() => {
|
|
229
|
-
setSessionTime(prev => prev + 1);
|
|
230
|
-
}, 1000);
|
|
231
|
-
|
|
232
|
-
// Show paywall after 30 seconds
|
|
233
|
-
const paywallTimer = setTimeout(() => {
|
|
234
|
-
showPaywall({
|
|
235
|
-
trigger: 'time_based',
|
|
236
|
-
context: { sessionTime },
|
|
237
|
-
});
|
|
238
|
-
}, 30000);
|
|
239
|
-
|
|
240
|
-
return () => {
|
|
241
|
-
clearInterval(timer);
|
|
242
|
-
clearTimeout(paywallTimer);
|
|
243
|
-
};
|
|
244
|
-
}, []);
|
|
245
|
-
|
|
246
|
-
return <PaywallModal isVisible={isPaywallVisible} onClose={() => {}} />;
|
|
247
|
-
}
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
### Event-Based Paywall
|
|
251
|
-
|
|
252
|
-
```typescript
|
|
253
|
-
function EventDrivenPaywall() {
|
|
254
|
-
const { showPaywall, isPaywallVisible } = usePaywall();
|
|
255
|
-
|
|
256
|
-
useEffect(() => {
|
|
257
|
-
const subscription = eventBus.subscribe('premium_required', (event) => {
|
|
258
|
-
showPaywall({
|
|
259
|
-
trigger: 'premium_required',
|
|
260
|
-
featureId: event.featureId,
|
|
261
|
-
source: event.source,
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
|
|
265
|
-
return () => subscription.unsubscribe();
|
|
266
|
-
}, []);
|
|
267
|
-
|
|
268
|
-
return <PaywallModal isVisible={isPaywallVisible} onClose={() => {}} />;
|
|
269
|
-
}
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
## Integration with Analytics
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
function AnalyticsIntegratedPaywall() {
|
|
276
|
-
const { showPaywall, hidePaywall, isPaywallVisible } = usePaywall();
|
|
277
|
-
const [paywallShownAt, setPaywallShownAt] = useState<number | null>(null);
|
|
278
|
-
|
|
279
|
-
const handleShowPaywall = (trigger: PaywallTrigger) => {
|
|
280
|
-
setPaywallShownAt(Date.now());
|
|
281
|
-
|
|
282
|
-
// Track impression
|
|
283
|
-
analytics.track('paywall_impression', {
|
|
284
|
-
trigger: trigger.trigger,
|
|
285
|
-
feature_id: trigger.featureId,
|
|
286
|
-
source: trigger.source,
|
|
287
|
-
timestamp: Date.now(),
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
showPaywall(trigger);
|
|
291
|
-
};
|
|
292
|
-
|
|
293
|
-
const handleClose = () => {
|
|
294
|
-
if (paywallShownAt) {
|
|
295
|
-
const duration = Date.now() - paywallShownAt;
|
|
296
|
-
|
|
297
|
-
analytics.track('paywall_dismissed', {
|
|
298
|
-
duration,
|
|
299
|
-
trigger: 'upgrade_button',
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
hidePaywall();
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
return (
|
|
307
|
-
<>
|
|
308
|
-
<Button onPress={() => handleShowPaywall({ trigger: 'manual' })} />
|
|
309
|
-
<PaywallModal isVisible={isPaywallVisible} onClose={handleClose} />
|
|
310
|
-
</>
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
## Best Practices
|
|
316
|
-
|
|
317
|
-
1. **Track triggers** - Always log what triggered the paywall
|
|
318
|
-
2. **Include context** - Add relevant metadata
|
|
319
|
-
3. **Handle dismissal** - Track when and why users close
|
|
320
|
-
4. **A/B test** - Test different paywall configurations
|
|
321
|
-
5. **Respect users** - Don't show paywall too frequently
|
|
322
|
-
6. **Close on purchase** - Automatically hide on successful purchase
|
|
323
|
-
|
|
324
|
-
## Related Hooks
|
|
325
|
-
|
|
326
|
-
- **usePaywallActions** - For paywall purchase actions
|
|
327
|
-
- **usePaywallVisibility** - For conditional paywall display
|
|
328
|
-
- **usePaywallOperations** - For complete paywall operations
|
|
329
|
-
|
|
330
|
-
## See Also
|
|
331
|
-
|
|
332
|
-
- [usePaywallActions](./usePaywallActions.md)
|
|
333
|
-
- [usePaywallVisibility](./usePaywallVisibility.md)
|
|
334
|
-
- [Paywall Domain](../../../domains/paywall/README.md)
|
|
85
|
+
- **usePaywallActions**: Paywall purchase actions
|
|
86
|
+
- **usePaywallVisibility**: Conditional paywall display logic
|
|
87
|
+
- **usePaywallOperations**: Complete paywall operations
|
|
88
|
+
- **Paywall Domain**: `src/domains/paywall/README.md`
|
|
89
|
+
- **Paywall Components**: `src/presentation/components/paywall/README.md`
|