This repository contains a proprietary Statamic addon that shows GA4 analytics inside the Statamic Control Panel. When making changes, optimize for reliability, compatibility with Statamic 5 and 6, and predictable CP UX.
- Backend: PHP 8.2+, Laravel/Statamic addon
- Analytics provider:
spatie/laravel-analytics:^5 - Frontend: Vue + Vite + Statamic CP UI components
- Styling/tooling: Tailwind CSS, ESLint, Prettier, Laravel Pint
src/ServiceProvider.php: addon bootstrapping, settings blueprint, CP routes, navigationsrc/Controllers/AnalyticsController.php: CP page + JSON endpoint (isapp-analytics/{chart?})src/Analytics/Analytics.php: custom analytics fetch methods (extends Spatie analytics service)src/Widgets/GoogleAnalytics.php: dashboard widget integrationresources/js/components/IsappAnalytics.vue: main CP analytics view, dynamic widget loadingresources/js/components/widgets/*.vue: individual analytics widgetsresources/views/*.blade.php: CP blade viewsresources/lang/en/cp.php: UI translations
- Install PHP deps:
composer install - Install JS deps:
yarn install - Run tests:
composer test - Run PHP lint/style:
composer lint - Run JS lint:
yarn lint(6.x only) - Build assets:
yarn build - Dev assets:
yarn dev
- Choose branch first and keep changes branch-compatible.
5.xbaseline:statamic/cms:^5.0,orchestra/testbench:^9.0.- Frontend: Vue 2.7 +
@vitejs/plugin-vue2+chart.js/vue-chartjs. - Settings flow uses
src/Controllers/ConfigController.php+resources/settings.yaml+resources/views/settings.blade.php. - Main analytics page component:
resources/js/components/GoogleAnalytics.vue. - CP routes include
isapp-ga.config.indexandisapp-ga.config.update.
6.xbaseline:statamic/cms:^6.0,orchestra/testbench:^10.0.- Frontend: Vue 3 + ApexCharts + ESLint/Prettier.
- Settings flow uses
registerSettingsBlueprint()insrc/ServiceProvider.php(noConfigController/settings.yaml). - Main analytics page component:
resources/js/components/IsappAnalytics.vue. - CP routes are analytics-focused (
isapp-ga.analytics.index,isapp-ga.chart) without separate config controller routes.
- Widget implementation expectations by branch:
5.x: updatesrc/Analytics/Analytics.php,resources/settings.yaml,resources/js/components/GoogleAnalytics.vue(or related widgets), translations.6.x: updatesrc/Analytics/Analytics.php, settings blueprint insrc/ServiceProvider.php,resources/js/components/IsappAnalytics.vue+resources/js/components/widgets/*.vue, translations.
- Do not backport 6.x-only frontend patterns into 5.x (Vue 3 APIs, ApexCharts,
@statamic/cms/uidate picker). - Do not introduce 5.x legacy patterns into 6.x (Vue 2 component API,
vue-chartjs/legacy,settings.yamlconfig flow).
- Preserve license/copyright headers in source files.
- Keep
declare(strict_types=1);in PHP files. - Follow existing namespace root:
Isapp\\GoogleAnalytics\\. - Do not commit secrets or credentials JSON paths/contents.
- Keep API method naming contract:
- Frontend calls
/{chart}. - Backend resolves to
fetch{chart}insrc/Analytics/Analytics.php.
- Frontend calls
- For new widgets, update both backend and frontend:
- Add/extend fetch method in
src/Analytics/Analytics.php. - Add widget option in settings blueprint (
src/ServiceProvider.php). - Add Vue widget component in
resources/js/components/widgets/. - Ensure widget is rendered by
IsappAnalytics.vuedynamic loading pattern. - Add/adjust translation strings in
resources/lang/en/cp.php.
- Add/extend fetch method in
- Run (6.x):
composer test,composer lint,yarn lint,yarn format,yarn build. - Run (5.x):
composer test,composer lint,yarn build. - Verify no regressions in route names:
isapp-ga.analytics.indexisapp-ga.chart
- On
5.x, also verify config routes:isapp-ga.config.indexisapp-ga.config.update
- Confirm date range and
property_idhandling still validate correctly in controller. - Confirm UI still works when widget list is empty or partially configured.
- Do not push unless explicitly requested.
- Before commit, review scope with
git statusandgit diff --stat. - Keep commits atomic: one logical change per commit when possible.
- Cross-branch cherry-pick rule:
- If changes touch any of the files below, create a dedicated commit that contains only cross-branch-safe changes for these files.
- Target files:
.gitattributesCLAUDE.mdsrc/Analytics/Analytics.phpsrc/Controllers/AnalyticsController.phpsrc/Widgets/GoogleAnalytics.phpsrc/Concerns/HasView.php.gitignoreLICENSE.mdREADME.mdWIDGETS.mdphpunit.xmlpint.json
- Do not mix these changes with branch-specific frontend/config refactors in the same commit.
- Cherry-pick PR workflow for shared files:
- Use this workflow when merged shared-file changes must be mirrored between
5.xand6.x. - Keep source commit isolated to shared files only.
- Create branch from destination base:
git checkout <destination-branch>git checkout -b chore/cherry-pick-<short-sha>
- Apply source commit with provenance:
git cherry-pick -x <source-sha>
- Open dedicated PR to destination base branch.
- PR title:
chore: cherry-pick <short-sha> from <source-branch>
- PR body must include:
- Source commit SHA.
- Source PR link.
- Exact list of changed files.
- Validation note: no branch-specific behavior introduced.
- Use this workflow when merged shared-file changes must be mirrored between
- Commit message format:
- Subject line:
<type>: <short summary> - Empty line after subject.
- Body: bullet list of concrete changes (
- ...). - Types:
feat,fix,refactor,docs,test,chore. - Example:
fix: validate GA property id in analytics endpoint- ``
- validate property_id as integer-like value- keep existing chart endpoint contract unchanged
- Subject line:
- Prefer imperative subject line, <= 72 chars.
- If behavior changed, include tests or explain gap in PR description.
- Before opening PR, run:
composer test,composer lint,yarn lint,yarn format,yarn build. - PR description should include:
- What changed.
- Why it changed.
- How it was validated.
- Any manual QA steps for Statamic CP widgets/pages.