feat(tiers): add display-name layer, push.frequency entitlement, and rename pricing cards

Reconciles tier docs with `PlanSeeder` reality (basic has price_threshold
and score_alerts; schema is stripe_price_id_monthly + stripe_price_id_annual)
and introduces the display-name layer from pricing-plan.md v2.

- PlanTier::label() + Plan::displayName() + PlanFeatures::displayName()
  expose user-facing names (Free/Daily/Smart/Pro); backend identifiers stay
  basic/plus/pro so every call site, Stripe mapping, and test keeps working.
- push.frequency key added to features JSON (none/daily/triggered), mirroring
  email.frequency so Daily's daily push is distinguishable from Smart/Pro's
  triggered push. Seeder, factory, free-tier stubs, and Filament form updated.
- Homepage pricing cards renamed: Basic→Daily, Plus→Smart; badge
  "Most Popular"→"Most pick this"; CTAs refreshed.
- docs/tiers.md change log records the full diff.

Fleet tier, 14-day trial copy, and Smart dark-card treatment deferred.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ovidiu U
2026-04-20 18:57:24 +01:00
parent 7dc41ba9ee
commit c2466e5a61
11 changed files with 179 additions and 42 deletions

View File

@@ -8,14 +8,20 @@ decision — which channels a user can receive, how often, and what features the
## Tiers at a glance
| Tier | Price | Email | Push | WhatsApp | SMS | AI predictions | Fuel types |
|-------|--------|-------------------|---------|----------|--------------|----------------|------------|
| free | £0 | weekly digest | — | — | — | — | 1 |
| basic | £0.99 | daily | daily | daily | — | — | 1 |
| plus | £2.49 | triggered | triggered | triggered | max 1/day | yes | 1 |
| pro | £3.99 | triggered | triggered | triggered | max 3/day | yes | unlimited |
| Tier | Price | Email | Push | WhatsApp | SMS | AI predictions | Price threshold | Score alerts | Fuel types |
|-------|--------|---------------|-----------|-----------|------------|----------------|-----------------|--------------|------------|
| free | £0 | weekly digest | — | — | — | — | — | — | 1 |
| basic | £0.99 | daily | daily | daily | — | — | ✓ | ✓ | 1 |
| plus | £2.49 | triggered | triggered | triggered | max 1/day | ✓ | ✓ | ✓ | 1 |
| pro | £3.99 | triggered | triggered | triggered | max 3/day | ✓ | ✓ | ✓ | unlimited |
Tiers are stored in the `plans` table. The `features` JSON column defines every limit and flag.
`database/seeders/PlanSeeder.php` is the source of truth — this table mirrors it.
> **Deeper entitlements** (history window, prediction level, leaderboard size, saved stations,
> fuel log caps, brand comparison, route planner, family sharing) are defined in
> `docs/superpowers/specs/2026-04-15-tier-features-design.md`. That spec extends the
> `features` JSON shape with additional keys beyond the notification-channel flags below.
---
@@ -38,21 +44,22 @@ Tiers are stored in the `plans` table. The `features` JSON column defines every
## The `plans` table
```
id bigint PK
name string — free | basic | plus | pro
stripe_price_id string nullable — matches Cashier's stripe_price column
features json — see shape below
active boolean
id bigint PK
name string — free | basic | plus | pro
stripe_price_id_monthly string nullable — Cashier price ID for monthly billing
stripe_price_id_annual string nullable — Cashier price ID for annual billing
features json — see shape below
active boolean
timestamps
```
### `features` JSON shape
### `features` JSON shape (notification-channel flags)
```json
{
"fuel_types": { "max": 1 },
"email": { "enabled": true, "frequency": "triggered" },
"push": { "enabled": true },
"push": { "enabled": true, "frequency": "triggered" },
"whatsapp": { "enabled": true, "daily_limit": 5, "scheduled_updates": 2 },
"sms": { "enabled": true, "daily_limit": 3 },
"ai_predictions": true,
@@ -63,8 +70,14 @@ timestamps
`fuel_types.max: null` means unlimited (pro only).
`email.frequency` values: `weekly_digest`, `daily`, `triggered`.
`push.frequency` values: `none` (when disabled), `daily`, `triggered`.
`whatsapp` and `sms` always carry `daily_limit` (and whatsapp carries `scheduled_updates`)
even when `enabled: false` — set to `0` on disabled tiers. See `PlanSeeder`.
Boolean features default to `false` on the free tier.
**`price_threshold` and `score_alerts` are enabled on basic and above** (not plus-only).
**`ai_predictions` is plus and above only.**
---
## Resolving the plan for a user
@@ -222,6 +235,45 @@ Test files live in `tests/Feature/Tiers/`:
| File | Covers |
|------|--------|
| `PlanFeaturesTest.php` | `canUseChannel`, `canSendNow`, `canTrackFuelType`, `can()`, middleware, log scopes |
| `PlanFeaturesTest.php` | `canUseChannel`, `canSendNow`, `canTrackFuelType`, `can()`, middleware, log scopes, display name, `push.frequency` shape |
| `PlanResourceTest.php` | Filament list/edit, no create/delete, saves features correctly |
| `DispatchUserNotificationJobTest.php` | Sent logging, `tier_restricted`, `daily_limit`, user-disabled suppression, queue name, fan-out |
Unit:
| File | Covers |
|------|--------|
| `tests/Unit/Enums/PlanTierTest.php` | `PlanTier::label()` — user-facing display names |
---
## Change log
### 2026-04-20 — display-name layer, `push.frequency`, pricing card rename
Reconciled docs with `PlanSeeder` reality and introduced the display-name layer from `Downloads/pricing-plan.md` v2.
**Entitlement reality (docs were stale before this pass):**
- `price_threshold` and `score_alerts` are on **basic, plus, pro** — not plus-only.
- `ai_predictions` is plus+pro only.
- Schema columns are `stripe_price_id_monthly` and `stripe_price_id_annual` (not a single `stripe_price_id`).
**New: display-name layer.** Backend tier identifiers stay `basic/plus/pro`; UI-facing names are `Free/Daily/Smart/Pro`.
- `app/Enums/PlanTier.php` — added `label(): string`
- `app/Models/Plan.php` — added `displayName(): string` (delegates to enum)
- `app/Services/PlanFeatures.php` — added `displayName(): string`
**New: `push.frequency` key in `features` JSON.** Mirrors `email.frequency` so Daily's "daily push" is distinguishable from Smart/Pro's "triggered push".
- Values: `none` (when disabled), `daily`, `triggered`
- Seeded: free=`none`, basic=`daily`, plus=`triggered`, pro=`triggered`
- Touched: `PlanSeeder`, `PlanFactory`, free-tier stubs in `Plan::resolveForUser` + `PlanFeatures::__construct`, Filament `PlanForm`
**Marketing: homepage pricing cards renamed.** `resources/js/views/Home.vue`:
- Card labels: `Basic``Daily`, `Plus``Smart`
- Badge: `Most Popular``Most pick this`
- CTAs: `Select Basic``Choose Daily`, `Join Plus``Choose Smart`, `Go Pro``Choose Pro`, free unauthed `Get started``Start free`
- Smart retains the existing accent-ring highlight; Pro retains the dark card.
**Deferred:** `Fleet` tier (per-seat B2B), `Start 14-day trial` CTA on Smart (no trial backend), swapping Smart to a dark card (current accent ring is sufficient).
**Operational:** existing DB rows won't have `push.frequency` until `php artisan db:seed --class=PlanSeeder` runs. The seeder is idempotent.