78% google-analytics-for-wordpress

Code Review | MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)

WordPress plugin MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy) scored78%from 54 tests.

About plugin

  • Plugin page: google-analytics-...
  • Plugin version: 8.22.0
  • PHP compatiblity: 7.2+
  • PHP version: 7.4.16
  • WordPress compatibility: 5.6.0-6.4.1
  • WordPress version: 6.3.1
  • First release: Sep 14, 2007
  • Latest release: Nov 29, 2023
  • Number of updates: 521
  • Update frequency: every 11.4 days
  • Top authors: chriscct7 (41.84%)joostdevalk (41.65%)manejaam (5.95%)gripgrip (4.8%)omarreiss (2.69%)

Code review

54 tests

User reviews

2730 reviews

Install metrics

3,000,000+ active /170,244,231 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Verifying that this plugin installs correctly without errors
The plugin installed gracefully, with no errors

Server metrics [RAM: ▲0.48MB] [CPU: ▲1.37ms] Passed 4 tests

An overview of server-side resources used by MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)
This plugin has minimal impact on server resources
Page Memory (MB) CPU Time (ms)
Home / 3.69 ▲0.23 39.75 ▼4.51
Dashboard /wp-admin 3.91 ▲0.56 60.30 ▼2.14
Posts /wp-admin/edit.php 3.95 ▲0.59 57.18 ▲4.08
Add New Post /wp-admin/post-new.php 6.49 ▲0.61 107.52 ▲23.16
Media Library /wp-admin/upload.php 3.76 ▲0.53 44.08 ▲8.04
Welcome to MonsterInsights /wp-admin/index.php?page=monsterinsights-getting-started 3.78 46.09
Settings /wp-admin/admin.php?page=monsterinsights_settings 3.77 46.05
Reports /wp-admin/admin.php?page=monsterinsights_reports 3.77 46.64

Server storage [IO: ▲16.90MB] [DB: ▲0.01MB] Passed 3 tests

Analyzing filesystem and database footprints of this plugin
There were no storage issued detected upon installing this plugin
Filesystem: 445 new files
Database: no new tables, 13 new options
New WordPress options
widget_theysaidso_widget
monsterinsights_settings
monsterinsights_sitenotes_installed
can_compress_scripts
widget_recent-posts
widget_recent-comments
monsterinsights_current_version
monsterinsights_review
monsterinsights_usage_tracking_config
theysaidso_admin_options
...

Browser metrics Passed 4 tests

A check of browser resources used by MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)
Normal browser usage
Page Nodes Memory (MB) Script (ms) Layout (ms)
Home / 3,128 ▲381 18.53 ▲4.20 26.12 ▲24.49 31.32 ▼12.30
Dashboard /wp-admin 2,410 ▲249 8.54 ▲2.98 162.66 ▲61.02 56.70 ▲11.92
Posts /wp-admin/edit.php 2,271 ▲171 3.55 ▲1.59 71.42 ▲33.65 41.41 ▲8.61
Add New Post /wp-admin/post-new.php 1,614 ▲88 19.04 ▼4.00 664.73 ▲22.90 67.70 ▲7.62
Media Library /wp-admin/upload.php 1,568 ▲165 6.04 ▲1.74 125.41 ▲27.61 50.53 ▲8.62
Setup Checklist15 /wp-admin/admin.php?page=monsterinsights_settings#/setup-checklist 1,621 7.71 187.56 154.11
Welcome to MonsterInsights /wp-admin/index.php?page=monsterinsights-getting-started 1,491 6.52 131.20 81.42
User Journey /wp-admin/admin.php?page=monsterinsights_reports#/user-journey-report 1,439 15.15 456.00 76.23
Settings /wp-admin/admin.php?page=monsterinsights_settings 1,581 7.72 175.03 79.13
Reports /wp-admin/admin.php?page=monsterinsights_reports 1,434 16.38 520.72 106.56

Uninstaller [IO: ▲0.00MB] [DB: ▲0.01MB] 75% from 4 tests

🔸 Tests weight: 35 | The uninstall procedure must remove all plugin files and extra database tables
Please fix the following items
  • This plugin did not uninstall successfully, leaving 10 options in the database
    • monsterinsights_current_version
    • theysaidso_admin_options
    • db_upgraded
    • widget_theysaidso_widget
    • widget_monsterinsights-popular-posts-widget
    • widget_recent-posts
    • widget_recent-comments
    • can_compress_scripts
    • monsterinsights_sitenotes_installed
    • monsterinsights_settings

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the server (in the Apache logs)
Good news, no errors were detected

SRP 0% from 2 tests

🔹 Tests weight: 20 | It is important to ensure that your PHP files perform no action when accessed directly, respecting the single-responsibility principle
Almost there! Just fix the following items
  • 7× GET requests to PHP files return non-empty strings:
    • > /wp-content/plugins/google-analytics-for-wordpress/includes/gutenberg/headline-tool/phpinsight/lib/PHPInsight/data/data.ign.php
    • > /wp-content/plugins/google-analytics-for-wordpress/includes/gutenberg/headline-tool/phpinsight/lib/PHPInsight/data/data.prefix.php
    • > /wp-content/plugins/google-analytics-for-wordpress/includes/gutenberg/headline-tool/phpinsight/examples/demo.php
    • > /wp-content/plugins/google-analytics-for-wordpress/includes/emails/templates/body-default-plain.php
    • > /wp-content/plugins/google-analytics-for-wordpress/includes/gutenberg/headline-tool/phpinsight/lib/PHPInsight/data/data.neg.php
    • > /wp-content/plugins/google-analytics-for-wordpress/includes/gutenberg/headline-tool/phpinsight/lib/PHPInsight/data/data.neu.php
    • > /wp-content/plugins/google-analytics-for-wordpress/includes/gutenberg/headline-tool/phpinsight/lib/PHPInsight/data/data.pos.php
  • 65× GET requests to PHP files have triggered server-side errors or warnings (only 10 are shown):
    • > PHP Warning
      require_once(ABSPATHwp-admin/includes/class-wp-upgrader.php): failed to open stream: No such file or directory in wp-content/plugins/google-analytics-for-wordpress/includes/admin/licensing/plugin-upgrader-legacy.php on line 4
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/google-analytics-for-wordpress/lite/includes/admin/connect.php:28
    • > PHP Warning
      Use of undefined constant MONSTERINSIGHTS_PLUGIN_DIR - assumed 'MONSTERINSIGHTS_PLUGIN_DIR' (this will throw an Error in a future version of PHP) in wp-content/plugins/google-analytics-for-wordpress/includes/admin/site-notes/Controller.php on line 29
    • > PHP Warning
      Use of undefined constant ABSPATH - assumed 'ABSPATH' (this will throw an Error in a future version of PHP) in wp-content/plugins/google-analytics-for-wordpress/includes/admin/licensing/plugin-upgrader.php on line 4
    • > PHP Warning
      require_once(MONSTERINSIGHTS_PLUGIN_DIRincludes/admin/site-notes/Database.php): failed to open stream: No such file or directory in wp-content/plugins/google-analytics-for-wordpress/includes/admin/site-notes/Controller.php on line 29
    • > PHP Fatal error
      require_once(): Failed opening required 'ABSPATHwp-admin/includes/class-wp-upgrader.php' (include_path='.:/usr/share/php') in wp-content/plugins/google-analytics-for-wordpress/includes/admin/licensing/plugin-upgrader.php on line 4
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/google-analytics-for-wordpress/includes/admin/sharedcount.php:58
    • > PHP Fatal error
      Uncaught Error: Class 'MonsterInsights_Notification_Event' not found in wp-content/plugins/google-analytics-for-wordpress/includes/admin/notifications/notification-audience.php:9
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/google-analytics-for-wordpress/lite/includes/admin/user-journey/init.php:82
    • > PHP Fatal error
      Uncaught Error: Class 'MonsterInsights_Notification_Event' not found in wp-content/plugins/google-analytics-for-wordpress/includes/admin/notifications/notification-traffic-dropping.php:9

User-side errors Passed 1 test

🔹 Test weight: 20 | Just a short smoke test targeting errors on the browser (console and network errors and warnings)
Everything seems fine on the user side

Optimizations

Plugin configuration 93% from 29 tests

readme.txt 94% from 16 tests

The readme.txt file describes your plugin functionality and requirements and it is parsed to prepare the your plugin's listing
Attributes that need to be fixed:
  • Tags: There are too many tags (19 tag instead of maximum 10)
The official readme.txt is a good inspiration

google-analytics-for-wordpress/googleanalytics.php 92% from 13 tests

This is the main PHP file of "MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)" version 8.22.0, providing information about the plugin in the header fields and serving as the principal entry point to the plugin's functions
It is important to fix the following:
  • Main file name: Even though not officially enforced, the main plugin file should be the same as the plugin slug ("google-analytics-for-wordpress.php" instead of "googleanalytics.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | A short glimpse at programming languages used with this plugin and a check that no dangerous files are present
Everything looks great! No dangerous files found in this plugin35,228 lines of code in 259 files:
Language Files Blank lines Comment lines Lines of code
PHP 145 6,262 21,215 31,871
JavaScript 25 207 293 1,551
CSS 26 222 24 1,214
SVG 60 13 0 547
JSON 1 1 0 26
Markdown 2 8 0 19

PHP code Passed 2 tests

This plugin's cyclomatic complexity and code structure detailed below
This plugin has no cyclomatic complexity issues
Cyclomatic complexity
Average complexity per logical line of code 0.47
Average class complexity 23.02
▷ Minimum class complexity 1.00
▷ Maximum class complexity 195.00
Average method complexity 4.10
▷ Minimum method complexity 1.00
▷ Maximum method complexity 44.00
Code structure
Namespaces 2
Interfaces 0
Traits 0
Classes 97
▷ Abstract classes 1 1.03%
▷ Concrete classes 96 98.97%
▷ Final classes 39 40.62%
Methods 689
▷ Static methods 25 3.63%
▷ Public methods 609 88.39%
▷ Protected methods 33 4.79%
▷ Private methods 47 6.82%
Functions 192
▷ Named functions 187 97.40%
▷ Anonymous functions 5 2.60%
Constants 23
▷ Global constants 20 86.96%
▷ Class constants 3 13.04%
▷ Public constants 3 100.00%

Plugin size 50% from 2 tests

Image compression 50% from 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
115 PNG files occupy 1.52MB with 0.55MB in potential savings
Potential savings
Compression of 5 random PNG files using pngquant
File Size - original Size - compressed Savings
lite/assets/img/emails/summaries/[email protected] 1.70KB 0.88KB ▼ 48.48%
lite/assets/img/emails/summaries/icon-button-arrow.png 0.21KB 0.21KB 0.00%
lite/assets/img/emails/summaries/[email protected] 8.72KB 4.06KB ▼ 53.38%
lite/assets/vue/img/[email protected] 7.83KB 7.84KB 0.00%
assets/images/up.png 1.03KB 0.21KB ▼ 79.54%