Skip to content

Commit 9c4e554

Browse files
docs: track demo app usage analytics (#4427)
1 parent 6ddae0e commit 9c4e554

585 files changed

Lines changed: 8032 additions & 372 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

advanced-api/automatic-vendor-sharing/app1/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"serve": "serve dist -p 3001 --cors",
2929
"clean": "rm -rf dist",
3030
"type-check": "tsc --noEmit",
31-
"analyze": "webpack-bundle-analyzer dist/static/js/*.js"
31+
"analyze": "webpack-bundle-analyzer dist/static/js/*.js",
32+
"prestart": "node ../../../scripts/track-demo-run.js",
33+
"preserve": "node ../../../scripts/track-demo-run.js"
3234
},
3335
"dependencies": {
3436
"react": "^18.3.1",

advanced-api/automatic-vendor-sharing/app1/public/index.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,40 @@
33
<head> </head>
44
<body>
55
<div id="root"></div>
6+
<!-- Module Federation demo analytics -->
7+
<script>
8+
(function () {
9+
var measurementId = "G-DRPXW0EEVT";
10+
var cidKey = 'mf_examples_ga_cid';
11+
var cid;
12+
try {
13+
cid = window.localStorage && window.localStorage.getItem(cidKey);
14+
if (!cid) {
15+
cid = String(Math.floor(Math.random() * 1000000000)) + '.' + String(Date.now());
16+
window.localStorage && window.localStorage.setItem(cidKey, cid);
17+
}
18+
} catch (error) {
19+
cid = String(Math.floor(Math.random() * 1000000000)) + '.' + String(Date.now());
20+
}
21+
22+
var hostname = window.location.hostname;
23+
var runtimeContext = /^(localhost|127\.|0\.0\.0\.0|::1)$/.test(hostname) ? 'local' : 'hosted';
24+
var pageLocation = window.location.origin + window.location.pathname;
25+
var params = new URLSearchParams({
26+
v: '2',
27+
tid: measurementId,
28+
cid: cid,
29+
en: 'demo_app_view',
30+
'ep.repository': "module-federation-examples",
31+
'ep.example': "advanced-api",
32+
'ep.demo_path': "advanced-api/automatic-vendor-sharing/app1/public",
33+
'ep.entrypoint': "advanced-api/automatic-vendor-sharing/app1/public/index.html",
34+
'ep.runtime_context': runtimeContext,
35+
dl: pageLocation,
36+
dt: document.title || ('ModuleFederationExamples ' + "advanced-api/automatic-vendor-sharing/app1/public")
37+
});
38+
new Image().src = 'https://www.google-analytics.com/g/collect?' + params.toString();
39+
})();
40+
</script>
641
</body>
742
</html>

advanced-api/automatic-vendor-sharing/app2/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"serve": "serve dist -p 3002 --cors",
2929
"clean": "rm -rf dist",
3030
"type-check": "tsc --noEmit",
31-
"analyze": "webpack-bundle-analyzer dist/static/js/*.js"
31+
"analyze": "webpack-bundle-analyzer dist/static/js/*.js",
32+
"prestart": "node ../../../scripts/track-demo-run.js",
33+
"preserve": "node ../../../scripts/track-demo-run.js"
3234
},
3335
"dependencies": {
3436
"react": "^18.3.1",

advanced-api/automatic-vendor-sharing/app2/public/index.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,40 @@
33
<head> </head>
44
<body>
55
<div id="root"></div>
6+
<!-- Module Federation demo analytics -->
7+
<script>
8+
(function () {
9+
var measurementId = "G-DRPXW0EEVT";
10+
var cidKey = 'mf_examples_ga_cid';
11+
var cid;
12+
try {
13+
cid = window.localStorage && window.localStorage.getItem(cidKey);
14+
if (!cid) {
15+
cid = String(Math.floor(Math.random() * 1000000000)) + '.' + String(Date.now());
16+
window.localStorage && window.localStorage.setItem(cidKey, cid);
17+
}
18+
} catch (error) {
19+
cid = String(Math.floor(Math.random() * 1000000000)) + '.' + String(Date.now());
20+
}
21+
22+
var hostname = window.location.hostname;
23+
var runtimeContext = /^(localhost|127\.|0\.0\.0\.0|::1)$/.test(hostname) ? 'local' : 'hosted';
24+
var pageLocation = window.location.origin + window.location.pathname;
25+
var params = new URLSearchParams({
26+
v: '2',
27+
tid: measurementId,
28+
cid: cid,
29+
en: 'demo_app_view',
30+
'ep.repository': "module-federation-examples",
31+
'ep.example': "advanced-api",
32+
'ep.demo_path': "advanced-api/automatic-vendor-sharing/app2/public",
33+
'ep.entrypoint': "advanced-api/automatic-vendor-sharing/app2/public/index.html",
34+
'ep.runtime_context': runtimeContext,
35+
dl: pageLocation,
36+
dt: document.title || ('ModuleFederationExamples ' + "advanced-api/automatic-vendor-sharing/app2/public")
37+
});
38+
new Image().src = 'https://www.google-analytics.com/g/collect?' + params.toString();
39+
})();
40+
</script>
641
</body>
742
</html>

advanced-api/automatic-vendor-sharing/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
"legacy:start": "pnpm --filter automatic-vendor-sharing_app* --parallel legacy:start",
1616
"legacy:build": "pnpm --filter automatic-vendor-sharing_app* --parallel legacy:build",
1717
"e2e:ci": "pnpm exec playwright test --config ./playwright.config.ts --reporter=list",
18-
"legacy:e2e:ci": "pnpm legacy:build && LEGACY_START=true pnpm exec playwright test --config ./playwright.config.ts --reporter=list"
18+
"legacy:e2e:ci": "pnpm legacy:build && LEGACY_START=true pnpm exec playwright test --config ./playwright.config.ts --reporter=list",
19+
"prestart": "node ../../scripts/track-demo-run.js",
20+
"preserve": "node ../../scripts/track-demo-run.js"
1921
},
2022
"devDependencies": {
2123
"@playwright/test": "1.58.2",

advanced-api/dynamic-remotes-runtime-environment-variables/host/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"docker:run": "docker run -it --name csr-env-host -p 3000:80 -d -e API_URL=https://host.com/api csr-env/host:0.0.0",
2929
"docker:rm": "docker rm -f csr-env-host",
3030
"legacy:start": "chmod +x ./env.sh && cp env-config.json ./public/ && NODE_ENV=development webpack-cli serve",
31-
"legacy:build": "NODE_ENV=production webpack --mode production"
31+
"legacy:build": "NODE_ENV=production webpack --mode production",
32+
"prestart": "node ../../../scripts/track-demo-run.js",
33+
"preserve": "node ../../../scripts/track-demo-run.js"
3234
},
3335
"dependencies": {
3436
"moment": "^2.30.1",

advanced-api/dynamic-remotes-runtime-environment-variables/host/public/index.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,40 @@
22
<html>
33
<body>
44
<div id="root"></div>
5+
<!-- Module Federation demo analytics -->
6+
<script>
7+
(function () {
8+
var measurementId = "G-DRPXW0EEVT";
9+
var cidKey = 'mf_examples_ga_cid';
10+
var cid;
11+
try {
12+
cid = window.localStorage && window.localStorage.getItem(cidKey);
13+
if (!cid) {
14+
cid = String(Math.floor(Math.random() * 1000000000)) + '.' + String(Date.now());
15+
window.localStorage && window.localStorage.setItem(cidKey, cid);
16+
}
17+
} catch (error) {
18+
cid = String(Math.floor(Math.random() * 1000000000)) + '.' + String(Date.now());
19+
}
20+
21+
var hostname = window.location.hostname;
22+
var runtimeContext = /^(localhost|127\.|0\.0\.0\.0|::1)$/.test(hostname) ? 'local' : 'hosted';
23+
var pageLocation = window.location.origin + window.location.pathname;
24+
var params = new URLSearchParams({
25+
v: '2',
26+
tid: measurementId,
27+
cid: cid,
28+
en: 'demo_app_view',
29+
'ep.repository': "module-federation-examples",
30+
'ep.example': "advanced-api",
31+
'ep.demo_path': "advanced-api/dynamic-remotes-runtime-environment-variables/host/public",
32+
'ep.entrypoint': "advanced-api/dynamic-remotes-runtime-environment-variables/host/public/index.html",
33+
'ep.runtime_context': runtimeContext,
34+
dl: pageLocation,
35+
dt: document.title || ('ModuleFederationExamples ' + "advanced-api/dynamic-remotes-runtime-environment-variables/host/public")
36+
});
37+
new Image().src = 'https://www.google-analytics.com/g/collect?' + params.toString();
38+
})();
39+
</script>
540
</body>
641
</html>

advanced-api/dynamic-remotes-runtime-environment-variables/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"docker:run": "pnpm --filter dynamic-remotes-runtime-environment-variables_* --parallel docker:run",
1717
"docker:rm": "pnpm --filter dynamic-remotes-runtime-environment-variables_* --parallel docker:rm",
1818
"e2e:ci": "npx playwright test",
19-
"legacy:e2e:ci": "USE_LEGACY=1 npx playwright test"
19+
"legacy:e2e:ci": "USE_LEGACY=1 npx playwright test",
20+
"prestart": "node ../../scripts/track-demo-run.js",
21+
"preserve": "node ../../scripts/track-demo-run.js"
2022
},
2123
"devDependencies": {
2224
"@playwright/test": "1.58.2",

advanced-api/dynamic-remotes-runtime-environment-variables/remote/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"docker:run": "docker run -it --name csr-env-remote -p 3001:80 -d -e API_URL=https://remote.com/api csr-env/remote:0.0.0",
2727
"docker:rm": "docker rm -f csr-env-remote",
2828
"legacy:start": "chmod +x ./env.sh && cp env-config.json ./public/ && NODE_ENV=development webpack-cli serve",
29-
"legacy:build": "NODE_ENV=production webpack --mode production"
29+
"legacy:build": "NODE_ENV=production webpack --mode production",
30+
"prestart": "node ../../../scripts/track-demo-run.js",
31+
"preserve": "node ../../../scripts/track-demo-run.js"
3032
},
3133
"dependencies": {
3234
"copy-webpack-plugin": "12.0.2",

advanced-api/dynamic-remotes-runtime-environment-variables/remote/public/index.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,40 @@
22
<html>
33
<body>
44
<div id="root"></div>
5+
<!-- Module Federation demo analytics -->
6+
<script>
7+
(function () {
8+
var measurementId = "G-DRPXW0EEVT";
9+
var cidKey = 'mf_examples_ga_cid';
10+
var cid;
11+
try {
12+
cid = window.localStorage && window.localStorage.getItem(cidKey);
13+
if (!cid) {
14+
cid = String(Math.floor(Math.random() * 1000000000)) + '.' + String(Date.now());
15+
window.localStorage && window.localStorage.setItem(cidKey, cid);
16+
}
17+
} catch (error) {
18+
cid = String(Math.floor(Math.random() * 1000000000)) + '.' + String(Date.now());
19+
}
20+
21+
var hostname = window.location.hostname;
22+
var runtimeContext = /^(localhost|127\.|0\.0\.0\.0|::1)$/.test(hostname) ? 'local' : 'hosted';
23+
var pageLocation = window.location.origin + window.location.pathname;
24+
var params = new URLSearchParams({
25+
v: '2',
26+
tid: measurementId,
27+
cid: cid,
28+
en: 'demo_app_view',
29+
'ep.repository': "module-federation-examples",
30+
'ep.example': "advanced-api",
31+
'ep.demo_path': "advanced-api/dynamic-remotes-runtime-environment-variables/remote/public",
32+
'ep.entrypoint': "advanced-api/dynamic-remotes-runtime-environment-variables/remote/public/index.html",
33+
'ep.runtime_context': runtimeContext,
34+
dl: pageLocation,
35+
dt: document.title || ('ModuleFederationExamples ' + "advanced-api/dynamic-remotes-runtime-environment-variables/remote/public")
36+
});
37+
new Image().src = 'https://www.google-analytics.com/g/collect?' + params.toString();
38+
})();
39+
</script>
540
</body>
641
</html>

0 commit comments

Comments
 (0)