v4.0.0
🏗️ Architecture Changes
-
Introduced
Devarts\PlausiblePHP\Contract\ConfigurationInterfaceandDevarts\PlausiblePHP\Contract\ConfigurationInterface\Configurationas it's implementation. This object provides client to be used for Plausible API communication, and accepts configuration parameters like API key and API base URI. -
Introduced separate classes for different Plausible APIs in
Devarts\PlausiblePHP\Apinamespace: -
❗ Renamed
Devarts\PlausiblePHP\PlausibleAPItoPlausibleApi. This class also now accepts object ofConfigurationInterfacetype in it's constructor. It's purpose is changed, as it now serves as a provider of different Plausible APIs. It implementsDevarts\PlausiblePHP\Contract\PlausibleApiInterface. -
Introduced new namespace
Devarts\PlausiblePHP\Contractthat holds interfaces that are self-explanatory:ApiResponseObjectConfigurationInterfaceEventsApiInterfaceSitesApiInterfaceStatsApiInterfacePlausibleApiInterface
🆕 New Features
- Added support for properties
event:goalandevent:hostname(see properties) - Added support for new metrics:
conversion_rate,time_on_pageandviews_per_visit(see metrics) - Added support for Sites List API: https://plausible.io/docs/sites-api#get-apiv1sites
- Added support for Goals List API: https://plausible.io/docs/sites-api#get-apiv1sitesgoals
- Added normalisation for
Devarts\PlausiblePHP\Support\MetricandDevarts\PlausiblePHP\Support\Filterobjects passed as arguments to different methods ofDevarts\PlausiblePHP\Api\StatsApi, which means if you pass raw objects they will automatically be converted to string representation.
❗Other Important Changes
- ❗ Dropped support for providing base API URI with
v1paths. Following URI is not valid base path anymore:https://plausible.io/api/v1/ - ❗ Dropped support for PHP 7.4
⏫ Upgrade Guide
- Update
Devarts\PlausiblePHP\PlausibleAPIconstruction:- (optional) Rename class from
PlausibleAPItoPlausibleApi - Pass instance of
ConfigurationInterfaceto the constructor (e.g.Devarts\PlausiblePHP\Configuration::create('api_key'))
- (optional) Rename class from
- Update API methods calls:
- For each method previously called on
Devarts\PlausiblePHP\PlausibleAPIobjects, add corresponding proxy call. For example, if you previously called$plausible_api->getAggregate(...)you should now call$plausible_api->stats()->getAggregate(...)
- For each method previously called on
- Make sure to tweak base URI when passing to
Devarts\PlausiblePHP\Configuration::createto not containv1/suffix