plausible / analytics

Simple, open source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics.
https://plausible.io
GNU Affero General Public License v3.0
18.98k stars 1.02k forks source link

Add listing sites, goals and custom props to Sites API #4302

Open zoldar opened 2 days ago

zoldar commented 2 days ago

Changes

This PR extends Sites API in following ways:

The list endpoints implement cursor based pagination. They accept following parameters: before, after and limit (defaults to 10, capped at 100 as max). The response payload always contains pagination metadata:

{
  "sites": [...],
  "meta": {
    "after": "Z2xc...",
    "before": null,
    "limit": 10
  }
}

After the initial request, previous and next pages can be retrieved by repeating the same request with before or after query parameter added from the last response. The limit parameter must remain the same when paginating (either at default or the same value must be passed each time explicitly). The null value in before or after means there are no more either previous or next pages to navigate to.

There are no breaking changes to the API and the new extensions follow existing path and data shape conventions.

Tests

Changelog

Documentation

Dark mode

github-actions[bot] commented 1 day ago
|Preview environment👷🏼‍♀️🏗️ | |:-:| | [PR-4302](https://pr-4302.review.plausible.io)
github-actions[bot] commented 1 day ago
|Preview environment👷🏼‍♀️🏗️ | |:-:| | [PR-4302](https://pr-4302.review.plausible.io)
macobo commented 1 day ago

100 seems quite low as a maximum limit and 10 as a default - why not 100 as default and 1000 as maximum? The query and response sizes are quite minimal and we're just inconveniencing users.

zoldar commented 23 hours ago

100 seems quite low as a maximum limit and 10 as a default - why not 100 as default and 1000 as maximum? The query and response sizes are quite minimal and we're just inconveniencing users.

Yes, I guess those could be bumped. The current limits are what's currently in effect for Plugin API.

zoldar commented 23 hours ago

Bumped pagination limits in https://github.com/plausible/analytics/pull/4302/commits/93b3c571491f1571f741620ad6814663d434a59e

github-actions[bot] commented 22 hours ago
|Preview environment👷🏼‍♀️🏗️ | |:-:| | [PR-4302](https://pr-4302.review.plausible.io)