Skip to content

Commit

Permalink
Telemetry: set pluginVersion user property
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Oct 2, 2023
1 parent 83a151e commit 8b88198
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions includes/Tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ private function get_user_properties(): array {
'adNetwork' => $ad_network,
'analytics' => $analytics,
'activePlugins' => implode( ',', $active_plugins ),
// This doesn't seem to be fully working for web properties.
// So we send it as both app_version and a user property.
// See https://support.google.com/analytics/answer/9268042.
'pluginVersion' => WEBSTORIES_VERSION,
];
}
}
3 changes: 3 additions & 0 deletions tests/phpunit/integration/tests/Tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,23 @@ public function test_get_settings(): void {
$this->assertArrayHasKey( 'analytics', $settings['userProperties'] );
$this->assertArrayHasKey( 'serverEnvironment', $settings['userProperties'] );
$this->assertArrayHasKey( 'activePlugins', $settings['userProperties'] );
$this->assertArrayHasKey( 'pluginVersion', $settings['userProperties'] );
$this->assertSame( get_locale(), $settings['userProperties']['siteLocale'] );
$this->assertSame( get_user_locale(), $settings['userProperties']['userLocale'] );
$this->assertSame( wp_get_environment_type(), $settings['userProperties']['serverEnvironment'] );
$this->assertSame( PHP_VERSION, $settings['userProperties']['phpVersion'] );
$this->assertSame( get_bloginfo( 'version' ), $settings['userProperties']['wpVersion'] );
$this->assertSame( 'administrator', $settings['userProperties']['userRole'] );
$this->assertSame( 'enableFoo,enableBar', $settings['userProperties']['enabledExperiments'] );
$this->assertSame( WEBSTORIES_VERSION, $settings['userProperties']['pluginVersion'] );
$this->assertIsString( $settings['userProperties']['wpVersion'] );
$this->assertIsString( $settings['userProperties']['phpVersion'] );
$this->assertIsInt( $settings['userProperties']['isMultisite'] );
$this->assertIsString( $settings['userProperties']['adNetwork'] );
$this->assertIsString( $settings['userProperties']['analytics'] );
$this->assertIsString( $settings['userProperties']['activePlugins'] );
$this->assertIsString( $settings['userProperties']['serverEnvironment'] );
$this->assertIsString( $settings['userProperties']['pluginVersion'] );
}

/**
Expand Down

0 comments on commit 8b88198

Please sign in to comment.