You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ai...@apache.org on 2022/02/07 09:29:23 UTC

[flink] branch release-1.13 updated: [FLINK-25879][Docs] Track used search terms in Matomo

This is an automated email from the ASF dual-hosted git repository.

airblader pushed a commit to branch release-1.13
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/release-1.13 by this push:
     new ab70e9b  [FLINK-25879][Docs] Track used search terms in Matomo
ab70e9b is described below

commit ab70e9b63201fe1916e0f0c500712cf4b5390980
Author: martijnvisser <ma...@2symbols.com>
AuthorDate: Tue Feb 1 14:54:02 2022 +0100

    [FLINK-25879][Docs] Track used search terms in Matomo
---
 docs/layouts/partials/docs/inject/menu-after.html |  2 +
 docs/static/js/track-search-terms.js              | 52 +++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/docs/layouts/partials/docs/inject/menu-after.html b/docs/layouts/partials/docs/inject/menu-after.html
index df19fb4..60d7938 100644
--- a/docs/layouts/partials/docs/inject/menu-after.html
+++ b/docs/layouts/partials/docs/inject/menu-after.html
@@ -74,3 +74,5 @@ for the one that is not currently active
   {{ .Language.LanguageName }}
 </a>
 {{ end }}{{ end }}{{ end }}
+<script src="{{.Site.BaseURL}}/js/track-search-terms.js"></script>
+
diff --git a/docs/static/js/track-search-terms.js b/docs/static/js/track-search-terms.js
new file mode 100644
index 0000000..9bca8e7
--- /dev/null
+++ b/docs/static/js/track-search-terms.js
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+'use strict';
+
+function debounce(fn, wait) {
+  var timeout
+  return function() {
+    clearTimeout(timeout)
+    var args = arguments;
+    timeout = setTimeout(function() {
+      fn.apply(this, args)
+    }, (wait || 1))
+  }
+}
+
+// Function which is called to track the actual search term
+function trackSearchQuery(e){
+  const searchHits = window.bookSearchIndex.search(input.value, 10);
+  //Call Matomo's trackSiteSearch function to track the search query in its internal search tracking capability
+  _paq.push(['trackSiteSearch',
+      // Search keyword searched for
+      input.value,
+      // Search category selected in your search engine. If you do not need this, set to false
+      false,
+      // Number of results on the Search results page. Zero indicates a 'No Result Search Keyword'. Set to false if you don't know
+      searchHits.length
+  ]);
+}
+
+// Whenever the search tracking event listener is fired, use the debounce function to track if we should measure the search term
+// We assume that if the value of the search term hasn't changed in 2 seconds, the user has searched for this specific term
+var debouncedSearchQuery = debounce(trackSearchQuery, 2000);
+
+/* Add event listener to track what users are searching for on the site */
+var input = document.querySelector('#book-search-input');
+input.addEventListener('input', debouncedSearchQuery);