›
›
›
  1. docs
  2. ›
  3. byrcsc/laravel-customer-health
1.x
Browse documentationOpenClose

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Product events
  • Features and milestones
  • Onboarding
  • Health scores
  • Summaries and tenancy

Operations

  • Querying customer health
  • Queueing events
  • Recomputing scores
  • Retention and erasure
  • Production operations

Reference

  • Configuration
  • Public API
  • Events
  • Console commands
  • Database storage
  • Testing
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Product events
  • Features and milestones
  • Onboarding
  • Health scores
  • Summaries and tenancy

Operations

  • Querying customer health
  • Queueing events
  • Recomputing scores
  • Retention and erasure
  • Production operations

Reference

  • Configuration
  • Public API
  • Events
  • Console commands
  • Database storage
  • Testing
  • Troubleshooting

byrcsc/laravel-customer-health · 1.x

Configuration.

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"

Configuration keys

KeyDefaultPurpose
table_names.eventscustomer_health_eventsRaw product-event table
table_names.milestonescustomer_health_milestonesFirst occurrences and onboarding completion
table_names.scorescustomer_health_scoresAppend-only score history
table_names.summariescustomer_health_summariesCurrent score summary rows
connectionnullConnection for events, milestones, and scores
summary_connectionnullConnection for summaries, falling back to connection
events[]Registered ProductEvent classes
checklists[]Registered Checklist classes
scores[]Registered HealthScore classes
tenant_resolverNullTenantResolver::classInvokable class that returns the current tenant ID
retention_daysnullDays to retain raw events; null keeps them forever
queuefalseWhether track() dispatches a queued write
queue_connectionnullQueue connection for product-event jobs
queue_namenullQueue 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.

Table names

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.

Storage connections

'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.

Event declarations

'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.

Checklist declarations

'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.

Score declarations

'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

'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

'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 settings

'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().

What to read next

  • Installation and setup to publish configuration and migrations in the correct order.
  • Queueing events for worker, transaction, and retry behavior.
  • Summaries and tenancy for split tenant and landlord storage.
PreviousProduction operationsNextPublic API
View source

On this page

  1. Configuration keys
  2. Table names
  3. Storage connections
  4. Event declarations
  5. Checklist declarations
  6. Score declarations
  7. Tenant resolver
  8. Retention
  9. Queue settings
  10. What to read next