carloeusebi/laravel-rybbit-tunnel

Provides endpoints to use as reverse-proxy for Rybbit analytics tool

Maintainers

Package info

github.com/carloeusebi/laravel-rybbit-tunnel

pkg:composer/carloeusebi/laravel-rybbit-tunnel

Statistics

Installs: 436

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v0.4.2 2026-03-30 13:34 UTC

This package is auto-updated.

Last update: 2026-04-14 14:15:06 UTC


README

A Laravel package that acts as a reverse proxy for Rybbit analytics. Routes analytics traffic through your own domain to avoid ad blockers and improve data accuracy.

Requirements

  • PHP 8.2+
  • Laravel 12 or 13

Installation

composer require carloeusebi/laravel-rybbit-tunnel

The service provider is auto-discovered. Publish the config file if you need to customise it:

php artisan vendor:publish --tag=rybbit-tunnel-config

Configuration

Add to your .env:

RYBBIT_TUNNEL_HOST=https://app.rybbit.io   # your Rybbit instance URL
RYBBIT_TUNNEL_URL=/analytics                # local route prefix
RYBBIT_TUNNEL_DEBUG=false                   # enable verbose request logging

Full config (config/rybbit-tunnel.php):

return [
    'host'             => env('RYBBIT_TUNNEL_HOST', 'https://app.rybbit.io'),
    'tunnel-url'       => env('RYBBIT_TUNNEL_URL', '/analytics'),
    'cache-key-prefix' => 'rybbit_',
    'debug'            => env('RYBBIT_TUNNEL_DEBUG', false),
    'middleware'       => ['web'],
];

Middleware

By default the routes use the web middleware group. Override via config:

'middleware' => ['web', 'auth'],

Routes

The package registers the following routes under the configured prefix (default /analytics):

Method Path Description
GET /{script} Proxy analytics scripts (script.js, script-full.js, replay.js, metrics.js) — cached 1 hour
POST /track Proxy pageview/event tracking
POST /identify Proxy user identification
POST /session-replay/record/{siteId} Proxy session replay data — dispatched via queue
GET /site/tracking-config/{siteId} Proxy site tracking config — cached 1 hour

Usage

Point your Rybbit script tag at your tunnel URL instead of the Rybbit host directly:

<script
  src="/analytics/script.js"
  data-site-id="your-site-id"
  async
></script>

Session Replay

Session replay requests are dispatched as queued jobs (ForwardRybbitData) to avoid blocking the response. Make sure your queue worker is running:

php artisan queue:work

Caching

Script files and site tracking configs are cached for 1 hour using Laravel's default cache driver. The cache key prefix defaults to rybbit_ and is configurable.

Debugging

Set RYBBIT_TUNNEL_DEBUG=true to log incoming proxy request details (method, path, URL, headers, client IP) at the debug level. Sensitive headers (Authorization, Cookie, X-CSRF-Token) are redacted automatically.

License

MIT