Skip to content

Network table: a Tracking switch per site - #19

Merged
padams merged 13 commits into
masterfrom
feat/site-switches
Oct 22, 2026
Merged

padams merged 13 commits into
masterfrom
feat/site-switches

Conversation

@padams

@padams padams commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #18; GitHub retargets it to master once #18 merges.

When the network configures each site's Profile, each row of the network table gets a Tracking switch, at the end of the row.

  • The network decides. In that mode the site's own Enable OWA is network-managed: hidden on its page, and kept as stored. The site's page says whether the network has tracking on or off there.
  • A site new to the network starts on. A site switched off keeps its Profile.
  • In site-choice mode there are no switches, and sites keep their own toggle.
  • Storage: disabledSiteIds in the network option. network::save() takes enabledSites (blog ID → on) for the network's own sites only, and keeps the stored state for any it isn't given.

Network table

Row Observation Profile column Tracking switch
Profile saved The saved Profile as text, with an Edit link that turns it into the dropdown (and Cancel to go back) Shown
New to the network The dropdown, and a New badge by the host None
Saved without a Profile The dropdown None
Tracking off Greyed out; Edit and the dropdown are disabled Shown, still works

Once a Profile is picked and saved for a row, it changes to the first kind and gets its switch. The page sends switches only for rows that show one.

The Status column is gone, and the "Website ID" column is now "Observation Profile". The dropdown's empty choice reads "Select Profile…".

Wording

OWA 2.x calls what this plugin tracks an Observation Profile, so the plugin now does too wherever 2.x is meant: the network page, its notices, and the site page in 2.x mode. The dropdowns' placeholder is "Select Profile…". 1.x keeps Website ID, including the "select a Site ID" notice, which now says Website ID.

The site page's field relabels as the 1.x/2.x switch flips: a field can carry title_v2 / description_v2, sent as v2 in the settings payload.

Site settings page

The link to OWA's tracking tag screen ("Configure this Observation Profile's tracking tag in OWA") shows only once the Observation Profile is saved, and only while the version, endpoint and Observation Profile on the page match what's saved.

Setup notices

The "enter your credentials" and "select a Website ID / Observation Profile" notices used to be printed by WordPress at page load, worded for the saved version, and stayed up after a save until a reload. Now:

  • setupNotices( $version ) builds them from the saved settings, worded for either version.
  • The settings route sends both versions' notices with every load and save, and the page shows the set for the version chosen on it. Switching 1.x/2.x rewords them straight away, and a save clears what it fixed.
  • WordPress no longer prints them on that screen; other admin screens still get them from admin_notices.
  • Where the network sets the Observation Profile, "select one" isn't shown, since the site admin can't.

Page cache purge

A cached page keeps the tag it was rendered with. When a save changes what decides a site's tag (tracking on or off, its Website ID, the OWA version or server), the plugin fires owa_wp_tag_changed (arg: blog ID) in that site's context.

  • Proxy Cache Purge (varnish-http-purge) is told through its varnish_http_purge_events and varnish_http_purge_events_full filters to purge the whole site on that action. We don't call its API.
  • Other page caches can listen for the action.
  • Network saves compare each site's effective tag before and after, and fire once per site that changed, switched into that site so the purge targets its host.
  • A save that changes no tag fires nothing.

Checked on the dev site: firing the action makes Proxy Cache Purge send http://127.0.0.1/.* to Varnish, which returns 200.

Also fixed: the SDK was only set up when tracking was on, so a tracking-off site's picker showed its saved Website ID as "not in the list".

Tests

  • PHP:
    • a switched-off site gets no tag and no wp_head hook, whatever its own toggle says;
    • a switched-on site is tracked even with its own toggle off;
    • switches apply only in network-configured mode, which is also the only mode where Enable OWA is managed;
    • saving ignores sites outside the network and keeps switches it isn't given;
    • a new site starts on;
    • purges: switching a site off purges that site inside switch_to_blog; another Profile purges that site; a new server purges every site; an unchanged save purges nothing; a site save purges only when its tag changes; the action is added to both Proxy Cache Purge filters. Each fails with its purge call or the blog switch removed.
  • Vitest: the saved label, when a row is in edit mode, which rows have a switch and which switches are sent, when the tag link shows.
  • Browser: Edit and Cancel on a saved row, the New badge, no switch on b.wp.test or c.wp.test until b.wp.test is saved with a Profile, switching a.wp.test off greys the row and keeps its Profile; a.wp.test then gets no tag while b.wp.test still gets its bundle, and a.wp.test's page shows the note without the Enable OWA toggle. Single site: the tag link is hidden until the Website ID is saved.

padams added 13 commits October 21, 2026 22:16
When the network configures each site's Profile, each row now has a
Tracking switch, and the network decides: the site's own Enable OWA is
managed (hidden on its page, kept as stored) and its note says whether the
network has tracking on or off. A site new to the network starts on; a site
switched off keeps its Profile. In site-choice mode there are no switches and
sites keep their own toggle.

Stored as disabledSiteIds in the network option; network::save() takes
enabledSites (blog ID => on) for the network's own sites only, keeping the
stored state for any left out. A row counts as changed when its switch or
its Profile differs from what is saved, and a saved row switched off reads
"Tracking off". The select's empty choice is "— no Profile —".
It was set up only inside the enable check, so on a site with tracking off
(its own Enable OWA, or the network's switch) the settings page could not list
the Website IDs, and the saved one showed as 'not in the list from OWA'. The
SDK only serves that list. Browser tests now check the chosen ID's label, not
only its value.
…ebsite ID

The link is built from the saved settings, so while the version, the endpoint
or the Website ID differs from what is saved it is hidden, rather than
pointing at the previously saved Profile.
…cking is off

The Status column is gone. A saved row shows its Profile as text with an Edit
link that turns it into the dropdown (Cancel puts it back); a row not saved
yet, such as a site new to the network, shows the dropdown with a "New"
badge. A row the network has switched off is greyed and cannot be edited;
its switch, at the end of the row, stays usable.

The per-row status text (network::rowStatus(), the payload's 'status') is
removed with the column. Rows carry data-host for the browser tests.
A save that changes what decides a site's tag (tracking on or off, the
Website ID, the OWA version or server) fires owa_wp_tag_changed in that
site's context. Proxy Cache Purge is told, through its
varnish_http_purge_events filters, to purge the whole site on it; any
other page cache can listen for the action.

Network saves compare each site's effective tag before and after and fire
once per site that changed.
A row new to the network, or saved without a Profile, shows its dropdown
and no switch. Once a Profile is saved for it, the row shows the Profile
as text with Edit, and its switch. The page sends switches only for the
rows that show one; the server keeps the stored state for the rest.
The network page, the site page in 2.x mode, their notes and notices
say "Observation Profile" (placeholder "Select Profile…"). 1.x keeps
"Website ID", which the one remaining "Site ID" notice now says too.

A field can carry title_v2 / description_v2; the site page uses them
while 2.x is chosen, so the Website ID field relabels as the version
switch flips.
The "enter your credentials" and "select a Website ID" notices were
printed by WordPress at page load, worded for the saved version, and
stayed after a save until a reload. setupNotices() now words them for a
version; the settings route sends both versions' notices with every
load and save, and the page shows the ones for the version chosen on
it. Other admin screens still get them from admin_notices.

Where the network sets the Observation Profile, "select one" is not
shown: the site admin cannot, and the page already says why.
@padams
padams deleted the branch feat/refresh-on-load October 22, 2026 00:36
@padams padams closed this Oct 22, 2026
@padams padams reopened this Oct 22, 2026
@padams
padams changed the base branch from feat/refresh-on-load to master October 22, 2026 00:38
@padams
padams merged commit fd34558 into master Oct 22, 2026
18 checks passed
@padams
padams deleted the feat/site-switches branch October 22, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant