From ad21bc06724ed9bc0d7ecf27cd6eeb39257b596f Mon Sep 17 00:00:00 2001 From: padams Date: Mon, 2 Nov 2026 02:55:09 +0000 Subject: [PATCH 1/2] An excluded logged-in user gets a paused tracker instead of none With Don't Track Logged-in Users on, the plugin printed no tag for a logged-in user. OWA's heatmap and Domstream player start from the tracker, so they never opened for the site's own admins. The tag is now printed with a pause command queued first. The tracker applies it before the page view, so nothing is sent; the overlay still starts. Track Named Users is skipped for them, since nothing is sent. --- README.txt | 2 +- owa-plugin.php | 11 +++++++---- tests/OwaV2Test.php | 25 ++++++++++++++++++++----- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/README.txt b/README.txt index f29158e..7f2220e 100644 --- a/README.txt +++ b/README.txt @@ -29,7 +29,7 @@ Choose the server version under OWA > Settings. * The user name of logged-in users, if Track Named Users is on. * WordPress admin pages, if Track WP Admin Pages is on (1.x only). -Previews, the Customizer and logged-in users are not tracked. Turn off Don't Track Logged-in Users (on by default) to track logged-in users. +Previews, the Customizer and logged-in users are not tracked. For a logged-in user the tracker still loads, paused, so OWA's heatmap and Domstream player open on the site. Turn off Don't Track Logged-in Users (on by default) to track logged-in users. = Multisite = diff --git a/owa-plugin.php b/owa-plugin.php index f7abdf7..0c5d29d 100644 --- a/owa-plugin.php +++ b/owa-plugin.php @@ -566,13 +566,16 @@ function insertTrackingTag() { return; } + // An excluded logged-in user gets the tracker paused rather than no + // tracker: it sends nothing, and the overlays OWA's reports open on + // the site (the heatmap, the Domstream player) start from it. The + // pause is queued first, so it is applied before the page view. if ( $this->getOption( 'excludeLoggedInUsers' ) && is_user_logged_in() ) { - return; - } + $this->cmds[] = $this->makeCmd( 'pause' ); // set user name in tracking for names users with wp-admin accounts - if ( $this->getOption( 'trackNamedUsers') ) { + } elseif ( $this->getOption( 'trackNamedUsers') ) { $this->setUserNameCmd(); } @@ -980,7 +983,7 @@ public function registerOptions() { 'title' => 'Don't Track Logged-in Users', 'page_name' => 'owa-wordpress', 'section' => 'tracking', - 'description' => 'No tracking tag for visitors who are logged in to WordPress.', + 'description' => 'The tracker loads paused for visitors who are logged in to WordPress: it sends nothing, and OWA\'s heatmap and Domstream player still open on the site.', 'label_for' => 'Do not track logged-in users', 'error_message' => '' ) diff --git a/tests/OwaV2Test.php b/tests/OwaV2Test.php index bdc9e0a..16fc2b1 100644 --- a/tests/OwaV2Test.php +++ b/tests/OwaV2Test.php @@ -97,18 +97,33 @@ public function testASiteIdThatCannotBeABundleFileGetsNoTag(): void { $this->assertSame( '', $this->renderTag( $this->v2( [ 'siteId' => '../owa-config' ] ) ) ); } - public function testLoggedInUsersCanBeExcludedInBothVersions(): void { + /** + * An excluded logged-in user gets the tracker, paused before anything is + * sent: OWA's overlays (the heatmap, the Domstream player) start from the + * tracker, so without it they never open for the site's own admins. + */ + public function testAnExcludedLoggedInUserGetsAPausedTrackerInBothVersions(): void { $this->stubConditionals( [ 'is_single' ] ); Functions\when( 'wp_title' )->justReturn( 'Post' ); Functions\when( 'is_user_logged_in' )->justReturn( true ); + Functions\when( 'wp_get_current_user' )->justReturn( (object) [ 'user_login' => 'editor1' ] ); + + $v2 = $this->renderTag( $this->v2( [ 'excludeLoggedInUsers' => true, 'trackNamedUsers' => true ] ) ); + $cmd = array_column( $this->pushedCmds( $v2 ), 0 ); + + $this->assertStringContainsString( 'https://owa.example.com/public/tracker/OWA-9b62dc7ce78a6934.js', $v2 ); + $this->assertSame( 'pause', $cmd[0], 'Queued before the bundle\'s page view.' ); + $this->assertNotContains( 'setUserName', $cmd, 'Nothing is sent, so there is no user to name.' ); - $this->assertSame( '', $this->renderTag( $this->v2( [ 'excludeLoggedInUsers' => true ] ) ) ); + $v1 = $this->renderTag( $this->makePlugin( [ 'owaEndpoint' => 'https://owa.example.com/', 'siteId' => 'abc123', 'excludeLoggedInUsers' => true ] ) ); + $cmd = array_column( $this->pushedCmds( $v1 ), 0 ); - $v1 = $this->makePlugin( [ 'owaEndpoint' => 'https://owa.example.com/', 'siteId' => 'abc123', 'excludeLoggedInUsers' => true ] ); - $this->assertSame( '', $this->renderTag( $v1 ) ); + $this->assertSame( 'pause', $cmd[0] ); + $this->assertLessThan( array_search( 'trackPageView', $cmd ), array_search( 'pause', $cmd ) ); - $this->assertNotSame( '', $this->renderTag( $this->v2() ), 'Logged-in users are tracked unless excluded.' ); + $this->assertNotContains( 'pause', array_column( $this->pushedCmds( $this->renderTag( $this->v2() ) ), 0 ), + 'Logged-in users are tracked unless excluded.' ); } public function testTheApplicationPasswordGoesToTheSdk(): void { From f49676843307039d61ddd20f0cbca3b0ba133507 Mon Sep 17 00:00:00 2001 From: padams Date: Mon, 2 Nov 2026 03:06:12 +0000 Subject: [PATCH 2/2] No paused tracker on admin screens; 2.4.1 changelog With Track WP Admin Pages (1.x) and Don't Track Logged-in Users both on, every admin screen loaded a paused tracker. No overlay opens there, so an excluded user gets no tracker on admin screens, as before. --- README.txt | 4 ++++ owa-plugin.php | 8 +++++++- tests/TrackingTagTest.php | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 7f2220e..82cfc9e 100644 --- a/README.txt +++ b/README.txt @@ -76,6 +76,10 @@ Application passwords are sent only over https. To use an http OWA server, turn == Changelog == += 2.4.1 = + +* Don't Track Logged-in Users: a logged-in user now gets the tracker paused instead of no tracker, so OWA's heatmap and Domstream player open on the site. Nothing is sent to OWA for them, but their browser still loads the tracker from the OWA server. Admin pages still get no tracker. + = 2.4.0 = * Don't Track Logged-in Users is on by default. A site that never saved this setting (last saved before 2.3.0) stops tracking logged-in users; turn the setting off to track them again. diff --git a/owa-plugin.php b/owa-plugin.php index 0c5d29d..2fc4ab5 100644 --- a/owa-plugin.php +++ b/owa-plugin.php @@ -570,8 +570,14 @@ function insertTrackingTag() { // tracker: it sends nothing, and the overlays OWA's reports open on // the site (the heatmap, the Domstream player) start from it. The // pause is queued first, so it is applied before the page view. + // No overlay opens on an admin screen, so those get no tracker. if ( $this->getOption( 'excludeLoggedInUsers' ) && is_user_logged_in() ) { - + + if ( is_admin() ) { + + return; + } + $this->cmds[] = $this->makeCmd( 'pause' ); // set user name in tracking for names users with wp-admin accounts diff --git a/tests/TrackingTagTest.php b/tests/TrackingTagTest.php index e154168..f7ee0a9 100644 --- a/tests/TrackingTagTest.php +++ b/tests/TrackingTagTest.php @@ -139,6 +139,25 @@ public function testAdminPagesAreNotTaggedUnlessEnabled(): void { $this->assertSame( '', $this->renderTag( $this->plugin() ) ); } + public function testAdminPagesAreNotTaggedForAnExcludedLoggedInUser(): void { + + Functions\when( 'is_admin' )->justReturn( true ); + Functions\when( 'is_user_logged_in' )->justReturn( true ); + Functions\when( 'get_current_screen' )->justReturn( (object) [ 'id' => 'dashboard' ] ); + $this->stubConditionals(); + Functions\when( 'wp_title' )->justReturn( 'Dashboard' ); + + $plugin = $this->plugin(); + $plugin->setOption( 'trackAdminPages', true ); + $plugin->setOption( 'excludeLoggedInUsers', true ); + + $this->assertSame( '', $this->renderTag( $plugin ), 'No overlay opens on an admin screen, so no paused tracker.' ); + + $plugin->setOption( 'excludeLoggedInUsers', false ); + + $this->assertNotSame( '', $this->renderTag( $plugin ), 'Admin pages are tagged when logged-in users are tracked.' ); + } + public function testOwnSettingsScreenIsNeverTagged(): void { Functions\when( 'is_admin' )->justReturn( true );