Merge pull request #2 from MattitjaAB/Remove-site

Remove site
This commit was merged in pull request #2.
This commit is contained in:
Mathias authored and GitHub committed 2025-01-31 14:16:52 +01:00
commit 9c2ebc5db8
2 files changed
+6 -27

No files matched your search

+6 -26
View File
@@ -5,7 +5,7 @@
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/mattitjaab/laravel-plausible-proxy/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/mattitjaab/laravel-plausible-proxy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain) [![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/mattitjaab/laravel-plausible-proxy/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/mattitjaab/laravel-plausible-proxy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/mattitjaab/laravel-plausible-proxy.svg?style=flat-square)](https://packagist.org/packages/mattitjaab/laravel-plausible-proxy) [![Total Downloads](https://img.shields.io/packagist/dt/mattitjaab/laravel-plausible-proxy.svg?style=flat-square)](https://packagist.org/packages/mattitjaab/laravel-plausible-proxy)
A Laravel package for proxying Plausible Analytics, improving performance and privacy. A Laravel package for proxying Plausible Analytics, improving performance.
## Requirements ## Requirements
- Laravel 11 - Laravel 11
@@ -26,27 +26,15 @@ A Laravel package for proxying Plausible Analytics, improving performance and pr
3. Add the following environment variables to your `.env` file: 3. Add the following environment variables to your `.env` file:
```env ```env
PLAUSIBLE_DOMAIN=https://plausible.io PLAUSIBLE_DOMAIN=https://plausible.io
PLAUSIBLE_SITE=example.com
```
4. **(Optional)** If you want to use Laravel Queues to send events in the background, ensure your queue driver is set up correctly:
```env
QUEUE_CONNECTION=database
```
Then run migrations to create the necessary queue tables:
```sh
php artisan queue:table
php artisan migrate
``` ```
## ⚙️ Configuration ## ⚙️ Configuration
The `config/plausible-proxy.php` file allows you to customize the package settings: The `config/plausible-proxy.php` file allows you to customize the plausible domain:
```php ```php
return [ return [
'domain' => env('PLAUSIBLE_DOMAIN', 'https://plausible.io'), 'domain' => env('PLAUSIBLE_DOMAIN', 'https://plausible.io'),
'site' => env('PLAUSIBLE_SITE', 'example.com'),
]; ];
``` ```
@@ -63,21 +51,13 @@ After installation, you can include the script like this:
The route `/js/script.js` is automatically handled and caches the script for **6 hours**. The route `/js/script.js` is automatically handled and caches the script for **6 hours**.
### **2. Sending Events to Plausible** ### **2. Sending Events to Plausible**
Instead of sending events directly to `plausible.io`, you can now send them to `/api/event`, and they will be queued and processed asynchronously. Instead of sending events directly to plausible.io, the script is loaded from /js/script.js and proxies the request to Plausible via /api/event, helping to prevent blocking by ad blockers.
Example request:
```sh
curl -X POST "https://example.com/api/event" \
-H "Content-Type: application/json" \
-d '{"n":"pageview","u":"https://example.com/page","d":"example.com"}'
```
## ✅ Features ## ✅ Features
- 🚀 **Fast & Optimized**: Caches the Plausible script to reduce external calls. - 🚀 **Fast & Optimized**: Caches the Plausible script to reduce external calls.
- 🔒 **Privacy-Friendly**: Prevents direct calls to `plausible.io`. - ✅ No issues with ad blockers: Proxies the request via a local API endpoint.
- 📊 **Improved Performance**: Events are processed via Laravel Queues to avoid blocking user interactions. - 🛠 **Fully Configurable**: Easily set your own Plausible instance via `.env`.
- 🛠 **Fully Configurable**: Easily set your own Plausible instance and domain via `.env`.
## 🛠 Testing ## 🛠 Testing
-1
View File
@@ -4,5 +4,4 @@
return [ return [
'domain' => env('PLAUSIBLE_DOMAIN', 'https://plausible.io'), 'domain' => env('PLAUSIBLE_DOMAIN', 'https://plausible.io'),
'site' => env('PLAUSIBLE_SITE', 'example.com'),
]; ];