Symptom
wp datamachine analytics ga path_sequence --start-date=... --end-date=... emits a flood of:
Warning: Array to string conversion in .../data-machine/inc/Cli/Commands/AnalyticsCommand.php on line 249
and prints no usable table. --format=json works fine and returns valid, complete data.
Root cause
path_sequence (the GA4 v1alpha funnel action from dmb#35) returns rows whose next_hosts value is an array of objects ([{next_host, users}, ...]), i.e. a nested array-of-arrays per host.
flatten_row() (AnalyticsCommand.php ~244-255) handles one level of array via implode(', ', array_map('strval', $value)):
foreach ( $row as $key => $value ) {
if ( is_array( $value ) ) {
$flat[ $key ] = implode( ', ', array_map( 'strval', $value ) ); // <-- L249: array_map strval on an array-of-arrays
} else {
$flat[ $key ] = $value;
}
}
When $value is next_hosts (an array whose elements are themselves arrays), strval() is called on each inner array → "Array to string conversion", once per inner element, hence the flood.
Impact
path_sequence is the best instrument for cross-site/network-density measurement (user-scoped activeUsers, bot-resistant — unlike the session-scoped UTM bridge channel which is ~98% bot-inflated). It's currently only usable via --format=json; the default table view is broken, which makes it look broken to anyone who runs it the normal way.
Fix options
- In
flatten_row(), when an array value contains nested arrays/objects, JSON-encode it (or summarize, e.g. host(users); host(users)) instead of implode+strval. A targeted path_sequence formatter that renders next_hosts as next_host:users pairs would be the nicest table output.
- Or detect non-scalar inner elements and
wp_json_encode() them as the cell value.
Repro
wp datamachine analytics ga path_sequence --start-date=2026-05-18 --end-date=2026-06-15
# -> flood of Array to string conversion at AnalyticsCommand.php:249
wp datamachine analytics ga path_sequence --start-date=2026-05-18 --end-date=2026-06-15 --format=json
# -> works, returns hostName/entry_users/onward_users/next_hosts[]
Env
extrachill.com VPS. data-machine CLI. path_sequence action (data-machine-business GoogleAnalyticsAbilities, dmb#35).
Symptom
wp datamachine analytics ga path_sequence --start-date=... --end-date=...emits a flood of:and prints no usable table.
--format=jsonworks fine and returns valid, complete data.Root cause
path_sequence(the GA4 v1alpha funnel action from dmb#35) returns rows whosenext_hostsvalue is an array of objects ([{next_host, users}, ...]), i.e. a nested array-of-arrays per host.flatten_row()(AnalyticsCommand.php ~244-255) handles one level of array viaimplode(', ', array_map('strval', $value)):When
$valueisnext_hosts(an array whose elements are themselves arrays),strval()is called on each inner array → "Array to string conversion", once per inner element, hence the flood.Impact
path_sequenceis the best instrument for cross-site/network-density measurement (user-scopedactiveUsers, bot-resistant — unlike the session-scoped UTM bridge channel which is ~98% bot-inflated). It's currently only usable via--format=json; the default table view is broken, which makes it look broken to anyone who runs it the normal way.Fix options
flatten_row(), when an array value contains nested arrays/objects, JSON-encode it (or summarize, e.g.host(users); host(users)) instead ofimplode+strval. A targetedpath_sequenceformatter that rendersnext_hostsasnext_host:userspairs would be the nicest table output.wp_json_encode()them as the cell value.Repro
Env
extrachill.com VPS. data-machine CLI. path_sequence action (data-machine-business GoogleAnalyticsAbilities, dmb#35).