Skip to content

543 remove analytics#426

Merged
tijsverkoyen merged 2 commits intomasterfrom
543-remove-analytics
Feb 13, 2026
Merged

543 remove analytics#426
tijsverkoyen merged 2 commits intomasterfrom
543-remove-analytics

Conversation

@tijsverkoyen
Copy link
Member

@tijsverkoyen tijsverkoyen commented Feb 11, 2026

Summary by Sourcery

Remove the deprecated Analytics backend module and its integration across the application.

Bug Fixes:

  • Adjust locale XML import to correctly read item and translation attributes when importing backend locale.

Enhancements:

  • Clean up database seed data, navigation entries, permissions, and locale strings related to the removed Analytics module.
  • Simplify settings by dropping the fallback to the removed Analytics web property ID for the Google Analytics tracking ID.
  • Remove unused Analytics JavaScript and resize hooks from the backend assets bundle.

Build:

  • Exclude the removed Analytics JavaScript from the frontend build configuration.

Tests:

  • Delete Analytics module PHPUnit tests and related fixtures now that the module is removed.

Chores:

  • Delete all remaining Analytics module source files, templates, widgets, and service configuration.

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 11, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Removes the legacy Analytics backend module and all associated schema, navigation, locale, JS hooks, settings defaults, and tests, while also slightly adjusting the locale XML import logic to be compatible without the module’s locale definitions.

Sequence diagram for window resize without Analytics chart initialization

sequenceDiagram
  actor Admin as AdminUser
  participant BrowserWindow
  participant jsBackend
  participant Navigation as jsBackend_navigation

  Admin->>BrowserWindow: Resize window
  BrowserWindow->>jsBackend: window.resize event
  jsBackend->>jsBackend: resizeFunctions.calculate
  jsBackend->>Navigation: navigation.resize()
  Note over jsBackend: Analytics chart initialization call removed
Loading

Class diagram for removed Analytics backend module

classDiagram
  direction LR

  class AnalyticsConfig {
  }

  class AnalyticsInstaller {
  }

  class AnalyticsExtension {
  }

  class DateRange {
  }

  class SettingsType {
  }

  class SettingsStepTypeInterface {
  }

  class SettingsStepAccountTypeInterface {
  }

  class SettingsStepAuthConfigFileTypeInterface {
  }

  class SettingsStepProfileTypeInterface {
  }

  class SettingsStepWebPropertyTypeInterface {
  }

  class ClientFactory {
  }

  class Connector {
  }

  class AnalyticsActionsIndex {
  }

  class AnalyticsActionsReset {
  }

  class AnalyticsActionsSettings {
  }

  class RecentVisits {
  }

  class TraficSources {
  }

  class AnalyticsWidgetRecentVisits {
  }

  class AnalyticsWidgetTraficSources {
  }

  class AnalyticsModuleInfo {
  }

  AnalyticsInstaller --> AnalyticsConfig
  AnalyticsInstaller --> AnalyticsExtension
  AnalyticsInstaller --> SettingsType
  AnalyticsInstaller --> DateRange

  SettingsType ..> SettingsStepTypeInterface
  SettingsType ..> SettingsStepAccountTypeInterface
  SettingsType ..> SettingsStepAuthConfigFileTypeInterface
  SettingsType ..> SettingsStepProfileTypeInterface
  SettingsType ..> SettingsStepWebPropertyTypeInterface

  ClientFactory --> Connector
  Connector --> DateRange

  AnalyticsActionsIndex --> SettingsType
  AnalyticsActionsIndex --> DateRange
  AnalyticsActionsSettings --> SettingsType
  AnalyticsActionsReset --> SettingsType

  RecentVisits --> Connector
  TraficSources --> Connector

  AnalyticsWidgetRecentVisits <|-- RecentVisits
  AnalyticsWidgetTraficSources <|-- TraficSources

  AnalyticsModuleInfo --> AnalyticsConfig
  AnalyticsModuleInfo --> AnalyticsInstaller
Loading

File-Level Changes

Change Details Files
Remove analytics-related database schema, navigation entries, ACL actions, module registration, and locale seed data from the test DB dump.
  • Delete creation of analytics_* tables from the SQL seed data.
  • Remove Analytics-related backend_navigation entries and their child items from the seed data.
  • Remove Analytics backend_action rights from the rights seed data.
  • Remove Analytics module registration from the modules seed data.
  • Drop Analytics-related backend locale rows including labels, errors, and messages from the seed data.
tests/data/test_db.sql
Drop Analytics labels from the installer locale XML so the installer no longer imports Analytics-specific translations.
  • Remove the block and its translations in multiple languages from the locale installer data.
src/Backend/Core/Installer/Data/locale.xml
Remove frontend JavaScript hooks that attempted to initialize Analytics charts on navigation resize.
  • Stop calling jsBackend.analytics.* chart initializers inside the resize handler, leaving only the navigation resize call.
src/Backend/Core/Js/backend.js
Fix locale XML import logic to work with updated SimpleXML attributes handling.
  • Wrap calls to $item->attributes() and $translation->attributes() in current() so that attribute access works correctly as an array, avoiding reliance on the Analytics module’s locale structure.
src/Backend/Modules/Locale/Engine/Model.php
Decouple settings page from removed Analytics module and clear default fallback for Google Analytics tracking ID.
  • Stop reading the google_tracking_google_analytics_tracking_id default from the Analytics module’s settings and instead default to an empty string.
src/Backend/Modules/Settings/Actions/Index.php
Remove inclusion of Analytics JavaScript from the backend JS build configuration.
  • Delete the Analytics.js module path from the package.json backend JS build list.
package.json
Remove the Analytics backend module implementation, configuration, resources, and tests.
  • Delete all Analytics backend actions (Index, Reset, Settings).
  • Delete Analytics module configuration, DI extension, date range and form classes, Google client integration, installer and locale, JS, templates, widgets, and service configuration.
  • Delete Analytics module PHPUnit tests and info.xml metadata.
src/Backend/Modules/Analytics/Actions/Index.php
src/Backend/Modules/Analytics/Actions/Reset.php
src/Backend/Modules/Analytics/Actions/Settings.php
src/Backend/Modules/Analytics/Config.php
src/Backend/Modules/Analytics/DateRange/DateRange.php
src/Backend/Modules/Analytics/DependencyInjection/AnalyticsExtension.php
src/Backend/Modules/Analytics/Form/DateRangeType.php
src/Backend/Modules/Analytics/Form/SettingsStepAccountTypeInterface.php
src/Backend/Modules/Analytics/Form/SettingsStepAuthConfigFileTypeInterface.php
src/Backend/Modules/Analytics/Form/SettingsStepProfileTypeInterface.php
src/Backend/Modules/Analytics/Form/SettingsStepTypeInterface.php
src/Backend/Modules/Analytics/Form/SettingsStepWebPropertyTypeInterface.php
src/Backend/Modules/Analytics/Form/SettingsType.php
src/Backend/Modules/Analytics/GoogleClient/ClientFactory.php
src/Backend/Modules/Analytics/GoogleClient/Connector.php
src/Backend/Modules/Analytics/Installer/Data/locale.xml
src/Backend/Modules/Analytics/Installer/Installer.php
src/Backend/Modules/Analytics/Js/Analytics.js
src/Backend/Modules/Analytics/Layout/Templates/Index.html.twig
src/Backend/Modules/Analytics/Layout/Templates/Settings.html.twig
src/Backend/Modules/Analytics/Layout/Widgets/RecentVisits.html.twig
src/Backend/Modules/Analytics/Layout/Widgets/TraficSources.html.twig
src/Backend/Modules/Analytics/Resources/config/services.yml
src/Backend/Modules/Analytics/Tests/Actions/IndexTest.php
src/Backend/Modules/Analytics/Tests/Actions/ResetTest.php
src/Backend/Modules/Analytics/Tests/Actions/SettingsTest.php
src/Backend/Modules/Analytics/Tests/GoogleClient/ConnectorTest.php
src/Backend/Modules/Analytics/Widgets/RecentVisits.php
src/Backend/Modules/Analytics/Widgets/TraficSources.php
src/Backend/Modules/Analytics/info.xml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • The changes in Backend/Modules/Locale/Engine/Model.php from $item->attributes() / $translation->attributes() to current($item->attributes()) / current($translation->attributes()) look unrelated to removing Analytics and may break attribute access (you’re now taking the first attribute value rather than the attribute collection); consider reverting or moving this into a separate, well‑justified change.
  • In Backend/Modules/Settings/Actions/Index.php you removed the fallback to the old Analytics setting for google_tracking_google_analytics_tracking_id; if existing installations relied on that stored value, consider adding an explicit migration or a one‑time copy so users don’t silently lose their configured tracking ID.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The changes in `Backend/Modules/Locale/Engine/Model.php` from `$item->attributes()` / `$translation->attributes()` to `current($item->attributes())` / `current($translation->attributes())` look unrelated to removing Analytics and may break attribute access (you’re now taking the first attribute value rather than the attribute collection); consider reverting or moving this into a separate, well‑justified change.
- In `Backend/Modules/Settings/Actions/Index.php` you removed the fallback to the old `Analytics` setting for `google_tracking_google_analytics_tracking_id`; if existing installations relied on that stored value, consider adding an explicit migration or a one‑time copy so users don’t silently lose their configured tracking ID.

## Individual Comments

### Comment 1
<location> `src/Backend/Modules/Locale/Engine/Model.php:479-482` </location>
<code_context>
                 foreach ($items as $item) {
                     // attributes
-                    $attributes = $item->attributes();
+                    $attributes = current($item->attributes());
                     $type = in_array($attributes['type'], $possibleTypes, true) ? $attributes['type'] : '';
                     $name = s($attributes['name'] ?? '')->title()->toString();
</code_context>

<issue_to_address>
**issue (bug_risk):** Using current() on SimpleXMLElement attributes likely breaks attribute access.

Wrapping `attributes()` in `current()` changes `$attributes` from the attribute collection to a single attribute node. On a single-attribute `SimpleXMLElement`, `$attributes['type']` then looks for a child element named `type` (which doesn’t exist) instead of the `type` attribute, so `$type`, `$name`, and `$language` will end up empty and imports will be skipped. You likely want to keep `$attributes = $item->attributes();` / `$translation->attributes();` or, if you need a normalized structure, cast to an array: `$attributes = (array) $item->attributes();`.
</issue_to_address>

### Comment 2
<location> `src/Backend/Modules/Settings/Actions/Index.php:70` </location>
<code_context>
             'Core',
             'google_tracking_google_analytics_tracking_id',
-            $this->get('fork.settings')->get('Analytics', 'web_property_id', '')
+            ''
         );
         $this->form->addCheckbox(
</code_context>

<issue_to_address>
**question (bug_risk):** Dropping the fallback from the old Analytics setting may affect existing installations.

The old default pulled `google_tracking_google_analytics_tracking_id` from `Analytics:web_property_id`, which ensured a transparent migration. With the default now set to `''`, existing sites that only configured the old module will lose their tracking ID after upgrade unless a separate migration exists. If that’s undesirable, either retain the fallback for one release or add an explicit upgrade step to copy the old setting into the new key.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@tijsverkoyen tijsverkoyen merged commit 905eb30 into master Feb 13, 2026
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants