Skip to content

docs: track demo app usage analytics#4427

Merged
ScriptedAlchemy merged 1 commit into
masterfrom
agent/add-demo-app-ga-pixels
Jul 8, 2026
Merged

docs: track demo app usage analytics#4427
ScriptedAlchemy merged 1 commit into
masterfrom
agent/add-demo-app-ga-pixels

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Member

Summary

  • add GA4 demo_app_view image beacons to all tracked browser entrypoints (index.html and Next _document files)
  • add opt-out local package-run analytics for start/dev/serve scripts via demo_app_run events
  • include labels for repository, example, demo_path, entrypoint, runtime_context, npm_script, and package_name

GA setup

  • added event-scoped custom dimensions in the module-federation.io GA4 property for demo_path, entrypoint, runtime_context, npm_script, and package_name
  • existing dimensions repository and example continue to apply

Validation

  • node --check scripts/add-demo-analytics.js
  • node --check scripts/add-demo-run-analytics.js
  • node --check scripts/track-demo-run.js
  • coverage check: 210/210 tracked browser entrypoints instrumented
  • lifecycle hook check: 661 generated hooks, 0 bad helper paths
  • dry run helper with MF_EXAMPLES_ANALYTICS=0 and CI=1
  • git diff --check

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 07dcecaba1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

dl: pageLocation,
dt: document.title || ('ModuleFederationExamples ' + ${escapeJs(demoPath)})
});
new Image().src = 'https://www.google-analytics.com/g/collect?' + params.toString();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid unconditional GA beacons in test pages

This browser snippet is injected into every demo page and always starts an external google-analytics.com image request, but many repo e2e helpers wait for Playwright networkidle on page load/reload (for example playwright-e2e/common/base.ts:150 and :168). In CI or other network-restricted environments where GA is slow or blocked, those page loads can now wait on an unrelated third-party request until timeout, and there is no browser-side equivalent of the CI/MF_EXAMPLES_ANALYTICS opt-out used by the package-run helper.

Useful? React with 👍 / 👎.

Comment on lines +26 to +28
function getDemoPath(file) {
return file.split('/').slice(0, -1).join('/') || 'root';
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize demo_path to the app package root

Using the entrypoint's containing directory makes browser demo_app_view events report paths such as basic-host-remote/app1/public or nextjs-csr/home/pages, while the package-run tracker records demoPath from process.cwd() (for example basic-host-remote/app1) in scripts/track-demo-run.js:18. For entrypoints under public, src, or pages, this splits one demo app across different demo_path values and breaks aggregation/correlation between view and run analytics.

Useful? React with 👍 / 👎.

@ScriptedAlchemy ScriptedAlchemy merged commit 9c4e554 into master Jul 8, 2026
115 checks passed
@ScriptedAlchemy ScriptedAlchemy deleted the agent/add-demo-app-ga-pixels branch July 8, 2026 01:07
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