Skip to content

[FEATURE] Attach a site to an active site and detach it again - #29

Open
sfsmfc wants to merge 7 commits into
feature/ui-overhaulfrom
feature/site-attach
Open

sfsmfc wants to merge 7 commits into
feature/ui-overhaulfrom
feature/site-attach

Conversation

@sfsmfc

@sfsmfc sfsmfc commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Summary

A second domain of a project can use the analytics of an active site instead of its own registration. This PR adds attach and detach to the backend module and limits all analytics to the domains of the selected site.

Stacked on #26. Needs TYPO3GmbH/site-analytics-middleware#91.

Attach and detach

  • The registration form offers "Attach to an active site". A confirmation dialog explains that the data of the site stays in the analytics of the active site, also after a detach.
  • Attach adds the domain of the site to the whitelisted domains of the website of the active site. The site gets the credentials and the tracking code of the active site and the setting attachedTo.
  • Detach removes the domain from the whitelist and removes the copied settings. The site is inactive again.

Module

  • An attached site shows in an indented row below its active site and the details of that site, with the status "Attached" and a "Detach" button.
  • An attached site cannot be the target of another attach.
  • The dashboard and the plan of an attached site open only for the active site. The site menu in the module header leaves out attached sites.

Analytics of the selected site

  • Each query of the dashboard widgets uses a filter on the page URL with the bases of the site and its languages, for example pageUrl in ["://example.com"]. The TWIPLA dashboard uses the same filter for "contains".
  • The top pages widget gets its pages from the API with this filter.
  • "Show in Analytics" links show only when the backend user has access to the root page of the site whose dashboard opens. Widgets of an attached site show no link, because the dashboard cannot filter by domain. The page performance bar opens the dashboard of the active site with the page filter.

Labels

  • The labels use "attach" and "detach" throughout, in German "anhängen" and "lösen".
  • Labels and badges use sentence case. The status badge shows translated values.
  • Duplicate label ids are removed. TYPO3 uses the last entry of an id, so the labels in the backend do not change.
  • The German labels use the formal "Sie".

Test

  • ddev composer t3g:test, t3g:test:functional, t3g:phpstan and t3g:cgl pass.
  • Tested live against the local middleware and TWIPLA stage: attach, detach, the confirmation dialogs, the widgets and the page performance bar for an active and an attached site.

A second domain of a project can use the analytics of an active site
instead of its own registration.

Attach to an active site
- The registration asks whether the site is registered as a new site or
  attached to an active site.
- The domain of the site is added to the whitelisted domains of the
  website of the active site, via the new middleware endpoint
  POST /website/{intpWebsiteId}/whitelisted-domains.
- The site gets the credentials and the tracking code of the active site
  and the setting "attachedTo". Plan and credits are shared.

Detach
- A "Detach" button with a confirmation dialog removes the domain from
  the whitelist (DELETE /website/{intpWebsiteId}/whitelisted-domains/{domain})
  and removes the copied settings. The site is inactive again.

Requires the whitelisted domain endpoints of the middleware.
Several sites can track into one website when a site is attached to an
active site. Each query of the dashboard widgets now uses a filter on
the page URL. The filter contains the base of the site and the bases of
all site languages, for example "://example.com". The API compares each
value as a part of the page URL, as the TWIPLA dashboard does for its
"contains" filter. The filter is also part of the cache keys.

- AnalyticsSiteProvider returns the filter with the credentials and
  lists attached sites again.
- The top pages widget gets its pages from the API with the filter.
- DashboardLinkBuilder builds the "Show in Analytics" links. A widget
  of an attached site shows no link, because the dashboard cannot show
  only the data of one domain. The page performance bar opens the
  dashboard of the active site with the page filter.
- A link shows only when the backend user has access to the root page
  of the site whose dashboard opens.
- The widgets for TYPO3 v13 show or hide the link when the site
  changes.
…tach

An attached site has no analytics of its own, so the module shows it
in an indented row below its active site and the details of that site.
The row shows the status "Attached" and the "Detach" button. A site
whose active site is not in the list keeps a row of its own.

- An attached site cannot be the target of another attach.
- The dashboard and the plan of an attached site open only for the
  active site. A direct call redirects with a message.
- The site menu in the module header leaves out attached sites.
- Attaching a site opens a confirmation dialog. The data of the site
  stays in the analytics of the active site, also after a detach.
- The labels use "attach" and "detach" throughout. Labels and badges
  use sentence case, and the status badge shows translated values.
Some labels had two or more entries with the same id: 35 ids with 37
extra entries in the German file and one id with 3 extra entries in
the English file. TYPO3 uses the last entry of an id, so the other
entries had no effect. Some of them differed from the entry in use,
for example a second "flash.accessDenied" with informal address.

The files now keep only the last entry of each id. The labels in the
backend do not change.
The German labels used formal and informal address. The TYPO3 backend
uses the formal "Sie", so all labels of the extension use it now:

- the status query error
- the messages about low and used up credits
- the question of the registration form
- the message after a plan upgrade
…t on TYPO3 v14

TrafficSourcesWidgetV14Pass still set the constructor argument
"$uriBuilder", which the widget no longer has. The container of TYPO3
v14 failed to build. The pass now sets "$dashboardLinkBuilder".
@sfsmfc
sfsmfc added this pull request to stack #31 October 14, 2026 09:22
The parameter docs of the page URL filter referred to
"buildPageUrlWhere()" without a class. The interface does not have this
method, so the reference now names AnalyticsDataClient, which
implements it.
@sfsmfc
sfsmfc force-pushed the feature/site-attach branch from 770552f to af4af88 Compare October 14, 2026 09:31
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