›
byrcsc/laravel-customer-health · 1.x
Configure storage, declarations, tenancy, retention, and queued product-event writes.
Use config/customer-health.php to define where package data lives and which
application declarations are available.
Publish the file with:
php artisan vendor:publish --tag="customer-health-config"| Key | Default | Purpose |
|---|---|---|
table_names.events | customer_health_events | Raw product-event table |
table_names.milestones | customer_health_milestones | First occurrences and onboarding completion |
table_names.scores | customer_health_scores | Append-only score history |
table_names.summaries | customer_health_summaries | Current score summary rows |
connection | null | Connection for events, milestones, and scores |
summary_connection | null | Connection for summaries, falling back to connection |
events | [] | Registered ProductEvent classes |
checklists | [] | Registered Checklist classes |
scores | [] | Registered HealthScore classes |
tenant_resolver | NullTenantResolver::class | Invokable class that returns the current tenant ID |
retention_days | null | Days to retain raw events; null keeps them forever |
queue | false | Whether track() dispatches a queued write |
queue_connection | null | Queue connection for product-event jobs |
queue_name | null | Queue name for product-event jobs |
The shipped file does not read environment variables. Add env() calls to
the published file when deployment configuration must control these values.
Set all names before publishing or running migrations:
'table_names' => [
'events' => 'product_events',
'milestones' => 'product_milestones',
'scores' => 'customer_health_scores',
'summaries' => 'customer_health_summaries',
],Models and published migrations resolve through the same map. If an older published config lacks a table key, the package falls back to the shipped default for that key.
Renaming a table after it contains data requires an application migration.
'connection' => null,
'summary_connection' => null,A null connection follows Laravel's current default connection. This is the
setting to use when a tenancy package switches the default database.
A null summary_connection follows connection. Set a separate value when
tenant history belongs in tenant databases and current summaries belong in a
landlord database:
'connection' => 'tenant',
'summary_connection' => 'landlord',An explicit connection set on a package model instance takes precedence over configuration.
'events' => [
App\CustomerHealth\Events\WorkflowCreated::class,
App\CustomerHealth\Events\TeammateInvited::class,
],Every tracked event must be registered. Classes must extend ProductEvent,
and event names must be unique.
Event list order is preserved within CustomerHealth::features() results. It
does not define event processing order.
'checklists' => [
App\CustomerHealth\Onboarding::class,
],Classes must extend Checklist. Every checklist needs at least one unique
step, and every step must be a registered milestone event.
When a facade call omits the checklist name, the package uses the first registered checklist.
'scores' => [
App\CustomerHealth\CustomerHealthScore::class,
],Classes must extend HealthScore and have unique non-empty names. Each score
must contain at least one valid signal and a state threshold at zero.
When a facade call omits the score name, the package uses the first registered score.
'tenant_resolver' => App\Tenancy\CurrentTenantId::class,The container resolves the class and invokes it during summary writes and
purges. It must return an integer, non-empty string, or null.
Use NullTenantResolver for applications without tenant identity. Use
SpatieTenantResolver with Spatie Laravel Multitenancy when Tenant::current()
is the intended source.
'retention_days' => 90,Only a non-negative integer enables pruning. Null, a negative value, or a non-integer makes the package's prunable query match no rows.
The value affects ProductEventRecord when Laravel's model:prune command
runs. It does not schedule pruning and never removes milestones, scores, or
summaries.
'queue' => true,
'queue_connection' => 'redis',
'queue_name' => 'customer-health',Queued writes are enabled only when queue is the boolean true. Null or
empty connection and queue strings become Laravel defaults.
The queue settings apply only to CustomerHealth::track().