diff --git a/docusaurus.config.js b/docusaurus.config.js index 45065395..a3da73df 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -26,6 +26,7 @@ const config = { onBrokenMarkdownLinks: "warn", clientModules: [require.resolve("./snowplow.js")], + // Even if you don't use internalization, you can use this field to set useful // metadata like html lang. For example, if your site is Chinese, you may want // to replace "en" with "zh-Hans". diff --git a/snowplow.js b/snowplow.js index ac3d8422..57feef2e 100644 --- a/snowplow.js +++ b/snowplow.js @@ -1,6 +1,7 @@ import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment"; import { newTracker, trackPageView } from "@snowplow/browser-tracker"; +const isProduction = process.env.NODE_ENV === "production"; const trackerConfig = { appId: "klaw-docs", platform: "web", @@ -8,7 +9,7 @@ const trackerConfig = { discoverRootDomain: true, cookieSameSite: "Lax", anonymousTracking: { withServerAnonymisation: true }, - postPath: "/aiven/dc", + postPath: "/aiven/dc2", crossDomainLinker: function (linkElement) { return linkElement.id === "crossDomainLink"; }, @@ -23,9 +24,24 @@ function setupBrowserTracker() { newTracker("at", "dc.aiven.io", trackerConfig); } -if (ExecutionEnvironment.canUseDOM) { +if (isProduction && ExecutionEnvironment.canUseDOM) { + // only set tracker on prod setupBrowserTracker(); - trackPageView(); } +const module = { + onRouteDidUpdate({ location, previousLocation }) { + // only set tracker on prod + if (isProduction) { + // only call trackPageView when page route changed + if (location.pathname !== previousLocation?.pathname) { + // see https://github.com/facebook/docusaurus/pull/7424 regarding setTimeout + setTimeout(() => { + trackPageView(); + }); + } + } + }, +}; + export default module; diff --git a/src/components/HomepageFeatures/index.js b/src/components/HomepageFeatures/index.js index 0ade2954..3e0b811a 100644 --- a/src/components/HomepageFeatures/index.js +++ b/src/components/HomepageFeatures/index.js @@ -140,7 +140,7 @@ function Feature({ Svg, title, description }) { Feature.propTypes = { Svg: PropTypes.any, title: PropTypes.string, - description: PropTypes.string, + description: PropTypes.node, }; export default function HomepageFeatures() {