Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

v4.0.0

Choose a tag to compare

@marko-ogg marko-ogg released this 21 Jul 11:59
· 4 commits to master since this release

🏗️ Architecture Changes

  • Introduced Devarts\PlausiblePHP\Contract\ConfigurationInterface and Devarts\PlausiblePHP\Contract\ConfigurationInterface\Configuration as 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\Api namespace:

    • StatsApi - works with Plausible Stats API (docs).
    • EventsApi - works with Plausible Events API (docs).
    • SitesApi - works with Plausible Sites API (docs).
  • ❗ Renamed Devarts\PlausiblePHP\PlausibleAPI to PlausibleApi. This class also now accepts object of ConfigurationInterface type in it's constructor. It's purpose is changed, as it now serves as a provider of different Plausible APIs. It implements Devarts\PlausiblePHP\Contract\PlausibleApiInterface.

  • Introduced new namespace Devarts\PlausiblePHP\Contract that holds interfaces that are self-explanatory:

    • ApiResponseObject
    • ConfigurationInterface
    • EventsApiInterface
    • SitesApiInterface
    • StatsApiInterface
    • PlausibleApiInterface

🆕 New Features

  • Added support for properties event:goal and event:hostname (see properties)
  • Added support for new metrics: conversion_rate, time_on_page and views_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\Metric and Devarts\PlausiblePHP\Support\Filter objects passed as arguments to different methods of Devarts\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 v1 paths. Following URI is not valid base path anymore: https://plausible.io/api/v1/
  • ❗ Dropped support for PHP 7.4

⏫ Upgrade Guide

  1. Update Devarts\PlausiblePHP\PlausibleAPI construction:
    • (optional) Rename class from PlausibleAPI to PlausibleApi
    • Pass instance of ConfigurationInterface to the constructor (e.g. Devarts\PlausiblePHP\Configuration::create('api_key'))
  2. Update API methods calls:
    • For each method previously called on Devarts\PlausiblePHP\PlausibleAPI objects, add corresponding proxy call. For example, if you previously called $plausible_api->getAggregate(...) you should now call $plausible_api->stats()->getAggregate(...)
  3. Make sure to tweak base URI when passing to Devarts\PlausiblePHP\Configuration::create to not contain v1/ suffix