Skip to content

Events

Listen for these like any other event of your application. Every class lives under CyrildeWit\EloquentViewable. Stores write without Eloquent, so listen for ViewRecorded rather than for View model events.

Event Fires Carries
Recording\Events\ViewRecorded when a view is handed to the store; from the worker when recording is queued, and before the row exists with the Redis buffer record
Recording\Events\ViewSkipped when a guard refuses a view attempt, guard
Recording\Events\ViewAttempted after every attempt, stored, queued or skipped, in the request that made it; only built when something listens attempt, result
Recording\Events\BurstDetected once when IgnoreBursts starts blocking a visitor or network attempt, by (visitor or network)
Recording\Events\ViewsDestroyed after the views of a model are deleted, by views($model)->destroy() or when the model is deleted viewable

See Finding out why a view was not recorded for ViewAttempted and ViewSkipped in practice.

These are dispatched once the row they report is written, so queue their listeners. Each carries the model’s morph type and key, and viewable() returns the model, or null once it is deleted.

Event Fires Carries
Milestones\Events\ViewMilestoneReached once per model and threshold, when a recount takes a counter column past a milestone type, key, column, milestone, count, passed
Spikes\Events\ViewsSpiked once when views:detect-spikes finds a model above its baseline type, key, baseline
Spikes\Events\ViewsDropped the same, below its baseline, for the types that watch drops type, key, baseline
Spikes\Events\ViewsSettled once a spike or drop has been back to normal for the cooldown type, key, direction, peakCount, peakScore, since
Event Fires Carries
Querying\Counters\Events\CountersRecounted after each chunk of counter columns is recounted, by views:recount, views:maintain or views($model)->destroy() class, keys
Querying\Rollups\Events\ViewsRolledUp once per rollup and tier that views:rollup or views:maintain folded at least one bucket into; never on a dry run rollup, tier, from, until, buckets, stopped
Querying\Pairs\Events\ViewsPaired once per period after views:pairs rewrites the pairs table since, viewables, pairs, period
Event Fires Carries
Erasure\Events\ViewHistoryForgotten after one viewer’s or visitor’s views are deleted subject, views
Erasure\Events\ViewHistoryAnonymised after one viewer’s or visitor’s views are anonymised subject, views
Erasure\Events\ViewHistoryExported after one viewer’s or visitor’s views are exported subject

subject is an Erasure\Subject, with the viewerType, viewerKey or visitor the run was about.

Each is dispatched once per run that changed at least one view, and every remembered count is forgotten with it.

Event Fires Carries
Retention\Events\ViewsPruned after views:prune deletes old views from, until, views
Retention\Events\ViewsAnonymised after views:anonymise anonymises old views from, until, views
Retention\Events\BotViewsPurged after views:purge-bots deletes bot views from, until, views, visitors