Extending

PHP API

The addon comes with a Facade for interacting with the Tracker: \Thoughtco\StatamicCacheTracker\Facades\Tracker

Add to Tracker

Adds a url and any particular tags to the tracker.

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::add('/', ['some:thing']);

Add Additional Tracker Information

Allows you to have your own custom tracking data

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

//...

Tracker::addAdditionalTracker(function ($tracker, $next) {
    // run your logic, for example in an augmentation hook
    // then call:
    $tracker->addContentTag('your-tag-here');

    return $next($tracker);
});

Get all tracked data

Returns all tracked data.

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::all();

Get all tracked data for an url.

Returns all tracked data for the passed url

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::get('/');

Get additional trackers

Returns any additional trackers that have been added.

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::getAdditionalTrackers();

Check for tags on an url

Returns any tags that have been set on an url.

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::has('/');

Invalidate tags

Invalidate an array of tags that have been passed.

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::invalidate(['pages:home', 'pages:about', 'blog:an-article-about-the-cache-tracker']);

Invalidate URLS

Invalidate any urls within the cache.

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::invalidateUrls(['/this-url', '/that-url']);

Flush URLS

Invalidates all tracked urls from the cache.

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::flush();

Remove URL

Invalidates the passed url and removes it from the tracker.

use Thoughtco\StatamicCacheTracker\Facades\Tracker;

Tracker::remove('/this-url');

Previous

Middleware

Next

Tracker Data