Browse Source

docs: theme & telemetry fix

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/6467/head
Raju Udava 1 year ago
parent
commit
85aa9d533f
  1. 17
      packages/noco-docs/src/modules/tele.js
  2. 2
      packages/noco-docs/src/theme/MDXComponents.js

17
packages/noco-docs/src/modules/tele.js

@ -1,16 +1,21 @@
import { init, push } from 'nc-analytics';
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
let push;
if (ExecutionEnvironment.canUseDOM) {
const { init, push: _push } = require("nc-analytics");
push = _push;
init();
}
export function onRouteDidUpdate({ location, previousLocation }) {
// Don't execute if we are still on the same page; the lifecycle may be fired
// because the hash changes (e.g. when navigating between headings)
if (location.pathname !== previousLocation?.pathname || location.hash !== previousLocation?.hash) {
if (
location.pathname !== previousLocation?.pathname ||
location.hash !== previousLocation?.hash
) {
push({
event: '$pageview',
event: "$pageview",
$current_url: location.pathname,
hash: location.hash,
});
}
}

2
packages/noco-docs/src/theme/MDXComponents.js

@ -1,5 +1,7 @@
// import the original mapper
import MDXComponents from "@theme-original/MDXComponents";
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
export default {
// re-use the default mapping

Loading…
Cancel
Save