diff options
author | Sarah German <sgerman@gitlab.com> | 2022-12-13 22:43:07 +0300 |
---|---|---|
committer | Sarah German <sgerman@gitlab.com> | 2022-12-13 22:43:07 +0300 |
commit | 23fbc13f0c60f1923b572993ee2d4ec3988574a1 (patch) | |
tree | a021a79c19a1924a6b48948ac0b2dbe56564cd03 | |
parent | 233ac4a672c78d384f9ba8ee788b03b2e3643388 (diff) |
Add Algolia event trackingsarahg/algolia-analytics
-rw-r--r-- | content/frontend/search/docsearch.js | 7 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | yarn.lock | 43 |
3 files changed, 52 insertions, 0 deletions
diff --git a/content/frontend/search/docsearch.js b/content/frontend/search/docsearch.js index 97601cf9..5cde048b 100644 --- a/content/frontend/search/docsearch.js +++ b/content/frontend/search/docsearch.js @@ -1,11 +1,17 @@ import docsearch from '@docsearch/js'; +import { createAlgoliaInsightsPlugin } from '@algolia/autocomplete-plugin-algolia-insights'; import '@docsearch/css'; +import insightsClient from 'search-insights'; import { getAlgoliaCredentials, getDocsVersion } from './search'; document.addEventListener('DOMContentLoaded', () => { const docsVersion = getDocsVersion(); const algoliaCredentials = getAlgoliaCredentials(); + // Initialize analytics + insightsClient('init', { appId: algoliaCredentials.appId, apiKey: algoliaCredentials.apiKey }); + const algoliaInsightsPlugin = createAlgoliaInsightsPlugin({ insightsClient }); + // eslint-disable-next-line no-undef docsearch({ apiKey: algoliaCredentials.apiKey, @@ -16,6 +22,7 @@ document.addEventListener('DOMContentLoaded', () => { searchParameters: { facetFilters: [`version:${docsVersion}`], }, + plugins: [algoliaInsightsPlugin], resultsFooterComponent({ state }) { return { type: 'a', diff --git a/package.json b/package.json index 855427ad..7c4a54c5 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "vue-template-compiler": "^2.7.0" }, "dependencies": { + "@algolia/autocomplete-plugin-algolia-insights": "^1.7.3", "@docsearch/css": "^3.3.0", "@docsearch/js": "3", "@gitlab/svgs": "^3.13.0", @@ -63,6 +64,7 @@ "mermaid": "^9.2.2", "pikaday": "^1.8.2", "rollup-plugin-import-css": "^3.1.0", + "search-insights": "^2.2.3", "vue": "^2.7.0", "vue-instantsearch": "^4.4.0" } @@ -9,6 +9,32 @@ dependencies: "@algolia/autocomplete-shared" "1.7.1" +"@algolia/autocomplete-core@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-core/-/autocomplete-core-1.7.3.tgz#a26caf9b09dd4546c173da532096a2a8e56c15e7" + integrity sha512-RFv3xndlhfnFYhRqbPAEgXhHp2mJV3ht1nFf5dNM6eXdJGLdBKQGt0ygKDXMSBpSYTUoX0US04xRTArMOMSYJw== + dependencies: + "@algolia/autocomplete-shared" "1.7.3" + +"@algolia/autocomplete-js@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-js/-/autocomplete-js-1.7.3.tgz#e92a1921e16121b242a9c6ad2932123148271535" + integrity sha512-O3Vo2vwRZqmkjGejd/7Vgz0H5Y7lBg3CBZsMQaNLEY09PSV2g2rh0jbQ6r52XzO+ce1brHUkLo2rXyBsJrZWvA== + dependencies: + "@algolia/autocomplete-core" "1.7.3" + "@algolia/autocomplete-preset-algolia" "1.7.3" + "@algolia/autocomplete-shared" "1.7.3" + htm "^3.0.0" + preact "^10.0.0" + +"@algolia/autocomplete-plugin-algolia-insights@^1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-plugin-algolia-insights/-/autocomplete-plugin-algolia-insights-1.7.3.tgz#7e8da96ae7d9dc95708306a22ecd033f3eaf2de0" + integrity sha512-sbOwAoH74n8Rwzhlg3oj8zNmUDfn3N3MQI7QVkUqqAL3QrMkb1rvMlj8eWvb180zxRYT6OgfJbJyOhhh489QAg== + dependencies: + "@algolia/autocomplete-js" "1.7.3" + "@algolia/autocomplete-shared" "1.7.3" + "@algolia/autocomplete-preset-algolia@1.7.1": version "1.7.1" resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.7.1.tgz#7dadc5607097766478014ae2e9e1c9c4b3f957c8" @@ -16,11 +42,23 @@ dependencies: "@algolia/autocomplete-shared" "1.7.1" +"@algolia/autocomplete-preset-algolia@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-preset-algolia/-/autocomplete-preset-algolia-1.7.3.tgz#1bbf264c7dab84eb160e5293094246669626b7cd" + integrity sha512-NHnyY6vxfZ542KoP50U94LO0y2pe82DJGaq//vqUvzqJTye9q5oqXjNRWpmXGg9OiZw58ifwgbYlxTX+i0c0gw== + dependencies: + "@algolia/autocomplete-shared" "1.7.3" + "@algolia/autocomplete-shared@1.7.1": version "1.7.1" resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.7.1.tgz#95c3a0b4b78858fed730cf9c755b7d1cd0c82c74" integrity sha512-eTmGVqY3GeyBTT8IWiB2K5EuURAqhnumfktAEoHxfDY2o7vg2rSnO16ZtIG0fMgt3py28Vwgq42/bVEuaQV7pg== +"@algolia/autocomplete-shared@1.7.3": + version "1.7.3" + resolved "https://registry.yarnpkg.com/@algolia/autocomplete-shared/-/autocomplete-shared-1.7.3.tgz#f1728ea38eb6c1e12dc9d4c5b1cb83a3ad4ef5fa" + integrity sha512-QLyvIbF4Xg2S5uxEOrGg0+HD2+gYe9ICUXWsYfhUxQ0yeBU1M1scoiGpulKJKuIIDHQY/yoqPRekBc1UF/wiMQ== + "@algolia/cache-browser-local-storage@4.14.2": version "4.14.2" resolved "https://registry.yarnpkg.com/@algolia/cache-browser-local-storage/-/cache-browser-local-storage-4.14.2.tgz#d5b1b90130ca87c6321de876e167df9ec6524936" @@ -6574,6 +6612,11 @@ search-insights@^2.1.0: resolved "https://registry.yarnpkg.com/search-insights/-/search-insights-2.2.1.tgz#9c93344fbae5fbf2f88c1a81b46b4b5d888c11f7" integrity sha512-JDfVGZbKqTtiKVZjAVbkNw9C9f0ib80yx6Ea17M3z4RvPmuD0GYWXuFwA9++dpbreBEMH4TC3lQ29Zq7O4b5oA== +search-insights@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/search-insights/-/search-insights-2.2.3.tgz#3ef11cc622261887d0a95d91d84eebb5e63fe6b3" + integrity sha512-fXwC0QzkBGZuGTb6FoQG+iLS81wljYuBU4Sco4TGTgp5boVkiKZeFqPV0e5h5++5QncTU2FQrQ+G3ILnqEa3yA== + select@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/select/-/select-1.1.2.tgz#0e7350acdec80b1108528786ec1d4418d11b396d" |