Remove posthog pageview middleware

This commit is contained in:
floppydiskette 2024-06-19 15:15:35 +01:00
parent 02c68f8545
commit 8f02ed0a76
Signed by: fwoppydwisk
SSH key fingerprint: SHA256:Hqn452XQ1ETzUt/FthJu6+OFkS4NBxCv5VQSEvuk7CE
7 changed files with 10 additions and 110 deletions

View file

@ -26,6 +26,3 @@ MEMCACHED_HOST=127.0.0.1
LASTFM_KEY= LASTFM_KEY=
LASTFM_USER= LASTFM_USER=
POSTHOG_KEY=
POSTHOG_HOST=

View file

@ -1,28 +0,0 @@
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use PostHog\PostHog;
use Symfony\Component\HttpFoundation\Response;
class PageView
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
PostHog::capture([
'distinctId' => request()->ip(),
'event' => '$pageview',
'properties' => array(
'$current_url' => url()->current(),
),
]);
return $next($request);
}
}

View file

@ -17,12 +17,5 @@ public function register(): void {
/** /**
* Bootstrap any application services. * Bootstrap any application services.
*/ */
public function boot(): void { public function boot(): void {}
PostHog::init(
Config::get('services.posthog.key'),
[
'host' => 'https://'.Config::get('services.posthog.host')
]
);
}
} }

View file

@ -10,7 +10,6 @@
"guzzlehttp/guzzle": "^7.2", "guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10", "laravel/framework": "^10.10",
"laravel/tinker": "^2.8", "laravel/tinker": "^2.8",
"posthog/posthog-php": "^3.3",
"scrivo/highlight.php": "v9.18.1.10", "scrivo/highlight.php": "v9.18.1.10",
"sentry/sentry-laravel": "^4.1", "sentry/sentry-laravel": "^4.1",
"spatie/laravel-honeypot": "^4.3", "spatie/laravel-honeypot": "^4.3",

56
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3204be06a1b7a37cc0af50a0babca0a0", "content-hash": "28176864af13fa0e06f1784e6e64e791",
"packages": [ "packages": [
{ {
"name": "auth0/auth0-php", "name": "auth0/auth0-php",
@ -3041,60 +3041,6 @@
], ],
"time": "2023-11-12T21:59:55+00:00" "time": "2023-11-12T21:59:55+00:00"
}, },
{
"name": "posthog/posthog-php",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/PostHog/posthog-php.git",
"reference": "34301d0f20e20b785d465c574557278d18620f31"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PostHog/posthog-php/zipball/34301d0f20e20b785d465c574557278d18620f31",
"reference": "34301d0f20e20b785d465c574557278d18620f31",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=8.0"
},
"require-dev": {
"overtrue/phplint": "^3.0",
"phpunit/phpunit": "^9.0",
"slope-it/clock-mock": "^0.4.0",
"squizlabs/php_codesniffer": "^3.7"
},
"bin": [
"bin/posthog"
],
"type": "library",
"autoload": {
"psr-4": {
"PostHog\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PostHog <hey@posthog.com>",
"homepage": "https://posthog.com/"
}
],
"description": "PostHog PHP Library",
"homepage": "https://github.com/PostHog/posthog-php",
"keywords": [
"posthog"
],
"support": {
"issues": "https://github.com/PostHog/posthog-php/issues",
"source": "https://github.com/PostHog/posthog-php/tree/3.3.2"
},
"time": "2024-04-03T13:19:42+00:00"
},
{ {
"name": "psr-discovery/all", "name": "psr-discovery/all",
"version": "1.0.1", "version": "1.0.1",

View file

@ -17,10 +17,5 @@
'lastfm' => [ 'lastfm' => [
'key' => env('LASTFM_KEY'), 'key' => env('LASTFM_KEY'),
'user' => env('LASTFM_USER'), 'user' => env('LASTFM_USER'),
],
'posthog' => [
'key' => env('POSTHOG_KEY'),
'host' => env('POSTHOG_HOST'),
] ]
]; ];

View file

@ -3,13 +3,13 @@
use App\Http\Controllers\AdminBookmarksController; use App\Http\Controllers\AdminBookmarksController;
use App\Http\Controllers\AdminGuestbookController; use App\Http\Controllers\AdminGuestbookController;
use App\Http\Controllers\AdminImportController; use App\Http\Controllers\AdminImportController;
use App\Http\Controllers\BlogController;
use App\Http\Controllers\BookmarksController; use App\Http\Controllers\BookmarksController;
use App\Http\Controllers\CalculatorsController; use App\Http\Controllers\CalculatorsController;
use App\Http\Controllers\ComputersController; use App\Http\Controllers\ComputersController;
use App\Http\Controllers\GuestbookController; use App\Http\Controllers\GuestbookController;
use App\Http\Controllers\HomeController; use App\Http\Controllers\HomeController;
use App\Http\Controllers\MusicController; use App\Http\Controllers\MusicController;
use App\Http\Middleware\PageView;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
/* /*
@ -24,15 +24,13 @@
*/ */
// Run the PageView middleware for *all* public GET routes // Run the PageView middleware for *all* public GET routes
Route::middleware(PageView::class)->group(function () {
Route::get('/', [HomeController::class, 'show']); Route::get('/', [HomeController::class, 'show']);
Route::get('/bookmarks', [BookmarksController::class, 'show']); Route::get('/bookmarks', [BookmarksController::class, 'show']);
Route::get('/blog', [BlogController::class, 'showPostList']);
Route::get('/guestbook', [GuestbookController::class, 'show']); Route::get('/guestbook', [GuestbookController::class, 'show']);
Route::get('/calculators', [CalculatorsController::class, 'show']); Route::get('/calculators', [CalculatorsController::class, 'show']);
Route::get('/computers', [ComputersController::class, 'show']); Route::get('/computers', [ComputersController::class, 'show']);
Route::get('/music', [MusicController::class, 'show']); Route::get('/music', [MusicController::class, 'show']);
});
Route::post('/guestbook', [GuestbookController::class, 'addEntry']) Route::post('/guestbook', [GuestbookController::class, 'addEntry'])
->middleware('rate_limit'); ->middleware('rate_limit');