Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5eff0cafe5 | ||
|
|
0e25ead520 | ||
|
|
67507d036a | ||
|
|
0ce7b51eff | ||
|
|
891c3d8ff8 | ||
|
|
e2062499ae | ||
|
|
1f4bbadab7 | ||
|
|
9c2ebc5db8 | ||
|
|
32721b82cc | ||
|
|
6df45258a6 | ||
|
|
6a358d9d65 | ||
|
|
6417d3bd6e | ||
|
|
3b6afc54f9 | ||
|
|
a2c3ad76c0 | ||
|
|
42debe755e | ||
|
|
9788f6f895 |
No files matched your search
@@ -14,7 +14,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Dependabot metadata
|
- name: Dependabot metadata
|
||||||
id: metadata
|
id: metadata
|
||||||
uses: dependabot/fetch-metadata@v2.3.0
|
uses: dependabot/fetch-metadata@v2.4.0
|
||||||
with:
|
with:
|
||||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
ref: ${{ github.head_ref }}
|
ref: ${{ github.head_ref }}
|
||||||
|
|
||||||
- name: Fix PHP code style issues
|
- name: Fix PHP code style issues
|
||||||
uses: aglipanci/laravel-pint-action@2.4
|
uses: aglipanci/laravel-pint-action@2.5
|
||||||
|
|
||||||
- name: Commit changes
|
- name: Commit changes
|
||||||
uses: stefanzweifel/git-auto-commit-action@v5
|
uses: stefanzweifel/git-auto-commit-action@v5
|
||||||
|
|||||||
@@ -16,14 +16,27 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest]
|
os: [ubuntu-latest]
|
||||||
php: [8.4]
|
php: [8.3, 8.4]
|
||||||
laravel: [11.*]
|
laravel: [11.*, 12.*]
|
||||||
stability: [prefer-lowest, prefer-stable]
|
stability: [prefer-lowest, prefer-stable]
|
||||||
include:
|
include:
|
||||||
- laravel: 11.*
|
- laravel: 11.*
|
||||||
|
php: 8.3
|
||||||
testbench: 9.*
|
testbench: 9.*
|
||||||
carbon: ^2.63
|
carbon: ^2.63
|
||||||
|
- laravel: 11.*
|
||||||
|
php: 8.4
|
||||||
|
testbench: 9.*
|
||||||
|
carbon: ^2.63
|
||||||
|
- laravel: 12.*
|
||||||
|
php: 8.3
|
||||||
|
testbench: 10.*
|
||||||
|
carbon: ^3.8.4
|
||||||
|
- laravel: 12.*
|
||||||
|
php: 8.4
|
||||||
|
testbench: 10.*
|
||||||
|
carbon: ^3.8.4
|
||||||
|
|
||||||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
|
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
|
||||||
|
|
||||||
@@ -43,9 +56,18 @@ jobs:
|
|||||||
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||||
|
|
||||||
|
- name: Remove Larastan if Laravel 12
|
||||||
|
if: startsWith(matrix.laravel, '12.')
|
||||||
|
run: composer remove larastan/larastan --dev --no-update || true
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.os == 'windows-latest' && '^^^' || '' }}${{ matrix.carbon }}" --no-interaction --no-update
|
composer require \
|
||||||
|
"laravel/framework:${{ matrix.laravel }}" \
|
||||||
|
"orchestra/testbench:${{ matrix.testbench }}" \
|
||||||
|
"nesbot/carbon:${{ matrix.carbon }}" \
|
||||||
|
--no-interaction --no-update
|
||||||
|
|
||||||
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
|
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
|
||||||
|
|
||||||
- name: List Installed Dependencies
|
- name: List Installed Dependencies
|
||||||
|
|||||||
@@ -2,6 +2,30 @@
|
|||||||
|
|
||||||
All notable changes to `laravel-plausible-proxy` will be documented in this file.
|
All notable changes to `laravel-plausible-proxy` will be documented in this file.
|
||||||
|
|
||||||
|
## v1.3 - 2025-01-31
|
||||||
|
|
||||||
|
### What's Changed
|
||||||
|
|
||||||
|
* Remove site by @mathiaspalmqvist in https://github.com/MattitjaAB/laravel-plausible-proxy/pull/2
|
||||||
|
|
||||||
|
**Full Changelog**: https://github.com/MattitjaAB/laravel-plausible-proxy/compare/v1.2...v1.3
|
||||||
|
|
||||||
|
## v1.2 - 2025-01-31
|
||||||
|
|
||||||
|
**Full Changelog**: https://github.com/MattitjaAB/laravel-plausible-proxy/compare/v1.1...v1.2
|
||||||
|
|
||||||
|
## v1.1 - 2025-01-31
|
||||||
|
|
||||||
|
### What's Changed
|
||||||
|
|
||||||
|
* Refactor event forwarding and improve test coverage by @mathiaspalmqvist in https://github.com/MattitjaAB/laravel-plausible-proxy/pull/1
|
||||||
|
|
||||||
|
### New Contributors
|
||||||
|
|
||||||
|
* @mathiaspalmqvist made their first contribution in https://github.com/MattitjaAB/laravel-plausible-proxy/pull/1
|
||||||
|
|
||||||
|
**Full Changelog**: https://github.com/MattitjaAB/laravel-plausible-proxy/compare/v1.0...v1.1
|
||||||
|
|
||||||
## First release - 2025-01-30
|
## First release - 2025-01-30
|
||||||
|
|
||||||
**Full Changelog**: https://github.com/MattitjaAB/laravel-plausible-proxy/commits/v1.0
|
**Full Changelog**: https://github.com/MattitjaAB/laravel-plausible-proxy/commits/v1.0
|
||||||
@@ -5,11 +5,11 @@
|
|||||||
[](https://github.com/mattitjaab/laravel-plausible-proxy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
|
[](https://github.com/mattitjaab/laravel-plausible-proxy/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
|
||||||
[](https://packagist.org/packages/mattitjaab/laravel-plausible-proxy)
|
[](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 12
|
||||||
- PHP 8.4+
|
- PHP 8.3, 8.4
|
||||||
|
|
||||||
## 🚀 Installation
|
## 🚀 Installation
|
||||||
|
|
||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -18,9 +18,9 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.4",
|
"php": "^8.3",
|
||||||
"spatie/laravel-package-tools": "^1.16",
|
"spatie/laravel-package-tools": "^1.16",
|
||||||
"illuminate/contracts": "^10.0||^11.0"
|
"illuminate/contracts": "^10.0||^11.0||^12.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"laravel/pint": "^1.14",
|
"laravel/pint": "^1.14",
|
||||||
|
|||||||
@@ -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'),
|
|
||||||
];
|
];
|
||||||
@@ -54,9 +54,6 @@ it('accepts valid event data and forwards headers', function () {
|
|||||||
|
|
||||||
Http::fake([
|
Http::fake([
|
||||||
'https://plausible.io/api/event' => function ($request) {
|
'https://plausible.io/api/event' => function ($request) {
|
||||||
dump($request->headers());
|
|
||||||
dump($request->data());
|
|
||||||
|
|
||||||
return Http::response(['status' => 'queued'], 200);
|
return Http::response(['status' => 'queued'], 200);
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
@@ -78,10 +75,6 @@ it('accepts valid event data and forwards headers', function () {
|
|||||||
Http::assertSentCount(1);
|
Http::assertSentCount(1);
|
||||||
|
|
||||||
Http::assertSent(function ($request) {
|
Http::assertSent(function ($request) {
|
||||||
dump($request->url());
|
|
||||||
dump($request->headers());
|
|
||||||
dump($request->data());
|
|
||||||
|
|
||||||
return $request->url() === 'https://plausible.io/api/event'
|
return $request->url() === 'https://plausible.io/api/event'
|
||||||
&& isset($request['n']) && $request['n'] === 'pageview'
|
&& isset($request['n']) && $request['n'] === 'pageview'
|
||||||
&& isset($request['u']) && $request['u'] === 'https://example.com/page'
|
&& isset($request['u']) && $request['u'] === 'https://example.com/page'
|
||||||
|
|||||||
Reference in new issue
Block a user