This is an automated email from the ASF dual-hosted git repository.
psxjoy pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fesod.git
The following commit(s) were added to refs/heads/main by this push:
new 1d5e1b94 feat: add analytics module for tracking page views (#635)
1d5e1b94 is described below
commit 1d5e1b9401ecbfbac2d8704d6a56305f7c47e536
Author: Shuxin Pan <[email protected]>
AuthorDate: Thu Oct 9 23:57:32 2025 +0800
feat: add analytics module for tracking page views (#635)
* feat: add analytics module for tracking page views
* feat: add analytics module for tracking page views
---
website/docusaurus.config.js | 1 +
website/src/analytics.ts | 63 ++++++++++++++++++++++++++++++++++++++++++++
website/static/config.json | 3 +++
3 files changed, 67 insertions(+)
diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js
index 83c22bd1..02594503 100644
--- a/website/docusaurus.config.js
+++ b/website/docusaurus.config.js
@@ -35,6 +35,7 @@ const config = {
customFields: {
repoUrl,
},
+ clientModules: [require.resolve('./src/analytics.ts')],
i18n: {
defaultLocale: 'en',
locales: ['en', 'zh-cn'],
diff --git a/website/src/analytics.ts b/website/src/analytics.ts
new file mode 100644
index 00000000..85eb8d1b
--- /dev/null
+++ b/website/src/analytics.ts
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
+
+(function () {
+ if (ExecutionEnvironment.canUseDOM) {
+ let prefix = '';
+ if (location.pathname.startsWith('/zh-cn')) {
+ prefix = '/zh-cn';
+ }
+ let s = document.getElementsByTagName('script')[0];
+
+ let matomo = document.createElement('script');
+ matomo.text = `
+ /* -- Matomo */
+ var _paq = window._paq = window._paq || [];
+ /* tracker methods like "setCustomDimension" should be called before
"trackPageView" */
+ /* _paq.push(["setDoNotTrack", true]); */
+ _paq.push(["disableCookies"]);
+ _paq.push(['trackPageView']);
+ _paq.push(['enableLinkTracking']);
+ (function() {
+ var u="https://analytics.apache.org/";
+ _paq.push(['setTrackerUrl', u+'matomo.php']);
+ _paq.push(['setSiteId', '83']);
+ var d=document, g=d.createElement('script'),
s=d.getElementsByTagName('script')[0];
+ g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
+ })();
+ /* End Matomo Code */
+ `;
+ s.parentNode.insertBefore(matomo, s);
+
+ const controller = new AbortController();
+ const signal = controller.signal;
+ // set timeout
+ setTimeout(() => {
+ controller.abort();
+ }, 5000);
+ fetch(prefix + '/config.json', {signal})
+ .then((res) => res.json())
+ .then((data) => {
+ if (data.analytics) {
+ }
+ }).catch((err => {
+ // do nothing
+ }));
+ }
+})();
\ No newline at end of file
diff --git a/website/static/config.json b/website/static/config.json
new file mode 100644
index 00000000..250baa88
--- /dev/null
+++ b/website/static/config.json
@@ -0,0 +1,3 @@
+{
+ "analytics": true
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]