72% googleanalytics

Code Review | ShareThis Dashboard for Google Analytics

WordPress plugin ShareThis Dashboard for Google Analytics scored72%from 54 tests.

About plugin

  • Plugin page: googleanalytics
  • Plugin version: 3.1.7
  • PHP version: 7.4.16
  • WordPress compatibility: 5.5-6.1.1
  • WordPress version: 6.3.1
  • First release: Jun 15, 2009
  • Latest release: Feb 28, 2023
  • Number of updates: 89
  • Update frequency: every 56.3 days
  • Top authors: ShareThis (86.52%)kevin.sylvestre (14.61%)

Code review

54 tests

User reviews

138 reviews

Install metrics

100,000+ active /5,935,410 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: ▲1.24MB] [CPU: ▲11.94ms] Passed 4 tests

Analyzing server-side resources used by ShareThis Dashboard for Google Analytics
This plugin has minimal impact on server resources
PageMemory (MB)CPU Time (ms)
Home /4.70 ▲1.2357.69 ▲13.34
Dashboard /wp-admin4.56 ▲1.2561.32 ▲8.82
Posts /wp-admin/edit.php4.61 ▲1.2561.28 ▲13.51
Add New Post /wp-admin/post-new.php7.14 ▲1.25107.36 ▲12.09
Media Library /wp-admin/upload.php4.48 ▲1.2549.66 ▲15.36
Dashboard /wp-admin/admin.php?page=googleanalytics4.7368.12
Settings /wp-admin/admin.php?page=googleanalytics/settings4.8946.54

Server storage [IO: ▲12.36MB] [DB: ▲0.00MB] Passed 3 tests

Input-output and database impact of this plugin
This plugin installed successfully
Filesystem: 2,089 new files
Database: no new tables, 24 new options
New WordPress options
googleanalytics_oauth_auth_code
googleanalytics_cache_buffer
widget_recent-comments
can_compress_scripts
googleanalytics_sherethis_property_id
googleanalytics_cache_last_time_attempt
googleanalytics_web_property_id_manually_value
widget_recent-posts
theysaidso_admin_options
googleanalytics_oauth_auth_token
...

Browser metrics Passed 4 tests

A check of browser resources used by ShareThis Dashboard for Google Analytics
Minimal impact on browser resources
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,845 ▲5914.48 ▲0.1310.18 ▲7.9844.62 ▼3.15
Dashboard /wp-admin2,219 ▲455.53 ▼0.1696.48 ▼0.2438.97 ▼1.30
Posts /wp-admin/edit.php2,127 ▲272.03 ▲0.0539.85 ▲2.6337.38 ▼0.51
Add New Post /wp-admin/post-new.php1,548 ▲2023.36 ▲0.15662.93 ▼27.2759.15 ▲7.12
Media Library /wp-admin/upload.php1,430 ▲334.19 ▲0.0197.66 ▼9.0844.56 ▼2.17
Dashboard /wp-admin/admin.php?page=googleanalytics8532.16764.2050.76
Settings /wp-admin/admin.php?page=googleanalytics/settings1,1312.0529.6153.69

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

🔸 Tests weight: 35 | Verifying that this plugin uninstalls completely without leaving any traces
It is recommended to fix the following
  • This plugin does not fully uninstall, leaving 7 options in the database
    • widget_recent-comments
    • theysaidso_admin_options
    • widget_theysaidso_widget
    • widget_recent-posts
    • googleanalytics_fresh
    • can_compress_scripts
    • db_upgraded

Smoke tests 25% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | This is a short smoke test looking for server-side errors
Even though everything seems fine, this is not an exhaustive test

SRP 0% from 2 tests

🔹 Tests weight: 20 | A shallow check of the single-responsibility principle; PHP files should perform no action - including output of placeholder text - and trigger no errors when accessed directly
Please fix the following
  • 1× PHP files perform the task of outputting text when accessed with GET requests:
    • > /wp-content/plugins/googleanalytics/view/templates/demo-popup.php
  • 1225× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Protobuf\\Internal\\Message' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/google/common-protos/src/Api/Expr/V1alpha1/Type/FunctionType.php:16
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Protobuf\\Internal\\Message' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/google/cloud/AnalyticsAdmin/src/V1alpha/LinkProposalStatusDetails.php:16
    • > PHP Fatal error
      Uncaught Error: Class 'Ramsey\\Collection\\AbstractArray' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/ramsey/collection/src/GenericArray.php:22
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Protobuf\\Internal\\Message' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/google/protobuf/src/Google/Protobuf/Field.php:16
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Protobuf\\Internal\\Message' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/google/protobuf/src/Google/Protobuf/Internal/FieldDescriptorProto.php:18
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Protobuf\\Internal\\Message' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/google/cloud/AnalyticsAdmin/src/V1alpha/ChangeHistoryChange/ChangeHistoryResource.php:17
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Protobuf\\Internal\\Message' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/google/grpc-gcp/src/generated/Grpc/Gcp/MethodConfig.php:12
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Collection' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/google/apiclient-services/src/Analytics/Profiles.php:20
    • > PHP Fatal error
      Uncaught Error: Interface 'Psr\\Http\\Message\\StreamInterface' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/guzzlehttp/psr7/src/FnStream.php:16
    • > PHP Fatal error
      Uncaught Error: Class 'Google\\Protobuf\\Internal\\Message' not found in wp-content/plugins/googleanalytics/lib/analytics-admin/vendor/google/cloud/AnalyticsAdmin/src/V1alpha/DeletePropertyRequest.php:16

User-side errors 0% from 1 test

🔹 Test weight: 20 | This is a smoke test targeting browser errors/issues
Please fix the following browser errors
    • > GET request to /wp-admin/admin.php?page=googleanalytics
    • > Console-api (warning) in unknown
    /wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,underscore,wp-util&ver=6.3.1 1:28609 "jQuery.Deferred exception: Cannot read properties of undefined (reading 'top')" "TypeError: Cannot read properties of undefined (reading 'top')\n at HTMLDocument.\u003Canonymous> (/wp-content/plugins/googleanalytics/js/googleanalytics_page.js?ver=1697659237:858:35)\n at e (/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,underscore,wp-util&ver=6.3.1:2:26990)\n at t (/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,underscore,wp-util&ver=6.3.1:2:27292)" undefined
    • > GET request to /wp-admin/admin.php?page=googleanalytics
    • > Javascript (severe) in unknown
    /wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils,underscore,wp-util&ver=6.3.1 1:28721 Uncaught TypeError: Cannot read properties of undefined (reading 'top')

Optimizations

Plugin configuration Passed 29 tests

readme.txt Passed 16 tests

The readme.txt file is an important file in your plugin as it is parsed by WordPress.org to prepare the public listing of your plugin
5 plugin tags: google analytics dashboard, analytics, google analytics widget, google analytics, google analytics plugin

googleanalytics/googleanalytics.php Passed 13 tests

Analyzing the main PHP file in "ShareThis Dashboard for Google Analytics" version 3.1.7
136 characters long description:
Use Google Analytics on your WordPress site without touching any code, and view visitor reports right in your WordPress admin dashboard!

Code Analysis 97% from 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is a short overview of programming languages used in this plugin, detecting executable files
No dangerous file extensions were detected143,093 lines of code in 2,014 files:
LanguageFilesBlank linesComment linesLines of code
PHP1,91328,103126,641131,270
JSON50005,037
Markdown201,14103,785
JavaScript4180761,291
CSS421151,136
C23570132
Python2327889
Bourne Shell5253375
Protocol Buffers2143864
XML30151
make2171651
YAML47243
m41111438
C/C++ Header1101825
SVG1006

PHP code 50% from 2 tests

Cyclomatic complexity and code structure are the fingerprint of this plugin
Please tend to the following items
  • Method cyclomatic complexity should be reduced to less than 100 (currently 105)
Cyclomatic complexity
Average complexity per logical line of code0.27
Average class complexity7.07
▷ Minimum class complexity1.00
▷ Maximum class complexity662.00
Average method complexity1.97
▷ Minimum method complexity1.00
▷ Maximum method complexity105.00
Code structure
Namespaces226
Interfaces85
Traits35
Classes1,749
▷ Abstract classes22813.04%
▷ Concrete classes1,52186.96%
▷ Final classes936.11%
Methods11,411
▷ Static methods1,37612.06%
▷ Public methods10,20889.46%
▷ Protected methods4574.00%
▷ Private methods7466.54%
Functions282
▷ Named functions8931.56%
▷ Anonymous functions19368.44%
Constants1,186
▷ Global constants231.94%
▷ Class constants1,16398.06%
▷ Public constants1,10294.75%

Plugin size Passed 2 tests

Image compression Passed 2 tests

All PNG images should be compressed to minimize bandwidth usage for end users
3 PNG files occupy 0.33MB with 0.23MB in potential savings
Potential savings
Compression of 3 random PNG files using pngquant
FileSize - originalSize - compressedSavings
assets/images/demographics-ad.png112.74KB27.33KB▼ 75.76%
assets/images/demographics-ex.png162.89KB37.71KB▼ 76.85%
assets/images/gdpr-ex.png63.58KB26.25KB▼ 58.72%