abr4xas/clarity-laravel
A lightweight Laravel integration for Microsoft Clarity. Configure your Clarity project ID and the package injects the tracking script, with a Blade directive available, so you can add session recordings, heatmaps, and user behavior analytics with minimal setup and no manual snippets.
clarity-laravel is a thin integration package that wires Microsoft Clarity (session replay, heatmaps, analytics) into a Laravel application — historically by injecting the Clarity JS snippet and exposing a small artisan surface (ClarityCommand) plus publishable config. It is a convenience wrapper, not infrastructure: it sits at the edge of the request lifecycle and has no persistence, queue, or domain-model footprint. That makes it architecturally cheap to adopt and equally cheap to replace with a hand-rolled Blade partial if it ever becomes a liability.
v3.0.0 is a major version with a refactor that is not described in the release notes. Two things matter:
ClarityCommand refactor — command class names, signatures, options, or output contracts may have changed. Anything that shells out to this command in CI, deploy scripts, or scheduler entries must be re-verified.ob_* output buffering, streaming responses, and Laravel Octane's long-lived workers, and it may change config keys.orchestra/testbench ^10.8 → ^11 plus "Laravel 13 maintenance" signals a minimum-version floor raise. Applications on Laravel 10/11 are likely out of support in v3; there is no documented upgrade guide in the notes.The remaining entries are Dependabot bumps to GitHub Actions (actions/checkout, dependabot/fetch-metadata). These are CI-only and carry no runtime or consumer-facing risk — they should not drive the adoption decision, though checkout 6→7 hints the project's own CI runner assumptions moved.
Technical risk is moderate and concentrated in one place: a major bump with a behavior-changing refactor and no changelog detail. The blast radius is small (a script tag and a command), so the risk is recoverable, not architectural.
Key questions before committing:
StreamedResponse and early-terminated requests?v2 → v3 upgrade path?ClarityCommand's signature, name, or exit codes change? Who calls it today?Stack fit: Good for Blade/server-rendered Laravel apps that already want Clarity and don't want to hand-maintain the snippet. Poor fit for API-only services, SPA front ends served outside Laravel, or teams with a strict third-party-script/CSP posture who will end up wrapping it in their own consent layer anyway.
Migration path: Treat v3 as unproven until validated. Pin ^2 in composer.json on the main branch, and stand up v3 on a short-lived branch. Because the package is edge-of-lifecycle, the migration is a verification exercise, not a rewrite: diff the published config, diff the rendered HTML before/after, and run the command in a scratch environment. If the buffering change only affects emit timing and the config surface is unchanged, the upgrade is a same-day change; if keys moved, it's a config-and-env audit across every environment.
Compatibility: Confirm the Laravel floor against your estate first. If any production app is below the v3 floor, this becomes a per-app staggered upgrade rather than a fleet-wide bump — plan for version skew across services and document which apps are on which major.
Sequencing:
ClarityCommand from CI/cron, which gate Clarity by env or consent.^2 pin.Maintenance: Very low steady-state cost — one config file and a composer constraint. The real cost is release review: this package ships frequently via Dependabot, so someone must triage majors. Budget a recurring 15-minute monthly check rather than a project.
Support: Single-maintainer, small-community project. Assume no vendor SLA. The mitigation is cheap: the integration is small enough to vendor or inline the snippet in under a day if the package stalls or a Laravel major breaks it. Do not let it become load-bearing for anything beyond script injection.
Scaling: Negligible — no runtime overhead beyond response emission, no per-request external calls (assuming buffering stays client-side; confirm). Watch only for interaction with response buffering under high concurrency and with streaming endpoints.
Failure modes:
config:cache) with a missing/blank project ID, or the service provider not registered — Clarity simply doesn't load and nobody notices. Add a smoke assertion on rendered HTML in staging.ClarityCommand refactor breaks CI/cron silently if exit codes changed.Ramp-up: A Laravel developer can own this in half a day, including reading the source. The onboarding risk is not skill — it's the undocumented v3 behavior change, which is exactly what the key questions above need to close out.
How can I help you explore Laravel packages today?