useSubscriptionTracking
Access subscription tracking methods to monitor subscription lifecycle events.Return Values
function
Track when a user starts a new subscription
function
Track when a user upgrades their subscription plan
function
Track when a user downgrades their subscription plan
function
Track when a user cancels their subscription
function
Track when a subscription is paused
function
Track when a canceled or paused subscription is reactivated
function
Track when a user starts a trial period
function
Track when a trial converts to a paid subscription
function
Track when a trial expires without conversion
function
Track failed payment attempts
function
Track successful payment events
function
Retrieve current subscription data from storageReturns
SubscriptionProperties | nullUsage Example
useChurnRisk
Monitor customer churn risk in real-time with automatic refresh and callback triggers.Parameters
Return Values
ChurnRiskMetrics | null
Current churn risk metrics including score, category, and contributing factors
boolean
Whether churn risk calculation is in progress
boolean
True if risk category is “high” or “critical”
boolean
True if risk category is “critical”
function
Manually trigger churn risk recalculation. Returns updated
ChurnRiskMetrics | nullUsage Example
useSubscriptionData
Access current subscription data with automatic refresh and convenience flags.Return Values
SubscriptionProperties | null
Complete subscription object with all properties. See SubscriptionProperties for full schema.
boolean
Whether subscription data is being loaded
boolean
True if subscription status is “active” or “trialing”
boolean
True if subscription status is “trialing”
boolean
True if subscription status is “canceled”
boolean
True if subscription is set to cancel at end of current billing period
function
Manually refresh subscription data from storage
Usage Example
useSubscriptionAutoDetect
Manually trigger subscription auto-detection from common payment providers.Return Values
function
Trigger subscription detection. Returns a promise with detection results:
boolean
Whether auto-detection is currently running
object | null
Last detection result, or null if detection hasn’t run
Usage Example
useSyncSubscription
Automatically sync subscription state changes and track lifecycle events.Parameters
Behavior
This hook automatically:- Stores subscription data in localStorage
- Compares with previous subscription state
- Tracks appropriate events when changes are detected:
- Upgrade: When MRR increases or plan changes to higher tier
- Downgrade: When MRR decreases or plan changes to lower tier
- Cancellation: When status changes to “canceled”
- Reactivation: When status changes from “canceled” to “active”
- Trial Conversion: When status changes from “trialing” to “active”