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
PageMemory (MB)CPU Time (ms)
Home /3.69 ▲0.2339.75 ▼4.51
Dashboard /wp-admin3.91 ▲0.5660.30 ▼2.14
Posts /wp-admin/edit.php3.95 ▲0.5957.18 ▲4.08
Add New Post /wp-admin/post-new.php6.49 ▲0.61107.52 ▲23.16
Media Library /wp-admin/upload.php3.76 ▲0.5344.08 ▲8.04
Welcome to MonsterInsights /wp-admin/index.php?page=monsterinsights-getting-started3.7846.09
Settings /wp-admin/admin.php?page=monsterinsights_settings3.7746.05
Reports /wp-admin/admin.php?page=monsterinsights_reports3.7746.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
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /3,128 ▲38118.53 ▲4.2026.12 ▲24.4931.32 ▼12.30
Dashboard /wp-admin2,410 ▲2498.54 ▲2.98162.66 ▲61.0256.70 ▲11.92
Posts /wp-admin/edit.php2,271 ▲1713.55 ▲1.5971.42 ▲33.6541.41 ▲8.61
Add New Post /wp-admin/post-new.php1,614 ▲8819.04 ▼4.00664.73 ▲22.9067.70 ▲7.62
Media Library /wp-admin/upload.php1,568 ▲1656.04 ▲1.74125.41 ▲27.6150.53 ▲8.62
Setup Checklist15 /wp-admin/admin.php?page=monsterinsights_settings#/setup-checklist1,6217.71187.56154.11
Welcome to MonsterInsights /wp-admin/index.php?page=monsterinsights-getting-started1,4916.52131.2081.42
User Journey /wp-admin/admin.php?page=monsterinsights_reports#/user-journey-report1,43915.15456.0076.23
Settings /wp-admin/admin.php?page=monsterinsights_settings1,5817.72175.0379.13
Reports /wp-admin/admin.php?page=monsterinsights_reports1,43416.38520.72106.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:
LanguageFilesBlank linesComment linesLines of code
PHP1456,26221,21531,871
JavaScript252072931,551
CSS26222241,214
SVG60130547
JSON11026
Markdown28019

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 code0.47
Average class complexity23.02
▷ Minimum class complexity1.00
▷ Maximum class complexity195.00
Average method complexity4.10
▷ Minimum method complexity1.00
▷ Maximum method complexity44.00
Code structure
Namespaces2
Interfaces0
Traits0
Classes97
▷ Abstract classes11.03%
▷ Concrete classes9698.97%
▷ Final classes3940.62%
Methods689
▷ Static methods253.63%
▷ Public methods60988.39%
▷ Protected methods334.79%
▷ Private methods476.82%
Functions192
▷ Named functions18797.40%
▷ Anonymous functions52.60%
Constants23
▷ Global constants2086.96%
▷ Class constants313.04%
▷ Public constants3100.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
FileSize - originalSize - compressedSavings
lite/assets/img/emails/summaries/views@2x.png1.70KB0.88KB▼ 48.48%
lite/assets/img/emails/summaries/icon-button-arrow.png0.21KB0.21KB0.00%
lite/assets/img/emails/summaries/logo-MonsterInsights@2x.png8.72KB4.06KB▼ 53.38%
lite/assets/vue/img/bg-sitespeed@2x.png7.83KB7.84KB0.00%
assets/images/up.png1.03KB0.21KB▼ 79.54%