78% segmentio

Code Review | Analytics for WordPress — by Segment

WordPress plugin Analytics for WordPress — by Segment scored78%from 54 tests.

About plugin

  • Plugin page: segmentio
  • Plugin version: 1.0.13
  • PHP version: 7.4.16
  • WordPress compatibility: 3.6-4.0
  • WordPress version: 6.3.1
  • First release: Feb 1, 2013
  • Latest release: Feb 23, 2016
  • Number of updates: 62
  • Update frequency: every 18.0 days
  • Top authors: segmentio (100%)

Code review

54 tests

User reviews

6 reviews

Install metrics

900+ active /43,842 total downloads

Benchmarks

Plugin footprint 83% from 16 tests

Installer Passed 1 test

🔺 Critical test (weight: 50) | Checking the installer triggered no errors
The plugin installed successfully, without throwing any errors or notices

Server metrics [RAM: ▲0.19MB] [CPU: ▼5.84ms] Passed 4 tests

Analyzing server-side resources used by Analytics for WordPress — by Segment
No issues were detected with server-side resource usage
PageMemory (MB)CPU Time (ms)
Home /3.67 ▲0.2139.71 ▼4.04
Dashboard /wp-admin3.50 ▲0.1546.03 ▼10.72
Posts /wp-admin/edit.php3.61 ▲0.2549.89 ▲1.36
Add New Post /wp-admin/post-new.php6.08 ▲0.1989.12 ▼9.97
Media Library /wp-admin/upload.php3.42 ▲0.1936.28 ▲3.51
Analytics /wp-admin/options-general.php?page=analytics3.3936.89

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

Input-output and database impact of this plugin
No storage issues were detected
Filesystem: 31 new files
Database: no new tables, 7 new options
New WordPress options
widget_theysaidso_widget
analytics_wordpress_options
can_compress_scripts
widget_recent-comments
db_upgraded
widget_recent-posts
theysaidso_admin_options

Browser metrics Passed 4 tests

This is an overview of browser requirements for Analytics for WordPress — by Segment
There were no issues detected in relation to browser resource usage
PageNodesMemory (MB)Script (ms)Layout (ms)
Home /2,805 ▲5914.26 ▼0.302.20 ▲0.5243.82 ▲4.32
Dashboard /wp-admin2,208 ▲445.62 ▲0.0092.12 ▼6.8041.61 ▲0.18
Posts /wp-admin/edit.php2,113 ▲101.98 ▼0.0541.87 ▼0.2635.72 ▼0.64
Add New Post /wp-admin/post-new.php1,534 ▲823.55 ▲0.46615.92 ▼49.4951.83 ▼2.22
Media Library /wp-admin/upload.php1,407 ▲104.13 ▼0.09106.03 ▼6.8841.89 ▼4.86
Analytics /wp-admin/options-general.php?page=analytics1,0002.1724.1328.51

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

🔸 Tests weight: 35 | Checking the uninstaller removed all traces of the plugin
These items require your attention
  • The uninstall procedure has failed, leaving 6 options in the database
    • theysaidso_admin_options
    • widget_recent-posts
    • can_compress_scripts
    • widget_recent-comments
    • db_upgraded
    • widget_theysaidso_widget

Smoke tests 50% from 4 tests

Server-side errors Passed 1 test

🔹 Test weight: 20 | A smoke test targeting server-side errors
Even though everything seems fine, this is not an exhaustive test

SRP 50% 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
The following issues need your attention
  • 21× PHP files trigger server-side errors or warnings when accessed directly (only 10 are shown):
    • > PHP Fatal error
      Uncaught Error: Class 'Segment_IO_Analytics_WordPress' not found in wp-content/plugins/segmentio/class.analytics-wordpress.php:4
    • > PHP Fatal error
      Uncaught Error: Class 'Segment_Analytics' not found in wp-content/plugins/segmentio/includes/class.analytics.php:8
    • > PHP Fatal error
      Uncaught Error: Call to undefined function register_activation_hook() in wp-content/plugins/segmentio/analytics-wordpress.php:1112
    • > PHP Fatal error
      Uncaught Error: Class 'Segment_IO_Analytics' not found in wp-content/plugins/segmentio/class.analytics.php:4
    • > PHP Warning
      require_once(/tmp/wordpress-tests-lib/includes/functions.php): failed to open stream: No such file or directory in wp-content/plugins/segmentio/tests/bootstrap.php on line 9
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_filter() in wp-content/plugins/segmentio/integrations/intercom.php:28
    • > PHP Fatal error
      Uncaught Error: Call to undefined function add_action() in wp-content/plugins/segmentio/includes/class.segment-cookie.php:74
    • > PHP Fatal error
      require_once(): Failed opening required '/tmp/wordpress-tests-lib/includes/functions.php' (include_path='.:/usr/share/php') in wp-content/plugins/segmentio/tests/bootstrap.php on line 9
    • > PHP Fatal error
      Uncaught Error: Class 'WP_UnitTestCase' not found in wp-content/plugins/segmentio/tests/test-segment-settings.php:2
    • > PHP Fatal error
      Uncaught Error: Call to undefined function _e() in wp-content/plugins/segmentio/templates/settings.php:2

User-side errors 0% from 1 test

🔹 Test weight: 20 | This is just a short smoke test looking for browser issues
Please fix the following user-side errors
    • > GET request to /wp-admin/options-general.php?page=analytics
    • > Javascript (severe) in unknown
    /wp-admin/options-general.php?page=analytics 206:1 Uncaught ReferenceError: analytics is not defined
    • > GET request to /wp-admin/options-general.php?page=analytics
    • > Javascript (severe) in unknown
    /wp-admin/options-general.php?page=analytics 208:2 Uncaught ReferenceError: analytics is not defined

Optimizations

Plugin configuration 93% from 29 tests

readme.txt 94% from 16 tests

Often overlooked, readme.txt is one of the most important files in your plugin
Attributes that require attention:
  • Tags: You are using too many tags: 11 tag instead of maximum 10
You can take inspiration from this readme.txt

segmentio/analytics-wordpress.php 92% from 13 tests

The main PHP script in "Analytics for WordPress — by Segment" version 1.0.13 is automatically included on every request by WordPress
It is important to fix the following:
  • Main file name: The principal plugin file should be the same as the plugin slug ("segmentio.php" instead of "analytics-wordpress.php")

Code Analysis Passed 3 tests

File types Passed 1 test

🔸 Test weight: 35 | This is an overview of file extensions present in this plugin and a short test that no dangerous files are bundled with this plugin
Good job! No executable or dangerous file extensions detected1,601 lines of code in 28 files:
LanguageFilesBlank linesComment linesLines of code
PHP224907941,420
Bourne Shell115459
Bourne Again Shell1201349
XML10032
Markdown121024
YAML14012
make1575

PHP code Passed 2 tests

This is a short overview of cyclomatic complexity and code structure for this plugin
There were no cyclomatic complexity issued detected
Cyclomatic complexity
Average complexity per logical line of code0.26
Average class complexity8.93
▷ Minimum class complexity1.00
▷ Maximum class complexity52.00
Average method complexity2.11
▷ Minimum method complexity1.00
▷ Maximum method complexity24.00
Code structure
Namespaces0
Interfaces0
Traits0
Classes14
▷ Abstract classes17.14%
▷ Concrete classes1392.86%
▷ Final classes00.00%
Methods105
▷ Static methods2826.67%
▷ Public methods10196.19%
▷ Protected methods00.00%
▷ Private methods43.81%
Functions7
▷ Named functions457.14%
▷ Anonymous functions342.86%
Constants6
▷ Global constants466.67%
▷ Class constants233.33%
▷ Public constants2100.00%

Plugin size Passed 2 tests

Image compression Passed 2 tests

Often times overlooked, PNG files can occupy unnecessary space in your plugin
No PNG images were found in this plugin