Skip to content

Commit c498aef

Browse files
committed
fix(stats): update URL handling for pageviews in the stats script
1 parent 596860e commit c498aef

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

.teamcity/scripts/stats/pageviews.mjs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,26 @@ try {
2626
}
2727

2828
if (pageviews < 1) return;
29+
2930
try {
30-
if (!(new URL(url).host.includes('kotlinlang.org'))) return;
31+
let uri = new URL(url);
32+
33+
if (uri.host.match(/^(www\.)?jetbrains\.com$/) && uri.pathname.startsWith('/help/kotlin-multiplatform-dev/')) {
34+
uri.hostname = 'kotlinlang.org';
35+
uri.pathname = uri.pathname.replace('/help/kotlin-multiplatform-dev/', '/docs/multiplatform/');
36+
}
37+
38+
if (uri.host !== 'kotlinlang.org') return;
39+
40+
const path = uri.toString();
41+
42+
await Promise.all([
43+
listViews.appendFile(JSON.stringify({ path, pageviews }) + ','),
44+
mapViews.appendFile(`${JSON.stringify(path)}: ${pageviews},`)
45+
]);
3146
} catch (e) {
3247
console.error('Error in', line, 'line');
33-
return;
3448
}
35-
36-
await Promise.all([
37-
listViews.appendFile(JSON.stringify({ url, pageviews }) + ','),
38-
mapViews.appendFile(`${JSON.stringify(url)}: ${pageviews},`)
39-
]);
4049
}
4150

4251
const lines = [];

0 commit comments

Comments
 (0)