Skip to content

Add Focus Item scripts developer page (split Focus scripts) - #614

Draft
promptless-for-oss wants to merge 2 commits into
mautic:7.2from
Promptless:promptless/pr-16926-focus-split-scripts
Draft

Add Focus Item scripts developer page (split Focus scripts)#614
promptless-for-oss wants to merge 2 commits into
mautic:7.2from
Promptless:promptless/pr-16926-focus-split-scripts

Conversation

@promptless-for-oss

@promptless-for-oss promptless-for-oss commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Open in Promptless

Adds a new developer page docs/mauticjs_api/focus_scripts.rst documenting the consent-aware split of Focus Item embed scripts introduced by mautic/mautic PR #16926, mirroring the existing "Script scopes and split scripts" model on the tracking-script page.

Updated to match the now-ready source PR (head ebe9fdfb). This suggestion was first drafted against an earlier draft of the source PR; it has been reconciled to the current implementation.

The page documents:

  • The RUNTIME / DISPLAY / TRACKING scope model (a Focus-specific FocusJsScope enum, distinct from BuildJsScope — the two share no code path and gate different script families).
  • The three public endpoints — /focus/{id}/display.js (display, no tracking), /focus/{id}/tracking.js (tracking layer), and the preserved legacy /focus/{id}.js aggregate — all sending Cache-Control: private, no-store.
  • The public activation API window.MauticFocus.enableTracking(<id>), plus the supporting globals window.MauticFocusItems, window.MauticFocusTrackingQueue, and window.MauticFocusUseMauticTrackingConsent, and the mautic:tracking-enabled document event.
  • Dynamic Web Content injection behavior: same-origin /focus/{id}/display.js is always injected; the legacy /focus/{id}.js is injected additionally (not instead) only when MauticJS.trackingEnabled is true.

A matching mautic:tracking-enabled bullet was added to the tracking-script page and the new page registered in the MauticJS API toctree.

Reconciliation note: the earlier draft described a generated per-item enableMauticFocusTracking{id}() callback; that named callback does not exist in the ready source. The documented public entry point is window.MauticFocus.enableTracking(<id>), which the copied 'Consent-managed' snippet calls inline (with a window.MauticFocusTrackingQueue fallback).

Targets the 7.2 docs branch (source base 7.x).

Document the split Focus Item embed scripts from mautic/mautic PR #16926:
the /focus/{id}/display.js and /focus/{id}/tracking.js endpoints (legacy
/focus/{id}.js preserved), the RUNTIME/DISPLAY/TRACKING scope model, and the
client-side runtime globals (MauticFocusItems, MauticFocusTrackingQueue,
MauticFocusUseMauticTrackingConsent), the enableMauticFocusTracking{id}()
callback, and the mautic:tracking-enabled event. Add a matching event bullet
and toctree entry.
@patrykgruszka

Copy link
Copy Markdown
Member

@promptless-for-oss the source PR was updated, re-check and update the docs.

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

Thanks @patrykgruszka — on it. We're re-checking the updated source PR (mautic/mautic#16926) and refreshing this developer page to match the current endpoints, runtime globals, and activation API. We'll follow up on this thread once the updated changes are ready.

Update the developer docs for the split Focus scripts to match the now-ready
state of mautic/mautic PR #16926 (source head ebe9fdfb):

- Foreground the public window.MauticFocus.enableTracking(<id>) API and remove
  the no-longer-existent generated enableMauticFocusTracking{id}() callback.
- Distinguish the Focus scope enum (FocusJsScope) from BuildJsScope, noting they
  share no code path and gate different script families.
- Clarify that Dynamic Web Content injects the legacy /focus/{id}.js additively
  on top of the always-allowed display.js once tracking is enabled.
- Add a runnable registry/queue inspection example and tighten the
  mautic:tracking-enabled cross-reference.
@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

Update: we've refreshed this developer page to match the current source PR. Highlights: the public activation API is now documented as window.MauticFocus.enableTracking(<id>) (the earlier draft-era enableMauticFocusTracking{id}() callback no longer exists in the ready PR and was removed), the FocusJsScope-vs-BuildJsScope distinction is sharpened (separate enums, distinct script families, no shared code path), and the Dynamic Web Content behavior is clarified (the legacy /focus/{id}.js is injected additively on top of the always-allowed display.js once tracking is enabled). A runnable registry/queue inspection example was added and citations re-anchored to the current source. Ready for another look.

@promptless-for-oss

Copy link
Copy Markdown
Contributor Author

@patrykgruszka done — we've re-checked this developer page against the updated source PR and pushed the corrected changes.

The key fix: the activation API is now documented as the public window.MauticFocus.enableTracking(<id>) call, since the earlier per-item enableMauticFocusTracking{id}() callback no longer exists in the current implementation. We also:

  • Sharpened the FocusJsScope-vs-BuildJsScope distinction (separate enums, distinct script families, no shared code path).
  • Clarified that Dynamic Web Content injects the legacy /focus/{id}.js additively on top of the always-allowed display.js once tracking is enabled.
  • Added a runnable registry/queue inspection example.
  • Re-anchored all citations to the current source.

The PR is updated and ready for another look. Since PR #16926 isn't merged yet, we'll reconcile again if further code changes land before merge.

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.

2 participants