From ea14025e85ce735e98d30ba69a7eb90b536aa439 Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 6 Aug 2021 15:29:23 +0200 Subject: [PATCH 1/2] docs: collect feedback form Signed-off-by: Andrea Luzzardi --- website/docusaurus.config.js | 13 ++++-- .../plugins/docusaurus-plugin-hotjar/index.js | 46 +++++++++++++++++++ 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 website/plugins/docusaurus-plugin-hotjar/index.js diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 174aa755..f055d3f8 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -30,6 +30,9 @@ module.exports = { apiKey: "b2324f1ac8932ab80916382521473115", indexName: "daggosaurus", }, + hotjar: { + siteId: "2541514", + }, colorMode: { // "light" | "dark" defaultMode: "light", @@ -40,7 +43,7 @@ module.exports = { }, }, gtag: { - trackingID: 'G-RDXG80F635', + trackingID: "G-RDXG80F635", anonymizeIP: true, }, }, @@ -63,10 +66,12 @@ module.exports = { plugins: [ "docusaurus-plugin-sass", [ - "docusaurus2-dotenv", { + "docusaurus2-dotenv", + { systemvars: true, expand: true, }, - ] + ], + path.resolve(__dirname, "plugins/docusaurus-plugin-hotjar"), ], -}; \ No newline at end of file +}; diff --git a/website/plugins/docusaurus-plugin-hotjar/index.js b/website/plugins/docusaurus-plugin-hotjar/index.js new file mode 100644 index 00000000..ee1dae89 --- /dev/null +++ b/website/plugins/docusaurus-plugin-hotjar/index.js @@ -0,0 +1,46 @@ +const path = require("path"); + +module.exports = function (context) { + const { siteConfig } = context; + const { themeConfig } = siteConfig; + const { hotjar } = themeConfig || {}; + + if (!hotjar) { + throw new Error( + `Create a 'hotjar' object containing a 'siteId' property in 'themeConfig'.` + ); + } + + const { siteId } = hotjar; + + if (!siteId) { + throw new Error( + "Error in `themeConfig`. `hotjar` object found but `siteId` prop is missing." + ); + } + + return { + name: "docusaurus-plugin-hotjar", + + injectHtmlTags() { + return { + headTags: [ + { + tagName: "script", + innerHTML: ` + + (function(h,o,t,j,a,r){ + h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)}; + h._hjSettings={hjid:${siteId},hjsv:6}; + a=o.getElementsByTagName('head')[0]; + r=o.createElement('script');r.async=1; + r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv; + a.appendChild(r); + })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv='); + `, + }, + ], + }; + }, + }; +}; From 2b5e789b899f53883ec6d0f3e44bb6d55a7b480c Mon Sep 17 00:00:00 2001 From: Andrea Luzzardi Date: Fri, 6 Aug 2021 15:39:54 +0200 Subject: [PATCH 2/2] docs: hotjar Signed-off-by: Andrea Luzzardi --- website/src/theme/DocPage/index.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/website/src/theme/DocPage/index.js b/website/src/theme/DocPage/index.js index 506b7ffc..40d08637 100644 --- a/website/src/theme/DocPage/index.js +++ b/website/src/theme/DocPage/index.js @@ -170,6 +170,10 @@ function DocPage(props) { apiEndpoint: `${window.location.hostname}/t` }); amplitude.getInstance().logEvent('Docs Viewed', { "hostname": window.location.hostname, "path": location.pathname }); + + if (window?.hj) { + window.hj("identify", userAccessStatus?.login.toLowerCase(), {}); + } } }) }, [location.pathname, userAccessStatus])