v5.0.0
What's changed
- Added subscription tracking:
TrackablePaymentnow reports whether a payment is part of a subscription, which plan it belongs to and how often it renews. This is the foundation for upcoming recurring revenue metrics (MRR/ARR) and plan-level segmentation. - Added the
SimpleStatsIo\LaravelClient\Data\TrackingSubscriptionvalue object (aplanstring and aSubscriptionInterval). - Added the
SimpleStatsIo\LaravelClient\Enums\SubscriptionIntervalenum withMonthandYearcases. - The
stats-paymenttrack payload now carriessubscription_interval(month,year, ornull) andsubscription_plan(free-form string ornull) fields.
Breaking
TrackablePaymentgained a required method:getTrackingSubscription(): ?TrackingSubscription. Every model implementingTrackablePayment(orTrackablePaymentWithCondition) must implement it.
Upgrade
Add the new method to each of your payment models. For one-time payments just return null:
use SimpleStatsIo\LaravelClient\Data\TrackingSubscription;
public function getTrackingSubscription(): ?TrackingSubscription
{
return null; // one-time payment
}For subscription payments, return a TrackingSubscription with the plan and interval so we can attribute and segment recurring revenue:
use SimpleStatsIo\LaravelClient\Data\TrackingSubscription;
use SimpleStatsIo\LaravelClient\Enums\SubscriptionInterval;
public function getTrackingSubscription(): ?TrackingSubscription
{
return match ($this->billing_cycle) {
'monthly' => new TrackingSubscription($this->plan_name, SubscriptionInterval::Month),
'yearly' => new TrackingSubscription($this->plan_name, SubscriptionInterval::Year),
default => null,
};
}The plan is optional, pass null if you don't want to track it.
See the payment tracking docs for the full walkthrough.
Full Changelog: v4.1.1...v5.0.0