Skip to content

Detect the OWA server version; show only its settings - #27

Merged
padams merged 15 commits into
masterfrom
feat/detect-owa-version
Dec 2, 2026
Merged

padams merged 15 commits into
masterfrom
feat/detect-owa-version

Conversation

@padams

@padams padams commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Replaces the OWA Server Version switch with detection, so the settings page only offers what works with the server at the OWA Server Endpoint.

Detection

GET <endpoint>api/index.php?owa_rest_params=base/v2/profiles with Authorization: Bearer owa-version-probe and no other credentials, through wp_remote_get (the stored scheme, WordPress's TLS defaults).

Answer Result
OWA 2.x's envelope ({data, error}, error a string or null, no requestId), or 401 with a WWW-Authenticate Bearer challenge 2
any other answer (1.14's {requestId, httpResponse} envelope for a route it lacks, an empty body from older 1.x, HTML, a proxy's login) 1
no answer: network error, 408, 429, 5xx none; the version found at the same endpoint before is kept, a new endpoint gets none

Either 2.x marker is enough, so a proxy that strips the header or replaces the body does not turn 2.x into 1.x. Endpoints that are not OWA never reach the probe: saving or checking one requires OWA's tracker at public/base/dist/owa.tracker.js (1.14 and later).

Settings page

  • Enable OWA first, then OWA Server Endpoint with Check.
  • Check identifies the URL in the field and stores nothing (POST owa-wp/v1/server with owaEndpoint, manage_options). On the saved endpoint it checks and stores, as the daily check does. A URL without OWA gets its error under the field.
  • The detected version's fields then show. Save Changes shows once the server is identified and that version's credentials are entered (API Key and Secret Auth Key, or Application Password). On the saved endpoint it always shows, and emptying a saved endpoint can be saved.
  • While the field holds another URL than the saved one, the saved server's Profile list and setup notices are hidden.
  • Check again is a button: "Checking…" while it runs (at least 0.6 s), then "Checked at ." Typed values are kept.
Stored version Shows
none (fresh install, or no answer at a new endpoint) Endpoint and Check
1 Enable, Endpoint, API Key, Secret Auth Key, Website ID; Tracking and Advanced tabs as before
2 Enable, Endpoint, Application Password (links to the OWA wiki's Application-Passwords), Observation Profile; Tracking tab without Track Clicks and Track Domstreams
1 or 2, last check had no answer that version's fields, plus a warning naming the error

When it checks

  • Check, and saving an endpoint that changed or was not identified yet.
  • Once a day (transient owa_wp_server_checked) on an admin page load by a user with manage_options; not on AJAX, never in network mode.

A version change purges the site's pages (owa_wp_tag_changed), since the tag changes with it.

Upgrades

  • Plugin update: the first admin page load after an update (option owa_wp_plugin_version) checks the server and stores the detected version. With no answer, the version chosen before is kept (1 when it was never saved, the old default). Without an endpoint the version is cleared. Front-end tags are unchanged until that load.
  • OWA 1.x → 2.x: the stored version becomes 2 and, when no application password is stored, a dismissible notice on the dashboard, Plugins and settings screens asks for one. The 1.x keys stay stored. The tag becomes the 2.x bundle tag with the stored site ID, which OWA 2.x keeps for migrated sites. Saving an application password or dismissing ends the notice.

Other changes

  • Network Admin > OWA refuses a new endpoint that identifies as 1.x.
  • New UI text is translatable (open-web-analytics, header Text Domain added; wp_set_script_translations for the settings scripts).
  • CI: OWA's v2 branch no longer exists, so the 2.x jobs use master; that integration job runs only the owa2 group, since master refuses 1.x keys. The OWA install step uses cmd=core-install when OWA has it, mints the application password without scope=, and stores app_passwords_require_https with persistSetting() (2.0 refuses an owa-config.php that uses $this).
  • CI's php -S router no longer rewrites api/index.php itself (Apache's rule skips existing files); it replaced the probe's owa_rest_params with index.php.
  • e2e reads Profile domains as OWA stores them (2.0 stores the bare host).
  • Version 2.5.0 in the plugin header and OWA_WP_VERSION; Stable tag unchanged.

Tests

  • tests/ServerTest.php: classification (2.x envelope or challenge; 1.14, empty, HTML and proxy answers as 1.x; no answer), the probe request, stored version, save and Check for fresh 1.x and 2.x, a new endpoint that does not answer, Check of an unsaved URL, daily check, update migration (still 1.x, 1.x → 2.x, 2.x on 2.x, a 2.x choice on a 1.x server, no answer, no endpoint), upgrade notice and dismissal.
  • Bundle tag on 2.x (exact markup; no trackClicks, trackDomStream, trackPageView, setSiteId, setDebug), 1.x tag unchanged, no tag without a version, network refusal.
  • Integration: the probe against OWA 1.14.0 (owa1) and OWA master (owa2).
  • Vitest: visibility per version, the server shown for the URL in the field, when Save Changes shows, server status states.
  • Playwright single site: Check, then the password, then Save, to a 2.x bundle tag.

Not covered: a browser run of a fresh 1.x setup (e2e runs against OWA master only), and a real 1.x → 2.x server upgrade.

Checked on test.photopressdev.com against the dev OWA: the update switched it to 2.x and raised the notice; with an application password and a Profile chosen, a logged-out page view was stored under that Profile.

Docs

.wordpress-org screenshots 1–5 are from this branch's CI run, and caption 1 mentions Check. The wiki's Setup page still shows the old label and the Save-first page.

padams added 15 commits December 2, 2026 06:00
The OWA Server Version switch is gone. The plugin asks the endpoint which
version it runs: GET api/index.php?owa_rest_params=base/v1/sites with
Authorization: Bearer owa-version-probe. 401 with a Bearer
WWW-Authenticate challenge is 2.x; OWA 1.x's REST envelope without one is
1.x; anything else identifies nothing, keeps the version found before and
the settings page says why.

- owaVersion stays the stored option, now detected: '1', '2', or '' while
  none is known. Only the OWA Endpoint shows until a version is known;
  then only that version's fields. On 2.x the Tracking tab stays without
  click tracking and Domstreams, as before.
- Checked when the endpoint is saved (new, or not identified yet), once a
  day on an administrator's admin page load, and with Check again
  (POST owa-wp/v1/server).
- After an update, the first admin page load checks the server and
  replaces the chosen version; when nothing is identified the chosen
  version (or 1, the old default) is kept. Until then the tag is as before.
- A server that was 1.x and is now 2.x flags a dismissible notice on the
  dashboard, Plugins and settings screens asking for an application
  password. The 1.x keys are kept.
- Network Admin > OWA refuses an endpoint that identifies as 1.x.
- The Application Password field links to OWA's documentation.
- CI: OWA's v2 branch is gone; the 2.x jobs run on master, which refuses
  1.x keys, so that integration job runs the owa2 group only.
…dex.php as Apache does

OWA master renamed cmd=install to cmd=core-install, takes no scope= for
app-password-create, and refuses an owa-config.php that uses $this, so
app_passwords_require_https is stored with persistSetting() instead.

The router rewrote api/index.php itself and replaced its owa_rest_params
with 'index.php'; Apache's rule skips existing files.
…main OWA stored

The tag-settings link read values, which WebsiteId no longer received:
the page crashed once the picker rendered.

OWA 2.0 stores a Profile's bare host, so the e2e labels and site IDs are
read with the domain as stored.
…754), which sends WWW-Authenticate"

This reverts commit 1170e45.
The probe asks for base/v2/profiles. OWA 2.x's envelope ({data, error}),
or a 401 with a Bearer challenge, is 2.x; any other answer is 1.x. No
answer (network error, 408, 429, 5xx) keeps the version found at the same
endpoint before; a new endpoint that does not answer gets none.

Settings page: the endpoint comes with Check, which identifies the URL in
the field without storing it. That version's fields then show, and Save
Changes once its credentials are entered (on the saved endpoint, always).
Check no longer reloads the form, so typed values stay.
…site on 2.x, and a 2.x choice on a 1.x server
@padams
padams merged commit 7669367 into master Dec 2, 2026
9 checks passed
@padams
padams deleted the feat/detect-owa-version branch December 2, 2026 09:37
@padams padams mentioned this pull request Dec 2, 2026
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