jeffersongoncalves/laravel-hotjar
Integrates Hotjar tracking into Laravel applications, letting you inject the Hotjar snippet and configure your site ID from a single config file. Simple to install and works with any Blade or Livewire app.
Architecture fit. The package is a Laravel-side script emitter: it injects <script> tags into rendered responses (widgets, embeds, analytics, or third-party integrations). That places it squarely in the presentation layer, typically registered through a service provider and hooked into Blade rendering or middleware. Fit is good for teams already on a standard Laravel request lifecycle; there is no new infrastructure to run.
Integration feasibility. Release 1.1.0 adds retrieval of Laravel's Vite CSP nonce and applies it to every <script> the package emits. This is a small, additive change: it requires no new configuration, no new dependency, and no schema work. It composes with laravel-security-headers or any app that calls Vite::useCspNonce(). Integration effort is effectively zero for apps that already set a nonce, and a non-event for apps that do not.
Technical risk. Low. The material risk is not the nonce logic itself but the coupling it implies: the package now reads shared state (Vite::cspNonce()) at render time, so correctness depends on nonce generation happening before the package renders. If the package emits scripts from a middleware that runs ahead of the nonce-setting middleware, the nonce will be null and the browser will silently block the script — a failure mode that is invisible server-side and only appears as a CSP violation in the browser console. Second-order risk: nonce reuse across responses would weaken the policy; that is Laravel's responsibility, not the package's, but it is worth confirming.
Key questions.
Vite::useCspNonce() in the stack?eval-style constructs used anywhere, which a strict script-src would still block regardless of nonce?src attributes to same-origin/allowlisted hosts, or can it emit arbitrary third-party origins?strict-dynamic policies?Stack fit. Assumes Laravel 10+ with the default Vite integration. No incompatibility with Blade, Livewire, or Inertia — the emitted tag is origin-agnostic as long as rendering happens through Laravel's response pipeline. Apps that render HTML outside Laravel (separate Node SSR service, static prebuild) will not get nonces on those paths.
Migration path. Purely additive. 1.0.x → 1.1.0 requires no code changes; behavior is unchanged for apps without a nonce. For apps currently relying on 'unsafe-inline' in script-src, this release is the enabler for tightening the policy — but the policy change should be a separate, deliberate step, not bundled with the package upgrade.
Compatibility. Verify the Laravel version floor: Vite::useCspNonce() and Vite::cspNonce() availability has shifted across minor versions, and the package may now implicitly require a newer framework than it declares. Also check compatibility with laravel-security-headers and any CSP middleware that rewrites headers after the response is built — ordering matters.
Sequencing.
'unsafe-inline'.Maintenance. Minimal ongoing cost — this is a passive, dependency-free feature. The real maintenance surface is the CSP policy itself and the coordination between the package, Vite, and whichever header middleware is in use. Pin the package version and review release notes for future changes to nonce handling, since that code path is now security-relevant.
Support. Support burden shifts toward the platform/security team rather than application developers. Expect questions of the form "the widget doesn't load in staging," whose answer is almost always a CSP or nonce-ordering issue. Document the nonce dependency in the runbook.
Scaling. No scaling implications — nonce retrieval is an in-memory read. Caution: if responses are cached at the CDN or via Laravel's response cache, a cached page will carry a stale nonce that no longer matches the per-response header. Any full-page caching layer must either bypass nonce-bearing routes or strip/reinject nonces at the edge. This is the most likely operational surprise.
Failure modes.
'unsafe-inline' cannot actually be removed yet.script-src still needs those hosts allowlisted.Ramp-up. Near-zero for developers — no new API to learn. The learning curve sits with whoever owns the CSP configuration: they need to understand nonce generation, middleware ordering, and caching interaction. Budget a short enablement session with the security/platform owner, and instrument CSP violation reporting before enforcing.
How can I help you explore Laravel packages today?