modera/backend-google-analytics-bundle
A backend bundle for Modera applications that integrates Google Analytics into the admin panel, providing configuration and reporting widgets so teams can view traffic and site metrics alongside their existing management tools.
Architecture fit — a cataloging mismatch that gates everything. The package is listed as a Laravel/PHP package, but modera/backend-google-analytics-bundle is a Symfony bundle (the "-bundle" suffix, the Modera vendor namespace, and the DI/HttpKernel assumptions are all Symfony idioms). It cannot be dropped into a Laravel app via composer require and used as intended: there is no Laravel service provider, facade, config publish, or middleware. Its admin UI components also depend on Modera's backend-bundle shell, which has no Laravel counterpart. As a TPM, the first thing to kill is the assumption that "it's a PHP package, so it's a candidate." It is not a candidate for a Laravel stack; it is a reference pattern at best.
What is actually portable. The idea — emit a server-side pageview for authenticated admin routes so the team can see which back-office screens get used, rather than relying on front-end JS in an admin template — is sound and small. In Laravel that is a route-middleware filter plus a queued job, roughly 100–200 lines. That is the deliverable worth funding; the repository is not.
Integration feasibility — low as a dependency, moderate as a pattern source. Three blockers beyond the framework mismatch:
UA-* property, ga() snippet or /collect GIF). UA stopped processing standard hits in July 2023. If so, the package is functionally dead regardless of framework — it would emit hits into a void with no error surfaced.Technical risk — high. Unaudited third-party code, and if it injects JS into admin pages it is a CSP and XSS surface in the most privileged part of the application.
Key questions to resolve in a 1–2 day timeboxed spike (if we spike at all):
/collect, gtag.js, or GA4 Measurement Protocol v2 with measurement_id/api_secret?Stack fit — do not integrate; reimplement the pattern. Recommendation: do not add this dependency to a Laravel codebase. The vendor mismatch makes it non-idiomatic and the GA-version risk makes the outcome uncertain even if it were ported. Frame the decision as "build, don't buy," and document the rationale in the ticket so it doesn't get re-litigated.
Migration path — port the pattern, not the code. Sequence:
web group, filtered to authenticated admin routes, that enqueues a pageview job onto a dedicated queue. Laravel's middleware and queue abstractions replace the Symfony listener wiring entirely.POST https://www.google-analytics.com/mp/collect?measurement_id=…&api_secret=…) — a short Guzzle call, or a maintained Laravel analytics package if we prefer an off-the-shelf path. Validate the payload shape (client_id, events[].name = page_view, page_location) against GA4's debug endpoint.config/analytics.php and env vars; measurement_id and api_secret in the secret manager, never committed.Compatibility notes. GA4 differs structurally from UA: client_id must be synthesized and persisted (a hashed Laravel session ID is a reasonable proxy), custom dimensions must be pre-registered in the GA4 property or they are silently dropped, and MP hits do not accept IP addresses — geo is derived from the request's origin IP, which is a privacy consideration. If anyone expects UA-parity reporting, that reporting model no longer exists.
Sequencing and effort. (a) Timeboxed 1–2 day spike to confirm protocol and dependencies — optional, and mostly valuable as cover for a "we checked" decision record; (b) decision gate — build, don't buy; (c) build middleware + queued job behind a flag; (d) validate against GA4 DebugView; (e) privacy review before production enable. Realistic total: 3–5 engineering days, none of which depends on this repository. Success criteria: we can answer "top 20 admin routes by weekly active users, last 90 days" without asking an engineer.
Maintenance — worst case. Adopting it means the team owns a frozen, unidiomatic Symfony artifact inside a Laravel app, with no path to security patches. Vendoring or forking transfers 100% of maintenance to us for a feature we could own outright in a fraction of the surface area.
Support. No community, no documentation beyond the repo, no known production users to consult. Escalation path is "read the source." If the maintainer's GA assumptions (UA-era dimensions, event naming) are wrong, there is no one to ask.
Scaling. Pageview volume from backend routes is negligible — this is not a throughput concern. The real scaling concerns are:
Failure modes to design against:
api_secret, or renamed measurement ID returns HTTP 2xx with no body. Mitigation: route a fraction of hits to /debug/mp/collect, alert on validation errors, keep a canary counter.connect-src/script-src restrictions or an internal-only network kill client-side dispatch; server-side egress to google-analytics.com may be firewalled. Mitigation: server-side dispatch, allowlist the endpoint explicitly.Ramp-up. Low technical ramp (the replacement code is small) but a non-trivial governance ramp: legal/privacy sign-off, a CSP/egress change, and a decision on GA4-vs-self-hosted (Matomo, Plausible, or PostHog are the likely alternatives; a first-party events table plus a BI dashboard beats GA on privacy and flexibility). Budget the TPM time against those approvals, not against the coding, and treat "we adopted a 0-star Symfony bundle into a Laravel app" as the outcome to avoid.
How can I help you explore Laravel packages today?