diff --git a/docusaurus.config.js b/docusaurus.config.js index d196c3424..763a13a78 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -18,6 +18,10 @@ const config = { projectName: 'deriv-api-docs', // Usually your repo name. trailingSlash: false, + customFields: { + trackJsToken: process.env.TRACKJS_TOKEN, + }, + // 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/package-lock.json b/package-lock.json index 432a7b907..862e2498d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,6 +36,7 @@ "sass": "^1.57.1", "sass-loader": "^13.2.0", "swiper": "^8.3.2", + "trackjs": "^3.10.4", "ts-jest": "^29.0.3", "usehooks-ts": "^2.9.1", "yup": "^0.32.11" @@ -23323,6 +23324,11 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" }, + "node_modules/trackjs": { + "version": "3.10.4", + "resolved": "https://registry.npmjs.org/trackjs/-/trackjs-3.10.4.tgz", + "integrity": "sha512-coQkj9d7OjPmrLKj4MeLvf1U5vPD9QfXMpqVghhKnF++BlFOkA9t64ry0Usqt+8dk1tunZ9DQ5IVKLYi+3H8+w==" + }, "node_modules/trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", diff --git a/package.json b/package.json index 41a507949..df1c3d8f6 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "sass": "^1.57.1", "sass-loader": "^13.2.0", "swiper": "^8.3.2", + "trackjs": "^3.10.4", "ts-jest": "^29.0.3", "usehooks-ts": "^2.9.1", "yup": "^0.32.11" diff --git a/src/theme/Root.tsx b/src/theme/Root.tsx index 181bc367c..b848eed08 100644 --- a/src/theme/Root.tsx +++ b/src/theme/Root.tsx @@ -1,6 +1,8 @@ import React from 'react'; import { ThemeProvider } from '@deriv/ui'; import type { ReactNode } from 'react'; +import { TrackJS } from 'trackjs'; +import siteConfig from '@generated/docusaurus.config'; import AuthProvider from '../contexts/auth/auth.provider'; import ApiTokenProvider from '../contexts/api-token/api-token.provider'; import AppManagerContextProvider from '../contexts/app-manager/app-manager.provider'; @@ -11,6 +13,12 @@ type TRootProps = { children: ReactNode; }; +if (siteConfig.customFields.trackJsToken) { + TrackJS.install({ token: siteConfig.customFields.trackJsToken.toString() }); +} else { + console.warn('trackjs is not installed due to a missing token'); +} + export default function Root({ children }: TRootProps) { return ( <>